Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
5b7a4614
Commit
5b7a4614
authored
Jun 24, 2019
by
阮思源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
早晚报
parent
1e82aa9d
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
1638 additions
and
4 deletions
+1638
-4
PushService.java
...c/main/java/com/pcloud/book/push/service/PushService.java
+4
-0
pom.xml
pcloud-service-book/pom.xml
+6
-0
WechatGroupConsr.java
...om/pcloud/book/consumer/wechatgroup/WechatGroupConsr.java
+18
-0
ESNewsBiz.java
...-book/src/main/java/com/pcloud/book/es/biz/ESNewsBiz.java
+23
-0
ESNewsBizImpl.java
.../main/java/com/pcloud/book/es/biz/impl/ESNewsBizImpl.java
+104
-0
ESNews.java
...-book/src/main/java/com/pcloud/book/es/entity/ESNews.java
+147
-0
ESNewsFacade.java
...src/main/java/com/pcloud/book/es/facade/ESNewsFacade.java
+28
-0
ESNewsFacadeImpl.java
...java/com/pcloud/book/es/facade/impl/ESNewsFacadeImpl.java
+43
-0
NewsRepository.java
...in/java/com/pcloud/book/es/repository/NewsRepository.java
+7
-0
GroupQrcodeDao.java
...c/main/java/com/pcloud/book/group/dao/GroupQrcodeDao.java
+6
-0
GroupQrcodeDaoImpl.java
...va/com/pcloud/book/group/dao/impl/GroupQrcodeDaoImpl.java
+5
-0
PushBiz.java
...-book/src/main/java/com/pcloud/book/push/biz/PushBiz.java
+27
-0
PushBizImpl.java
.../main/java/com/pcloud/book/push/biz/impl/PushBizImpl.java
+295
-0
PushCheck.java
...k/src/main/java/com/pcloud/book/push/check/PushCheck.java
+31
-0
MorningEveningNewsDao.java
.../java/com/pcloud/book/push/dao/MorningEveningNewsDao.java
+13
-0
NewsDao.java
...-book/src/main/java/com/pcloud/book/push/dao/NewsDao.java
+23
-0
PushNewsRecordDao.java
...main/java/com/pcloud/book/push/dao/PushNewsRecordDao.java
+21
-0
MorningEveningNewsDaoImpl.java
.../pcloud/book/push/dao/impl/MorningEveningNewsDaoImpl.java
+19
-0
NewsDaoImpl.java
.../main/java/com/pcloud/book/push/dao/impl/NewsDaoImpl.java
+44
-0
PushNewsRecordDaoImpl.java
.../com/pcloud/book/push/dao/impl/PushNewsRecordDaoImpl.java
+30
-0
MorningEveningNews.java
.../java/com/pcloud/book/push/entity/MorningEveningNews.java
+154
-0
News.java
...-book/src/main/java/com/pcloud/book/push/entity/News.java
+119
-0
PushNewsRecord.java
...main/java/com/pcloud/book/push/entity/PushNewsRecord.java
+46
-0
PushFacade.java
...src/main/java/com/pcloud/book/push/facade/PushFacade.java
+21
-0
PushFacadeImpl.java
...java/com/pcloud/book/push/facade/impl/PushFacadeImpl.java
+59
-0
PushServiceImpl.java
...va/com/pcloud/book/push/service/impl/PushServiceImpl.java
+14
-4
GroupQrcode.Mapper.xml
...ok/src/main/resources/mapper/group/GroupQrcode.Mapper.xml
+7
-0
MorningEveningNewsMapper.xml
...c/main/resources/mapper/push/MorningEveningNewsMapper.xml
+111
-0
NewsMapper.xml
...ervice-book/src/main/resources/mapper/push/NewsMapper.xml
+138
-0
PushNewsRecordMapper.xml
...k/src/main/resources/mapper/push/PushNewsRecordMapper.xml
+75
-0
No files found.
pcloud-facade-book/src/main/java/com/pcloud/book/push/service/PushService.java
View file @
5b7a4614
...
...
@@ -17,4 +17,8 @@ public interface PushService {
@PostMapping
(
"/sendGroupMessage"
)
void
sendGroupMessage
(
@RequestBody
Map
<
String
,
Object
>
map
)
throws
BizException
;
@ApiOperation
(
"发送早晚报"
)
@PostMapping
(
"/sendMorningEveningNews"
)
void
sendMorningEveningNews
(
@RequestBody
Map
<
String
,
Object
>
map
)
throws
BizException
;
}
pcloud-service-book/pom.xml
View file @
5b7a4614
...
...
@@ -170,6 +170,12 @@
<version>
${wxgroup-sdk.version}
</version>
</dependency>
<!--ES相关-->
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-elasticsearch
</artifactId>
</dependency>
<!--spring-cloud相关-->
<dependency>
<groupId>
mysql
</groupId>
...
...
pcloud-service-book/src/main/java/com/pcloud/book/consumer/wechatgroup/WechatGroupConsr.java
View file @
5b7a4614
...
...
@@ -172,4 +172,22 @@ public class WechatGroupConsr {
}
return
map
;
}
@ParamLog
(
value
=
"根据群id集合批量获取发消息的小号"
)
public
Map
<
String
,
String
>
getSendDailyRobotByGroupIds
(
List
<
String
>
weixinIds
)
throws
BizException
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
for
(
String
weixinId:
weixinIds
){
map
.
put
(
weixinId
,
"wxid_mxrau68qs7ou22"
);
}
try
{
map
=
ResponseHandleUtil
.
parseMapResponse
(
groupMemberService
.
getSendDailyRobotByGroupIds
(
weixinIds
),
String
.
class
,
String
.
class
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"根据群id集合批量获取发消息的小号.[getRobotIdByWeixinIdBatch]:"
+
e
.
getMessage
(),
e
);
}
if
(
map
==
null
)
{
return
new
HashMap
<>();
}
return
map
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/es/biz/ESNewsBiz.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
es
.
biz
;
import
com.pcloud.book.es.entity.ESNews
;
import
com.pcloud.book.push.entity.News
;
import
java.util.List
;
public
interface
ESNewsBiz
{
/**
* 将所有的新闻新增到es,初始化
*/
void
addAllNewsToES
();
/**
* 新增新闻
*/
void
addNews
(
News
news
);
/**
* 查询新闻
*/
List
<
ESNews
>
getNews
(
String
title
,
List
<
Long
>
notInIds
,
Integer
top
);
}
pcloud-service-book/src/main/java/com/pcloud/book/es/biz/impl/ESNewsBizImpl.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
es
.
biz
.
impl
;
import
com.pcloud.book.es.biz.ESNewsBiz
;
import
com.pcloud.book.es.entity.ESNews
;
import
com.pcloud.book.es.repository.NewsRepository
;
import
com.pcloud.book.push.dao.NewsDao
;
import
com.pcloud.book.push.entity.News
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.utils.BeanUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
org.elasticsearch.index.query.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/13 16:36
**/
@Component
(
"esNewsBiz"
)
public
class
ESNewsBizImpl
implements
ESNewsBiz
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ESNewsBizImpl
.
class
);
@Autowired
private
NewsRepository
newsRepository
;
@Autowired
private
NewsDao
newsDao
;
@ParamLog
(
"导入全部"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
addAllNewsToES
()
{
if
(
newsRepository
.
count
()
>
0
)
{
return
;
}
Integer
count
=
newsDao
.
count
();
LOGGER
.
info
(
"总数:"
+
count
);
if
(
null
==
count
||
count
<=
0
)
{
return
;
}
Long
maxId
=
0L
;
Integer
index
=
0
;
Integer
offset
=
10000
;
while
(
index
*
offset
<
count
)
{
List
<
ESNews
>
list
=
newsDao
.
findAll
(
maxId
,
offset
);
if
(
ListUtils
.
isEmpty
(
list
))
{
break
;
}
newsRepository
.
save
(
list
);
maxId
=
Long
.
valueOf
(
list
.
get
(
list
.
size
()
-
1
).
getId
());
LOGGER
.
info
(
"导入数据至"
+
maxId
);
index
+=
1
;
}
}
@ParamLog
(
"新增新闻"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
addNews
(
News
news
)
{
if
(
news
==
null
)
{
return
;
}
//查询之前有没有相同的
News
newsHas
=
newsDao
.
getByUrl
(
news
.
getUrl
());
if
(
newsHas
!=
null
){
LOGGER
.
info
(
"该news已存在"
+
news
.
toString
());
return
;
}
newsDao
.
insert
(
news
);
ESNews
esNews
=
new
ESNews
();
BeanUtils
.
copyProperties
(
news
,
esNews
);
esNews
.
setId
(
news
.
getId
().
toString
());
esNews
.
setCreateTime
(
new
Date
());
newsRepository
.
save
(
esNews
);
}
@ParamLog
(
"查询新闻"
)
@Override
public
List
<
ESNews
>
getNews
(
String
title
,
List
<
Long
>
notInIds
,
Integer
top
)
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
if
(!
StringUtil
.
isEmpty
(
title
))
{
MatchQueryBuilder
matchQuery
=
QueryBuilders
.
matchQuery
(
"title"
,
title
);
boolQueryBuilder
.
must
(
matchQuery
);
}
if
(!
ListUtils
.
isEmpty
(
notInIds
)){
TermsQueryBuilder
termsQuery
=
QueryBuilders
.
termsQuery
(
"id"
,
notInIds
);
boolQueryBuilder
.
mustNot
(
termsQuery
);
}
PageRequest
pageRequest
=
new
PageRequest
(
0
,
top
);
return
newsRepository
.
search
(
boolQueryBuilder
,
pageRequest
).
getContent
();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/es/entity/ESNews.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
es
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.elasticsearch.annotations.Document
;
import
java.util.Date
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/13 16:03
**/
@Document
(
indexName
=
"book"
,
type
=
"news"
)
public
class
ESNews
{
@Id
private
String
id
;
/**
* 类型
*/
private
String
type
;
/**
* 来源
*/
private
String
newsFrom
;
/**
* 标题
*/
private
String
title
;
/**
* 发布者
*/
private
String
publisher
;
/**
* 链接
*/
private
String
url
;
/**
* 短链接
*/
private
String
shortUrl
;
/**
* 发布日期
*/
private
String
newsDate
;
/**
* 创建时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createTime
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getNewsFrom
()
{
return
newsFrom
;
}
public
void
setNewsFrom
(
String
newsFrom
)
{
this
.
newsFrom
=
newsFrom
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getPublisher
()
{
return
publisher
;
}
public
void
setPublisher
(
String
publisher
)
{
this
.
publisher
=
publisher
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getShortUrl
()
{
return
shortUrl
;
}
public
void
setShortUrl
(
String
shortUrl
)
{
this
.
shortUrl
=
shortUrl
;
}
public
String
getNewsDate
()
{
return
newsDate
;
}
public
void
setNewsDate
(
String
newsDate
)
{
this
.
newsDate
=
newsDate
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
@Override
public
String
toString
()
{
return
"ESNews{"
+
"id='"
+
id
+
'\''
+
", type='"
+
type
+
'\''
+
", newsFrom='"
+
newsFrom
+
'\''
+
", title='"
+
title
+
'\''
+
", publisher='"
+
publisher
+
'\''
+
", url='"
+
url
+
'\''
+
", shortUrl='"
+
shortUrl
+
'\''
+
", newsDate='"
+
newsDate
+
'\''
+
", createTime="
+
createTime
+
'}'
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/es/facade/ESNewsFacade.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
es
.
facade
;
import
com.pcloud.book.push.entity.News
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
java.util.List
;
@FeignClient
(
value
=
"pcloud-service-book"
,
qualifier
=
"esNewsFacadeCloud"
,
path
=
"esNews"
)
@Api
(
description
=
"ES外部接口"
)
public
interface
ESNewsFacade
{
@ApiOperation
(
"添加所有的新闻到es"
)
@PostMapping
(
"addAllNewsToES"
)
ResponseDto
<?>
addAllNewsToES
()
throws
BizException
;
@ApiOperation
(
"新增新闻"
)
@PostMapping
(
"addNews"
)
ResponseDto
<?>
addNews
(
@RequestBody
News
news
)
throws
BizException
;
}
pcloud-service-book/src/main/java/com/pcloud/book/es/facade/impl/ESNewsFacadeImpl.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
es
.
facade
.
impl
;
import
com.pcloud.book.es.biz.ESNewsBiz
;
import
com.pcloud.book.es.facade.ESNewsFacade
;
import
com.pcloud.book.push.entity.News
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/13 16:43
**/
@RestController
(
"esNewsFacade"
)
@RequestMapping
(
"esNews"
)
public
class
ESNewsFacadeImpl
implements
ESNewsFacade
{
@Autowired
private
ESNewsBiz
esNewsBiz
;
@ApiOperation
(
"添加所有的新闻到es"
)
@PostMapping
(
"addAllNewsToES"
)
@Override
public
ResponseDto
<?>
addAllNewsToES
()
throws
BizException
{
esNewsBiz
.
addAllNewsToES
();
return
new
ResponseDto
<>();
}
@ApiOperation
(
"新增新闻"
)
@PostMapping
(
"addNews"
)
@Override
public
ResponseDto
<?>
addNews
(
@RequestBody
News
news
)
throws
BizException
{
esNewsBiz
.
addNews
(
news
);
return
new
ResponseDto
<>();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/es/repository/NewsRepository.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
es
.
repository
;
import
com.pcloud.book.es.entity.ESNews
;
import
org.springframework.data.elasticsearch.repository.ElasticsearchRepository
;
public
interface
NewsRepository
extends
ElasticsearchRepository
<
ESNews
,
String
>
{
}
pcloud-service-book/src/main/java/com/pcloud/book/group/dao/GroupQrcodeDao.java
View file @
5b7a4614
...
...
@@ -158,4 +158,10 @@ public interface GroupQrcodeDao extends BaseDao<GroupQrcode> {
* @param groupName
*/
void
updateGroupName
(
Long
id
,
String
groupName
);
/**
* 获取群人数大于或等于人数的群
* @param userCount
*/
List
<
GroupQrcode
>
getListByUserCount
(
Integer
userCount
);
}
pcloud-service-book/src/main/java/com/pcloud/book/group/dao/impl/GroupQrcodeDaoImpl.java
View file @
5b7a4614
...
...
@@ -142,4 +142,9 @@ public class GroupQrcodeDaoImpl extends BaseDaoImpl<GroupQrcode> implements Grou
paramMap
.
put
(
"groupName"
,
groupName
);
this
.
getSqlSession
().
update
(
this
.
getStatement
(
"updateGroupName"
),
paramMap
);
}
@Override
public
List
<
GroupQrcode
>
getListByUserCount
(
Integer
userCount
)
{
return
this
.
getSqlSession
().
selectList
(
this
.
getStatement
(
"getListByUserCount"
),
userCount
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/push/biz/PushBiz.java
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
biz
;
import
com.pcloud.book.push.dto.*
;
import
com.pcloud.book.push.entity.MorningEveningNews
;
import
com.pcloud.book.push.entity.Push
;
import
com.pcloud.book.push.entity.PushGroup
;
import
com.pcloud.book.push.entity.PushItem
;
...
...
@@ -112,6 +113,32 @@ public interface PushBiz {
* @return
*/
PageBeanNew
<
PushRecordDTO
>
getPushRecordList
(
Long
partyId
,
Integer
currentPage
,
Integer
numPerPage
);
/**
* 新增早晚报
* @param morningEveningNews
* @return
*/
Long
createMorningEveningNews
(
MorningEveningNews
morningEveningNews
);
/**
* 修改早晚报
* @param morningEveningNews
*/
void
updateMorningEveningNews
(
MorningEveningNews
morningEveningNews
);
/**
* 获取早晚报
* @param partyId
* @return
*/
MorningEveningNews
getMorningEveningNews
(
Long
partyId
);
/**
* 发送早晚报
*/
void
sendMorningEveningNews
(
Long
partyId
);
/**
* 新增计划式群发
*/
...
...
pcloud-service-book/src/main/java/com/pcloud/book/push/biz/impl/PushBizImpl.java
View file @
5b7a4614
...
...
@@ -7,6 +7,8 @@ import com.pcloud.book.consumer.app.AppConsr;
import
com.pcloud.book.consumer.channel.QrcodeSceneConsr
;
import
com.pcloud.book.consumer.resource.ProductConsr
;
import
com.pcloud.book.consumer.wechatgroup.WechatGroupConsr
;
import
com.pcloud.book.es.biz.ESNewsBiz
;
import
com.pcloud.book.es.entity.ESNews
;
import
com.pcloud.book.group.biz.BookGroupClassifyBiz
;
import
com.pcloud.book.group.dao.AppTouchRecordDao
;
import
com.pcloud.book.group.dao.BookGroupClassifyDao
;
...
...
@@ -94,12 +96,22 @@ public class PushBizImpl implements PushBiz {
@Autowired
private
AppTouchRecordDao
appTouchRecordDao
;
@Autowired
private
MorningEveningNewsDao
morningEveningNewsDao
;
@Autowired
private
PushNewsRecordDao
pushNewsRecordDao
;
@Autowired
private
ESNewsBiz
esNewsBiz
;
@Autowired
private
PushPlanDao
pushPlanDao
;
@Autowired
private
BookGroupDao
bookGroupDao
;
private
static
final
String
PUSH_SCHEDULE_PRE
=
"BOOK_GROUP_PUSH_"
;
private
static
final
String
MORNING_NEWS_SCHEDULE
=
"MORNING_NEWS_SCHEDULE"
;
private
static
final
String
EVENING_NEWS_SCHEDULE
=
"EVENING_NEWS_SCHEDULE"
;
private
static
final
ThreadFactory
NAMED_THREAD_FACTORY
=
new
ThreadFactoryBuilder
().
setNameFormat
(
"pushBizImpl-pool-%d"
).
build
();
private
static
final
ExecutorService
EXECUTOR_SERVICE
=
new
ThreadPoolExecutor
(
5
,
20
,
0L
,
TimeUnit
.
MILLISECONDS
,
new
LinkedBlockingQueue
<>(
1024
),
NAMED_THREAD_FACTORY
,
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
...
...
@@ -625,6 +637,289 @@ public class PushBizImpl implements PushBiz {
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"新增早晚报"
)
@Override
public
Long
createMorningEveningNews
(
MorningEveningNews
morningEveningNews
)
{
MorningEveningNews
morningEveningNewsOld
=
morningEveningNewsDao
.
getByPartyId
(
morningEveningNews
.
getCreateUser
());
if
(
morningEveningNewsOld
!=
null
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"已有记录,请勿重复添加!"
);
}
//参数校验
pushCheck
.
createMorningEveningNewsParamCheck
(
morningEveningNews
);
//插入
morningEveningNewsDao
.
insert
(
morningEveningNews
);
if
(
morningEveningNews
.
getHasMorningOpen
())
{
//早报定时任务
addNewsSch
(
morningEveningNews
.
getMorningTime
(),
MORNING_NEWS_SCHEDULE
,
morningEveningNews
.
getCreateUser
());
}
if
(
morningEveningNews
.
getHasEveningOpen
())
{
//晚报定是任务
addNewsSch
(
morningEveningNews
.
getEveningTime
(),
EVENING_NEWS_SCHEDULE
,
morningEveningNews
.
getCreateUser
());
}
return
morningEveningNews
.
getId
();
}
@ParamLog
(
"新增早晚报定时任务"
)
private
void
addNewsSch
(
String
time
,
String
jobName
,
Long
partyId
)
{
//创建早晚报定时任务
String
cron
;
try
{
int
hour
=
Integer
.
parseInt
(
time
.
substring
(
0
,
2
));
int
minute
=
Integer
.
parseInt
(
time
.
substring
(
3
,
5
));
int
second
=
Integer
.
parseInt
(
time
.
substring
(
6
,
8
));
cron
=
second
+
" "
+
minute
+
" "
+
hour
+
" * * ?"
;
}
catch
(
Exception
e
)
{
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"时间格式错误"
);
}
ScheduleJob
scheduleJob
=
new
ScheduleJob
();
scheduleJob
.
setJobGroup
(
"book"
);
scheduleJob
.
setJobName
(
jobName
);
scheduleJob
.
setCronExpression
(
cron
);
CallBackParam
callBackParam
=
new
CallBackParam
();
callBackParam
.
setMethodName
(
"sendMorningEveningNews"
);
callBackParam
.
setBeanName
(
"pushService"
);
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
//定时任务调用时用到的参数
paramMap
.
put
(
"partyId"
,
partyId
);
callBackParam
.
setParamMap
(
paramMap
);
Map
<
String
,
Object
>
scheduleMap
=
new
HashMap
<>();
scheduleMap
.
put
(
"scheduleJob"
,
scheduleJob
);
scheduleMap
.
put
(
"callBackParam"
,
callBackParam
);
try
{
scheduleService
.
addCronJob
(
scheduleMap
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"设置定时任务失败"
+
e
.
getMessage
(),
e
);
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"定时任务设置失败"
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"修改早晚报"
)
@Override
public
void
updateMorningEveningNews
(
MorningEveningNews
morningEveningNews
)
{
//参数校验
pushCheck
.
createMorningEveningNewsParamCheck
(
morningEveningNews
);
MorningEveningNews
morningEveningNewsOld
=
morningEveningNewsDao
.
getById
(
morningEveningNews
.
getId
());
if
(
morningEveningNewsOld
==
null
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"未找到该数据!"
);
}
//修改
morningEveningNewsDao
.
update
(
morningEveningNews
);
//删除之前的早晚报定时任务
deleteNewsSch
(
MORNING_NEWS_SCHEDULE
);
deleteNewsSch
(
EVENING_NEWS_SCHEDULE
);
if
(
morningEveningNews
.
getHasMorningOpen
())
{
//早报定时任务
addNewsSch
(
morningEveningNews
.
getMorningTime
(),
MORNING_NEWS_SCHEDULE
,
morningEveningNewsOld
.
getCreateUser
());
}
if
(
morningEveningNews
.
getHasEveningOpen
())
{
//晚报定时任务
addNewsSch
(
morningEveningNews
.
getEveningTime
(),
EVENING_NEWS_SCHEDULE
,
morningEveningNewsOld
.
getCreateUser
());
}
}
@ParamLog
(
"删除早晚报定时任务"
)
private
void
deleteNewsSch
(
String
jobName
)
{
try
{
scheduleService
.
deleteJob
(
jobName
,
"book"
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"删除定时任务失败"
);
}
}
@ParamLog
(
"获取早晚报"
)
@Override
public
MorningEveningNews
getMorningEveningNews
(
Long
partyId
)
{
return
morningEveningNewsDao
.
getByPartyId
(
partyId
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"发送早晚报"
)
@Override
public
void
sendMorningEveningNews
(
Long
partyId
)
{
//查询要发送的早晚报基本信息
MorningEveningNews
morningEveningNews
=
morningEveningNewsDao
.
getByPartyId
(
partyId
);
if
(
morningEveningNews
==
null
)
{
return
;
}
Integer
top
=
morningEveningNews
.
getSendCount
();
//查询群人数>10的群
List
<
GroupQrcode
>
groupQrcodes
=
groupQrcodeDao
.
getListByUserCount
(
10
);
if
(
ListUtils
.
isEmpty
(
groupQrcodes
))
{
return
;
}
List
<
String
>
wechatGroupIds
=
groupQrcodes
.
stream
().
map
(
GroupQrcode:
:
getWeixinGroupId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
classifyIds
=
groupQrcodes
.
stream
().
map
(
GroupQrcode:
:
getClassifyId
).
collect
(
Collectors
.
toList
());
List
<
ClassifyDTO
>
classifyDTOS
=
bookGroupClassifyDao
.
getNameWithBookNameByIds
(
classifyIds
);
Map
<
Long
,
String
>
classifyNameMap
=
new
HashMap
<>();
for
(
ClassifyDTO
classifyDTO
:
classifyDTOS
)
{
classifyNameMap
.
put
(
classifyDTO
.
getId
(),
classifyDTO
.
getClassify
());
}
//查询发送记录
List
<
PushNewsRecord
>
pushNewsRecords
=
pushNewsRecordDao
.
getListByGroupIds
(
wechatGroupIds
);
Map
<
String
,
List
<
PushNewsRecord
>>
pushNewsMap
=
pushNewsRecords
.
stream
().
collect
(
Collectors
.
groupingBy
(
PushNewsRecord:
:
getWeixinGroupId
));
Map
<
String
,
String
>
classifyNameToWeixinIdMap
=
new
HashMap
<>();
for
(
GroupQrcode
groupQrcode
:
groupQrcodes
)
{
classifyNameToWeixinIdMap
.
put
(
groupQrcode
.
getWeixinGroupId
(),
classifyNameMap
.
get
(
groupQrcode
.
getClassifyId
()));
}
//内部接口批量获取小号id
Map
<
String
,
String
>
weixinIdToRobotMap
=
wechatGroupConsr
.
getSendDailyRobotByGroupIds
(
wechatGroupIds
);
List
<
List
<
String
>>
weixinIdsList
=
weixinIdsList
(
weixinIdToRobotMap
);
String
startContent
=
null
;
String
endContent
=
null
;
if
(
morningEveningNews
.
getHasStartContent
()
&&
!
StringUtil
.
isEmpty
(
morningEveningNews
.
getStartContent
()))
{
startContent
=
morningEveningNews
.
getStartContent
();
}
if
(
morningEveningNews
.
getHasEndContent
()
&&
!
StringUtil
.
isEmpty
(
morningEveningNews
.
getEndContent
()))
{
endContent
=
morningEveningNews
.
getEndContent
();
}
if
(!
ListUtils
.
isEmpty
(
weixinIdsList
))
{
for
(
List
<
String
>
weixinIds
:
weixinIdsList
)
{
if
(!
ListUtils
.
isEmpty
(
weixinIds
))
{
//发送一组小号不一样的群
sendNewsGroup
(
weixinIds
,
pushNewsMap
,
classifyNameToWeixinIdMap
,
weixinIdToRobotMap
,
top
,
startContent
,
endContent
);
LOGGER
.
info
(
"一组消息发送完成"
+
weixinIds
.
toString
());
try
{
LOGGER
.
info
(
"一组消息发完之后线程等2秒之后再发下一组"
);
Thread
.
sleep
(
2000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
LOGGER
.
info
(
"所有消息发送完毕!"
);
}
}
/**
* 发送一组群消息
*/
private
void
sendNewsGroup
(
List
<
String
>
weixinIds
,
Map
<
String
,
List
<
PushNewsRecord
>>
pushNewsMap
,
Map
<
String
,
String
>
classifyNameToWeixinIdMap
,
Map
<
String
,
String
>
weixinIdToRobotMap
,
Integer
top
,
String
startContent
,
String
endContent
)
{
if
(!
ListUtils
.
isEmpty
(
weixinIds
))
{
for
(
String
weixinGroupId
:
weixinIds
)
{
List
<
PushNewsRecord
>
pushNewsRecordList
=
pushNewsMap
.
get
(
weixinGroupId
);
List
<
Long
>
hasPushNewsIds
=
new
ArrayList
<>();
if
(!
ListUtils
.
isEmpty
(
pushNewsRecordList
))
{
hasPushNewsIds
=
pushNewsRecordList
.
stream
().
filter
(
s
->
s
.
getNewsId
()
!=
null
).
map
(
PushNewsRecord:
:
getNewsId
).
collect
(
Collectors
.
toList
());
}
//按照群排除已经发送的新闻
String
classify
=
classifyNameToWeixinIdMap
.
get
(
weixinGroupId
);
List
<
ESNews
>
news
=
esNewsBiz
.
getNews
(
classify
,
hasPushNewsIds
,
top
);
if
(!
ListUtils
.
isEmpty
(
news
))
{
//发送早晚报
String
robotId
=
weixinIdToRobotMap
.
get
(
weixinGroupId
);
if
(!
StringUtil
.
isEmpty
(
startContent
))
{
//发送开场语
sendText
(
startContent
,
robotId
,
weixinGroupId
);
}
//发送中间信息
sendNews
(
news
,
robotId
,
weixinGroupId
);
if
(!
StringUtil
.
isEmpty
(
endContent
))
{
//发送结束语
sendText
(
endContent
,
robotId
,
weixinGroupId
);
}
List
<
PushNewsRecord
>
pushNewsRecordsToAdd
=
new
ArrayList
<>();
for
(
ESNews
esNews
:
news
)
{
PushNewsRecord
pushNewsRecord
=
new
PushNewsRecord
();
pushNewsRecord
.
setNewsId
(
new
Long
(
esNews
.
getId
()));
pushNewsRecord
.
setWeixinGroupId
(
weixinGroupId
);
pushNewsRecordsToAdd
.
add
(
pushNewsRecord
);
}
//存发送记录
pushNewsRecordDao
.
batchInsert
(
pushNewsRecordsToAdd
);
}
}
}
}
/**
* 转换为一组一组,每组小号不一样,同时发
*/
private
List
<
List
<
String
>>
weixinIdsList
(
Map
<
String
,
String
>
weixinIdToRobotMap
)
{
List
<
String
>
robotsIds
=
new
ArrayList
<>(
weixinIdToRobotMap
.
values
()).
stream
().
distinct
().
collect
(
Collectors
.
toList
());
List
<
String
>
weixinIds
=
new
ArrayList
<>(
weixinIdToRobotMap
.
keySet
());
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
for
(
String
robotId
:
robotsIds
)
{
for
(
String
weixinId
:
weixinIds
)
{
if
(
weixinIdToRobotMap
.
get
(
weixinId
).
equals
(
robotId
))
{
List
<
String
>
oldOne
=
map
.
get
(
robotId
);
if
(
oldOne
==
null
)
{
List
<
String
>
newOne
=
new
ArrayList
<>();
newOne
.
add
(
weixinId
);
map
.
put
(
robotId
,
newOne
);
}
else
{
oldOne
.
add
(
weixinId
);
map
.
put
(
robotId
,
oldOne
);
}
}
}
}
List
<
List
<
String
>>
result
=
new
ArrayList
<>();
List
<
String
>
allWeixinIds
=
new
ArrayList
<>();
allWeixinIds
.
addAll
(
weixinIds
);
while
(!
ListUtils
.
isEmpty
(
allWeixinIds
))
{
List
<
String
>
oneGroup
=
new
ArrayList
<>();
for
(
String
robotId
:
robotsIds
)
{
List
<
String
>
weixinIdsForOne
=
map
.
get
(
robotId
);
Iterator
<
String
>
iterator
=
weixinIdsForOne
.
iterator
();
while
(
iterator
.
hasNext
())
{
oneGroup
.
add
(
iterator
.
next
());
iterator
.
remove
();
break
;
}
}
result
.
add
(
oneGroup
);
allWeixinIds
.
removeAll
(
oneGroup
);
}
LOGGER
.
info
(
"转换List<List<String>>结果"
+
result
.
toString
());
return
result
;
}
/**
* 发送消息
*/
private
void
sendNews
(
List
<
ESNews
>
esNewsList
,
String
robotId
,
String
weixinGroupId
)
{
if
(!
ListUtils
.
isEmpty
(
esNewsList
))
{
List
<
String
>
contents
=
new
ArrayList
<>();
String
content
=
""
;
int
i
=
1
;
for
(
ESNews
esNews
:
esNewsList
)
{
String
contentL
=
content
+
i
+
"."
+
esNews
.
getTitle
()
+
esNews
.
getUrl
()
+
"\n"
;
if
(
contentL
.
length
()
>=
300
)
{
contents
.
add
(
content
);
content
=
i
+
"."
+
esNews
.
getTitle
()
+
esNews
.
getUrl
()
+
"\n"
;
}
else
{
content
=
contentL
;
}
if
(
i
==
esNewsList
.
size
())
{
contents
.
add
(
content
);
}
i
=
i
+
1
;
}
if
(!
ListUtils
.
isEmpty
(
contents
))
{
for
(
String
contentToSend
:
contents
)
{
sendText
(
contentToSend
,
robotId
,
weixinGroupId
);
}
}
}
}
/**
* 发送文本消息
*/
private
void
sendText
(
String
content
,
String
robotId
,
String
weixinGroupId
)
{
SendTextMessageVO
sendTextMessageVO
=
new
SendTextMessageVO
();
sendTextMessageVO
.
setContent
(
content
);
sendTextMessageVO
.
setAltId
(
robotId
);
sendTextMessageVO
.
setGroupId
(
weixinGroupId
);
WxGroupSDK
.
sendTextMessage
(
sendTextMessageVO
);
LOGGER
.
info
(
"发送早晚报"
+
sendTextMessageVO
.
toString
());
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"新增计划式群发"
)
@Override
public
void
createPushPlan
(
PushPlanDTO
pushPlanDTO
)
{
...
...
pcloud-service-book/src/main/java/com/pcloud/book/push/check/PushCheck.java
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
check
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.push.entity.MorningEveningNews
;
import
com.pcloud.book.push.entity.Push
;
import
com.pcloud.book.push.entity.PushGroup
;
import
com.pcloud.book.push.entity.PushItem
;
...
...
@@ -250,4 +251,34 @@ public class PushCheck {
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"发送消息项内容类型为图片时,图片不能为空!"
);
}
}
/**
* 新增早晚报参数校验
* @param morningEveningNews
*/
public
void
createMorningEveningNewsParamCheck
(
MorningEveningNews
morningEveningNews
)
{
if
(
morningEveningNews
.
getHasMorningOpen
()==
null
||
morningEveningNews
.
getHasEveningOpen
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"是否开启早报和晚报不能为空!"
);
}
if
(
morningEveningNews
.
getHasStartContent
()==
null
||
morningEveningNews
.
getHasEndContent
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"是否开启开场和结束语不能为空!"
);
}
if
(
morningEveningNews
.
getSendCount
()==
null
||
morningEveningNews
.
getSendCount
()<=
0
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"推送条数必须不能为空且大于0!"
);
}
if
(
morningEveningNews
.
getHasMorningOpen
()&&
StringUtil
.
isEmpty
(
morningEveningNews
.
getMorningTime
())){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"开启早报后,早报时间不能为空!"
);
}
if
(
morningEveningNews
.
getHasEveningOpen
()&&
StringUtil
.
isEmpty
(
morningEveningNews
.
getEveningTime
())){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"开启晚报后,晚报时间不能为空!"
);
}
if
(
morningEveningNews
.
getHasStartContent
()&&
StringUtil
.
isEmpty
(
morningEveningNews
.
getStartContent
())){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"开启开场语后,开场语不能为空!"
);
}
if
(
morningEveningNews
.
getHasEndContent
()&&
StringUtil
.
isEmpty
(
morningEveningNews
.
getEndContent
())){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"开启结束语后,结束语不能为空!"
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/push/dao/MorningEveningNewsDao.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
dao
;
import
com.pcloud.book.push.entity.MorningEveningNews
;
import
com.pcloud.common.core.dao.BaseDao
;
public
interface
MorningEveningNewsDao
extends
BaseDao
<
MorningEveningNews
>
{
/**
* 获取详情
* @param partyId
* @return
*/
MorningEveningNews
getByPartyId
(
Long
partyId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/push/dao/NewsDao.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
dao
;
import
com.pcloud.book.es.entity.ESNews
;
import
com.pcloud.book.push.entity.News
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/13 17:45
**/
public
interface
NewsDao
extends
BaseDao
<
News
>
{
List
<
ESNews
>
findAll
(
Long
maxId
,
Integer
offset
);
Integer
count
();
void
batchInsert
(
List
<
News
>
news
);
News
getByUrl
(
String
url
);
}
pcloud-service-book/src/main/java/com/pcloud/book/push/dao/PushNewsRecordDao.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
dao
;
import
com.pcloud.book.push.entity.PushNewsRecord
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
public
interface
PushNewsRecordDao
extends
BaseDao
<
PushNewsRecord
>
{
/**
* 根据微信群id集合查询发送记录
* @param weixinGroupIds
* @return
*/
List
<
PushNewsRecord
>
getListByGroupIds
(
List
<
String
>
weixinGroupIds
);
/**
* 批量新增
* @param pushNewsRecords
*/
void
batchInsert
(
List
<
PushNewsRecord
>
pushNewsRecords
);
}
pcloud-service-book/src/main/java/com/pcloud/book/push/dao/impl/MorningEveningNewsDaoImpl.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
dao
.
impl
;
import
com.pcloud.book.push.dao.MorningEveningNewsDao
;
import
com.pcloud.book.push.entity.MorningEveningNews
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Repository
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/3 11:44
**/
@Repository
(
"morningEveningNewsDao"
)
public
class
MorningEveningNewsDaoImpl
extends
BaseDaoImpl
<
MorningEveningNews
>
implements
MorningEveningNewsDao
{
@Override
public
MorningEveningNews
getByPartyId
(
Long
partyId
)
{
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getByPartyId"
),
partyId
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/push/dao/impl/NewsDaoImpl.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
dao
.
impl
;
import
com.pcloud.book.es.entity.ESNews
;
import
com.pcloud.book.push.dao.NewsDao
;
import
com.pcloud.book.push.entity.News
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Repository
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/13 17:46
**/
@Repository
(
"newsDao"
)
public
class
NewsDaoImpl
extends
BaseDaoImpl
<
News
>
implements
NewsDao
{
@Override
public
List
<
ESNews
>
findAll
(
Long
maxId
,
Integer
offset
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"maxId"
,
maxId
);
map
.
put
(
"offset"
,
offset
);
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"findAll"
),
map
);
}
@Override
public
Integer
count
()
{
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"count"
));
}
@Override
public
void
batchInsert
(
List
<
News
>
news
)
{
super
.
getSqlSession
().
insert
(
getStatement
(
"batchInsert"
),
news
);
}
@Override
public
News
getByUrl
(
String
url
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"url"
,
url
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getByUrl"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/push/dao/impl/PushNewsRecordDaoImpl.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
dao
.
impl
;
import
com.pcloud.book.push.dao.PushNewsRecordDao
;
import
com.pcloud.book.push.entity.PushNewsRecord
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Repository
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/14 12:05
**/
@Repository
(
"pushNewsRecordDao"
)
public
class
PushNewsRecordDaoImpl
extends
BaseDaoImpl
<
PushNewsRecord
>
implements
PushNewsRecordDao
{
@Override
public
List
<
PushNewsRecord
>
getListByGroupIds
(
List
<
String
>
weixinGroupIds
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"weixinGroupIds"
,
weixinGroupIds
);
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"getListByGroupIds"
),
map
);
}
@Override
public
void
batchInsert
(
List
<
PushNewsRecord
>
pushNewsRecords
)
{
super
.
getSqlSession
().
insert
(
getStatement
(
"batchInsert"
),
pushNewsRecords
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/push/entity/MorningEveningNews.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/3 10:02
**/
@ApiModel
(
"微信早晚报推送模型"
)
public
class
MorningEveningNews
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
53098150399104256L
;
@ApiModelProperty
(
"早报时间"
)
private
String
morningTime
;
@ApiModelProperty
(
"晚报时间"
)
private
String
eveningTime
;
@ApiModelProperty
(
"是否开启早报"
)
private
Boolean
hasMorningOpen
;
@ApiModelProperty
(
"是否开启晚报"
)
private
Boolean
hasEveningOpen
;
@ApiModelProperty
(
"发送次数"
)
private
Integer
sendCount
;
@ApiModelProperty
(
"开场语"
)
private
String
startContent
;
@ApiModelProperty
(
"结束语"
)
private
String
endContent
;
@ApiModelProperty
(
"是否开启开场语"
)
private
Boolean
hasStartContent
;
@ApiModelProperty
(
"是否开启结束语"
)
private
Boolean
hasEndContent
;
@ApiModelProperty
(
"创建人"
)
private
Long
createUser
;
@ApiModelProperty
(
"修改人"
)
private
Long
updateUser
;
public
String
getMorningTime
()
{
return
morningTime
;
}
public
void
setMorningTime
(
String
morningTime
)
{
this
.
morningTime
=
morningTime
;
}
public
String
getEveningTime
()
{
return
eveningTime
;
}
public
void
setEveningTime
(
String
eveningTime
)
{
this
.
eveningTime
=
eveningTime
;
}
public
Boolean
getHasMorningOpen
()
{
return
hasMorningOpen
;
}
public
void
setHasMorningOpen
(
Boolean
hasMorningOpen
)
{
this
.
hasMorningOpen
=
hasMorningOpen
;
}
public
Boolean
getHasEveningOpen
()
{
return
hasEveningOpen
;
}
public
void
setHasEveningOpen
(
Boolean
hasEveningOpen
)
{
this
.
hasEveningOpen
=
hasEveningOpen
;
}
public
Integer
getSendCount
()
{
return
sendCount
;
}
public
void
setSendCount
(
Integer
sendCount
)
{
this
.
sendCount
=
sendCount
;
}
public
String
getStartContent
()
{
return
startContent
;
}
public
void
setStartContent
(
String
startContent
)
{
this
.
startContent
=
startContent
;
}
public
String
getEndContent
()
{
return
endContent
;
}
public
void
setEndContent
(
String
endContent
)
{
this
.
endContent
=
endContent
;
}
public
Boolean
getHasStartContent
()
{
return
hasStartContent
;
}
public
void
setHasStartContent
(
Boolean
hasStartContent
)
{
this
.
hasStartContent
=
hasStartContent
;
}
public
Boolean
getHasEndContent
()
{
return
hasEndContent
;
}
public
void
setHasEndContent
(
Boolean
hasEndContent
)
{
this
.
hasEndContent
=
hasEndContent
;
}
public
Long
getCreateUser
()
{
return
createUser
;
}
public
void
setCreateUser
(
Long
createUser
)
{
this
.
createUser
=
createUser
;
}
public
Long
getUpdateUser
()
{
return
updateUser
;
}
public
void
setUpdateUser
(
Long
updateUser
)
{
this
.
updateUser
=
updateUser
;
}
@Override
public
String
toString
()
{
return
"MorningEveningNews{"
+
"morningTime='"
+
morningTime
+
'\''
+
", eveningTime='"
+
eveningTime
+
'\''
+
", hasMorningOpen="
+
hasMorningOpen
+
", hasEveningOpen="
+
hasEveningOpen
+
", sendCount="
+
sendCount
+
", startContent='"
+
startContent
+
'\''
+
", endContent='"
+
endContent
+
'\''
+
", hasStartContent="
+
hasStartContent
+
", hasEndContent="
+
hasEndContent
+
", createUser="
+
createUser
+
", updateUser="
+
updateUser
+
"} "
+
super
.
toString
();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/push/entity/News.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/13 17:16
**/
@ApiModel
(
"新闻模型"
)
public
class
News
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
-
3896134057717180981L
;
/**
* 类型
*/
private
String
type
;
/**
* 来源
*/
private
String
newsFrom
;
/**
* 标题
*/
private
String
title
;
/**
* 发布者
*/
private
String
publisher
;
/**
* 链接
*/
private
String
url
;
/**
* 短链接
*/
private
String
shortUrl
;
/**
* 发布日期
*/
private
String
newsDate
;
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getNewsFrom
()
{
return
newsFrom
;
}
public
void
setNewsFrom
(
String
newsFrom
)
{
this
.
newsFrom
=
newsFrom
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getPublisher
()
{
return
publisher
;
}
public
void
setPublisher
(
String
publisher
)
{
this
.
publisher
=
publisher
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getShortUrl
()
{
return
shortUrl
;
}
public
void
setShortUrl
(
String
shortUrl
)
{
this
.
shortUrl
=
shortUrl
;
}
public
String
getNewsDate
()
{
return
newsDate
;
}
public
void
setNewsDate
(
String
newsDate
)
{
this
.
newsDate
=
newsDate
;
}
@Override
public
String
toString
()
{
return
"News{"
+
"type='"
+
type
+
'\''
+
", newsFrom='"
+
newsFrom
+
'\''
+
", title='"
+
title
+
'\''
+
", publisher='"
+
publisher
+
'\''
+
", url='"
+
url
+
'\''
+
", shortUrl='"
+
shortUrl
+
'\''
+
", newsDate='"
+
newsDate
+
'\''
+
"} "
+
super
.
toString
();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/push/entity/PushNewsRecord.java
0 → 100644
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/14 12:02
**/
@ApiModel
(
"早晚报推送记录"
)
public
class
PushNewsRecord
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
9057936389239373740L
;
@ApiModelProperty
(
"微信群id"
)
private
String
weixinGroupId
;
@ApiModelProperty
(
"新闻id"
)
private
Long
newsId
;
public
String
getWeixinGroupId
()
{
return
weixinGroupId
;
}
public
void
setWeixinGroupId
(
String
weixinGroupId
)
{
this
.
weixinGroupId
=
weixinGroupId
;
}
public
Long
getNewsId
()
{
return
newsId
;
}
public
void
setNewsId
(
Long
newsId
)
{
this
.
newsId
=
newsId
;
}
@Override
public
String
toString
()
{
return
"PushNewsRecord{"
+
"weixinGroupId='"
+
weixinGroupId
+
'\''
+
", newsId="
+
newsId
+
"} "
+
super
.
toString
();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/push/facade/PushFacade.java
View file @
5b7a4614
package
com
.
pcloud
.
book
.
push
.
facade
;
import
com.pcloud.book.push.dto.PushPlanDTO
;
import
com.pcloud.book.push.entity.MorningEveningNews
;
import
com.pcloud.book.push.entity.Push
;
import
com.pcloud.book.push.entity.PushGroup
;
import
com.pcloud.book.push.entity.PushItem
;
...
...
@@ -116,6 +117,26 @@ public interface PushFacade {
@RequestParam
(
"numPerPage"
)
@ApiParam
(
"每页条数"
)
Integer
numPerPage
)
throws
BizException
,
PermissionException
;
@ApiOperation
(
"新增早晚报"
)
@PostMapping
(
"/createMorningEveningNews"
)
ResponseDto
<?>
createMorningEveningNews
(
@RequestHeader
(
"token"
)
@ApiParam
(
"token信息"
)
String
token
,
@RequestBody
@ApiParam
(
"早晚报模型"
)
MorningEveningNews
morningEveningNews
)
throws
BizException
,
PermissionException
;
@ApiOperation
(
"修改早晚报"
)
@PostMapping
(
"/updateMorningEveningNews"
)
ResponseDto
<?>
updateMorningEveningNews
(
@RequestHeader
(
"token"
)
@ApiParam
(
"token信息"
)
String
token
,
@RequestBody
@ApiParam
(
"新增早晚报模型"
)
MorningEveningNews
morningEveningNews
)
throws
BizException
,
PermissionException
;
@ApiOperation
(
"获取早晚报"
)
@GetMapping
(
"/getMorningEveningNews"
)
ResponseDto
<?>
getMorningEveningNews
(
@RequestHeader
(
"token"
)
@ApiParam
(
"token信息"
)
String
token
)
throws
BizException
,
PermissionException
;
@ApiOperation
(
"新增计划式群发"
)
@PostMapping
(
"/createPushPlan"
)
...
...
pcloud-service-book/src/main/java/com/pcloud/book/push/facade/impl/PushFacadeImpl.java
View file @
5b7a4614
...
...
@@ -3,10 +3,12 @@ package com.pcloud.book.push.facade.impl;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.push.biz.PushBiz
;
import
com.pcloud.book.push.dto.PushPlanDTO
;
import
com.pcloud.book.push.entity.MorningEveningNews
;
import
com.pcloud.book.push.entity.Push
;
import
com.pcloud.book.push.entity.PushGroup
;
import
com.pcloud.book.push.entity.PushItem
;
import
com.pcloud.book.push.facade.PushFacade
;
import
com.pcloud.common.core.constant.SystemCode
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.permission.PermissionException
;
...
...
@@ -223,6 +225,63 @@ public class PushFacadeImpl implements PushFacade {
return
new
ResponseDto
<>(
pushBiz
.
getPushRecordList
(
partyId
,
currentPage
,
numPerPage
));
}
@ApiOperation
(
"新增早晚报"
)
@PostMapping
(
"/createMorningEveningNews"
)
@Override
public
ResponseDto
<?>
createMorningEveningNews
(
@RequestHeader
(
"token"
)
@ApiParam
(
"token信息"
)
String
token
,
@RequestBody
@ApiParam
(
"早晚报模型"
)
MorningEveningNews
morningEveningNews
)
throws
BizException
,
PermissionException
{
if
(
morningEveningNews
==
null
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数为空!"
);
}
String
systemCode
=
(
String
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
SYSTEM_CODE
);
if
(!
SystemCode
.
pcloud
.
code
.
equalsIgnoreCase
(
systemCode
))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"登陆角色不正确!"
);
}
Long
partyId
=
(
Long
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
PARTY_ID
);
morningEveningNews
.
setCreateUser
(
partyId
);
morningEveningNews
.
setUpdateUser
(
partyId
);
return
new
ResponseDto
<>(
pushBiz
.
createMorningEveningNews
(
morningEveningNews
));
}
@ApiOperation
(
"修改早晚报"
)
@PostMapping
(
"/updateMorningEveningNews"
)
@Override
public
ResponseDto
<?>
updateMorningEveningNews
(
@RequestHeader
(
"token"
)
@ApiParam
(
"token信息"
)
String
token
,
@RequestBody
@ApiParam
(
"早晚报模型"
)
MorningEveningNews
morningEveningNews
)
throws
BizException
,
PermissionException
{
String
systemCode
=
(
String
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
SYSTEM_CODE
);
if
(!
SystemCode
.
pcloud
.
code
.
equalsIgnoreCase
(
systemCode
))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"登陆角色不正确!"
);
}
if
(
morningEveningNews
==
null
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数为空!"
);
}
if
(
morningEveningNews
.
getId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"早晚报id为空!"
);
}
Long
partyId
=
(
Long
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
PARTY_ID
);
morningEveningNews
.
setUpdateUser
(
partyId
);
pushBiz
.
updateMorningEveningNews
(
morningEveningNews
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"获取早晚报"
)
@GetMapping
(
"/getMorningEveningNews"
)
@Override
public
ResponseDto
<?>
getMorningEveningNews
(
@RequestHeader
(
"token"
)
@ApiParam
(
"token信息"
)
String
token
)
throws
BizException
,
PermissionException
{
String
systemCode
=
(
String
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
SYSTEM_CODE
);
if
(!
SystemCode
.
pcloud
.
code
.
equalsIgnoreCase
(
systemCode
))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"登陆角色不正确!"
);
}
Long
partyId
=
(
Long
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
PARTY_ID
);
return
new
ResponseDto
<>(
pushBiz
.
getMorningEveningNews
(
partyId
));
}
@ApiOperation
(
"新增计划式群发"
)
@PostMapping
(
"/createPushPlan"
)
@Override
...
...
pcloud-service-book/src/main/java/com/pcloud/book/push/service/impl/PushServiceImpl.java
View file @
5b7a4614
...
...
@@ -7,12 +7,11 @@ import io.swagger.annotations.ApiOperation;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
/**
* @Description
...
...
@@ -25,6 +24,8 @@ public class PushServiceImpl implements PushService {
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
PushServiceImpl
.
class
);
private
static
final
ExecutorService
EXECUTOR_SINGLE_SERVICE
=
Executors
.
newSingleThreadExecutor
();
@Autowired
private
PushBiz
pushBiz
;
...
...
@@ -36,4 +37,13 @@ public class PushServiceImpl implements PushService {
LOGGER
.
info
(
"内部接口群发消息被调用"
+
map
.
toString
());
pushBiz
.
sendGroupMessage
(
new
Long
(
map
.
get
(
"pushId"
).
toString
()));
}
@ApiOperation
(
"发送早晚报"
)
@PostMapping
(
"/sendMorningEveningNews"
)
@Override
public
void
sendMorningEveningNews
(
@RequestBody
Map
<
String
,
Object
>
map
)
throws
BizException
{
LOGGER
.
info
(
"内部接口发送早晚报被调用"
+
map
.
toString
());
//开线程跑,及时给定时任务返回,避免超时重复调用
EXECUTOR_SINGLE_SERVICE
.
execute
(()
->
pushBiz
.
sendMorningEveningNews
(
new
Long
(
map
.
get
(
"partyId"
).
toString
())));
}
}
pcloud-service-book/src/main/resources/mapper/group/GroupQrcode.Mapper.xml
View file @
5b7a4614
...
...
@@ -313,4 +313,10 @@
</set>
WHERE id = #{id}
</update>
<!--获取群人数大于或等于人数的群-->
<select
id=
"getListByUserCount"
parameterType=
"Integer"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from book_group_qrcode
where user_number>=#{userCount} and is_delete=0
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/push/MorningEveningNewsMapper.xml
0 → 100644
View file @
5b7a4614
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.push.dao.impl.MorningEveningNewsDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.push.entity.MorningEveningNews"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"morning_time"
property=
"morningTime"
jdbcType=
"VARCHAR"
/>
<result
column=
"evening_time"
property=
"eveningTime"
jdbcType=
"VARCHAR"
/>
<result
column=
"has_morning_open"
property=
"hasMorningOpen"
jdbcType=
"BOOLEAN"
/>
<result
column=
"has_evening_open"
property=
"hasEveningOpen"
jdbcType=
"BOOLEAN"
/>
<result
column=
"send_count"
property=
"sendCount"
jdbcType=
"INTEGER"
/>
<result
column=
"start_content"
property=
"startContent"
jdbcType=
"VARCHAR"
/>
<result
column=
"end_content"
property=
"endContent"
jdbcType=
"VARCHAR"
/>
<result
column=
"has_start_content"
property=
"hasStartContent"
jdbcType=
"BOOLEAN"
/>
<result
column=
"has_end_content"
property=
"hasEndContent"
jdbcType=
"BOOLEAN"
/>
<result
column=
"create_user"
property=
"createUser"
jdbcType=
"BIGINT"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_user"
property=
"updateUser"
jdbcType=
"BIGINT"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, morning_time, evening_time, has_morning_open, has_evening_open, send_count, start_content,
end_content, has_start_content, has_end_content, create_user, create_time, update_user, update_time
</sql>
<select
id=
"getById"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Long"
>
select
<include
refid=
"Base_Column_List"
/>
from morning_evening_news
where id = #{id,jdbcType=BIGINT}
</select>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.push.entity.MorningEveningNews"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into morning_evening_news
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
morning_time,
evening_time,
has_morning_open,
has_evening_open,
send_count,
start_content,
end_content,
has_start_content,
has_end_content,
create_user,
create_time,
update_user,
update_time
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
#{morningTime,jdbcType=VARCHAR},
#{eveningTime,jdbcType=VARCHAR},
#{hasMorningOpen,jdbcType=BOOLEAN},
#{hasEveningOpen,jdbcType=BOOLEAN},
#{sendCount,jdbcType=INTEGER},
#{startContent,jdbcType=VARCHAR},
#{endContent,jdbcType=VARCHAR},
#{hasStartContent,jdbcType=BOOLEAN},
#{hasEndContent,jdbcType=BOOLEAN},
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<update
id=
"update"
parameterType=
"com.pcloud.book.push.entity.MorningEveningNews"
>
update morning_evening_news
<set>
<if
test=
"morningTime != null"
>
morning_time = #{morningTime,jdbcType=VARCHAR},
</if>
<if
test=
"eveningTime != null"
>
evening_time = #{eveningTime,jdbcType=VARCHAR},
</if>
<if
test=
"hasMorningOpen != null"
>
has_morning_open = #{hasMorningOpen,jdbcType=BOOLEAN},
</if>
<if
test=
"hasEveningOpen != null"
>
has_evening_open = #{hasEveningOpen,jdbcType=BOOLEAN},
</if>
<if
test=
"sendCount != null"
>
send_count = #{sendCount,jdbcType=INTEGER},
</if>
<if
test=
"startContent != null"
>
start_content = #{startContent,jdbcType=VARCHAR},
</if>
<if
test=
"endContent != null"
>
end_content = #{endContent,jdbcType=VARCHAR},
</if>
<if
test=
"hasStartContent != null"
>
has_start_content = #{hasStartContent,jdbcType=BOOLEAN},
</if>
<if
test=
"hasEndContent != null"
>
has_end_content = #{hasEndContent,jdbcType=BOOLEAN},
</if>
<if
test=
"updateUser != null"
>
update_user = #{updateUser,jdbcType=BIGINT},
</if>
update_time = NOW(),
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select
id=
"getByPartyId"
parameterType=
"Long"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from morning_evening_news where create_user=#{partyId}
order by create_time desc limit 1
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/push/NewsMapper.xml
0 → 100644
View file @
5b7a4614
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.push.dao.impl.NewsDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.push.entity.News"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"type"
property=
"type"
jdbcType=
"VARCHAR"
/>
<result
column=
"news_from"
property=
"newsFrom"
jdbcType=
"VARCHAR"
/>
<result
column=
"title"
property=
"title"
jdbcType=
"VARCHAR"
/>
<result
column=
"publisher"
property=
"publisher"
jdbcType=
"VARCHAR"
/>
<result
column=
"url"
property=
"url"
jdbcType=
"VARCHAR"
/>
<result
column=
"short_url"
property=
"shortUrl"
jdbcType=
"VARCHAR"
/>
<result
column=
"news_date"
property=
"newsDate"
jdbcType=
"VARCHAR"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<resultMap
id=
"BaseResultESMap"
type=
"com.pcloud.book.es.entity.ESNews"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"type"
property=
"type"
jdbcType=
"VARCHAR"
/>
<result
column=
"news_from"
property=
"newsFrom"
jdbcType=
"VARCHAR"
/>
<result
column=
"title"
property=
"title"
jdbcType=
"VARCHAR"
/>
<result
column=
"publisher"
property=
"publisher"
jdbcType=
"VARCHAR"
/>
<result
column=
"url"
property=
"url"
jdbcType=
"VARCHAR"
/>
<result
column=
"short_url"
property=
"shortUrl"
jdbcType=
"VARCHAR"
/>
<result
column=
"news_date"
property=
"newsDate"
jdbcType=
"VARCHAR"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, type, news_from, title, publisher, url, short_url, news_date, create_time
</sql>
<select
id=
"getById"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Long"
>
select
<include
refid=
"Base_Column_List"
/>
from news
where id = #{id,jdbcType=BIGINT}
</select>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.push.entity.News"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into news
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
type,
news_from,
title,
publisher,
url,
short_url,
news_date,
create_time
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
#{type,jdbcType=VARCHAR},
#{newsFrom,jdbcType=VARCHAR},
#{title,jdbcType=VARCHAR},
#{publisher,jdbcType=VARCHAR},
#{url,jdbcType=VARCHAR},
#{shortUrl,jdbcType=VARCHAR},
#{newsDate,jdbcType=VARCHAR},
NOW()
</trim>
</insert>
<update
id=
"update"
parameterType=
"com.pcloud.book.push.entity.News"
>
update news
<set>
<if
test=
"type != null"
>
type = #{type,jdbcType=VARCHAR},
</if>
<if
test=
"newsFrom != null"
>
news_from = #{newsFrom,jdbcType=VARCHAR},
</if>
<if
test=
"title != null"
>
title = #{title,jdbcType=VARCHAR},
</if>
<if
test=
"publisher != null"
>
publisher = #{publisher,jdbcType=VARCHAR},
</if>
<if
test=
"url != null"
>
url = #{url,jdbcType=VARCHAR},
</if>
<if
test=
"shortUrl != null"
>
short_url = #{shortUrl,jdbcType=VARCHAR},
</if>
<if
test=
"newsDate != null"
>
news_date = #{newsDate,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<!--查询所有-->
<select
id=
"findAll"
parameterType=
"map"
resultMap=
"BaseResultESMap"
>
select
<include
refid=
"Base_Column_List"
/>
from news
where id>#{maxId}
limit #{offset}
</select>
<!--获取全表数量-->
<select
id=
"count"
resultType=
"Integer"
>
select count(1) from news
</select>
<!--批量新增-->
<insert
id=
"batchInsert"
useGeneratedKeys=
"true"
parameterType=
"java.util.List"
>
insert into news (
type,
news_from,
title,
publisher,
url,
short_url,
news_date,
create_time
)
values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
#{item.type,jdbcType=VARCHAR},
#{item.newsFrom,jdbcType=VARCHAR},
#{item.title,jdbcType=VARCHAR},
#{item.publisher,jdbcType=VARCHAR},
#{item.url,jdbcType=VARCHAR},
#{item.shortUrl,jdbcType=VARCHAR},
#{item.newsDate,jdbcType=VARCHAR},
NOW()
)
</foreach>
</insert>
<!--根据链接查询-->
<select
id=
"getByUrl"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from news
where url = #{url} limit 1
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/push/PushNewsRecordMapper.xml
0 → 100644
View file @
5b7a4614
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.push.dao.impl.PushNewsRecordDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.push.entity.PushNewsRecord"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"weixin_group_id"
property=
"weixinGroupId"
jdbcType=
"VARCHAR"
/>
<result
column=
"news_id"
property=
"newsId"
jdbcType=
"BIGINT"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, weixin_group_id, news_id, create_time
</sql>
<select
id=
"getById"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Long"
>
select
<include
refid=
"Base_Column_List"
/>
from push_news_record
id = #{id,jdbcType=BIGINT}
</select>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.push.entity.PushNewsRecord"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into push_news_record
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
weixin_group_id,
news_id,
create_time
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
#{weixinGroupId,jdbcType=VARCHAR},
#{newsId,jdbcType=BIGINT},
NOW()
</trim>
</insert>
<update
id=
"update"
parameterType=
"com.pcloud.book.push.entity.PushNewsRecord"
>
update push_news_record
<set>
<if
test=
"weixinGroupId != null"
>
weixin_group_id = #{weixinGroupId,jdbcType=VARCHAR},
</if>
<if
test=
"newsId != null"
>
news_id = #{newsId,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<!--根据微信群id集合查询发送记录-->
<select
id=
"getListByGroupIds"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from push_news_record
where weixin_group_id in
<foreach
collection=
"weixinGroupIds"
index=
"index"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</select>
<!--批量新增-->
<insert
id=
"batchInsert"
parameterType=
"com.pcloud.book.push.entity.PushNewsRecord"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into push_news_record (
weixin_group_id,
news_id,
create_time
) values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
#{item.weixinGroupId,jdbcType=VARCHAR},
#{item.newsId,jdbcType=BIGINT},
NOW()
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment