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
26d37862
Commit
26d37862
authored
Apr 23, 2020
by
郑勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版本回退后提交
parent
4bb6ee41
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
1608 additions
and
1 deletions
+1608
-1
CultivateNotifySend.java
...com/pcloud/book/cultivate/entity/CultivateNotifySend.java
+56
-0
CultivateNotifyService.java
...pcloud/book/cultivate/service/CultivateNotifyService.java
+36
-0
PcloudRobotService.java
...pcloud/book/pcloudKeyword/service/PcloudRobotService.java
+7
-0
BookDao.java
...-book/src/main/java/com/pcloud/book/book/dao/BookDao.java
+3
-0
SearchRecordDao.java
...c/main/java/com/pcloud/book/book/dao/SearchRecordDao.java
+7
-0
BookDaoImpl.java
.../main/java/com/pcloud/book/book/dao/impl/BookDaoImpl.java
+8
-0
SearchRecordDaoImpl.java
...va/com/pcloud/book/book/dao/impl/SearchRecordDaoImpl.java
+24
-0
ReaderConsr.java
...ain/java/com/pcloud/book/consumer/reader/ReaderConsr.java
+28
-0
WechatGroupConsr.java
...om/pcloud/book/consumer/wechatgroup/WechatGroupConsr.java
+8
-0
CultivateNotifyBiz.java
...ava/com/pcloud/book/cultivate/biz/CultivateNotifyBiz.java
+32
-0
CultivateNotifyBizImpl.java
...cloud/book/cultivate/biz/impl/CultivateNotifyBizImpl.java
+312
-0
NotifyParamCheck.java
...ava/com/pcloud/book/cultivate/check/NotifyParamCheck.java
+48
-0
CultivateNotifyDao.java
...ava/com/pcloud/book/cultivate/dao/CultivateNotifyDao.java
+11
-0
CultivateNotifyItemDao.java
...com/pcloud/book/cultivate/dao/CultivateNotifyItemDao.java
+15
-0
CultivateNotifySendDao.java
...com/pcloud/book/cultivate/dao/CultivateNotifySendDao.java
+25
-0
CultivateNotifyDaoImpl.java
...cloud/book/cultivate/dao/impl/CultivateNotifyDaoImpl.java
+22
-0
CultivateNotifyItemDaoImpl.java
...d/book/cultivate/dao/impl/CultivateNotifyItemDaoImpl.java
+27
-0
CultivateNotifySendDaoImpl.java
...d/book/cultivate/dao/impl/CultivateNotifySendDaoImpl.java
+67
-0
CultivateNotifyDTO.java
...ava/com/pcloud/book/cultivate/dto/CultivateNotifyDTO.java
+45
-0
CultivateNotifyPageDTO.java
...com/pcloud/book/cultivate/dto/CultivateNotifyPageDTO.java
+33
-0
CultivateNotifyTypeDTO.java
...com/pcloud/book/cultivate/dto/CultivateNotifyTypeDTO.java
+20
-0
SearchNotifyDTO.java
...n/java/com/pcloud/book/cultivate/dto/SearchNotifyDTO.java
+20
-0
SearchSendUserDTO.java
...java/com/pcloud/book/cultivate/dto/SearchSendUserDTO.java
+15
-0
SendUserDetailDto.java
...java/com/pcloud/book/cultivate/dto/SendUserDetailDto.java
+58
-0
WechatUserDTO.java
...ain/java/com/pcloud/book/cultivate/dto/WechatUserDTO.java
+15
-0
CultivateNotify.java
...ava/com/pcloud/book/cultivate/entity/CultivateNotify.java
+25
-0
CultivateNotifyItem.java
...com/pcloud/book/cultivate/entity/CultivateNotifyItem.java
+63
-0
NotifySendTypeEnum.java
...a/com/pcloud/book/cultivate/enums/NotifySendTypeEnum.java
+28
-0
CultivateNotifyFacade.java
...m/pcloud/book/cultivate/facade/CultivateNotifyFacade.java
+104
-0
CultivateNotifyServiceImpl.java
...ok/cultivate/service/impl/CultivateNotifyServiceImpl.java
+46
-0
PcloudRobotClassifyBiz.java
...pcloud/book/pcloudkeyword/biz/PcloudRobotClassifyBiz.java
+5
-0
PcloudRobotClassifyBizImpl.java
...ok/pcloudkeyword/biz/impl/PcloudRobotClassifyBizImpl.java
+14
-0
PcloudRobotClassifyDao.java
...pcloud/book/pcloudkeyword/dao/PcloudRobotClassifyDao.java
+4
-0
PcloudRobotClassifyDaoImpl.java
...ok/pcloudkeyword/dao/impl/PcloudRobotClassifyDaoImpl.java
+8
-1
PcloudRobotServiceImpl.java
...ok/pcloudkeyword/service/impl/PcloudRobotServiceImpl.java
+5
-0
ThreadPoolUtils.java
...ain/java/com/pcloud/book/util/common/ThreadPoolUtils.java
+11
-0
Book.Mapper.xml
...rvice-book/src/main/resources/mapper/book/Book.Mapper.xml
+19
-0
SearchRecord.xml
...vice-book/src/main/resources/mapper/book/SearchRecord.xml
+53
-0
CultivateNotify.xml
...k/src/main/resources/mapper/cultivate/CultivateNotify.xml
+64
-0
CultivateNotifyItem.xml
...c/main/resources/mapper/cultivate/CultivateNotifyItem.xml
+59
-0
CultivateNotifySend.xml
...c/main/resources/mapper/cultivate/CultivateNotifySend.xml
+144
-0
PcloudRobotClassify.Mapper.xml
...urces/mapper/pcloudkeyword/PcloudRobotClassify.Mapper.xml
+14
-0
No files found.
pcloud-facade-book/src/main/java/com/pcloud/book/cultivate/entity/CultivateNotifySend.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
entity
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.xml.bind.annotation.XmlElement
;
import
java.util.Date
;
@Data
@ApiModel
(
"小睿站内信发送"
)
public
class
CultivateNotifySend
extends
BaseEntity
{
@ApiModelProperty
(
"消息id"
)
private
Long
messageId
;
@ApiModelProperty
(
"用户wxId"
)
private
String
wxUserId
;
@ApiModelProperty
(
"用户微信id"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"发送类型(1-指定用户,2-分类用户,3-按书籍查询,4-全局公告消息)"
)
private
Integer
sendType
;
@ApiModelProperty
(
"消息类型(1-系统消息,2-通知消息,3-提醒消息,4-活动消息)"
)
private
Integer
messageType
;
@ApiModelProperty
(
"是否已读1-是,0-否"
)
private
Boolean
isRead
;
@ApiModelProperty
(
"阅读时间"
)
private
Date
readTime
;
@JSONField
(
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@XmlElement
public
Date
getReadTime
()
{
return
this
.
createTime
;
}
public
void
setReadTime
(
Date
readTime
)
{
this
.
readTime
=
readTime
;
}
}
pcloud-facade-book/src/main/java/com/pcloud/book/cultivate/service/CultivateNotifyService.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
service
;
import
com.pcloud.book.copyright.dto.BookAuthInfoCountDTO
;
import
com.pcloud.book.copyright.dto.BookAuthTotalCountDTO
;
import
com.pcloud.book.copyright.dto.CheckUserAuthDTO
;
import
com.pcloud.book.cultivate.entity.CultivateNotifySend
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
/**
* @author lily
* @date 2018/12/4 16:23
*/
@FeignClient
(
value
=
"pcloud-service-book"
,
qualifier
=
"cultivateNotifyServiceCloud"
,
path
=
"book/v1.0/cultivateNotifyService"
)
@Api
(
description
=
"小程序站内信"
)
public
interface
CultivateNotifyService
{
@ApiOperation
(
value
=
"批量插入发送小程序用户"
,
httpMethod
=
"POST"
)
@RequestMapping
(
value
=
"/batchSendMiniUser"
,
method
=
RequestMethod
.
POST
)
void
batchSendMiniUser
(
@RequestBody
List
<
CultivateNotifySend
>
list
)
throws
BizException
;
}
pcloud-facade-book/src/main/java/com/pcloud/book/pcloudKeyword/service/PcloudRobotService.java
View file @
26d37862
...
...
@@ -76,9 +76,16 @@ public interface PcloudRobotService {
@GetMapping
(
"getClassifyInfo"
)
public
ResponseEntity
<
ResponseDto
<
RobotClassifyDTO
>>
getClassifyInfo
(
@RequestParam
(
"robotType"
)
@ApiParam
(
"小号分类"
)
Long
robotType
);
@ApiOperation
(
"获取已开启小睿分类对应的图书分类"
)
@GetMapping
(
"getOpenTempletIds"
)
public
ResponseEntity
<
ResponseDto
<
List
<
Long
>>>
getOpenTempletIds
();
@ApiOperation
(
value
=
"批量获取个人号分类名称"
,
httpMethod
=
"POST"
)
@PostMapping
(
"getClassifyNameBatch"
)
ResponseEntity
<
ResponseDto
<
Map
<
Integer
,
String
>>>
getClassifyNameBatch
(
@RequestBody
List
<
Integer
>
classifyIds
);
}
pcloud-service-book/src/main/java/com/pcloud/book/book/dao/BookDao.java
View file @
26d37862
...
...
@@ -3,6 +3,7 @@
*/
package
com
.
pcloud
.
book
.
book
.
dao
;
import
com.pcloud.book.book.dto.AdviserBookInfoDTO
;
import
com.pcloud.book.book.dto.BookDto
;
import
com.pcloud.book.book.dto.BookInfo4AnlysicsDTO
;
import
com.pcloud.book.book.dto.BookInfoAnalysicsDTO
;
...
...
@@ -348,4 +349,6 @@ public interface BookDao extends BaseDao<Book> {
Map
<
Long
,
BookDto
>
getMapByBookIds
(
List
<
Long
>
bookIds
);
BookDto
getBookByName
(
String
bookName
);
List
<
AdviserBookInfoDTO
>
getBookAdviserInfos
(
List
<
Long
>
bookIds
);
}
pcloud-service-book/src/main/java/com/pcloud/book/book/dao/SearchRecordDao.java
View file @
26d37862
package
com
.
pcloud
.
book
.
book
.
dao
;
import
com.pcloud.book.book.dto.AdviserBookInfoDTO
;
import
com.pcloud.book.book.entity.SearchRecord
;
import
com.pcloud.book.book.vo.BookSearchTopVO
;
import
com.pcloud.common.core.dao.BaseDao
;
...
...
@@ -16,4 +17,10 @@ public interface SearchRecordDao extends BaseDao<SearchRecord> {
List
<
BookSearchTopVO
>
getBookSearchTop
(
Integer
top
);
void
updateUserDeleteByWechatUserId
(
Long
wechatUserId
,
Boolean
userDelete
);
Integer
getBookSearchCount
(
String
keyword
);
List
<
AdviserBookInfoDTO
>
getBookSearchIds
(
String
keyword
,
Integer
currentPage
,
Integer
numPerPage
);
List
<
Long
>
getWechatUserIds
(
Long
bookId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/book/dao/impl/BookDaoImpl.java
View file @
26d37862
...
...
@@ -5,6 +5,7 @@ package com.pcloud.book.book.dao.impl;
import
com.google.common.collect.Maps
;
import
com.pcloud.book.book.dao.BookDao
;
import
com.pcloud.book.book.dto.AdviserBookInfoDTO
;
import
com.pcloud.book.book.dto.BookDto
;
import
com.pcloud.book.book.dto.BookInfo4AnlysicsDTO
;
import
com.pcloud.book.book.dto.BookInfoAnalysicsDTO
;
...
...
@@ -378,4 +379,11 @@ public class BookDaoImpl extends BaseDaoImpl<Book> implements BookDao {
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getBookByName"
),
paramMap
);
}
@Override
public
List
<
AdviserBookInfoDTO
>
getBookAdviserInfos
(
List
<
Long
>
bookIds
)
{
Map
<
String
,
Object
>
paramMap
=
Maps
.
newHashMap
();
paramMap
.
put
(
"bookIds"
,
bookIds
);
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"getBookAdviserInfos"
),
paramMap
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/book/dao/impl/SearchRecordDaoImpl.java
View file @
26d37862
package
com
.
pcloud
.
book
.
book
.
dao
.
impl
;
import
com.pcloud.book.book.dao.SearchRecordDao
;
import
com.pcloud.book.book.dto.AdviserBookInfoDTO
;
import
com.pcloud.book.book.entity.SearchRecord
;
import
com.pcloud.book.book.vo.BookSearchTopVO
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
...
...
@@ -45,4 +46,27 @@ public class SearchRecordDaoImpl extends BaseDaoImpl<SearchRecord> implements Se
map
.
put
(
"userDelete"
,
userDelete
);
super
.
getSqlSession
().
update
(
super
.
getStatement
(
"updateUserDeleteByWechatUserId"
),
map
);
}
@Override
public
Integer
getBookSearchCount
(
String
keyword
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"keyword"
,
keyword
);
return
super
.
getSqlSession
().
selectOne
(
super
.
getStatement
(
"getBookSearchCount"
),
map
);
}
@Override
public
List
<
AdviserBookInfoDTO
>
getBookSearchIds
(
String
keyword
,
Integer
currentPage
,
Integer
numPerPage
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"keyword"
,
keyword
);
map
.
put
(
"pageNum"
,
currentPage
*
numPerPage
);
map
.
put
(
"numPerPage"
,
numPerPage
);
return
super
.
getSqlSession
().
selectList
(
super
.
getStatement
(
"getBookSearchIds"
),
map
);
}
@Override
public
List
<
Long
>
getWechatUserIds
(
Long
bookId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"bookId"
,
bookId
);
return
super
.
getSqlSession
().
selectList
(
super
.
getStatement
(
"getWechatUserIds"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/consumer/reader/ReaderConsr.java
View file @
26d37862
...
...
@@ -6,10 +6,12 @@ import java.util.List;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.utils.string.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Component
;
import
com.alibaba.druid.support.json.JSONUtils
;
import
com.pcloud.common.core.aspect.ParamLog
;
...
...
@@ -17,6 +19,8 @@ import com.pcloud.common.exceptions.BizException;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ResponseHandleUtil
;
import
com.pcloud.readercenter.appUser.service.AppUserService
;
import
com.pcloud.readercenter.wechat.dto.MiniUserDto
;
import
com.pcloud.readercenter.wechat.dto.ReaderMessageDto
;
import
com.pcloud.readercenter.wechat.dto.WechatUserRobotDto
;
import
com.pcloud.readercenter.wechat.entity.WechatUser
;
import
com.pcloud.readercenter.wechat.service.WechatUserService
;
...
...
@@ -118,6 +122,30 @@ public class ReaderConsr {
return
list
;
}
//给小程序用户发送系统消息站内信
public
void
sendNotifyMiniUser
(
ReaderMessageDto
readerMessageDto
)
{
try
{
wechatUserService
.
sendNotifyMiniUser
(
readerMessageDto
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"发送系统消息给小程序用户失败:"
+
e
.
getMessage
(),
e
);
}
}
//获取小程序和小睿关系
public
List
<
MiniUserDto
>
getSendUserRobotInfo
(
List
<
Long
>
wechatUserIds
)
{
if
(
ListUtils
.
isEmpty
(
wechatUserIds
)){
return
new
ArrayList
<>();
}
List
<
MiniUserDto
>
result
=
new
ArrayList
<>();
try
{
ResponseEntity
<
ResponseDto
<
List
<
MiniUserDto
>>>
sendUserRobotInfo
=
wechatUserService
.
getSendUserRobotInfo
(
wechatUserIds
);
result
=
ResponseHandleUtil
.
parseList
(
sendUserRobotInfo
,
MiniUserDto
.
class
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"获取小程序和小睿关系失败:"
+
e
.
getMessage
(),
e
);
}
return
result
;
}
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/consumer/wechatgroup/WechatGroupConsr.java
View file @
26d37862
...
...
@@ -739,4 +739,12 @@ public class WechatGroupConsr {
log
.
error
(
"qq机器人给用户发送消息失败.[sendMessage]:"
+
e
.
getMessage
(),
e
);
}
}
public
void
sendMessageToMiniUser
(
SendMessageDTO
sendMessageDTO
)
{
try
{
selfRobotService
.
sendMessageToMiniUser
(
sendMessageDTO
);
}
catch
(
Exception
e
)
{
log
.
error
(
"给指定分类小程序用户发送站内信失败.[sendMessage]:"
+
e
.
getMessage
(),
e
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/biz/CultivateNotifyBiz.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
biz
;
import
com.pcloud.book.book.dto.AdviserBookInfoDTO
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyPageDTO
;
import
com.pcloud.book.cultivate.dto.SearchNotifyDTO
;
import
com.pcloud.book.cultivate.dto.SearchSendUserDTO
;
import
com.pcloud.book.cultivate.dto.SendUserDetailDto
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyTypeDTO
;
import
com.pcloud.readercenter.wechat.dto.MiniUserDto
;
import
java.util.List
;
public
interface
CultivateNotifyBiz
{
void
createNotify
(
CultivateNotifyDTO
cultivateNotifyDTO
);
PageBeanNew
<
CultivateNotifyPageDTO
>
listPage4CultivateNotify
(
SearchNotifyDTO
searchNotifyDTO
);
CultivateNotifyDTO
getFirstNoReadNotify
(
Long
wechatUserId
);
List
<
CultivateNotifyTypeDTO
>
getNotify4Type
(
Long
wechatUserId
);
PageBeanNew
<
CultivateNotifyDTO
>
getNotifyListByType
(
Long
wechatUserId
,
Integer
messageType
,
Integer
currentPage
,
Integer
numPerPage
);
PageBeanNew
<
MiniUserDto
>
listPage4SendUser
(
SearchSendUserDTO
searchSendUserDTO
);
PageBeanNew
<
AdviserBookInfoDTO
>
listPage4SearchBook
(
SearchSendUserDTO
searchSendUserDTO
);
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/biz/impl/CultivateNotifyBizImpl.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
biz
.
impl
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.book.dao.BookDao
;
import
com.pcloud.book.book.dao.SearchRecordDao
;
import
com.pcloud.book.book.dto.AdviserBookInfoDTO
;
import
com.pcloud.book.consumer.content.ResourceConsr
;
import
com.pcloud.book.consumer.reader.ReaderConsr
;
import
com.pcloud.book.consumer.user.AdviserConsr
;
import
com.pcloud.book.consumer.wechatgroup.WechatGroupConsr
;
import
com.pcloud.book.cultivate.biz.CultivateNotifyBiz
;
import
com.pcloud.book.cultivate.check.NotifyParamCheck
;
import
com.pcloud.book.cultivate.dao.CultivateNotifyDao
;
import
com.pcloud.book.cultivate.dao.CultivateNotifyItemDao
;
import
com.pcloud.book.cultivate.dao.CultivateNotifySendDao
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyPageDTO
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyTypeDTO
;
import
com.pcloud.book.cultivate.dto.SearchNotifyDTO
;
import
com.pcloud.book.cultivate.dto.SearchSendUserDTO
;
import
com.pcloud.book.cultivate.dto.WechatUserDTO
;
import
com.pcloud.book.cultivate.entity.CultivateNotify
;
import
com.pcloud.book.cultivate.entity.CultivateNotifyItem
;
import
com.pcloud.book.cultivate.entity.CultivateNotifySend
;
import
com.pcloud.book.cultivate.enums.NotifySendTypeEnum
;
import
com.pcloud.book.util.common.ThreadPoolUtils
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.contentcenter.resource.dto.ResourceDTO
;
import
com.pcloud.readercenter.wechat.dto.MiniUserDto
;
import
com.pcloud.readercenter.wechat.dto.ReaderMessageDto
;
import
com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto
;
import
com.pcloud.wechatgroup.selfrobot.dto.SendMessageDTO
;
import
org.apache.commons.collections.MapUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
@Component
(
"cultivateNotifyBiz"
)
public
class
CultivateNotifyBizImpl
implements
CultivateNotifyBiz
{
@Autowired
private
NotifyParamCheck
notifyParamCheck
;
@Autowired
private
CultivateNotifyDao
cultivateNotifyDao
;
@Autowired
private
CultivateNotifyItemDao
cultivateNotifyItemDao
;
@Autowired
private
CultivateNotifySendDao
cultivateNotifySendDao
;
@Autowired
private
WechatGroupConsr
wechatGroupConsr
;
@Autowired
private
ReaderConsr
readerConsr
;
@Autowired
private
ResourceConsr
resourceConsr
;
@Autowired
private
SearchRecordDao
searchRecordDao
;
@Autowired
private
BookDao
bookDao
;
@Autowired
private
AdviserConsr
adviserConsr
;
private
final
Integer
SEND_BATCH_NUM
=
100
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
createNotify
(
CultivateNotifyDTO
cultivateNotifyDTO
)
{
notifyParamCheck
.
createNotifyCheck
(
cultivateNotifyDTO
);
CultivateNotify
cultivateNotify
=
new
CultivateNotify
();
cultivateNotify
.
setMessageType
(
cultivateNotifyDTO
.
getMessageType
());
cultivateNotify
.
setTitle
(
cultivateNotifyDTO
.
getTitle
());
cultivateNotify
.
setSendType
(
cultivateNotifyDTO
.
getSendType
());
cultivateNotifyDao
.
insert
(
cultivateNotify
);
cultivateNotifyDTO
.
getCultivateNotifyItems
().
forEach
(
a
->
a
.
setMessageId
(
cultivateNotify
.
getMessageId
()));
cultivateNotifyItemDao
.
insert
(
cultivateNotifyDTO
.
getCultivateNotifyItems
());
ThreadPoolUtils
.
SEND_NOTIFY_POOL
.
execute
(()->{
addSendNotify
(
cultivateNotifyDTO
,
cultivateNotify
);
});
}
@Override
public
CultivateNotifyDTO
getFirstNoReadNotify
(
Long
wechatUserId
)
{
Long
messageId
=
cultivateNotifySendDao
.
getFirstNoReadNotify
(
wechatUserId
);
if
(
messageId
==
null
){
return
new
CultivateNotifyDTO
();
}
CultivateNotifyDTO
notifyDTO
=
new
CultivateNotifyDTO
();
List
<
CultivateNotifyItem
>
list
=
cultivateNotifyItemDao
.
getNotifyItemsByMessageId
(
messageId
);
fillResource
(
list
);
notifyDTO
.
setCultivateNotifyItems
(
list
);
CultivateNotify
byId
=
cultivateNotifyDao
.
getById
(
messageId
);
notifyDTO
.
setMessageType
(
byId
.
getMessageType
());
notifyDTO
.
setTitle
(
byId
.
getTitle
());
cultivateNotifySendDao
.
updateIsRead
(
wechatUserId
,
messageId
);
return
notifyDTO
;
}
@Override
public
List
<
CultivateNotifyTypeDTO
>
getNotify4Type
(
Long
wechatUserId
)
{
return
cultivateNotifySendDao
.
getNotify4Type
(
wechatUserId
);
}
@Override
public
PageBeanNew
<
CultivateNotifyDTO
>
getNotifyListByType
(
Long
wechatUserId
,
Integer
messageType
,
Integer
currentPage
,
Integer
numPerPage
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"messageType"
,
messageType
);
PageBeanNew
<
CultivateNotifyDTO
>
pageBeanNew
=
cultivateNotifySendDao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
map
,
"getNotifyListByType"
);
for
(
CultivateNotifyDTO
cultivateNotifyDTO:
pageBeanNew
.
getRecordList
())
{
List
<
CultivateNotifyItem
>
list1
=
cultivateNotifyItemDao
.
getNotifyItemsByMessageId
(
cultivateNotifyDTO
.
getMessageId
());
fillResource
(
list1
);
cultivateNotifyDTO
.
setCultivateNotifyItems
(
list1
);
}
//批量更新消息已读未读
List
<
CultivateNotifySend
>
notifySends
=
cultivateNotifySendDao
.
getNotifySendsByType
(
wechatUserId
,
messageType
);
for
(
CultivateNotifySend
notifySend:
notifySends
)
{
notifySend
.
setIsRead
(
true
);
notifySend
.
setReadTime
(
new
Date
());
notifySend
.
setUpdateTime
(
new
Date
());
cultivateNotifySendDao
.
update
(
notifySend
);
}
return
pageBeanNew
;
}
private
void
fillResource
(
List
<
CultivateNotifyItem
>
list
){
List
<
Long
>
resourceIds
=
new
ArrayList
<>();
for
(
CultivateNotifyItem
notifyItem
:
list
){
Integer
type
=
notifyItem
.
getContentType
();
if
(
type
==
3
){
resourceIds
.
add
(
notifyItem
.
getResourceId
());
}
}
Map
<
Long
,
ResourceDTO
>
resourceDTOMap
=
new
HashMap
<>();
if
(!
ListUtils
.
isEmpty
(
resourceIds
)){
resourceDTOMap
=
resourceConsr
.
mapByIds
(
resourceIds
);
}
for
(
CultivateNotifyItem
notifyItem
:
list
)
{
Integer
type
=
notifyItem
.
getContentType
();
if
(
type
==
3
)
{
ResourceDTO
resourceDTO
=
resourceDTOMap
.
get
(
notifyItem
.
getResourceId
());
if
(
resourceDTO
!=
null
)
{
notifyItem
.
setResourceName
(
resourceDTO
.
getResourceName
());
notifyItem
.
setResourceUrl
(
resourceDTO
.
getFileUrl
());
notifyItem
.
setResourceTypeCode
(
resourceDTO
.
getTypeCode
());
notifyItem
.
setResourceTypeName
(
resourceDTO
.
getTypeName
());
notifyItem
.
setFileType
(
resourceDTO
.
getFileType
());
notifyItem
.
setFileSize
(
resourceDTO
.
getFileSize
());
notifyItem
.
setResourcePdfItems
(
resourceDTO
.
getResourcePdfItems
());
notifyItem
.
setResourceOfficeItemDTOs
(
resourceDTO
.
getResourceOfficeItemDTOs
());
notifyItem
.
setDuration
(
resourceDTO
.
getDuration
());
}
}
}
}
private
void
addSendNotify
(
CultivateNotifyDTO
cultivateNotifyDTO
,
CultivateNotify
cultivateNotify
){
List
<
CultivateNotifySend
>
list
=
new
ArrayList
<>();
//指定用户发送
if
(
NotifySendTypeEnum
.
APPOINT_USER
.
value
.
equals
(
cultivateNotifyDTO
.
getSendType
()))
{
CultivateNotifySend
cultivateNotifySend
=
null
;
for
(
WechatUserDTO
wechatUserDTO
:
cultivateNotifyDTO
.
getWechatUserDTOS
())
{
cultivateNotifySend
=
new
CultivateNotifySend
();
cultivateNotifySend
.
setMessageId
(
cultivateNotify
.
getMessageId
());
cultivateNotifySend
.
setMessageType
(
cultivateNotifyDTO
.
getMessageType
());
cultivateNotifySend
.
setSendType
(
cultivateNotifyDTO
.
getSendType
());
cultivateNotifySend
.
setWxUserId
(
wechatUserDTO
.
getWxUserId
());
cultivateNotifySend
.
setWechatUserId
(
wechatUserDTO
.
getWechatUserId
());
list
.
add
(
cultivateNotifySend
);
}
cultivateNotifySendDao
.
insert
(
list
);
}
//分类用户发送
if
(
NotifySendTypeEnum
.
CLASSIFY_USER
.
value
.
equals
(
cultivateNotifyDTO
.
getSendType
()))
{
SendMessageDTO
sendMessageDTO
=
new
SendMessageDTO
();
sendMessageDTO
.
setClassifyId
(
cultivateNotifyDTO
.
getClassifyId
());
sendMessageDTO
.
setMessageId
(
cultivateNotify
.
getMessageId
());
sendMessageDTO
.
setMessageType
(
cultivateNotify
.
getMessageType
());
sendMessageDTO
.
setSendType
(
cultivateNotifyDTO
.
getSendType
());
sendMessageDTO
.
setWxId
(
cultivateNotifyDTO
.
getWxId
());
wechatGroupConsr
.
sendMessageToMiniUser
(
sendMessageDTO
);
}
//书刊发送
if
(
NotifySendTypeEnum
.
BOOK_USER
.
value
.
equals
(
cultivateNotifyDTO
.
getSendType
())){
List
<
Long
>
wechatUserIds
=
searchRecordDao
.
getWechatUserIds
(
cultivateNotifyDTO
.
getBookId
());
if
(
ListUtils
.
isEmpty
(
wechatUserIds
)){
return
;
}
for
(
int
i
=
0
;
i
<=
wechatUserIds
.
size
()
/
SEND_BATCH_NUM
;
i
++)
{
int
beginIndex
=
i
*
SEND_BATCH_NUM
;
int
endIndex
=
beginIndex
+
SEND_BATCH_NUM
;
if
(
i
==
(
wechatUserIds
.
size
()
-
1
)/
SEND_BATCH_NUM
){
endIndex
=
wechatUserIds
.
size
();
}
List
<
Long
>
subList
=
wechatUserIds
.
subList
(
beginIndex
,
endIndex
);
List
<
CultivateNotifySend
>
cultivateNotifySendList
=
new
ArrayList
<>();
if
(!
ListUtils
.
isEmpty
(
subList
)){
for
(
Long
wechatUserId
:
subList
)
{
CultivateNotifySend
cultivateNotifySend
=
new
CultivateNotifySend
();
cultivateNotifySend
.
setMessageId
(
cultivateNotify
.
getMessageId
());
cultivateNotifySend
.
setMessageType
(
cultivateNotifyDTO
.
getMessageType
());
cultivateNotifySend
.
setSendType
(
cultivateNotifyDTO
.
getSendType
());
cultivateNotifySend
.
setWechatUserId
(
wechatUserId
);
cultivateNotifySendList
.
add
(
cultivateNotifySend
);
}
cultivateNotifySendDao
.
insert
(
cultivateNotifySendList
);
}
}
}
//全局发送
if
(
NotifySendTypeEnum
.
ALL_USER
.
value
.
equals
(
cultivateNotifyDTO
.
getSendType
())){
ReaderMessageDto
readerMessageDto
=
new
ReaderMessageDto
();
readerMessageDto
.
setMessageId
(
cultivateNotify
.
getMessageId
());
readerMessageDto
.
setSendType
(
cultivateNotifyDTO
.
getSendType
());
readerMessageDto
.
setMessageType
(
cultivateNotifyDTO
.
getMessageType
());
readerConsr
.
sendNotifyMiniUser
(
readerMessageDto
);
}
}
@Override
public
PageBeanNew
<
CultivateNotifyPageDTO
>
listPage4CultivateNotify
(
SearchNotifyDTO
searchNotifyDTO
)
{
if
(
null
==
searchNotifyDTO
||
Objects
.
isNull
(
searchNotifyDTO
.
getNumPerPage
())
||
Objects
.
isNull
(
searchNotifyDTO
.
getPageNum
())){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"分页参数有误!"
);
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"keyword"
,
searchNotifyDTO
.
getKeyword
());
map
.
put
(
"sendType"
,
searchNotifyDTO
.
getSendType
());
map
.
put
(
"messageType"
,
searchNotifyDTO
.
getMessageType
());
PageBeanNew
<
CultivateNotifyPageDTO
>
pageBeanNew
=
cultivateNotifySendDao
.
listPageNew
(
new
PageParam
(
searchNotifyDTO
.
getPageNum
(),
searchNotifyDTO
.
getNumPerPage
()),
map
,
"listPage4CultivateNotify"
);
if
(
null
==
pageBeanNew
||
ListUtils
.
isEmpty
(
pageBeanNew
.
getRecordList
())){
return
new
PageBeanNew
<>(
searchNotifyDTO
.
getPageNum
(),
searchNotifyDTO
.
getNumPerPage
(),
pageBeanNew
.
getTotalCount
(),
new
ArrayList
<>());
}
buildSendInfo
(
pageBeanNew
.
getRecordList
());
return
pageBeanNew
;
}
private
void
buildSendInfo
(
List
<
CultivateNotifyPageDTO
>
list
)
{
List
<
Long
>
messageIds
=
list
.
stream
().
filter
(
a
->
null
!=
a
.
getMessageId
()).
map
(
a
->
a
.
getMessageId
()).
distinct
().
collect
(
Collectors
.
toList
());
Map
<
Long
,
String
>
titleMap
=
new
HashMap
<>();
Map
<
Long
,
List
<
CultivateNotifyItem
>>
itemMap
=
new
HashMap
<>();
if
(!
ListUtils
.
isEmpty
(
messageIds
)){
/* List<CultivateNotify> cultivateNotifies = cultivateNotifyDao.getByIds(messageIds);
titleMap= cultivateNotifies.stream().collect(Collectors.toMap(a -> a.getMessageId(), a -> a.getTitle(), (k1, k2) -> k2));*/
List
<
CultivateNotifyItem
>
cultivateNotifyItems
=
cultivateNotifyItemDao
.
getByMessageIds
(
messageIds
);
itemMap
=
cultivateNotifyItems
.
stream
().
collect
(
Collectors
.
groupingBy
(
a
->
a
.
getMessageId
()));
}
for
(
CultivateNotifyPageDTO
cultivateNotifyPageDTO
:
list
)
{
/* if(MapUtils.isNotEmpty(titleMap) && titleMap.containsKey(cultivateNotifyPageDTO.getMessageId())){
cultivateNotifyPageDTO.setTitle(titleMap.get(cultivateNotifyPageDTO.getMessageId()));
}*/
if
(
MapUtils
.
isNotEmpty
(
itemMap
)
&&
itemMap
.
containsKey
(
cultivateNotifyPageDTO
.
getMessageId
())){
cultivateNotifyPageDTO
.
setCultivateNotifyItems
(
itemMap
.
get
(
cultivateNotifyPageDTO
.
getMessageId
()));
}
if
(!
ListUtils
.
isEmpty
(
cultivateNotifyPageDTO
.
getCultivateNotifyItems
())){
fillResource
(
cultivateNotifyPageDTO
.
getCultivateNotifyItems
());
}
}
}
@Override
public
PageBeanNew
<
MiniUserDto
>
listPage4SendUser
(
SearchSendUserDTO
searchSendUserDTO
)
{
if
(
null
==
searchSendUserDTO
||
null
==
searchSendUserDTO
.
getMessageId
()
||
null
==
searchSendUserDTO
.
getCurrentPage
()
||
null
==
searchSendUserDTO
.
getNumPerPage
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"参数有误!"
);
}
Integer
count
=
cultivateNotifySendDao
.
getSendUserCount
(
searchSendUserDTO
.
getMessageId
());
if
(
count
<=
0
){
return
new
PageBeanNew
<>(
searchSendUserDTO
.
getCurrentPage
(),
searchSendUserDTO
.
getNumPerPage
(),
new
ArrayList
<>());
}
List
<
Long
>
sendUserIds
=
cultivateNotifySendDao
.
getSendUserIds
(
searchSendUserDTO
.
getMessageId
(),
searchSendUserDTO
.
getCurrentPage
(),
searchSendUserDTO
.
getNumPerPage
());
List
<
MiniUserDto
>
list
=
readerConsr
.
getSendUserRobotInfo
(
sendUserIds
);
return
new
PageBeanNew
<>(
searchSendUserDTO
.
getCurrentPage
(),
searchSendUserDTO
.
getNumPerPage
(),
count
,
list
);
}
@Override
public
PageBeanNew
<
AdviserBookInfoDTO
>
listPage4SearchBook
(
SearchSendUserDTO
searchSendUserDTO
)
{
if
(
null
==
searchSendUserDTO
||
null
==
searchSendUserDTO
.
getCurrentPage
()
||
null
==
searchSendUserDTO
.
getNumPerPage
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"参数有误!"
);
}
Integer
count
=
searchRecordDao
.
getBookSearchCount
(
searchSendUserDTO
.
getKeyword
());
if
(
count
<=
0
){
return
new
PageBeanNew
<>(
searchSendUserDTO
.
getCurrentPage
(),
searchSendUserDTO
.
getNumPerPage
(),
new
ArrayList
<>());
}
List
<
AdviserBookInfoDTO
>
infos
=
searchRecordDao
.
getBookSearchIds
(
searchSendUserDTO
.
getKeyword
(),
searchSendUserDTO
.
getCurrentPage
(),
searchSendUserDTO
.
getNumPerPage
());
//Map<Long, AdviserBookInfoDTO> adviserBookInfoDTOMap = infos.stream().collect(Collectors.toMap(a -> a.getBookId(), a -> a, (k1, k2) -> k2));
List
<
Long
>
adviserIds
=
infos
.
stream
().
filter
(
s
->
s
.
getAdviserId
()
!=
null
).
map
(
AdviserBookInfoDTO:
:
getAdviserId
).
distinct
().
collect
(
Collectors
.
toList
());
Map
<
Long
,
AdviserBaseInfoDto
>
adviserMap
=
adviserConsr
.
getAdviserId2AdviserInfoDtoMap
(
adviserIds
);
for
(
AdviserBookInfoDTO
dto
:
infos
)
{
if
(!
MapUtils
.
isEmpty
(
adviserMap
)
&&
null
!=
dto
.
getAdviserId
()
&&
adviserMap
.
containsKey
(
dto
.
getAdviserId
()))
{
AdviserBaseInfoDto
adviserBaseInfoDto
=
adviserMap
.
get
(
dto
.
getAdviserId
());
if
(
null
!=
adviserBaseInfoDto
){
dto
.
setAdviserName
(
adviserBaseInfoDto
.
getPartyName
());
dto
.
setAgentName
(
adviserBaseInfoDto
.
getAgentName
());
}
}
}
return
new
PageBeanNew
<>(
searchSendUserDTO
.
getCurrentPage
(),
searchSendUserDTO
.
getNumPerPage
(),
count
,
infos
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/check/NotifyParamCheck.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
check
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.enums.NotifySendTypeEnum
;
import
com.pcloud.common.utils.ListUtils
;
import
org.springframework.stereotype.Component
;
@Component
(
"notifyParamCheck"
)
public
class
NotifyParamCheck
{
public
void
createNotifyCheck
(
CultivateNotifyDTO
cultivateNotifyDTO
)
{
if
(
null
==
cultivateNotifyDTO
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"参数为空!"
);
}
if
(
null
==
cultivateNotifyDTO
.
getSendType
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"发送消息类型为空!"
);
}
if
(
null
==
cultivateNotifyDTO
.
getMessageType
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"消息类型为空!"
);
}
if
(
null
==
cultivateNotifyDTO
.
getTitle
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"消息标题为空!"
);
}
if
(
ListUtils
.
isEmpty
(
cultivateNotifyDTO
.
getCultivateNotifyItems
())){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"消息内容为空!"
);
}
else
{
if
(
cultivateNotifyDTO
.
getCultivateNotifyItems
().
size
()>
3
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"消息内容不能超过3条!"
);
}
}
if
(
NotifySendTypeEnum
.
APPOINT_USER
.
value
.
equals
(
cultivateNotifyDTO
.
getSendType
()))
{
if
(
ListUtils
.
isEmpty
(
cultivateNotifyDTO
.
getWechatUserDTOS
()))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"未选择发送人!"
);
}
}
if
(
NotifySendTypeEnum
.
CLASSIFY_USER
.
value
.
equals
(
cultivateNotifyDTO
.
getSendType
()))
{
if
(
null
==
cultivateNotifyDTO
.
getWxId
()
||
null
==
cultivateNotifyDTO
.
getClassifyId
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"小睿信息缺失!"
);
}
}
if
(
NotifySendTypeEnum
.
BOOK_USER
.
value
.
equals
(
cultivateNotifyDTO
.
getSendType
()))
{
if
(
null
==
cultivateNotifyDTO
.
getBookId
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"bookId缺失!"
);
}
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateNotifyDao.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dao
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.entity.CultivateNotify
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
public
interface
CultivateNotifyDao
extends
BaseDao
<
CultivateNotify
>
{
List
<
CultivateNotify
>
getByIds
(
List
<
Long
>
ids
);
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateNotifyItemDao.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dao
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.book.cultivate.entity.CultivateNotifyItem
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
public
interface
CultivateNotifyItemDao
extends
BaseDao
<
CultivateNotifyItem
>
{
List
<
CultivateNotifyItem
>
getNotifyItemsByMessageId
(
Long
messageId
);
List
<
CultivateNotifyItem
>
getByMessageIds
(
List
<
Long
>
messageIds
);
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateNotifySendDao.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dao
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyTypeDTO
;
import
com.pcloud.book.cultivate.entity.CultivateNotifySend
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
public
interface
CultivateNotifySendDao
extends
BaseDao
<
CultivateNotifySend
>
{
Long
getFirstNoReadNotify
(
Long
wechatUserId
);
void
updateIsRead
(
Long
wechatUserId
,
Long
messageId
);
List
<
CultivateNotifyTypeDTO
>
getNotify4Type
(
Long
wechatUserId
);
List
<
CultivateNotifyDTO
>
getNotifyListByType
(
Long
wechatUserId
,
Integer
messageType
,
Integer
currentPage
,
Integer
numPerPage
);
List
<
CultivateNotifySend
>
getNotifySendsByType
(
Long
wechatUserId
,
Integer
messageType
);
List
<
Long
>
getSendUserIds
(
Long
messageId
,
Integer
currentPage
,
Integer
numPerPage
);
Integer
getSendUserCount
(
Long
messageId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateNotifyDaoImpl.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dao
.
impl
;
import
com.pcloud.book.cultivate.dao.CultivateNotifyDao
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.entity.CultivateNotify
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
(
"cultivateNotifyDao"
)
public
class
CultivateNotifyDaoImpl
extends
BaseDaoImpl
<
CultivateNotify
>
implements
CultivateNotifyDao
{
@Override
public
List
<
CultivateNotify
>
getByIds
(
List
<
Long
>
ids
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"ids"
,
ids
);
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"getByIds"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateNotifyItemDaoImpl.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dao
.
impl
;
import
com.pcloud.book.cultivate.dao.CultivateNotifyItemDao
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.entity.CultivateNotifyItem
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
(
"cultivateNotifyItemDao"
)
public
class
CultivateNotifyItemDaoImpl
extends
BaseDaoImpl
<
CultivateNotifyItem
>
implements
CultivateNotifyItemDao
{
@Override
public
List
<
CultivateNotifyItem
>
getNotifyItemsByMessageId
(
Long
messageId
)
{
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getNotifyItemsByMessageId"
),
messageId
);
}
@Override
public
List
<
CultivateNotifyItem
>
getByMessageIds
(
List
<
Long
>
messageIds
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"messageIds"
,
messageIds
);
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"getByMessageIds"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateNotifySendDaoImpl.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dao
.
impl
;
import
com.pcloud.book.cultivate.dao.CultivateNotifySendDao
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyTypeDTO
;
import
com.pcloud.book.cultivate.entity.CultivateNotifySend
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
(
"cultivateNotifySendDao"
)
public
class
CultivateNotifySendDaoImpl
extends
BaseDaoImpl
<
CultivateNotifySend
>
implements
CultivateNotifySendDao
{
@Override
public
Long
getFirstNoReadNotify
(
Long
wechatUserId
)
{
return
super
.
getSessionTemplate
().
selectOne
(
getStatement
(
"getFirstNoReadNotify"
),
wechatUserId
);
}
@Override
public
void
updateIsRead
(
Long
wechatUserId
,
Long
messageId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"messageId"
,
messageId
);
super
.
getSessionTemplate
().
update
(
getStatement
(
"updateIsRead"
),
map
);
}
@Override
public
List
<
CultivateNotifyTypeDTO
>
getNotify4Type
(
Long
wechatUserId
)
{
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getNotify4Type"
),
wechatUserId
);
}
@Override
public
List
<
CultivateNotifyDTO
>
getNotifyListByType
(
Long
wechatUserId
,
Integer
messageType
,
Integer
currentPage
,
Integer
numPerPage
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"messageType"
,
messageType
);
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getNotifyListByType"
),
map
);
}
@Override
public
List
<
CultivateNotifySend
>
getNotifySendsByType
(
Long
wechatUserId
,
Integer
messageType
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"messageType"
,
messageType
);
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getNotifySendsByType"
),
map
);
}
@Override
public
List
<
Long
>
getSendUserIds
(
Long
messageId
,
Integer
currentPage
,
Integer
numPerPage
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"messageId"
,
messageId
);
map
.
put
(
"pageNum"
,
currentPage
*
numPerPage
);
map
.
put
(
"numPerPage"
,
numPerPage
);
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getSendUserIds"
),
map
);
}
@Override
public
Integer
getSendUserCount
(
Long
messageId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"messageId"
,
messageId
);
return
super
.
getSessionTemplate
().
selectOne
(
getStatement
(
"getSendUserCount"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/CultivateNotifyDTO.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.pcloud.book.cultivate.entity.CultivateNotifyItem
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
@Data
public
class
CultivateNotifyDTO
{
@ApiModelProperty
(
"消息类型(1-系统消息,2-通知消息,3-提醒消息,4-活动消息)"
)
private
Integer
messageType
;
@ApiModelProperty
(
"标题"
)
private
String
title
;
@ApiModelProperty
(
"消息id"
)
private
Long
messageId
;
@ApiModelProperty
(
"个人号分类id"
)
private
Long
classifyId
;
@ApiModelProperty
(
"个人号wxId"
)
private
String
wxId
;
@ApiModelProperty
(
"bookId"
)
private
Long
bookId
;
@ApiModelProperty
(
"发送类型(1-指定用户,2-分类用户,3-按书籍查询,4-全局公告消息)"
)
private
Integer
sendType
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
sendTime
;
@ApiModelProperty
(
"发送内容"
)
private
List
<
CultivateNotifyItem
>
cultivateNotifyItems
;
@ApiModelProperty
(
"用户id"
)
private
List
<
WechatUserDTO
>
wechatUserDTOS
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/CultivateNotifyPageDTO.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.pcloud.book.cultivate.entity.CultivateNotifyItem
;
import
java.util.Date
;
import
java.util.List
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
CultivateNotifyPageDTO
{
@ApiModelProperty
(
"消息类型(1-系统消息,2-通知消息,3-提醒消息,4-活动消息)"
)
private
Integer
messageType
;
@ApiModelProperty
(
"标题"
)
private
String
title
;
@ApiModelProperty
(
"消息Id"
)
private
Long
messageId
;
@ApiModelProperty
(
"发送类型(1-指定用户,2-分类用户,3-按书籍查询,4-全局公告消息)"
)
private
Integer
sendType
;
@ApiModelProperty
(
"发送内容"
)
private
List
<
CultivateNotifyItem
>
cultivateNotifyItems
;
@ApiModelProperty
(
"发送时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
sendTime
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/CultivateNotifyTypeDTO.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
CultivateNotifyTypeDTO
{
@ApiModelProperty
(
"消息类型(1-系统消息,2-通知消息,3-提醒消息,4-活动消息)"
)
private
Integer
messageType
;
@ApiModelProperty
(
"首条未读消息时间"
)
private
Date
firstNoReadDate
;
@ApiModelProperty
(
"未读消息数量"
)
private
Integer
noReadCounts
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/SearchNotifyDTO.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
com.pcloud.common.page.PageParam
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
SearchNotifyDTO
extends
PageParam
{
@ApiModelProperty
(
"搜索关键词"
)
private
String
keyword
;
@ApiModelProperty
(
"发送类型(1-指定用户,2-分类用户,3-按书籍查询,4-全局公告消息)"
)
private
Integer
sendType
;
@ApiModelProperty
(
"消息类型(1-系统消息,2-通知消息,3-提醒消息,4-活动消息)"
)
private
Integer
messageType
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/SearchSendUserDTO.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
lombok.Data
;
@Data
public
class
SearchSendUserDTO
{
private
Long
messageId
;
private
Integer
currentPage
;
private
Integer
numPerPage
;
private
String
keyword
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/SendUserDetailDto.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.pcloud.wechatgroup.selfrobot.dto.RobotAndFriendInfoDTO
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlElement
;
import
lombok.Data
;
/**
*小程序用户
*/
@Data
public
class
SendUserDetailDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
3666718926619191804L
;
private
Long
wechatUserId
;
private
String
wxId
;
/**
* 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
*/
private
Integer
sex
;
private
String
headUrl
;
private
String
phoneNumber
;
private
Date
createTime
;
//是否加小睿好友
private
Boolean
isSelfFriend
;
//小睿好友列表
private
List
<
RobotAndFriendInfoDTO
>
robotInfoList
;
@JSONField
(
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@XmlElement
public
Date
getCreateTime
()
{
return
this
.
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/WechatUserDTO.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
WechatUserDTO
{
@ApiModelProperty
(
"微信userId"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"wxId"
)
private
String
wxUserId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/entity/CultivateNotify.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
"小睿站内信"
)
public
class
CultivateNotify
extends
BaseEntity
{
@ApiModelProperty
(
"消息id"
)
private
Long
messageId
;
@ApiModelProperty
(
"消息类型(1-系统消息,2-通知消息,3-提醒消息,4-活动消息)"
)
private
Integer
messageType
;
@ApiModelProperty
(
"消息标题"
)
private
String
title
;
@ApiModelProperty
(
"发送类型(1-指定用户,2-分类用户,3-按书籍查询,4-全局公告消息)"
)
private
Integer
sendType
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/entity/CultivateNotifyItem.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
com.pcloud.contentcenter.resource.dto.ResourceOfficeItemDTO
;
import
com.pcloud.contentcenter.resource.dto.ResourcePdfItemDTO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
@Data
@ApiModel
(
"小睿站内信内容"
)
public
class
CultivateNotifyItem
extends
BaseEntity
{
@ApiModelProperty
(
"消息id"
)
private
Long
messageId
;
@ApiModelProperty
(
"发送内容(1-文本,2-图片,3-音频)"
)
private
Integer
contentType
;
@ApiModelProperty
(
"文字内容"
)
private
String
content
;
@ApiModelProperty
(
"图片地址"
)
private
String
picUrl
;
@ApiModelProperty
(
"音频资源id"
)
private
Long
resourceId
;
@ApiModelProperty
(
"文件名称"
)
private
String
fileName
;
@ApiModelProperty
(
"文件类型"
)
private
String
fileType
;
@ApiModelProperty
(
"文件大小"
)
private
Long
fileSize
;
@ApiModelProperty
(
"资源链接"
)
private
String
resourceUrl
;
@ApiModelProperty
(
"资源名称"
)
private
String
resourceName
;
@ApiModelProperty
(
"资源类型编码"
)
private
String
resourceTypeCode
;
@ApiModelProperty
(
"资源类型名称"
)
private
String
resourceTypeName
;
@ApiModelProperty
(
"pdf转码后的单张图片集合"
)
private
List
<
ResourcePdfItemDTO
>
resourcePdfItems
;
@ApiModelProperty
(
"文件转码后的单张图片集合"
)
private
List
<
ResourceOfficeItemDTO
>
resourceOfficeItemDTOs
;
@ApiModelProperty
(
"音频时长"
)
private
BigDecimal
duration
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/enums/NotifySendTypeEnum.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
enums
;
public
enum
NotifySendTypeEnum
{
/**
* 指定用户
*/
APPOINT_USER
(
1
),
/**
* 分类用户
*/
CLASSIFY_USER
(
2
),
/**
* 书籍查询
*/
BOOK_USER
(
3
),
/**
* 全局公告消息
*/
ALL_USER
(
4
);
public
final
Integer
value
;
NotifySendTypeEnum
(
Integer
value
)
{
this
.
value
=
value
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/facade/CultivateNotifyFacade.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
facade
;
import
com.pcloud.book.cultivate.biz.CultivateNotifyBiz
;
import
com.pcloud.book.cultivate.dto.CultivateNotifyDTO
;
import
com.pcloud.book.cultivate.dto.SearchNotifyDTO
;
import
com.pcloud.book.cultivate.dto.SearchSendUserDTO
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.permission.PermissionException
;
import
com.pcloud.common.utils.NumberUtil
;
import
com.pcloud.common.utils.cookie.Cookie
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.GetMapping
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
"站内信"
)
@RestController
(
"cultivateNotifyFacade"
)
@RequestMapping
(
"cultivateNotify"
)
public
class
CultivateNotifyFacade
{
@Autowired
private
CultivateNotifyBiz
cultivateNotifyBiz
;
@ApiOperation
(
"新增站内信"
)
@PostMapping
(
"/createCultivateNotify"
)
public
ResponseDto
<?>
createCultivate
(
@RequestBody
CultivateNotifyDTO
cultivateNotifyDTO
)
throws
BizException
,
PermissionException
{
cultivateNotifyBiz
.
createNotify
(
cultivateNotifyDTO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"站内信列表"
)
@PostMapping
(
"/listPage4CultivateNotify"
)
public
ResponseDto
<?>
listPage4CultivateNotify
(
@RequestBody
SearchNotifyDTO
searchNotifyDTO
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateNotifyBiz
.
listPage4CultivateNotify
(
searchNotifyDTO
));
}
@ApiOperation
(
"站内信发送用户列表"
)
@PostMapping
(
"/listPage4SendUser"
)
public
ResponseDto
<?>
listPage4SendUser
(
@RequestBody
SearchSendUserDTO
searchSendUserDTO
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateNotifyBiz
.
listPage4SendUser
(
searchSendUserDTO
));
}
@ApiOperation
(
"站内信发送书刊列表"
)
@PostMapping
(
"/listPage4SearchBook"
)
public
ResponseDto
<?>
listPage4SearchBook
(
@RequestBody
SearchSendUserDTO
searchSendUserDTO
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateNotifyBiz
.
listPage4SearchBook
(
searchSendUserDTO
));
}
@ApiOperation
(
"首条未读消息详情"
)
@GetMapping
(
"/getFirstNoReadNotify"
)
public
ResponseDto
<?>
getFirstNoReadNotify
(
@CookieValue
(
value
=
"userInfo"
,
required
=
false
)
String
userInfo
){
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
if
(!
NumberUtil
.
isNumber
(
wechatUserId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"wechatUserId 不能为空"
);
}
return
new
ResponseDto
<>(
cultivateNotifyBiz
.
getFirstNoReadNotify
(
wechatUserId
));
}
@ApiOperation
(
"4种不同类型消息的的列表"
)
@GetMapping
(
"/getNotify4Type"
)
public
ResponseDto
<?>
getNotify4Type
(
@CookieValue
(
value
=
"userInfo"
,
required
=
false
)
String
userInfo
){
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
if
(!
NumberUtil
.
isNumber
(
wechatUserId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"wechatUserId 不能为空"
);
}
return
new
ResponseDto
<>(
cultivateNotifyBiz
.
getNotify4Type
(
wechatUserId
));
}
@ApiOperation
(
"单个分类消息列表"
)
@GetMapping
(
"/getNotifyListByType"
)
public
ResponseDto
<?>
getNotifyListByType
(
@CookieValue
(
value
=
"userInfo"
,
required
=
false
)
String
userInfo
,
@RequestParam
Integer
messageType
,
@RequestParam
(
value
=
"currentPage"
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
value
=
"numPerPage"
,
required
=
false
)
Integer
numPerPage
){
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
if
(!
NumberUtil
.
isNumber
(
wechatUserId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"wechatUserId 不能为空"
);
}
return
new
ResponseDto
<>(
cultivateNotifyBiz
.
getNotifyListByType
(
wechatUserId
,
messageType
,
currentPage
,
numPerPage
));
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/service/impl/CultivateNotifyServiceImpl.java
0 → 100644
View file @
26d37862
package
com
.
pcloud
.
book
.
cultivate
.
service
.
impl
;
import
com.pcloud.book.cultivate.dao.CultivateNotifySendDao
;
import
com.pcloud.book.cultivate.entity.CultivateNotifySend
;
import
com.pcloud.book.cultivate.service.CultivateNotifyService
;
import
com.pcloud.book.timecontrol.biz.TaskBiz
;
import
com.pcloud.book.timecontrol.biz.TaskSubscribeBiz
;
import
com.pcloud.book.timecontrol.dto.BookTaskBindingDto
;
import
com.pcloud.book.timecontrol.dto.LabelDto
;
import
com.pcloud.book.timecontrol.dto.TaskDto
;
import
com.pcloud.book.timecontrol.mapper.TimeControlTaskMapper
;
import
com.pcloud.book.timecontrol.service.TimeControlTaskService
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ResponseHandleUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
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
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
@RestController
(
"cultivateNotifyService"
)
@RequestMapping
(
"cultivateNotifyService"
)
public
class
CultivateNotifyServiceImpl
implements
CultivateNotifyService
{
@Autowired
private
CultivateNotifySendDao
cultivateNotifySendDao
;
@Override
@RequestMapping
(
value
=
"/batchSendMiniUser"
,
method
=
RequestMethod
.
POST
)
public
void
batchSendMiniUser
(
@RequestBody
List
<
CultivateNotifySend
>
list
)
throws
BizException
{
if
(!
ListUtils
.
isEmpty
(
list
)){
cultivateNotifySendDao
.
insert
(
list
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/pcloudkeyword/biz/PcloudRobotClassifyBiz.java
View file @
26d37862
...
...
@@ -9,6 +9,7 @@ import com.pcloud.book.pcloudkeyword.vo.ClassifySeqNumUpdateVO;
import
com.pcloud.common.page.PageBeanNew
;
import
java.util.List
;
import
java.util.Map
;
public
interface
PcloudRobotClassifyBiz
{
...
...
@@ -58,7 +59,11 @@ public interface PcloudRobotClassifyBiz {
PageBeanNew
<
PcloudRobotClassifyResponseVO
>
listClassifyByPage4Mini
(
Integer
currentPage
,
Integer
numPerPage
);
void
updateOpenStatus4RobotClassify
(
ClassifyOpenStatusUpdateVO
vo
);
List
<
Long
>
getOpenTempletIds
();
Map
<
Integer
,
String
>
getClassifyNameBatch
(
List
<
Integer
>
classifyIds
);
}
pcloud-service-book/src/main/java/com/pcloud/book/pcloudkeyword/biz/impl/PcloudRobotClassifyBizImpl.java
View file @
26d37862
...
...
@@ -217,4 +217,18 @@ public class PcloudRobotClassifyBizImpl implements PcloudRobotClassifyBiz {
public
List
<
Long
>
getOpenTempletIds
()
{
return
pcloudRobotClassifyDao
.
getOpenTempletIds
();
}
@Override
public
Map
<
Integer
,
String
>
getClassifyNameBatch
(
List
<
Integer
>
classifyIds
)
{
if
(
ListUtils
.
isEmpty
(
classifyIds
)){
return
new
HashMap
<>();
}
List
<
RobotClassifyDTO
>
classifyInfoBatch
=
pcloudRobotClassifyDao
.
getClassifyInfoBatch
(
classifyIds
);
if
(
ListUtils
.
isEmpty
(
classifyInfoBatch
)){
return
new
HashMap
<>();
}
Map
<
Integer
,
String
>
map
=
classifyInfoBatch
.
stream
().
collect
(
Collectors
.
toMap
(
a
->
a
.
getClassifyId
(),
a
->
a
.
getClassifyName
(),
(
k1
,
k2
)
->
k2
));
return
map
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/pcloudkeyword/dao/PcloudRobotClassifyDao.java
View file @
26d37862
...
...
@@ -30,5 +30,9 @@ public interface PcloudRobotClassifyDao extends BaseDao<PcloudRobotClassify> {
RobotClassifyDTO
getClassifyInfo
(
Long
robotType
);
List
<
Long
>
getOpenTempletIds
();
List
<
RobotClassifyDTO
>
getClassifyInfoBatch
(
List
<
Integer
>
classifyIds
)
;
}
pcloud-service-book/src/main/java/com/pcloud/book/pcloudkeyword/dao/impl/PcloudRobotClassifyDaoImpl.java
View file @
26d37862
...
...
@@ -64,6 +64,13 @@ public class PcloudRobotClassifyDaoImpl extends BaseDaoImpl<PcloudRobotClassify>
@Override
public
List
<
Long
>
getOpenTempletIds
()
{
return
this
.
getSessionTemplate
().
selectList
(
getStatement
(
"getOpenTempletIds"
));
return
this
.
getSessionTemplate
().
selectList
(
getStatement
(
"getOpenTempletIds"
));
}
@Override
public
List
<
RobotClassifyDTO
>
getClassifyInfoBatch
(
List
<
Integer
>
classifyIds
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"classifyIds"
,
classifyIds
);
return
this
.
getSessionTemplate
().
selectList
(
getStatement
(
"getClassifyInfoBatch"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/pcloudkeyword/service/impl/PcloudRobotServiceImpl.java
View file @
26d37862
...
...
@@ -137,4 +137,9 @@ public class PcloudRobotServiceImpl implements PcloudRobotService {
}
@Override
@PostMapping
(
"getClassifyNameBatch"
)
public
ResponseEntity
<
ResponseDto
<
Map
<
Integer
,
String
>>>
getClassifyNameBatch
(
@RequestBody
List
<
Integer
>
classifyIds
)
{
return
ResponseHandleUtil
.
toResponse
(
pcloudRobotClassifyBiz
.
getClassifyNameBatch
(
classifyIds
));
}
}
pcloud-service-book/src/main/java/com/pcloud/book/util/common/ThreadPoolUtils.java
View file @
26d37862
...
...
@@ -39,4 +39,15 @@ public class ThreadPoolUtils {
public
static
final
ExecutorService
SIGN_OUT_THREAD_POOL
=
new
ThreadPoolExecutor
(
5
,
5
,
0L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"sign-out-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
/**
* 其他线程池
*/
public
static
final
ExecutorService
OTHER_POOL
=
new
ThreadPoolExecutor
(
8
,
8
,
0L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"other-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
/**
* 其他线程池
*/
public
static
final
ExecutorService
SEND_NOTIFY_POOL
=
new
ThreadPoolExecutor
(
8
,
8
,
0L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"send-notify-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
}
pcloud-service-book/src/main/resources/mapper/book/Book.Mapper.xml
View file @
26d37862
...
...
@@ -2336,4 +2336,22 @@
AND IS_DELETE = 0
LIMIT 1
</select>
<select
id=
"getBookAdviserInfos"
parameterType=
"map"
resultType=
"com.pcloud.book.book.dto.AdviserBookInfoDTO"
>
SELECT
b.BOOK_ID bookId,
b.ISBN isbn,
b.BOOK_NAME bookName,
a.ADVISER_ID adviserId
FROM
book_adviser a
INNER JOIN book b ON b.BOOK_ID = a.BOOK_ID AND b.IS_DELETE = 0
WHERE
b.BOOK_ID in
<foreach
collection=
"bookIds"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
group by b.BOOK_ID
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/book/SearchRecord.xml
View file @
26d37862
...
...
@@ -106,4 +106,56 @@
where wechat_user_id=#{wechatUserId}
</update>
<select
id=
"getBookSearchCount"
parameterType=
"map"
resultType=
"Integer"
>
select ifnull(count(1),0) from(
SELECT
b.BOOK_ID bookId
FROM
(select book_id bookId from
search_record
where wechat_user_id>0 and book_id>0
GROUP BY book_id)c
INNER JOIN
book_adviser a on c.bookId=a.book_id
INNER JOIN book b ON b.BOOK_ID = a.BOOK_ID AND b.IS_DELETE = 0
WHERE
1=1
<if
test=
"keyword !=null"
>
AND (b.BOOK_NAME LIKE CONCAT('%', #{keyword}, '%') or b.ISBN LIKE
CONCAT(#{keyword},'%'))
</if>
GROUP BY b.BOOK_ID
)t
</select>
<select
id=
"getBookSearchIds"
parameterType=
"map"
resultType=
"com.pcloud.book.book.dto.AdviserBookInfoDTO"
>
SELECT
b.BOOK_ID bookId,
b.ISBN isbn,
b.BOOK_NAME bookName,
a.ADVISER_ID adviserId
FROM
(select book_id bookId from
search_record
where wechat_user_id>0 and book_id>0
GROUP BY book_id)c
INNER JOIN
book_adviser a on c.bookId=a.book_id
INNER JOIN book b ON b.BOOK_ID = a.BOOK_ID AND b.IS_DELETE = 0
WHERE
1=1
<if
test=
"keyword !=null"
>
AND (b.BOOK_NAME LIKE CONCAT('%', #{keyword}, '%') or b.ISBN LIKE CONCAT(#{keyword},'%'))
</if>
group by b.BOOK_ID
order by count(1) desc
limit #{pageNum}, #{numPerPage}
</select>
<select
id=
"getWechatUserIds"
parameterType=
"map"
resultType=
"Long"
>
select distinct wechat_user_id
from search_record
where book_id=#{bookId}
and wechat_user_id>0
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/cultivate/CultivateNotify.xml
0 → 100644
View file @
26d37862
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.cultivate.dao.impl.CultivateNotifyDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.cultivate.entity.CultivateNotify"
>
<id
column=
"message_id"
property=
"messageId"
jdbcType=
"BIGINT"
/>
<result
column=
"message_type"
property=
"messageType"
jdbcType=
"INTEGER"
/>
<result
column=
"title"
property=
"title"
jdbcType=
"VARCHAR"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"send_type"
property=
"sendType"
jdbcType=
"INTEGER"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
message_id, message_type, title, create_time,update_time,send_type
</sql>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateNotify"
useGeneratedKeys=
"true"
keyProperty=
"messageId"
>
insert into cultivate_notify
(
message_type,
title,
create_time,
update_time,
send_type
)
values (
#{messageType},
#{title},
NOW(),
NOW(),
#{sendType}
)
</insert>
<update
id=
"update"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateNotify"
>
update cultivate_notify
<set>
<if
test=
"messageType != null"
>
message_type = #{messageType},
</if>
<if
test=
"title != null"
>
title = #{title},
</if>
update_time=NOW()
</set>
where message_id = #{messageId}
</update>
<select
id=
"getByIds"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_notify
where message_id in
<foreach
collection=
"ids"
open=
"("
close=
")"
separator=
","
item=
"item"
>
#{item}
</foreach>
</select>
<select
id=
"getById"
resultMap=
"BaseResultMap"
parameterType=
"Long"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_notify where message_id = #{messageId}
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/cultivate/CultivateNotifyItem.xml
0 → 100644
View file @
26d37862
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.cultivate.dao.impl.CultivateNotifyItemDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.cultivate.entity.CultivateNotifyItem"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"message_id"
property=
"messageId"
jdbcType=
"BIGINT"
/>
<result
column=
"content_type"
property=
"contentType"
jdbcType=
"INTEGER"
/>
<result
column=
"content"
property=
"content"
jdbcType=
"VARCHAR"
/>
<result
column=
"pic_url"
property=
"picUrl"
jdbcType=
"VARCHAR"
/>
<result
column=
"resource_id"
property=
"resourceId"
jdbcType=
"BIGINT"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id,message_id, content_type, content,pic_url,resource_id, create_time,update_time
</sql>
<insert
id=
"batchInsert"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateNotifyItem"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into cultivate_notify_item
(
message_id,
content_type,
content,
pic_url,
resource_id,
create_time,
update_time
)
values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
#{item.messageId},
#{item.contentType},
#{item.content},
#{item.picUrl},
#{item.resourceId},
NOW(),
NOW()
)
</foreach>
</insert>
<select
id=
"getNotifyItemsByMessageId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_notify_item where message_id=#{messageId}
</select>
<select
id=
"getByMessageIds"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_notify_item
where message_id in
<foreach
collection=
"messageIds"
open=
"("
close=
")"
separator=
","
item=
"item"
>
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/cultivate/CultivateNotifySend.xml
0 → 100644
View file @
26d37862
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.cultivate.dao.impl.CultivateNotifySendDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.cultivate.entity.CultivateNotifySend"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"send_type"
property=
"sendType"
jdbcType=
"INTEGER"
/>
<result
column=
"wx_user_id"
property=
"wxUserId"
jdbcType=
"VARCHAR"
/>
<result
column=
"wechat_user_id"
property=
"wechatUserId"
jdbcType=
"BIGINT"
/>
<result
column=
"message_id"
property=
"messageId"
jdbcType=
"BIGINT"
/>
<result
column=
"message_type"
property=
"messageType"
jdbcType=
"INTEGER"
/>
<result
column=
"is_read"
property=
"isRead"
jdbcType=
"INTEGER"
/>
<result
column=
"read_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id,wx_user_id, wechat_user_id, send_type,message_id,message_type,is_read,read_time, create_time,update_time
</sql>
<insert
id=
"batchInsert"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateNotifySend"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into cultivate_notify_send
(
wx_user_id,
wechat_user_id,
send_type,
message_id,
message_type,
is_read,
create_time,
update_time
)
values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
#{item.wxUserId},
#{item.wechatUserId},
#{item.sendType},
#{item.messageId},
#{item.messageType},
0,
NOW(),
NOW()
)
</foreach>
</insert>
<select
id=
"getFirstNoReadNotify"
parameterType=
"Long"
resultType=
"Long"
>
select message_id messageId from cultivate_notify_send
where wechat_user_id=#{wechatUserId}
and is_read=0
order by create_time desc limit 1
</select>
<update
id=
"update"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateNotifySend"
>
update cultivate_notify_send
<set>
<if
test=
"messageType != null"
>
message_type = #{messageType},
</if>
<if
test=
"messageId != null"
>
message_id = #{messageId},
</if>
<if
test=
"is_read != null"
>
is_read = #{isRead},
</if>
<if
test=
"readTime != null"
>
read_time = #{readTime},
</if>
update_time=NOW()
</set>
where id = #{id}
</update>
<update
id=
"updateIsRead"
parameterType=
"map"
>
update cultivate_notify_send set is_read=1,read_time=now(),update_time=now()
where wechat_user_id=#{wechatUserId}
and message_id=#{messageId}
</update>
<select
id=
"getNotify4Type"
resultType=
"com.pcloud.book.cultivate.dto.CultivateNotifyTypeDTO"
>
select message_type messageType ,MAX(create_time) firstNoReadDate ,count(1) noReadCounts from cultivate_notify_send
where is_read=0
and wechat_user_id=#{wechatUserId}
group by message_type
</select>
<select
id=
"getNotifyListByType"
parameterType=
"map"
resultType=
"com.pcloud.book.cultivate.dto.CultivateNotifyDTO"
>
select a.message_id messageId ,a.title,a.message_type messageType ,c.create_time sendTime from cultivate_notify a, cultivate_notify_send c
where a.message_id=c.message_id
and c.wechat_user_id=#{wechatUserId}
and c.message_type=#{messageType}
order by c.create_time desc
</select>
<select
id=
"getNotifySendsByType"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_notify_send
where wechat_user_id=#{wechatUserId}
and message_type=#{messageType}
order by create_time desc
</select>
<select
id=
"listPage4CultivateNotify"
parameterType=
"map"
resultType=
"com.pcloud.book.cultivate.dto.CultivateNotifyPageDTO"
>
select
a.send_type sendType,
a.message_type messageType,
a.create_time createTime,
a.message_id messageId,
a.create_time sendTime,
a.title title
from cultivate_notify a
<if
test=
"keyword !=null"
>
LEFT JOIN cultivate_notify_item b on a.message_id=b.message_id
</if>
where
1=1
<if
test=
"sendType!=null"
>
and a.send_type=#{sendType}
</if>
<if
test=
"messageType !=null"
>
and a.message_type=#{messageType}
</if>
<if
test=
"keyword !=null"
>
and b.content like concat('%',#{keyword},'%')
</if>
order by a.create_time DESC
</select>
<select
id=
"getSendUserIds"
parameterType=
"map"
resultType=
"Long"
>
select distinct wechat_user_id
from cultivate_notify_send
where message_id=#{messageId}
order by id
limit #{pageNum}, #{numPerPage}
</select>
<select
id=
"getSendUserCount"
parameterType=
"map"
resultType=
"Integer"
>
select ifnull(count(1),0)
from cultivate_notify_send
where message_id=#{messageId}
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/pcloudkeyword/PcloudRobotClassify.Mapper.xml
View file @
26d37862
...
...
@@ -141,5 +141,18 @@
FROM book_rays_classify a LEFT JOIN pcloud_robot_classify b
on a.rays_classify_id=b.id
where b.open_status=1
</select>
<select
id=
"getClassifyInfoBatch"
parameterType=
"map"
resultType=
"com.pcloud.book.pcloudKeyword.dto.RobotClassifyDTO"
>
select
id classifyId,
classify_name classifyName
from
pcloud_robot_classify
where
id in
<foreach
collection=
"classifyIds"
index=
"index"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</select>
</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