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
3c9d55d2
Commit
3c9d55d2
authored
Jan 22, 2021
by
田超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/1003971' into 'master'
feat:[1003971]第三方资源新增收藏 See merge request rays/pcloud-book!1167
parents
efc05b90
4d0037bc
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
458 additions
and
35 deletions
+458
-35
AppletNewsDTO.java
...c/main/java/com/pcloud/book/applet/dto/AppletNewsDTO.java
+6
-1
ServeCollectDTO.java
...main/java/com/pcloud/book/applet/dto/ServeCollectDTO.java
+4
-0
AppletNewsBiz.java
...c/main/java/com/pcloud/book/applet/biz/AppletNewsBiz.java
+1
-1
ServeCollectBiz.java
...main/java/com/pcloud/book/applet/biz/ServeCollectBiz.java
+35
-2
AppletNewsBizImpl.java
...va/com/pcloud/book/applet/biz/impl/AppletNewsBizImpl.java
+48
-13
ServeCollectBizImpl.java
.../com/pcloud/book/applet/biz/impl/ServeCollectBizImpl.java
+143
-8
ServeCollectDao.java
...main/java/com/pcloud/book/applet/dao/ServeCollectDao.java
+13
-1
ServeCollectDaoImpl.java
.../com/pcloud/book/applet/dao/impl/ServeCollectDaoImpl.java
+32
-2
CollectionTypeNameAndCountDTO.java
...pcloud/book/applet/dto/CollectionTypeNameAndCountDTO.java
+23
-0
ServeCollect.java
...main/java/com/pcloud/book/applet/entity/ServeCollect.java
+2
-0
AppletHomeFacade.java
.../java/com/pcloud/book/applet/facade/AppletHomeFacade.java
+15
-1
ServeCollectFacade.java
...ava/com/pcloud/book/applet/facade/ServeCollectFacade.java
+42
-3
CollectionTypeNameCodeClassifyVO.java
...loud/book/applet/vo/CollectionTypeNameCodeClassifyVO.java
+16
-0
ServeCollect.Mapper.xml
.../src/main/resources/mapper/applet/ServeCollect.Mapper.xml
+78
-3
No files found.
pcloud-facade-book/src/main/java/com/pcloud/book/applet/dto/AppletNewsDTO.java
View file @
3c9d55d2
...
...
@@ -51,7 +51,12 @@ public class AppletNewsDTO extends BaseDto {
@ApiModelProperty
(
"是否展示"
)
private
Boolean
showState
;
@ApiModelProperty
(
"是否删除"
)
private
Integer
isDelete
;
;
private
Integer
isDelete
;
/**
* 被收藏为1,未收藏为0
*/
@ApiModelProperty
(
"是否被收藏"
)
private
Integer
isCollection
;
@ApiModelProperty
(
"分类名称"
)
private
String
newsClassify
;
@JsonFormat
(
...
...
pcloud-facade-book/src/main/java/com/pcloud/book/applet/dto/ServeCollectDTO.java
View file @
3c9d55d2
...
...
@@ -26,6 +26,8 @@ public class ServeCollectDTO {
private
String
serveTypeCode
;
private
String
serveTypeName
;
private
String
linkUrl
;
private
String
picUrl
;
...
...
@@ -46,4 +48,6 @@ public class ServeCollectDTO {
@ApiModelProperty
(
"资源是否删除"
)
private
Integer
sourceDelete
;
@ApiModelProperty
(
"是否被收藏"
)
private
Integer
isCollected
;
}
pcloud-service-book/src/main/java/com/pcloud/book/applet/biz/AppletNewsBiz.java
View file @
3c9d55d2
...
...
@@ -286,7 +286,7 @@ public interface AppletNewsBiz {
*/
void
updateCardShowState
(
AppletNews
appletNews
);
AppletNewsDTO
getNewsById4Applet
(
Long
newsId
);
AppletNewsDTO
getNewsById4Applet
(
Long
newsId
,
Long
wechatUserId
);
/**
* 根据公众号id获取出版社id
...
...
pcloud-service-book/src/main/java/com/pcloud/book/applet/biz/ServeCollectBiz.java
View file @
3c9d55d2
package
com
.
pcloud
.
book
.
applet
.
biz
;
import
com.pcloud.book.applet.dto.AppletTaskDTO
;
import
com.pcloud.book.applet.dto.CollectionTypeNameAndCountDTO
;
import
com.pcloud.book.applet.dto.ServeCollectDTO
;
import
com.pcloud.book.applet.entity.ServeCollect
;
import
com.pcloud.common.page.PageBeanNew
;
...
...
@@ -27,7 +28,7 @@ public interface ServeCollectBiz {
/**
* 分页查询
*/
PageBeanNew
getList
(
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
);
PageBeanNew
getList
(
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
,
String
typeCode
);
/**
* 新增数据
...
...
@@ -76,7 +77,7 @@ public interface ServeCollectBiz {
* @param wechatUserId
* @return
*/
List
<
Long
>
getAllCollect
(
Long
wechatUserId
);
List
<
Long
>
getAllCollect
(
Long
wechatUserId
,
String
typeCode
);
/**
* 查询收藏情况
...
...
@@ -86,4 +87,35 @@ public interface ServeCollectBiz {
List
<
ServeCollectDTO
>
getList4Collect
(
List
<
ServeCollectDTO
>
serveCollects
);
List
<
ServeCollect
>
getList4RightsSettingByWechatUserId
(
Long
wechatUserId
);
/**
* 获取收藏中的所有服务种类及其对应的条数
* @param wechatUserId
* @return
*/
List
<
CollectionTypeNameAndCountDTO
>
getTypeNameAndCountByWechatId
(
Long
wechatUserId
);
/**
* 分类分页查询
* @param typeName
* @param wechatUserId
* @param currentPage
* @param numPerPage
* @return
*/
PageBeanNew
getListByTypeNameAndWechatUserId
(
String
typeName
,
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
);
/**
* 根据查询单挑数据是否被收藏
* @param wechatUserId
* @param serverId
* @return
*/
ServeCollectDTO
isCollected
(
Long
wechatUserId
,
Long
serverId
);
/**
* 填充TypeName
*/
void
processingData
();
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/applet/biz/impl/AppletNewsBizImpl.java
View file @
3c9d55d2
...
...
@@ -27,18 +27,7 @@ import com.pcloud.book.applet.dto.AppletNewsServeDTO;
import
com.pcloud.book.applet.dto.AppletNewsVO
;
import
com.pcloud.book.applet.dto.AppletThirdResourcesDTO
;
import
com.pcloud.book.applet.dto.PvuvDTO
;
import
com.pcloud.book.applet.entity.AppletBusinessCard
;
import
com.pcloud.book.applet.entity.AppletLinkClick
;
import
com.pcloud.book.applet.entity.AppletNews
;
import
com.pcloud.book.applet.entity.AppletNewsCategory
;
import
com.pcloud.book.applet.entity.AppletNewsClassify
;
import
com.pcloud.book.applet.entity.AppletNewsClassifyUser
;
import
com.pcloud.book.applet.entity.AppletNewsComment
;
import
com.pcloud.book.applet.entity.AppletNewsCustomTag
;
import
com.pcloud.book.applet.entity.AppletNewsServe
;
import
com.pcloud.book.applet.entity.AppletThirdResources
;
import
com.pcloud.book.applet.entity.AppletThirdResourcesRelation
;
import
com.pcloud.book.applet.entity.AppletUserBookcase
;
import
com.pcloud.book.applet.entity.*
;
import
com.pcloud.book.applet.enums.AppletNewsServeTypeEnum
;
import
com.pcloud.book.applet.enums.DataRecordTypeEnum
;
import
com.pcloud.book.applet.enums.DataTypeEnum
;
...
...
@@ -533,6 +522,8 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
// 获取周权益资讯 如果周权益不为空 则直接返回
pageBeanNew
=
rightsSettingBiz
.
getWeekRightsSettingNewsByBookId
(
userReadBook
,
currentPage
,
numPerPage
);
if
(
CollUtil
.
isNotEmpty
(
pageBeanNew
.
getRecordList
()))
{
//处理是否收藏流程
solvePageBeanCollectionState
(
pageBeanNew
,
wechatUserId
);
return
pageBeanNew
;
}
}
...
...
@@ -561,9 +552,24 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if
(!
ListUtils
.
isEmpty
(
pageBeanNew
.
getRecordList
()))
{
fillBrowseCount
(
pageBeanNew
.
getRecordList
());
}
//处理收藏状态
solvePageBeanCollectionState
(
pageBeanNew
,
wechatUserId
);
return
pageBeanNew
;
}
private
void
solvePageBeanCollectionState
(
PageBeanNew
<
AppletNewsDTO
>
pageBeanNew
,
Long
wechatUserId
){
if
(
null
==
wechatUserId
){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"参数为空"
)
;
}
//获取用户收藏列表
List
<
ServeCollect
>
list4RightsSettingByWechatUserId
=
serveCollectBiz
.
getList4RightsSettingByWechatUserId
(
wechatUserId
);
List
<
AppletNewsDTO
>
recordList
=
pageBeanNew
.
getRecordList
();
for
(
AppletNewsDTO
appletNewsDTO
:
recordList
)
{
fillCollectionState
(
appletNewsDTO
,
wechatUserId
,
list4RightsSettingByWechatUserId
);
}
}
private
PageBeanNew
<
AppletNewsDTO
>
getAppletNewsDTOPageBeanNew
(
Integer
currentPage
,
Integer
numPerPage
,
Long
newsClassifyId
,
Map
<
String
,
Object
>
paramMap
,
String
subKey
)
{
PageBeanNew
<
AppletNewsDTO
>
pageBeanNew
;
List
<
AppletNewsDTO
>
homeList
=
JedisClusterUtils
.
getJsonList
(
AppletConstants
.
HOME_NEWS_LIST
+
subKey
,
AppletNewsDTO
.
class
);
...
...
@@ -1226,7 +1232,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
}
@Override
public
AppletNewsDTO
getNewsById4Applet
(
Long
id
)
{
public
AppletNewsDTO
getNewsById4Applet
(
Long
id
,
Long
wechatUserId
)
{
AppletNews
appletNews
=
appletNewsDao
.
getById
(
id
);
AppletNewsDTO
appletNewsDTO
=
new
AppletNewsDTO
();
if
(
null
!=
appletNews
){
...
...
@@ -1248,9 +1254,38 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if
(
StrUtil
.
isNotBlank
(
appletNews
.
getCityCode
()))
{
appletNewsDTO
.
setCity
(
regionMapMapper
.
getCitysByCode
(
appletNews
.
getCityCode
()));
}
//填充收藏状态
if
(
wechatUserId
!=
null
){
fillCollectionState
(
appletNewsDTO
,
wechatUserId
,
null
);
}
return
appletNewsDTO
;
}
/**
* 填充是否收藏状态
* @param appletNewsDTO
* @param wechatUserId
*/
private
void
fillCollectionState
(
AppletNewsDTO
appletNewsDTO
,
Long
wechatUserId
,
List
<
ServeCollect
>
list4RightsSettingByWechatUserId
){
//被收藏为1,未收藏为0
//用户收藏列表为空,直接将收藏状态置为0
if
(
null
==
list4RightsSettingByWechatUserId
)
{
list4RightsSettingByWechatUserId
=
serveCollectBiz
.
getList4RightsSettingByWechatUserId
(
wechatUserId
);
if
(
ListUtils
.
isEmpty
(
list4RightsSettingByWechatUserId
))
{
appletNewsDTO
.
setIsCollection
(
0
);
return
;
}
}
List
<
Long
>
serverIdList
=
list4RightsSettingByWechatUserId
.
stream
().
filter
(
s
->
s
.
getServeId
()
!=
null
)
.
filter
(
s
->
s
.
getServeType
()
==
1
).
map
(
ServeCollect:
:
getServeId
).
collect
(
Collectors
.
toList
());
boolean
contains
=
serverIdList
.
contains
(
appletNewsDTO
.
getId
());
if
(
contains
)
{
appletNewsDTO
.
setIsCollection
(
1
);
}
else
{
appletNewsDTO
.
setIsCollection
(
0
);
}
}
@Override
public
Map
<
Long
,
AppletNewsDTO
>
getByIds4Record
(
List
<
Long
>
newsIds
)
{
if
(
ListUtils
.
isEmpty
(
newsIds
)){
...
...
pcloud-service-book/src/main/java/com/pcloud/book/applet/biz/impl/ServeCollectBizImpl.java
View file @
3c9d55d2
...
...
@@ -2,18 +2,16 @@ package com.pcloud.book.applet.biz.impl;
import
cn.hutool.core.map.MapUtil
;
import
com.pcloud.appcenter.app.dto.AppDto
;
import
com.pcloud.appcenter.app.dto.AppTypeDto
;
import
com.pcloud.appcenter.app.entity.AppType
;
import
com.pcloud.book.applet.biz.AppletNewsBiz
;
import
com.pcloud.book.applet.biz.ServeCollectBiz
;
import
com.pcloud.book.applet.dao.ServeCollectDao
;
import
com.pcloud.book.applet.dto.AppletAppOrProductDTO
;
import
com.pcloud.book.applet.dto.AppletNewsDTO
;
import
com.pcloud.book.applet.dto.AppletRecordDTO
;
import
com.pcloud.book.applet.dto.AppletTaskDTO
;
import
com.pcloud.book.applet.dto.ServeCollectDTO
;
import
com.pcloud.book.applet.dto.*
;
import
com.pcloud.book.applet.entity.ServeCollect
;
import
com.pcloud.book.applet.enums.AppletRecordTypeEnum
;
import
com.pcloud.book.applet.enums.CollectionTypeEnum
;
import
com.pcloud.book.applet.vo.CollectionTypeNameCodeClassifyVO
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.consumer.app.AppConsr
;
import
com.pcloud.book.consumer.channel.QrcodeSceneConsr
;
...
...
@@ -37,6 +35,7 @@ import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import
com.pcloud.readercenter.rmall.constants.RmallContants
;
import
com.pcloud.readercenter.rmall.enums.MoneyReceiveTypeEnum
;
import
com.pcloud.resourcecenter.product.dto.ProductDto
;
import
com.pcloud.resourcecenter.product.dto.ProductTypeDto
;
import
io.swagger.models.auth.In
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -92,9 +91,10 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
@Override
@ParamLog
(
"查询多条数据"
)
public
PageBeanNew
getList
(
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
)
{
public
PageBeanNew
getList
(
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
,
String
typeCode
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"wechatUserId"
,
wechatUserId
);
paramMap
.
put
(
"typeCode"
,
typeCode
);
PageBeanNew
pageBeanNew
=
serveCollectDao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
paramMap
,
"getList"
);
List
recordList
=
pageBeanNew
.
getRecordList
();
if
(
ListUtils
.
isEmpty
(
recordList
))
{
...
...
@@ -352,8 +352,143 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
}
@Override
public
List
<
Long
>
getAllCollect
(
Long
wechatUserId
)
{
return
serveCollectDao
.
getAllCollect
(
wechatUserId
);
public
List
<
CollectionTypeNameAndCountDTO
>
getTypeNameAndCountByWechatId
(
Long
wechatUserId
)
{
return
serveCollectDao
.
getTypeNameAndCountByWechatId
(
wechatUserId
);
}
@Override
public
PageBeanNew
getListByTypeNameAndWechatUserId
(
String
typeName
,
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
)
{
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"typeName"
,
typeName
);
param
.
put
(
"wechatUserId"
,
wechatUserId
);
PageBeanNew
pageBeanNew
=
serveCollectDao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
param
,
"getListByTypeNameAndWechatUserId"
);
return
pageBeanNew
;
}
@Override
public
ServeCollectDTO
isCollected
(
Long
wechatUserId
,
Long
serverId
)
{
if
(
null
==
wechatUserId
||
null
==
serverId
){
LOGGER
.
error
(
"[ServeCollectBizImpl.isCollected]参数为空,wechatUserId:{} serverId:{}"
,
wechatUserId
,
serverId
);
throw
BizException
.
PARAM_IS_NULL
;
}
ServeCollectDTO
collected
=
serveCollectDao
.
isCollected
(
wechatUserId
,
serverId
);
if
(
null
==
collected
){
ServeCollectDTO
serveCollectDTO
=
new
ServeCollectDTO
();
serveCollectDTO
.
setIsCollected
(
0
);
return
serveCollectDTO
;
}
collected
.
setIsCollected
(
1
);
return
collected
;
}
@Override
public
void
processingData
()
{
List
<
CollectionTypeNameCodeClassifyVO
>
typeNameCodeClassifyVOList
=
getDistinctTypeCode
();
if
(
ListUtils
.
isEmpty
(
typeNameCodeClassifyVOList
))
{
LOGGER
.
warn
(
"[ServeCollectBizImpl.processingData] 获取typeCode失败:{}"
,
typeNameCodeClassifyVOList
);
return
;
}
//product与App
solveTypeName
(
typeNameCodeClassifyVOList
);
}
/**
* 填充TypeName
* @param typeNameCodeClassifyVOList
*/
private
void
solveTypeName
(
List
<
CollectionTypeNameCodeClassifyVO
>
typeNameCodeClassifyVOList
){
if
(
ListUtils
.
isEmpty
(
typeNameCodeClassifyVOList
)){
return
;
}
List
<
String
>
productTypeCodes
=
typeNameCodeClassifyVOList
.
stream
().
filter
(
collectionTypeNameCodeClassifyVO
->
AppletRecordTypeEnum
.
PRODUCT
.
value
.
equals
(
collectionTypeNameCodeClassifyVO
.
getServeType
())).
map
(
collectionTypeNameCodeClassifyVO
->
collectionTypeNameCodeClassifyVO
.
getServeTypeCode
()).
distinct
().
collect
(
Collectors
.
toList
());
List
<
String
>
AppTypeCodes
=
typeNameCodeClassifyVOList
.
stream
().
filter
(
collectionTypeNameCodeClassifyVO
->
AppletRecordTypeEnum
.
APP
.
value
.
equals
(
collectionTypeNameCodeClassifyVO
.
getServeType
())).
map
(
collectionTypeNameCodeClassifyVO
->
collectionTypeNameCodeClassifyVO
.
getServeTypeCode
()).
distinct
().
collect
(
Collectors
.
toList
());
//map资源
Map
<
String
,
ProductTypeDto
>
productTypeDtoMap
=
new
HashMap
<>();
Future
<
Map
<
String
,
ProductTypeDto
>>
productTypeDtoMapFuture
=
null
;
Map
<
String
,
AppTypeDto
>
appTypeDtoMap
=
new
HashMap
<>();
Future
<
Map
<
String
,
AppTypeDto
>>
appTypeDtoMapFuture
=
null
;
productTypeDtoMapFuture
=
ThreadPoolUtils
.
FILL_APPLET_RECORD
.
submit
(()
->
productConsr
.
getProType
());
appTypeDtoMapFuture
=
ThreadPoolUtils
.
FILL_APPLET_RECORD
.
submit
(()
->
appConsr
.
listAllCode
());
//更新TypeName
//product
updateProductTypeName
(
productTypeDtoMap
,
productTypeDtoMapFuture
,
productTypeCodes
);
//App
updateAppTypeName
(
appTypeDtoMap
,
appTypeDtoMapFuture
,
AppTypeCodes
);
}
/**
* 更新PRODUCT的TypeName
* @param productTypeDtoMap
* @param productTypeDtoMapFuture
* @param productTypeCodes
*/
private
void
updateProductTypeName
(
Map
<
String
,
ProductTypeDto
>
productTypeDtoMap
,
Future
<
Map
<
String
,
ProductTypeDto
>>
productTypeDtoMapFuture
,
List
<
String
>
productTypeCodes
){
try
{
productTypeDtoMap
=
productTypeDtoMapFuture
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
LOGGER
.
error
(
"获取商品TypeName错误: {}=="
,
e
);
}
if
(
MapUtil
.
isEmpty
(
productTypeDtoMap
))
{
return
;
}
for
(
String
productTypeCode
:
productTypeCodes
)
{
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
String
typeName
=
null
;
ProductTypeDto
productTypeData
=
productTypeDtoMap
.
get
(
productTypeCode
);
if
(
null
!=
productTypeData
){
typeName
=
productTypeData
.
getTypeName
();
}
paramMap
.
put
(
"serveTypeCode"
,
productTypeCode
);
paramMap
.
put
(
"serveTypeName"
,
typeName
);
serveCollectDao
.
updateTypeName
(
paramMap
);
LOGGER
.
info
(
"[ServeCollectBizImpl.processingData] 更新TypeName TypeCode:{}"
,
productTypeCode
);
}
}
/**
* 更新App的TypeName
* @param appTypeDtoMap
* @param appTypeDtoMapFuture
* @param AppTypeCodes
*/
private
void
updateAppTypeName
(
Map
<
String
,
AppTypeDto
>
appTypeDtoMap
,
Future
<
Map
<
String
,
AppTypeDto
>>
appTypeDtoMapFuture
,
List
<
String
>
AppTypeCodes
){
try
{
appTypeDtoMap
=
appTypeDtoMapFuture
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
LOGGER
.
error
(
"获取AppTypeName错误: {}=="
,
e
);
}
if
(
MapUtil
.
isEmpty
(
appTypeDtoMap
))
{
return
;
}
for
(
String
appTypeCode
:
AppTypeCodes
)
{
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
String
typeName
=
null
;
AppTypeDto
appTypeData
=
appTypeDtoMap
.
get
(
appTypeCode
);
if
(
null
!=
appTypeData
){
typeName
=
appTypeData
.
getTypeName
();
}
paramMap
.
put
(
"serveTypeCode"
,
appTypeCode
);
paramMap
.
put
(
"serveTypeName"
,
typeName
);
serveCollectDao
.
updateTypeName
(
paramMap
);
LOGGER
.
info
(
"[ServeCollectBizImpl.processingData] 更新TypeName TypeCode:{}"
,
appTypeCode
);
}
}
/**
* 获取所有TypeCode
* @return
*/
private
List
<
CollectionTypeNameCodeClassifyVO
>
getDistinctTypeCode
(){
return
serveCollectDao
.
getDistinctTypeCode
();
}
@Override
public
List
<
Long
>
getAllCollect
(
Long
wechatUserId
,
String
typeCode
)
{
return
serveCollectDao
.
getAllCollect
(
wechatUserId
,
typeCode
);
}
@Override
...
...
pcloud-service-book/src/main/java/com/pcloud/book/applet/dao/ServeCollectDao.java
View file @
3c9d55d2
package
com
.
pcloud
.
book
.
applet
.
dao
;
import
com.pcloud.book.applet.dto.CollectionTypeNameAndCountDTO
;
import
com.pcloud.book.applet.dto.ServeCollectDTO
;
import
com.pcloud.book.applet.entity.ServeCollect
;
import
com.pcloud.book.applet.vo.CollectionTypeNameCodeClassifyVO
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
import
java.util.Map
;
/**
* (ServeCollect)表数据库访问层
...
...
@@ -20,9 +23,17 @@ public interface ServeCollectDao extends BaseDao<ServeCollect> {
List
<
ServeCollect
>
getList4RightsSetting
(
List
<
ServeCollect
>
serveCollects
);
List
<
Long
>
getAllCollect
(
Long
wechatUserId
);
List
<
Long
>
getAllCollect
(
Long
wechatUserId
,
String
typeCode
);
List
<
ServeCollectDTO
>
getList4Collect
(
List
<
ServeCollectDTO
>
serveCollects
);
List
<
ServeCollect
>
getList4RightsSettingByWechatUserId
(
Long
wechatUserId
);
List
<
CollectionTypeNameAndCountDTO
>
getTypeNameAndCountByWechatId
(
Long
wechatUserId
);
ServeCollectDTO
isCollected
(
Long
wechatUserId
,
Long
serveId
);
List
<
CollectionTypeNameCodeClassifyVO
>
getDistinctTypeCode
();
void
updateTypeName
(
Map
<
String
,
String
>
paramMap
);
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/applet/dao/impl/ServeCollectDaoImpl.java
View file @
3c9d55d2
package
com
.
pcloud
.
book
.
applet
.
dao
.
impl
;
import
com.pcloud.book.applet.dao.ServeCollectDao
;
import
com.pcloud.book.applet.dto.CollectionTypeNameAndCountDTO
;
import
com.pcloud.book.applet.dto.ServeCollectDTO
;
import
com.pcloud.book.applet.entity.ServeCollect
;
import
com.pcloud.book.applet.vo.CollectionTypeNameCodeClassifyVO
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Repository
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* (ServeCollect)表数据库访问层
...
...
@@ -39,8 +43,34 @@ public class ServeCollectDaoImpl extends BaseDaoImpl<ServeCollect> implements Se
}
@Override
public
List
<
Long
>
getAllCollect
(
Long
wechatUserId
)
{
return
getSessionTemplate
().
selectList
(
getStatement
(
"getAllCollect"
),
wechatUserId
);
public
List
<
CollectionTypeNameAndCountDTO
>
getTypeNameAndCountByWechatId
(
Long
wechatUserId
)
{
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"getTypeNameAndCountByWechatId"
),
wechatUserId
);
}
@Override
public
ServeCollectDTO
isCollected
(
Long
wechatUserId
,
Long
serveId
)
{
Map
<
String
,
Object
>
paraMap
=
new
HashMap
<>();
paraMap
.
put
(
"wechatUserId"
,
wechatUserId
);
paraMap
.
put
(
"serveId"
,
serveId
);
return
getSessionTemplate
().
selectOne
(
getStatement
(
"isCollected"
),
paraMap
);
}
@Override
public
List
<
CollectionTypeNameCodeClassifyVO
>
getDistinctTypeCode
()
{
return
getSessionTemplate
().
selectList
(
getStatement
(
"getDistinctTypeCode"
));
}
@Override
public
void
updateTypeName
(
Map
<
String
,
String
>
paramMap
)
{
super
.
getSqlSession
().
update
(
getStatement
(
"updateTypeName"
),
paramMap
);
}
@Override
public
List
<
Long
>
getAllCollect
(
Long
wechatUserId
,
String
typeCode
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"wechatUserId"
,
wechatUserId
);
paramMap
.
put
(
"typeCode"
,
typeCode
);
return
getSessionTemplate
().
selectList
(
getStatement
(
"getAllCollect"
),
paramMap
);
}
@Override
...
...
pcloud-service-book/src/main/java/com/pcloud/book/applet/dto/CollectionTypeNameAndCountDTO.java
0 → 100644
View file @
3c9d55d2
package
com
.
pcloud
.
book
.
applet
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
*
* @Author dominic_Z
* @Date 2021年1月14日 14:05:15
*/
@Data
public
class
CollectionTypeNameAndCountDTO
{
@ApiModelProperty
(
"服务具体类型"
)
private
String
typeCode
;
@ApiModelProperty
(
"服务具体类型名称"
)
private
String
typeName
;
@ApiModelProperty
(
"该类型下的收藏数"
)
private
Integer
count
;
}
pcloud-service-book/src/main/java/com/pcloud/book/applet/entity/ServeCollect.java
View file @
3c9d55d2
...
...
@@ -39,6 +39,8 @@ public class ServeCollect extends BaseEntity {
private
String
serveTypeCode
;
private
String
serveTypeName
;
private
String
linkUrl
;
private
String
picUrl
;
...
...
pcloud-service-book/src/main/java/com/pcloud/book/applet/facade/AppletHomeFacade.java
View file @
3c9d55d2
...
...
@@ -671,11 +671,25 @@ public class AppletHomeFacade {
@ApiOperation
(
"根据ID查资讯详情"
)
@GetMapping
(
"getAppletNewsById"
)
public
ResponseDto
<
AppletNewsDTO
>
getAppletNewsById
(
@CookieValue
(
value
=
"userInfo"
,
required
=
false
)
String
userInfo
,
@RequestHeader
(
value
=
"token"
,
required
=
false
)
String
token
,
@RequestParam
(
"newsId"
)
@ApiParam
(
"资讯id"
)
Long
newsId
){
if
(
null
==
newsId
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"缺少参数"
);
}
return
new
ResponseDto
<>(
appletNewsBiz
.
getNewsById4Applet
(
newsId
));
Long
wechatUserId
=
null
;
Long
partyId
=
null
;
if
(
StringUtil
.
isNotNull
(
userInfo
))
{
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
}
if
(
StringUtil
.
isNotNull
(
token
))
{
Map
<
String
,
Object
>
map
=
SessionUtil
.
getToken4Redis
(
token
);
partyId
=
(
Long
)
map
.
get
(
SessionUtil
.
PARTY_ID
);
}
if
(
null
==
wechatUserId
&&
null
==
partyId
)
{
throw
new
PermissionException
(
PermissionException
.
PERMISSION_USER_NOT_LOGIN
);
}
return
new
ResponseDto
<>(
appletNewsBiz
.
getNewsById4Applet
(
newsId
,
wechatUserId
));
}
@ApiOperation
(
"查图书详情-出版作者分类书名"
)
...
...
pcloud-service-book/src/main/java/com/pcloud/book/applet/facade/ServeCollectFacade.java
View file @
3c9d55d2
package
com
.
pcloud
.
book
.
applet
.
facade
;
import
com.pcloud.book.applet.biz.ServeCollectBiz
;
import
com.pcloud.book.applet.dto.CollectionTypeNameAndCountDTO
;
import
com.pcloud.book.applet.entity.ServeCollect
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.common.dto.ResponseDto
;
...
...
@@ -10,6 +11,7 @@ import com.pcloud.common.utils.ListUtils;
import
com.pcloud.common.utils.SessionUtil
;
import
com.pcloud.common.utils.cookie.Cookie
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -47,11 +49,12 @@ public class ServeCollectFacade {
@ApiOperation
(
"分页查询"
)
@GetMapping
(
"getList"
)
public
ResponseDto
<?>
getList
(
@CookieValue
(
"userInfo"
)
String
userInfo
,
@RequestParam
(
value
=
"typeCode"
,
required
=
false
)
String
typeCode
,
@RequestParam
(
value
=
"currentPage"
,
defaultValue
=
"0"
)
Integer
currentPage
,
@RequestParam
(
value
=
"numPerPage"
,
defaultValue
=
"10"
)
Integer
numPerPage
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
return
new
ResponseDto
<>(
serveCollectBiz
.
getList
(
wechatUserId
,
currentPage
,
numPerPage
));
return
new
ResponseDto
<>(
serveCollectBiz
.
getList
(
wechatUserId
,
currentPage
,
numPerPage
,
typeCode
));
}
@ApiOperation
(
"新增"
)
...
...
@@ -103,10 +106,45 @@ public class ServeCollectFacade {
@ApiOperation
(
"删除"
)
@GetMapping
(
"getAllCollect"
)
public
ResponseDto
<?>
getAllCollect
(
@CookieValue
(
"userInfo"
)
String
userInfo
)
throws
BizException
,
PermissionException
{
public
ResponseDto
<?>
getAllCollect
(
@CookieValue
(
"userInfo"
)
String
userInfo
,
@RequestParam
(
value
=
"typeCode"
,
required
=
false
)
String
typeCode
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
List
<
Long
>
ids
=
serveCollectBiz
.
getAllCollect
(
wechatUserId
);
List
<
Long
>
ids
=
serveCollectBiz
.
getAllCollect
(
wechatUserId
,
typeCode
);
return
new
ResponseDto
<>(
ListUtils
.
isEmpty
(
ids
)
?
new
ArrayList
<>()
:
ids
);
}
@ApiOperation
(
"获取用户收藏种类名称及其个数"
)
@GetMapping
(
"getTypeNameAndCountByWechatUserId"
)
public
ResponseDto
<
List
<
CollectionTypeNameAndCountDTO
>>
getTypeNameAndCountByWechatUserId
(
@CookieValue
(
"userInfo"
)
String
userInfo
){
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
List
<
CollectionTypeNameAndCountDTO
>
typeNameAndCountByWechatId
=
serveCollectBiz
.
getTypeNameAndCountByWechatId
(
wechatUserId
);
return
new
ResponseDto
<>(
ListUtils
.
isEmpty
(
typeNameAndCountByWechatId
)
?
new
ArrayList
<>()
:
typeNameAndCountByWechatId
);
}
@ApiOperation
(
"根据类别名称的收藏"
)
@GetMapping
(
"getListByTypeNameAndWechatUserId"
)
public
ResponseDto
<?>
getListByTypeNameAndWechatUserId
(
@CookieValue
(
"userInfo"
)
String
userInfo
,
@RequestParam
(
"typeName"
)
String
typeName
,
@RequestParam
(
value
=
"currentPage"
,
defaultValue
=
"0"
)
Integer
currentPage
,
@RequestParam
(
value
=
"numPerPage"
,
defaultValue
=
"10"
)
Integer
numPerPage
){
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
return
new
ResponseDto
<>(
serveCollectBiz
.
getListByTypeNameAndWechatUserId
(
typeName
,
wechatUserId
,
currentPage
,
numPerPage
));
}
@ApiOperation
(
"查询单条资讯是否被收藏"
)
@GetMapping
(
"isCollected"
)
public
ResponseDto
<?>
isCollected
(
@CookieValue
(
"userInfo"
)
String
userInfo
,
@RequestParam
(
"serverId"
)
Long
serverId
){
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
return
new
ResponseDto
<>(
serveCollectBiz
.
isCollected
(
wechatUserId
,
serverId
));
}
@ApiOperation
(
"填充TypeName"
)
@GetMapping
(
"processingData"
)
public
ResponseDto
<?>
processingData
(
@RequestHeader
(
"token"
)
@ApiParam
(
"token"
)
String
token
){
SessionUtil
.
getInfoToken4Redis
(
token
);
serveCollectBiz
.
processingData
();
return
new
ResponseDto
<>();
}
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/applet/vo/CollectionTypeNameCodeClassifyVO.java
0 → 100644
View file @
3c9d55d2
package
com
.
pcloud
.
book
.
applet
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
CollectionTypeNameCodeClassifyVO
{
@ApiModelProperty
(
"应用类型 1资讯 5 product 6 app"
)
private
Integer
serveType
;
@ApiModelProperty
(
"一般为英文名称"
)
private
String
serveTypeCode
;
private
String
serveTypeName
;
}
pcloud-service-book/src/main/resources/mapper/applet/ServeCollect.Mapper.xml
View file @
3c9d55d2
...
...
@@ -9,7 +9,8 @@
<result
column=
"serve_type"
property=
"serveType"
jdbcType=
"INTEGER"
/>
<result
column=
"serve_name"
property=
"serveName"
jdbcType=
"VARCHAR"
/>
<result
column=
"serve_code"
property=
"serveCode"
jdbcType=
"INTEGER"
/>
<result
column=
"serve_type_code"
property=
"serveTypeCode"
jdbcType=
"INTEGER"
/>
<result
column=
"serve_type_code"
property=
"serveTypeCode"
jdbcType=
"VARCHAR"
/>
<result
column=
"serve_type_name"
property=
"serveTypeName"
jdbcType=
"VARCHAR"
/>
<result
column=
"link_url"
property=
"linkUrl"
jdbcType=
"VARCHAR"
/>
<result
column=
"is_delete"
property=
"isDelete"
jdbcType=
"INTEGER"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
...
...
@@ -25,7 +26,8 @@
<result
column=
"serve_type"
property=
"serveType"
jdbcType=
"INTEGER"
/>
<result
column=
"serve_name"
property=
"serveName"
jdbcType=
"VARCHAR"
/>
<result
column=
"serve_code"
property=
"serveCode"
jdbcType=
"INTEGER"
/>
<result
column=
"serve_type_code"
property=
"serveTypeCode"
jdbcType=
"INTEGER"
/>
<result
column=
"serve_type_code"
property=
"serveTypeCode"
jdbcType=
"VARCHAR"
/>
<result
column=
"serve_type_name"
property=
"serveTypeName"
jdbcType=
"VARCHAR"
/>
<result
column=
"link_url"
property=
"linkUrl"
jdbcType=
"VARCHAR"
/>
<result
column=
"is_delete"
property=
"isDelete"
jdbcType=
"INTEGER"
/>
<result
column=
"collect_day"
property=
"collectDay"
jdbcType=
"DATE"
/>
...
...
@@ -33,7 +35,7 @@
</resultMap>
<sql
id=
"Base_Column_List"
>
id, wechat_user_id, serve_id, serve_name,serve_type, serve_code,serve_type_code, link_url, is_delete, create_time, update_time, collect_day,
id, wechat_user_id, serve_id, serve_name,serve_type, serve_code,serve_type_code
,serve_type_name
, link_url, is_delete, create_time, update_time, collect_day,
pic_url
</sql>
...
...
@@ -50,6 +52,9 @@
FROM serve_collect
where
wechat_user_id = #{wechatUserId}
<if
test=
"typeCode != null"
>
and serve_type_code = #{typeCode}
</if>
and
is_delete = 0
order by
...
...
@@ -63,6 +68,7 @@
serve_name,
serve_type,
serve_type_Code,
serve_type_name,
link_url,
pic_url,
is_delete,
...
...
@@ -75,6 +81,7 @@
#{serveName},
#{serveType, jdbcType=INTEGER},
#{serveTypeCode, jdbcType=VARCHAR},
#{serveTypeName, jdbcType=VARCHAR},
#{linkUrl, jdbcType=VARCHAR},
#{picUrl},
#{isDelete, jdbcType=INTEGER},
...
...
@@ -221,8 +228,12 @@
serve_collect
where
is_delete = 0
<if
test=
"typeCode != null"
>
and serve_type_code =#{typeCode}
</if>
and
wechat_user_id = #{wechatUserId}
order by update_time desc
</select>
...
...
@@ -243,4 +254,67 @@
</foreach>
</where>
</select>
<select
id=
"getTypeNameAndCountByWechatId"
parameterType=
"long"
resultType=
"com.pcloud.book.applet.dto.CollectionTypeNameAndCountDTO"
>
SELECT
serve_type_code as typeCode ,
serve_type_name as typeName ,
COUNT(1) as count
from
serve_collect
where
wechat_user_id = #{wechatUserId}
and
is_delete = 0
group by
serve_type_name,serve_type_code
</select>
<select
id=
"getListByTypeNameAndWechatUserId"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
from
serve_collect
where
serve_type_name= #{typeName}
and
wechat_user_id = #{wechatUserId}
and
is_delete = 0
order by
update_time desc
</select>
<select
id=
"isCollected"
resultMap=
"BaseResultMap4DTO"
parameterType=
"map"
>
Select
<include
refid=
"Base_Column_List"
/>
from
serve_collect
where
wechat_user_id = #{wechatUserId}
and
serve_id = #{serveId}
and
is_delete = 0
LIMIT 1
</select>
<select
id=
"getDistinctTypeCode"
resultType=
"com.pcloud.book.applet.vo.CollectionTypeNameCodeClassifyVO"
>
select distinct
serve_type_code as serveTypeCode,
serve_type as serveType
from
serve_collect
where
serve_type_code is not null
</select>
<update
id=
"updateTypeName"
parameterType=
"map"
>
update
serve_collect
set
serve_type_name= #{serveTypeName}
where
serve_type_code =#{serveTypeCode}
</update>
</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