Commit 4d0037bc by 郑江涛

feat:[1003971]第三方资源新增收藏

parent efc05b90
...@@ -51,7 +51,12 @@ public class AppletNewsDTO extends BaseDto { ...@@ -51,7 +51,12 @@ public class AppletNewsDTO extends BaseDto {
@ApiModelProperty("是否展示") @ApiModelProperty("是否展示")
private Boolean showState; private Boolean showState;
@ApiModelProperty("是否删除") @ApiModelProperty("是否删除")
private Integer isDelete; ; private Integer isDelete;
/**
* 被收藏为1,未收藏为0
*/
@ApiModelProperty("是否被收藏")
private Integer isCollection;
@ApiModelProperty("分类名称") @ApiModelProperty("分类名称")
private String newsClassify; private String newsClassify;
@JsonFormat( @JsonFormat(
......
...@@ -26,6 +26,8 @@ public class ServeCollectDTO { ...@@ -26,6 +26,8 @@ public class ServeCollectDTO {
private String serveTypeCode; private String serveTypeCode;
private String serveTypeName;
private String linkUrl; private String linkUrl;
private String picUrl; private String picUrl;
...@@ -46,4 +48,6 @@ public class ServeCollectDTO { ...@@ -46,4 +48,6 @@ public class ServeCollectDTO {
@ApiModelProperty("资源是否删除") @ApiModelProperty("资源是否删除")
private Integer sourceDelete; private Integer sourceDelete;
@ApiModelProperty("是否被收藏")
private Integer isCollected;
} }
...@@ -286,7 +286,7 @@ public interface AppletNewsBiz { ...@@ -286,7 +286,7 @@ public interface AppletNewsBiz {
*/ */
void updateCardShowState(AppletNews appletNews); void updateCardShowState(AppletNews appletNews);
AppletNewsDTO getNewsById4Applet(Long newsId); AppletNewsDTO getNewsById4Applet(Long newsId,Long wechatUserId);
/** /**
* 根据公众号id获取出版社id * 根据公众号id获取出版社id
......
package com.pcloud.book.applet.biz; package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.dto.AppletTaskDTO; 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.dto.ServeCollectDTO;
import com.pcloud.book.applet.entity.ServeCollect; import com.pcloud.book.applet.entity.ServeCollect;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -27,7 +28,7 @@ public interface ServeCollectBiz { ...@@ -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 { ...@@ -76,7 +77,7 @@ public interface ServeCollectBiz {
* @param wechatUserId * @param wechatUserId
* @return * @return
*/ */
List<Long> getAllCollect(Long wechatUserId); List<Long> getAllCollect(Long wechatUserId,String typeCode);
/** /**
* 查询收藏情况 * 查询收藏情况
...@@ -86,4 +87,35 @@ public interface ServeCollectBiz { ...@@ -86,4 +87,35 @@ public interface ServeCollectBiz {
List<ServeCollectDTO> getList4Collect(List<ServeCollectDTO> serveCollects); List<ServeCollectDTO> getList4Collect(List<ServeCollectDTO> serveCollects);
List<ServeCollect> getList4RightsSettingByWechatUserId(Long wechatUserId); 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
...@@ -27,18 +27,7 @@ import com.pcloud.book.applet.dto.AppletNewsServeDTO; ...@@ -27,18 +27,7 @@ import com.pcloud.book.applet.dto.AppletNewsServeDTO;
import com.pcloud.book.applet.dto.AppletNewsVO; import com.pcloud.book.applet.dto.AppletNewsVO;
import com.pcloud.book.applet.dto.AppletThirdResourcesDTO; import com.pcloud.book.applet.dto.AppletThirdResourcesDTO;
import com.pcloud.book.applet.dto.PvuvDTO; import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletBusinessCard; import com.pcloud.book.applet.entity.*;
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.enums.AppletNewsServeTypeEnum; import com.pcloud.book.applet.enums.AppletNewsServeTypeEnum;
import com.pcloud.book.applet.enums.DataRecordTypeEnum; import com.pcloud.book.applet.enums.DataRecordTypeEnum;
import com.pcloud.book.applet.enums.DataTypeEnum; import com.pcloud.book.applet.enums.DataTypeEnum;
...@@ -533,6 +522,8 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -533,6 +522,8 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
// 获取周权益资讯 如果周权益不为空 则直接返回 // 获取周权益资讯 如果周权益不为空 则直接返回
pageBeanNew = rightsSettingBiz.getWeekRightsSettingNewsByBookId(userReadBook, currentPage, numPerPage); pageBeanNew = rightsSettingBiz.getWeekRightsSettingNewsByBookId(userReadBook, currentPage, numPerPage);
if (CollUtil.isNotEmpty(pageBeanNew.getRecordList())) { if (CollUtil.isNotEmpty(pageBeanNew.getRecordList())) {
//处理是否收藏流程
solvePageBeanCollectionState(pageBeanNew,wechatUserId);
return pageBeanNew; return pageBeanNew;
} }
} }
...@@ -561,9 +552,24 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -561,9 +552,24 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if (!ListUtils.isEmpty(pageBeanNew.getRecordList())) { if (!ListUtils.isEmpty(pageBeanNew.getRecordList())) {
fillBrowseCount(pageBeanNew.getRecordList()); fillBrowseCount(pageBeanNew.getRecordList());
} }
//处理收藏状态
solvePageBeanCollectionState(pageBeanNew,wechatUserId);
return pageBeanNew; 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) { private PageBeanNew<AppletNewsDTO> getAppletNewsDTOPageBeanNew(Integer currentPage, Integer numPerPage, Long newsClassifyId, Map<String, Object> paramMap, String subKey) {
PageBeanNew<AppletNewsDTO> pageBeanNew; PageBeanNew<AppletNewsDTO> pageBeanNew;
List<AppletNewsDTO> homeList = JedisClusterUtils.getJsonList(AppletConstants.HOME_NEWS_LIST + subKey, AppletNewsDTO.class); List<AppletNewsDTO> homeList = JedisClusterUtils.getJsonList(AppletConstants.HOME_NEWS_LIST + subKey, AppletNewsDTO.class);
...@@ -1226,7 +1232,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -1226,7 +1232,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
} }
@Override @Override
public AppletNewsDTO getNewsById4Applet(Long id) { public AppletNewsDTO getNewsById4Applet(Long id,Long wechatUserId) {
AppletNews appletNews = appletNewsDao.getById(id); AppletNews appletNews = appletNewsDao.getById(id);
AppletNewsDTO appletNewsDTO = new AppletNewsDTO(); AppletNewsDTO appletNewsDTO = new AppletNewsDTO();
if (null!=appletNews){ if (null!=appletNews){
...@@ -1248,9 +1254,38 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -1248,9 +1254,38 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if (StrUtil.isNotBlank(appletNews.getCityCode())) { if (StrUtil.isNotBlank(appletNews.getCityCode())) {
appletNewsDTO.setCity(regionMapMapper.getCitysByCode(appletNews.getCityCode())); appletNewsDTO.setCity(regionMapMapper.getCitysByCode(appletNews.getCityCode()));
} }
//填充收藏状态
if (wechatUserId != null){
fillCollectionState(appletNewsDTO,wechatUserId,null);
}
return appletNewsDTO; 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 @Override
public Map<Long, AppletNewsDTO> getByIds4Record(List<Long> newsIds) { public Map<Long, AppletNewsDTO> getByIds4Record(List<Long> newsIds) {
if(ListUtils.isEmpty(newsIds)){ if(ListUtils.isEmpty(newsIds)){
......
...@@ -2,18 +2,16 @@ package com.pcloud.book.applet.biz.impl; ...@@ -2,18 +2,16 @@ package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.pcloud.appcenter.app.dto.AppDto; import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.app.dto.AppTypeDto;
import com.pcloud.appcenter.app.entity.AppType; import com.pcloud.appcenter.app.entity.AppType;
import com.pcloud.book.applet.biz.AppletNewsBiz; import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.ServeCollectBiz; import com.pcloud.book.applet.biz.ServeCollectBiz;
import com.pcloud.book.applet.dao.ServeCollectDao; import com.pcloud.book.applet.dao.ServeCollectDao;
import com.pcloud.book.applet.dto.AppletAppOrProductDTO; import com.pcloud.book.applet.dto.*;
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.entity.ServeCollect; import com.pcloud.book.applet.entity.ServeCollect;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum; import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.applet.enums.CollectionTypeEnum; 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.base.exception.BookBizException;
import com.pcloud.book.consumer.app.AppConsr; import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr; import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
...@@ -37,6 +35,7 @@ import com.pcloud.readercenter.common.enums.YesOrNoNumEnum; ...@@ -37,6 +35,7 @@ import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.readercenter.rmall.constants.RmallContants; import com.pcloud.readercenter.rmall.constants.RmallContants;
import com.pcloud.readercenter.rmall.enums.MoneyReceiveTypeEnum; import com.pcloud.readercenter.rmall.enums.MoneyReceiveTypeEnum;
import com.pcloud.resourcecenter.product.dto.ProductDto; import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.ProductTypeDto;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -92,9 +91,10 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -92,9 +91,10 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
@Override @Override
@ParamLog("查询多条数据") @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<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserId", wechatUserId); paramMap.put("wechatUserId", wechatUserId);
paramMap.put("typeCode",typeCode);
PageBeanNew pageBeanNew = serveCollectDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "getList"); PageBeanNew pageBeanNew = serveCollectDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "getList");
List recordList = pageBeanNew.getRecordList(); List recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)) { if (ListUtils.isEmpty(recordList)) {
...@@ -352,8 +352,143 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -352,8 +352,143 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
} }
@Override @Override
public List<Long> getAllCollect(Long wechatUserId) { public List<CollectionTypeNameAndCountDTO> getTypeNameAndCountByWechatId(Long wechatUserId) {
return serveCollectDao.getAllCollect(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 @Override
......
package com.pcloud.book.applet.dao; 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.dto.ServeCollectDTO;
import com.pcloud.book.applet.entity.ServeCollect; import com.pcloud.book.applet.entity.ServeCollect;
import com.pcloud.book.applet.vo.CollectionTypeNameCodeClassifyVO;
import com.pcloud.common.core.dao.BaseDao; import com.pcloud.common.core.dao.BaseDao;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* (ServeCollect)表数据库访问层 * (ServeCollect)表数据库访问层
...@@ -20,9 +23,17 @@ public interface ServeCollectDao extends BaseDao<ServeCollect> { ...@@ -20,9 +23,17 @@ public interface ServeCollectDao extends BaseDao<ServeCollect> {
List<ServeCollect> getList4RightsSetting(List<ServeCollect> serveCollects); 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<ServeCollectDTO> getList4Collect(List<ServeCollectDTO> serveCollects);
List<ServeCollect> getList4RightsSettingByWechatUserId(Long wechatUserId); 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
package com.pcloud.book.applet.dao.impl; package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.ServeCollectDao; 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.dto.ServeCollectDTO;
import com.pcloud.book.applet.entity.ServeCollect; import com.pcloud.book.applet.entity.ServeCollect;
import com.pcloud.book.applet.vo.CollectionTypeNameCodeClassifyVO;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* (ServeCollect)表数据库访问层 * (ServeCollect)表数据库访问层
...@@ -39,8 +43,34 @@ public class ServeCollectDaoImpl extends BaseDaoImpl<ServeCollect> implements Se ...@@ -39,8 +43,34 @@ public class ServeCollectDaoImpl extends BaseDaoImpl<ServeCollect> implements Se
} }
@Override @Override
public List<Long> getAllCollect(Long wechatUserId) { public List<CollectionTypeNameAndCountDTO> getTypeNameAndCountByWechatId(Long wechatUserId) {
return getSessionTemplate().selectList(getStatement("getAllCollect"), 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 @Override
......
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;
}
...@@ -39,6 +39,8 @@ public class ServeCollect extends BaseEntity { ...@@ -39,6 +39,8 @@ public class ServeCollect extends BaseEntity {
private String serveTypeCode; private String serveTypeCode;
private String serveTypeName;
private String linkUrl; private String linkUrl;
private String picUrl; private String picUrl;
......
...@@ -671,11 +671,25 @@ public class AppletHomeFacade { ...@@ -671,11 +671,25 @@ public class AppletHomeFacade {
@ApiOperation("根据ID查资讯详情") @ApiOperation("根据ID查资讯详情")
@GetMapping("getAppletNewsById") @GetMapping("getAppletNewsById")
public ResponseDto<AppletNewsDTO> 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){ @RequestParam("newsId") @ApiParam("资讯id")Long newsId){
if (null == newsId){ if (null == newsId){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数"); 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("查图书详情-出版作者分类书名") @ApiOperation("查图书详情-出版作者分类书名")
......
package com.pcloud.book.applet.facade; package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.biz.ServeCollectBiz; 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.applet.entity.ServeCollect;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
...@@ -10,6 +11,7 @@ import com.pcloud.common.utils.ListUtils; ...@@ -10,6 +11,7 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.SessionUtil; import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie; import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -47,11 +49,12 @@ public class ServeCollectFacade { ...@@ -47,11 +49,12 @@ public class ServeCollectFacade {
@ApiOperation("分页查询") @ApiOperation("分页查询")
@GetMapping("getList") @GetMapping("getList")
public ResponseDto<?> getList(@CookieValue("userInfo") String userInfo, public ResponseDto<?> getList(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "typeCode",required = false) String typeCode,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage, @RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage) @RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException { throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID); 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("新增") @ApiOperation("新增")
...@@ -103,10 +106,45 @@ public class ServeCollectFacade { ...@@ -103,10 +106,45 @@ public class ServeCollectFacade {
@ApiOperation("删除") @ApiOperation("删除")
@GetMapping("getAllCollect") @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); 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); 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
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;
}
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
<result column="serve_type" property="serveType" jdbcType="INTEGER"/> <result column="serve_type" property="serveType" jdbcType="INTEGER"/>
<result column="serve_name" property="serveName" jdbcType="VARCHAR"/> <result column="serve_name" property="serveName" jdbcType="VARCHAR"/>
<result column="serve_code" property="serveCode" jdbcType="INTEGER"/> <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="link_url" property="linkUrl" jdbcType="VARCHAR"/>
<result column="is_delete" property="isDelete" jdbcType="INTEGER"/> <result column="is_delete" property="isDelete" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
...@@ -25,7 +26,8 @@ ...@@ -25,7 +26,8 @@
<result column="serve_type" property="serveType" jdbcType="INTEGER"/> <result column="serve_type" property="serveType" jdbcType="INTEGER"/>
<result column="serve_name" property="serveName" jdbcType="VARCHAR"/> <result column="serve_name" property="serveName" jdbcType="VARCHAR"/>
<result column="serve_code" property="serveCode" jdbcType="INTEGER"/> <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="link_url" property="linkUrl" jdbcType="VARCHAR"/>
<result column="is_delete" property="isDelete" jdbcType="INTEGER"/> <result column="is_delete" property="isDelete" jdbcType="INTEGER"/>
<result column="collect_day" property="collectDay" jdbcType="DATE"/> <result column="collect_day" property="collectDay" jdbcType="DATE"/>
...@@ -33,7 +35,7 @@ ...@@ -33,7 +35,7 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <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 pic_url
</sql> </sql>
...@@ -50,6 +52,9 @@ ...@@ -50,6 +52,9 @@
FROM serve_collect FROM serve_collect
where where
wechat_user_id = #{wechatUserId} wechat_user_id = #{wechatUserId}
<if test="typeCode != null">
and serve_type_code = #{typeCode}
</if>
and and
is_delete = 0 is_delete = 0
order by order by
...@@ -63,6 +68,7 @@ ...@@ -63,6 +68,7 @@
serve_name, serve_name,
serve_type, serve_type,
serve_type_Code, serve_type_Code,
serve_type_name,
link_url, link_url,
pic_url, pic_url,
is_delete, is_delete,
...@@ -75,6 +81,7 @@ ...@@ -75,6 +81,7 @@
#{serveName}, #{serveName},
#{serveType, jdbcType=INTEGER}, #{serveType, jdbcType=INTEGER},
#{serveTypeCode, jdbcType=VARCHAR}, #{serveTypeCode, jdbcType=VARCHAR},
#{serveTypeName, jdbcType=VARCHAR},
#{linkUrl, jdbcType=VARCHAR}, #{linkUrl, jdbcType=VARCHAR},
#{picUrl}, #{picUrl},
#{isDelete, jdbcType=INTEGER}, #{isDelete, jdbcType=INTEGER},
...@@ -221,8 +228,12 @@ ...@@ -221,8 +228,12 @@
serve_collect serve_collect
where where
is_delete = 0 is_delete = 0
<if test="typeCode != null">
and serve_type_code =#{typeCode}
</if>
and and
wechat_user_id = #{wechatUserId} wechat_user_id = #{wechatUserId}
order by update_time desc
</select> </select>
...@@ -243,4 +254,67 @@ ...@@ -243,4 +254,67 @@
</foreach> </foreach>
</where> </where>
</select> </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> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment