Commit 4da99b1f by 田超

Merge branch 'feature/1003479' into 'master'

feat: [1003479] 我的社群板块调整为我的足迹,记录用点击浏览资源历史

See merge request rays/pcloud-book!939
parents d650acc4 b5d3ed53
...@@ -281,4 +281,11 @@ public interface AppletBooklistBiz { ...@@ -281,4 +281,11 @@ public interface AppletBooklistBiz {
* * @param null * * @param null
*/ */
void autoCreateBooklistByTemplet(Long firstClassify); void autoCreateBooklistByTemplet(Long firstClassify);
/**
* 获取小程序精选书单
* @param bookListIds
* @return
*/
Map<Long, AppletBooklistDTO> getBookListMap(List<Long> bookListIds);
} }
...@@ -302,4 +302,11 @@ public interface AppletNewsBiz { ...@@ -302,4 +302,11 @@ public interface AppletNewsBiz {
* * @param null * * @param null
*/ */
void addDefaultAppletNewsClassify(Long agentId); void addDefaultAppletNewsClassify(Long agentId);
/**
*获取资讯 无论是否删除或下架
* @param newsIds
* @return
*/
Map<Long, AppletNewsDTO> getByIds4Record(List<Long> newsIds);
} }
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
/**
* (AppletRecord)表服务接口
*
* @author makejava
* @since 2020-08-27 15:49:57
*/
public interface AppletRecordBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
AppletRecord getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param appletRecord 实例对象
* @return 主键
*/
Long insert(AppletRecord appletRecord);
/**
* 修改数据
*
* @param appletRecord 实例对象
*/
void update(AppletRecord appletRecord);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
/**
* 获取足迹列表
* @param wechatUserId
* @param date
* @param recordTypes
* @param queryName
* @param currentPage
* @param numPerPage
* @return
*/
PageBeanNew<AppletRecordDTO> listAppletRecord(Long wechatUserId, String date, List<Integer> recordTypes, String queryName, Integer currentPage, Integer numPerPage);
}
\ No newline at end of file
...@@ -28,6 +28,7 @@ import com.pcloud.book.book.dto.BookAdviserDto; ...@@ -28,6 +28,7 @@ import com.pcloud.book.book.dto.BookAdviserDto;
import com.pcloud.book.book.entity.BookLabel; import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.consumer.app.AssistTempletConsr; import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.user.AdviserConsr; import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.book.consumer.user.ChannelConsr; import com.pcloud.book.consumer.user.ChannelConsr;
import com.pcloud.book.util.properties.BookProps; import com.pcloud.book.util.properties.BookProps;
import com.pcloud.channelcenter.wechat.entity.AccountSetting; import com.pcloud.channelcenter.wechat.entity.AccountSetting;
...@@ -140,7 +141,7 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz { ...@@ -140,7 +141,7 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
@Override @Override
public void deleteBooklistById(Long id) { public void deleteBooklistById(Long id) {
appletBooklistDao.deleteById(id); appletBooklistDao.updateDeleteState(id);
appletBooklistDao.deleteConfigByBooklistId(id); appletBooklistDao.deleteConfigByBooklistId(id);
//删除客户端缓存 //删除客户端缓存
JedisClusterUtils.del(AppletConstants.BOOKLIST_BOOK+id); JedisClusterUtils.del(AppletConstants.BOOKLIST_BOOK+id);
...@@ -591,7 +592,7 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz { ...@@ -591,7 +592,7 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
@Override @Override
public void deleteOuterBooklistById(Long id) { public void deleteOuterBooklistById(Long id) {
appletOuterBooklistDao.deleteById(id); appletOuterBooklistDao.updateDeleteState(id);
appletOuterBooklistDao.deleteConfigByOuterBooklistId(id); appletOuterBooklistDao.deleteConfigByOuterBooklistId(id);
} }
...@@ -757,4 +758,10 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz { ...@@ -757,4 +758,10 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
} }
} }
@Override
@ParamLog("获取小程序精选书单")
public Map<Long, AppletBooklistDTO> getBookListMap(List<Long> bookListIds) {
return appletBooklistDao.getBookListMap(bookListIds);
}
} }
...@@ -327,7 +327,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -327,7 +327,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if (null == beforeNews) { if (null == beforeNews) {
return; return;
} }
appletNewsDao.deleteById(id); appletNewsDao.deleteByNews(Lists.newArrayList(id));
//同时删除配置的资讯 1 删除即享权益 2 删除删除周或长期 //同时删除配置的资讯 1 删除即享权益 2 删除删除周或长期
rightsSettingBiz.deleteInvalidNews(Lists.newArrayList(id)); rightsSettingBiz.deleteInvalidNews(Lists.newArrayList(id));
this.updateSource(beforeNews.getSource(), null, beforeNews.getAgentId()); this.updateSource(beforeNews.getSource(), null, beforeNews.getAgentId());
...@@ -837,7 +837,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -837,7 +837,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
@Override @Override
public void batchDeleteAppletNews(List<Long> appletNewsIds) { public void batchDeleteAppletNews(List<Long> appletNewsIds) {
appletNewsDao.batchDeleteAppletNews(appletNewsIds); appletNewsDao.deleteByNews(appletNewsIds);
//资讯下架 删除与权益的关联关系
rightsSettingBiz.deleteInvalidNews(appletNewsIds);
JedisClusterUtils.del(AppletConstants.HOME_NEWS_LIST);
} }
@Override @Override
...@@ -1227,6 +1230,14 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -1227,6 +1230,14 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
return appletNewsDTO; return appletNewsDTO;
} }
@Override
public Map<Long, AppletNewsDTO> getByIds4Record(List<Long> newsIds) {
if(ListUtils.isEmpty(newsIds)){
new HashMap<>();
}
return appletNewsDao.getByIds4Record(newsIds);
}
private void fillThirdResources4Applet(List<AppletNewsDTO> appletNewsDTOList) { private void fillThirdResources4Applet(List<AppletNewsDTO> appletNewsDTOList) {
if (ListUtils.isEmpty(appletNewsDTOList)) { if (ListUtils.isEmpty(appletNewsDTOList)) {
return; return;
......
package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.map.MapUtil;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.book.applet.biz.AppletBooklistBiz;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.AppletRecordBiz;
import com.pcloud.book.applet.dao.AppletBooklistDao;
import com.pcloud.book.applet.dao.AppletRecordDao;
import com.pcloud.book.applet.dto.AppletAppOrProductDTO;
import com.pcloud.book.applet.dto.AppletBooklistDTO;
import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.dto.AppletOuterBooklistDTO;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.dto.BookDTO4Booklist;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
/**
* (AppletRecord)表服务实现类
*
* @author makejava
* @since 2020-08-27 15:49:57
*/
@Service("appletRecordBiz")
public class AppletRecordBizImpl implements AppletRecordBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(AppletRecordBizImpl.class);
@Autowired
private AppletRecordDao appletRecordDao;
@Autowired
private ProductConsr productConsr;
@Autowired
private AppConsr appConsr;
@Autowired
private AppletNewsBiz appletNewsBiz;
@Autowired
private PcloudGroupActivityBiz pcloudGroupActivityBiz;
@Autowired
private AppletBooklistBiz appletBooklistBiz;
@Autowired
private RightsSettingBiz rightsSettingBiz;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired
private AppletBooklistDao appletBooklistDao;
@Override
@ParamLog("通过ID查询单条数据")
public AppletRecord getById(Long id) {
return appletRecordDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Integer currentPage, Integer numPerPage) {
PageBeanNew pageBeanNew = appletRecordDao.listPageNew(new PageParam(currentPage, numPerPage), null, "getList");
List recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)) {
return pageBeanNew;
}
// 加载其它数据
return pageBeanNew;
}
@Override
@ParamLog("新增足迹埋点")
public Long insert(AppletRecord appletRecord) {
insertCheck(appletRecord);
appletRecordDao.insert(appletRecord);
return appletRecord.getId();
}
private void insertCheck(AppletRecord appletRecord) {
if (null == appletRecord) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "appletRecord为空");
}
if (null == appletRecord.getRecordType()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "recordType不能为空");
}
if (null == appletRecord.getWechatUserId()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "wechatUserId不能为空");
}
if (null == appletRecord.getFromId() || StringUtil.isEmpty(appletRecord.getFromName())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "fromId或fromName为空");
}
}
@Override
@ParamLog("修改")
public void update(AppletRecord appletRecord) {
if (appletRecord == null || !NumberUtil.isNumber(appletRecord.getId())) {
throw BizException.PARAM_IS_NULL;
}
appletRecordDao.update(appletRecord);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
appletRecordDao.deleteById(id);
}
@Override
@ParamLog(value = "我的足迹", isAfterReturn = false)
public PageBeanNew<AppletRecordDTO> listAppletRecord(Long wechatUserId, String date, List<Integer> recordTypes, String queryName,
Integer currentPage, Integer numPerPage) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserId", wechatUserId);
paramMap.put("date", date);
paramMap.put("recordTypes", recordTypes);
paramMap.put("queryName", queryName);
PageBeanNew<AppletRecordDTO> listAppletRecord = appletRecordDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listAppletRecord");
List<AppletRecordDTO> recordList = listAppletRecord.getRecordList();
fillAppletRecord(recordList);
return listAppletRecord;
}
private void fillAppletRecord(List<AppletRecordDTO> recordList) {
if (ListUtils.isEmpty(recordList)) {
return;
}
//根据不同的类型填充不同的数据
List<Long> newsIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.NEWS.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
List<Long> bookGroupClassifyIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.ADVISER_GROUP.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
List<Long> activityGroupIds4Model = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.MODEL_GROUP.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
List<Long> activityGroupIds4Third = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.THIRD_GROUP.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
List<Long> productIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.PRODUCT.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
List<Long> appIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.APP.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
List<AppletRecordDTO> appletRecordDTOS4Book = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.BOOK.value.equals(appletRecordDTO.getRecordType())).
collect(Collectors.toList());
List<Long> bookRecommendIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.BOOK_RECOMMEND.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
List<Long> bookListIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.BOOK_LIST.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
//资源map
Map<Long, AppletNewsDTO> newsDtoMap = new HashMap<>();
Future<Map<Long, AppletNewsDTO>> newsDtoMapFuture = null;
Map<Long, GroupActivity4AppletDTO> groupDtoMap4BookGroupClassify = new HashMap<>();
Future<Map<Long, GroupActivity4AppletDTO>> groupDtoMap4BookGroupClassifyFuture = null;
Map<Long, GroupActivity4AppletDTO> groupDtoMap4ModelGroup = new HashMap<>();
Future<Map<Long, GroupActivity4AppletDTO>> groupDtoMap4ModelGroupFuture = null;
Map<Long, GroupActivity4AppletDTO> groupDtoMap4ThirdGroup = new HashMap<>();
Future<Map<Long, GroupActivity4AppletDTO>> groupDtoMap4ThirdGroupFuture = null;
Map<Long, ProductDto> productDtoMap = new HashMap<>();
Future<Map<Long, ProductDto>> productDtoMapFuture = null;
Map<Long, AppDto> appDtoMap = new HashMap<>();
Future<Map<Long, AppDto>> appDtoMappFuture = null;
Map<Long, AppletUserBookcaseDTO> appletUserBookcaseDTOMap = new HashMap<>();
Future<Map<Long, AppletUserBookcaseDTO>> appletUserBookcaseDTOMapFuture = null;
Map<Long, AppletOuterBooklistDTO> appletOuterBooklistDTOMap = new HashMap<>();
Future<Map<Long, AppletOuterBooklistDTO>> appletOuterBooklistDTOMapFuture = null;
Map<Long, AppletBooklistDTO> appletBooklistDTOMap = new HashMap<>();
Future<Map<Long, AppletBooklistDTO>> appletBooklistDTOMapFuture = null;
if (!ListUtils.isEmpty(newsIds)) {
newsDtoMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletNewsBiz.getByIds4Record(newsIds));
}
if (!ListUtils.isEmpty(bookGroupClassifyIds)) {
groupDtoMap4BookGroupClassifyFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> pcloudGroupActivityBiz.getByIds4NowRecord(bookGroupClassifyIds, AppletRecordTypeEnum.ADVISER_GROUP.value));
}
if (!ListUtils.isEmpty(activityGroupIds4Model)) {
groupDtoMap4ModelGroupFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> pcloudGroupActivityBiz.getByIds4NowRecord(activityGroupIds4Model, AppletRecordTypeEnum.MODEL_GROUP.value));
}
if (!ListUtils.isEmpty(activityGroupIds4Third)) {
groupDtoMap4ThirdGroupFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> pcloudGroupActivityBiz.getByIds4NowRecord(activityGroupIds4Third, AppletRecordTypeEnum.THIRD_GROUP.value));
}
if (!ListUtils.isEmpty(productIds)) {
productDtoMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> productConsr.getProBasesByIds(productIds));
}
if (!ListUtils.isEmpty(appIds)) {
appDtoMappFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appConsr.mapByIds4AuditPass(appIds));
}
if (!ListUtils.isEmpty(appletRecordDTOS4Book)) {
appletUserBookcaseDTOMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletRecordDao.getBookMap(appletRecordDTOS4Book));
}
if (!ListUtils.isEmpty(bookRecommendIds)) {
appletOuterBooklistDTOMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletBooklistBiz.getByIds(bookRecommendIds));
}
if (!ListUtils.isEmpty(bookListIds)) {
appletBooklistDTOMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletBooklistBiz.getBookListMap(bookListIds));
}
//存储已经删除群的群分类; 精选文章类型并且跳转链接包含qrcode.5rs.me
Iterator<AppletRecordDTO> iterator = recordList.iterator();
while (iterator.hasNext()) {
AppletRecordDTO appletRecordDTO = iterator.next();
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.NO.getValue());
if (Objects.equals(AppletRecordTypeEnum.NEWS.value, appletRecordDTO.getRecordType()) && null != newsDtoMap) {
//填充资讯信息
filllAppletNews4Record(newsDtoMap, newsDtoMapFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.ADVISER_GROUP.value, appletRecordDTO.getRecordType())) {
//填充编辑群信息
fillGroup4Record(groupDtoMap4BookGroupClassify, groupDtoMap4BookGroupClassifyFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.MODEL_GROUP.value, appletRecordDTO.getRecordType())) {
//填充模板群信息
fillGroup4Record(groupDtoMap4ModelGroup, groupDtoMap4ModelGroupFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.THIRD_GROUP.value, appletRecordDTO.getRecordType())) {
//填充第三方群信息
fillGroup4Record(groupDtoMap4ThirdGroup, groupDtoMap4ThirdGroupFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.PRODUCT.value, appletRecordDTO.getRecordType())) {
//填充作品信息
fillProduct4Record(productDtoMap, productDtoMapFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.APP.value, appletRecordDTO.getRecordType())) {
//填充应用信息
fillApp4Record(appDtoMap, appDtoMappFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.BOOK.value, appletRecordDTO.getRecordType())) {
//填充书籍信息
fillBook4Record(appletUserBookcaseDTOMap, appletUserBookcaseDTOMapFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.BOOK_RECOMMEND.value, appletRecordDTO.getRecordType())) {
//填充书单推荐信息
fillAppletOuterBooklist4Record(appletOuterBooklistDTOMap, appletRecordDTO, appletOuterBooklistDTOMapFuture);
} else if (Objects.equals(AppletRecordTypeEnum.BOOK_LIST.value, appletRecordDTO.getRecordType())) {
//填充精选书单信息
fillAppletBooklist4Record(appletBooklistDTOMap, appletBooklistDTOMapFuture, appletRecordDTO);
}
}
}
private void fillAppletBooklist4Record(Map<Long, AppletBooklistDTO> appletBooklistDTOMap, Future<Map<Long, AppletBooklistDTO>> appletBooklistDTOMapFuture, AppletRecordDTO appletRecordDTO) {
try {
appletBooklistDTOMap = appletBooklistDTOMapFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("获取精选书单错误: {}==", e);
}
if (MapUtil.isEmpty(appletBooklistDTOMap)) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
AppletBooklistDTO appletBooklistDTO = appletBooklistDTOMap.get(appletRecordDTO.getFromId());
if (null == appletBooklistDTO) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
List<BookDTO4Booklist> bookList = appletBooklistDao.getBookBaseByBooklistId(appletBooklistDTO.getId(), 0, 3);
appletBooklistDTO.setBookDTO4Booklists(ListUtils.isEmpty(bookList) ? new ArrayList<>() : bookList);
appletRecordDTO.setAppletBooklistDTO(appletBooklistDTO);
}
private void fillAppletOuterBooklist4Record(Map<Long, AppletOuterBooklistDTO> appletOuterBooklistDTOMap, AppletRecordDTO appletRecordDTO, Future<Map<Long, AppletOuterBooklistDTO>> appletOuterBooklistDTOMapFuture) {
try {
appletOuterBooklistDTOMap = appletOuterBooklistDTOMapFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("获取书单推荐错误: {}==", e);
}
if (MapUtil.isEmpty(appletOuterBooklistDTOMap)) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
AppletOuterBooklistDTO outerBooklistDTO = appletOuterBooklistDTOMap.get(appletRecordDTO.getFromId());
if (null == outerBooklistDTO) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
appletRecordDTO.setAppletOuterBooklistDTO(outerBooklistDTO);
}
private void fillBook4Record(Map<Long, AppletUserBookcaseDTO> appletUserBookcaseDTOMap, Future<Map<Long, AppletUserBookcaseDTO>> appletUserBookcaseDTOMapFuture, AppletRecordDTO appletRecordDTO) {
try {
appletUserBookcaseDTOMap = appletUserBookcaseDTOMapFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("获取书籍错误: {}==", e);
}
if (MapUtil.isEmpty(appletUserBookcaseDTOMap)) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
AppletUserBookcaseDTO appletUserBookcaseDTO = appletUserBookcaseDTOMap.get(appletRecordDTO.getId());
if (null == appletUserBookcaseDTO) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
appletRecordDTO.setAppletUserBookcaseDTO(appletUserBookcaseDTO);
}
private void fillGroup4Record(Map<Long, GroupActivity4AppletDTO> groupDtoMap4BookGroupClassify, Future<Map<Long, GroupActivity4AppletDTO>> groupDtoMap4BookGroupClassifyFuture, AppletRecordDTO appletRecordDTO) {
//填充群信息
try {
groupDtoMap4BookGroupClassify = groupDtoMap4BookGroupClassifyFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("获取群错误: {}==", e);
}
if (MapUtil.isEmpty(groupDtoMap4BookGroupClassify)) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
GroupActivity4AppletDTO groupActivity4AppletDTO = groupDtoMap4BookGroupClassify.get(appletRecordDTO.getFromId());
if (null == groupActivity4AppletDTO) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
appletRecordDTO.setAppletGroupDTO(groupActivity4AppletDTO);
}
private void filllAppletNews4Record(Map<Long, AppletNewsDTO> newsDtoMap, Future<Map<Long, AppletNewsDTO>> newsDtoMapFuture, AppletRecordDTO appletRecordDTO) {
//填充资讯信息
try {
newsDtoMap = newsDtoMapFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("获取资讯错误: {}==", e);
}
if (MapUtil.isEmpty(newsDtoMap)) {
appletRecordDao.updateDeleteState(appletRecordDTO.getFromId(), appletRecordDTO.getRecordType());
return;
}
AppletNewsDTO appletNewsDTO = newsDtoMap.get(appletRecordDTO.getFromId());
if (null == appletNewsDTO || Objects.equals(YesOrNoNumEnum.YES.getValue(), appletNewsDTO.getIsDelete())) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
appletNewsDTO.setNewsType(appletNewsDTO.getType());
appletNewsDTO.setNewsName(appletRecordDTO.getFromName());
appletRecordDTO.setAppletNewsDTO(appletNewsDTO);
appletRecordDTO.setShowState(appletNewsDTO.getShowState() ? YesOrNoNumEnum.YES.getValue() : YesOrNoNumEnum.NO.getValue());
appletRecordDTO.setIsDelete(appletNewsDTO.getIsDelete());
}
private void fillApp4Record(Map<Long, AppDto> appDtoMap, Future<Map<Long, AppDto>> appDtoMappFuture, AppletRecordDTO appletRecordDTO) {
try {
appDtoMap = appDtoMappFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("获取app错误: {}==", e);
}
if (MapUtil.isEmpty(appDtoMap)) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
AccountSettingDto accountSettingDto;
AppDto appDto = appDtoMap.get(appletRecordDTO.getFromId());
AppletAppOrProductDTO appletAppOrProductDTO = new AppletAppOrProductDTO();
if (appDto == null || appDto.getIsDelete()) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
if (!StringUtil.isEmpty(appletRecordDTO.getLinkUrl()) && appletRecordDTO.getLinkUrl().contains("qrcode.5rs.me") && "ARTICLE".equals(appDto.getTypeCode())) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
appletAppOrProductDTO.setServeName(appDto.getTitle());
appletAppOrProductDTO.setServePic(appDto.getSquareImg());
appletAppOrProductDTO.setServeTypeCode(appDto.getTypeCode());
appletAppOrProductDTO.setServeTypeName(appDto.getTypeName());
accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
if (null == accountSettingDto) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, appletRecordDTO.getLinkUrl());
appletAppOrProductDTO.setResultUrl(resultLinkUrl);
appletRecordDTO.setAppletAppOrProductDTO(appletAppOrProductDTO);
}
private void fillProduct4Record(Map<Long, ProductDto> productDtoMap, Future<Map<Long, ProductDto>> productDtoMapFuture, AppletRecordDTO appletRecordDTO) {
try {
productDtoMap = productDtoMapFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("获取product错误: {}==", e);
}
if (MapUtil.isEmpty(productDtoMap)) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
AccountSettingDto accountSettingDto;
ProductDto productDto = productDtoMap.get(appletRecordDTO.getFromId());
AppletAppOrProductDTO appletAppOrProductDTO = new AppletAppOrProductDTO();
if (productDto == null || YesOrNoNumEnum.YES.getValue().equals(productDto.getIsDelete())) {
appletRecordDTO.setSourceDelete(YesOrNoNumEnum.YES.getValue());
return;
}
appletAppOrProductDTO.setServeName(productDto.getProductName());
appletAppOrProductDTO.setServePic(productDto.getCoverImg());
if (productDto.getProductTypeDto() != null) {
appletAppOrProductDTO.setServeTypeCode(productDto.getProductTypeDto().getTypeCode());
appletAppOrProductDTO.setServeTypeName(productDto.getProductTypeDto().getTypeName());
}
//获取channelId,/C1404/product/display/10234028?adviserId=1001587&proType=MEMBER&source_type=QRCODE
Long channelId = null;
String url = appletRecordDTO.getLinkUrl();
if (!StringUtil.isEmpty(url) && url.contains("/C") && !url.startsWith("https")) {
url = url.substring(url.indexOf("/C") + 2);
url = url.substring(0, url.indexOf("/"));
if (!StringUtil.isEmpty(url)) {
channelId = Long.valueOf(url);
}
}
if (null != channelId) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
if (null != accountSettingDto) {
String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, productDto.getTurnUrl());
appletAppOrProductDTO.setResultUrl(resultLinkUrl);
}
} else {
appletAppOrProductDTO.setResultUrl(appletRecordDTO.getLinkUrl());
}
appletRecordDTO.setAppletAppOrProductDTO(appletAppOrProductDTO);
}
}
\ No newline at end of file
...@@ -6,6 +6,7 @@ import com.pcloud.book.applet.entity.AppletBooklist; ...@@ -6,6 +6,7 @@ import com.pcloud.book.applet.entity.AppletBooklist;
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;
public interface AppletBooklistDao extends BaseDao<AppletBooklist> { public interface AppletBooklistDao extends BaseDao<AppletBooklist> {
...@@ -77,4 +78,17 @@ public interface AppletBooklistDao extends BaseDao<AppletBooklist> { ...@@ -77,4 +78,17 @@ public interface AppletBooklistDao extends BaseDao<AppletBooklist> {
/**
* 更新删除状态
* @param id
*/
void updateDeleteState(Long id);
/**
* 获取小程序书单
* @param bookListIds
* @return
*/
Map<Long, AppletBooklistDTO> getBookListMap(List<Long> bookListIds);
} }
...@@ -8,6 +8,7 @@ import com.pcloud.book.applet.vo.AppletNewsClassifyVO; ...@@ -8,6 +8,7 @@ import com.pcloud.book.applet.vo.AppletNewsClassifyVO;
import com.pcloud.book.applet.vo.AppletNewsShowStateVO; import com.pcloud.book.applet.vo.AppletNewsShowStateVO;
import com.pcloud.common.core.dao.BaseDao; import com.pcloud.common.core.dao.BaseDao;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -172,4 +173,17 @@ public interface AppletNewsDao extends BaseDao<AppletNews> { ...@@ -172,4 +173,17 @@ public interface AppletNewsDao extends BaseDao<AppletNews> {
* @param cityId * @param cityId
*/ */
List<AppletNewsDTO> listNewsByCityCode(String cityId); List<AppletNewsDTO> listNewsByCityCode(String cityId);
/**
* 删除资讯
* @param newArrayList
*/
void deleteByNews(List<Long> newArrayList);
/**
* 查询资讯 无论是否删除
* @param newsIds
* @return
*/
Map<Long, AppletNewsDTO> getByIds4Record(List<Long> newsIds);
} }
...@@ -80,4 +80,10 @@ public interface AppletOuterBooklistDao extends BaseDao<AppletOuterBooklist>{ ...@@ -80,4 +80,10 @@ public interface AppletOuterBooklistDao extends BaseDao<AppletOuterBooklist>{
* * @param null * * @param null
*/ */
void batchDeleteOuterBookFromBooklist(List<Long> configIds); void batchDeleteOuterBookFromBooklist(List<Long> configIds);
/**
* 更新书单删除状态
* @param id
*/
void updateDeleteState(Long id);
} }
\ No newline at end of file
package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* (AppletRecord)表数据库访问层
*
* @author makejava
* @since 2020-08-27 15:49:55
*/
public interface AppletRecordDao extends BaseDao<AppletRecord> {
Map<Long, AppletUserBookcaseDTO> getBookMap(List<AppletRecordDTO> appletRecordDTOS4Book);
void updateDeleteState(Long fromId, Integer recordType);
}
\ No newline at end of file
...@@ -82,4 +82,14 @@ public class AppletBooklistDaoImpl extends BaseDaoImpl<AppletBooklist> implement ...@@ -82,4 +82,14 @@ public class AppletBooklistDaoImpl extends BaseDaoImpl<AppletBooklist> implement
return getSessionTemplate().selectList(getStatement("getByLabel"), paramMap); return getSessionTemplate().selectList(getStatement("getByLabel"), paramMap);
} }
@Override
public void updateDeleteState(Long id) {
getSessionTemplate().update(getStatement("updateDeleteState"), id);
}
@Override
public Map<Long, AppletBooklistDTO> getBookListMap(List<Long> bookListIds) {
return getSessionTemplate().selectMap(getStatement("getBookListMap"),bookListIds,"id");
}
} }
...@@ -10,6 +10,7 @@ import com.pcloud.book.applet.vo.AppletNewsShowStateVO; ...@@ -10,6 +10,7 @@ import com.pcloud.book.applet.vo.AppletNewsShowStateVO;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -234,6 +235,16 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet ...@@ -234,6 +235,16 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet
} }
@Override @Override
public void deleteByNews(List<Long> newsIds) {
getSessionTemplate().update(getStatement("deleteByNews"), newsIds);
}
@Override
public Map<Long, AppletNewsDTO> getByIds4Record(List<Long> newsIds) {
return this.getSqlSession().selectMap(getStatement("getByIds4Record"), newsIds, "id");
}
@Override
public Integer listAppletNews4WechatCount(Map<String, Object> paramMap) { public Integer listAppletNews4WechatCount(Map<String, Object> paramMap) {
return getSessionTemplate().selectOne(getStatement("listAppletNews4WechatCount"), paramMap); return getSessionTemplate().selectOne(getStatement("listAppletNews4WechatCount"), paramMap);
} }
......
...@@ -64,4 +64,10 @@ public class AppletOuterBooklistDaoImpl extends BaseDaoImpl<AppletOuterBooklist> ...@@ -64,4 +64,10 @@ public class AppletOuterBooklistDaoImpl extends BaseDaoImpl<AppletOuterBooklist>
public void batchDeleteOuterBookFromBooklist(List<Long> configIds) { public void batchDeleteOuterBookFromBooklist(List<Long> configIds) {
getSessionTemplate().delete(getStatement("batchDeleteOuterBookFromBooklist"), configIds); getSessionTemplate().delete(getStatement("batchDeleteOuterBookFromBooklist"), configIds);
} }
@Override
public void updateDeleteState(Long id) {
getSessionTemplate().update(getStatement("updateDeleteState"), id);
}
} }
package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.AppletRecordDao;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* (AppletRecord)表数据库访问层
*
* @author makejava
* @since 2020-08-27 15:49:56
*/
@Repository("appletRecordDaoImpl")
public class AppletRecordDaoImpl extends BaseDaoImpl<AppletRecord> implements AppletRecordDao {
@Override
public Map<Long, AppletUserBookcaseDTO> getBookMap(List<AppletRecordDTO> appletRecordDTOS4Book) {
return getSessionTemplate().selectMap(getStatement("getBookMap"), appletRecordDTOS4Book, "id");
}
@Override
public void updateDeleteState(Long fromId, Integer recordType) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("fromId", fromId);
paramMap.put("recordType", recordType);
getSessionTemplate().update(getStatement("updateDeleteState"), paramMap);
}
}
\ No newline at end of file
package com.pcloud.book.applet.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AppletAppOrProductDTO {
@ApiModelProperty("应用/资讯/作品图片")
private String servePic;
@ApiModelProperty("应用/资讯/作品名称")
private String serveName;
@ApiModelProperty("应用/资讯/作品类型名称")
private String serveTypeName;
@ApiModelProperty("应用/资讯/作品类型编码")
private String serveTypeCode;
@ApiModelProperty("结果链接")
private String resultUrl;
}
...@@ -51,6 +51,8 @@ public class AppletNewsDTO extends BaseDto { ...@@ -51,6 +51,8 @@ public class AppletNewsDTO extends BaseDto {
private String content; private String content;
@ApiModelProperty("是否展示") @ApiModelProperty("是否展示")
private Boolean showState; private Boolean showState;
@ApiModelProperty("是否删除")
private Integer isDelete; ;
@ApiModelProperty("分类名称") @ApiModelProperty("分类名称")
private String newsClassify; private String newsClassify;
@JsonFormat( @JsonFormat(
......
package com.pcloud.book.applet.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class AppletRecordDTO {
private Long id;
@ApiModelProperty("微信用户id")
private Long wechatUserId;
@ApiModelProperty("1资讯 2编辑群 3 模板群 4 作品 5 应用 6 书刊 7 好书推荐 8 精选书单")
private Integer recordType;
@ApiModelProperty("权益id")
private Long rightsSettingId;
@ApiModelProperty("书籍id")
private Long bookId;
@ApiModelProperty("渠道id")
private Long channelId;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("来源id")
private Long fromId;
@ApiModelProperty("来源名称")
private String fromName;
@ApiModelProperty("资讯")
private AppletNewsDTO appletNewsDTO;
@ApiModelProperty("社群")
private GroupActivity4AppletDTO appletGroupDTO;
@ApiModelProperty("应用/作品")
private AppletAppOrProductDTO appletAppOrProductDTO;
@ApiModelProperty("书籍")
private AppletUserBookcaseDTO appletUserBookcaseDTO;
@ApiModelProperty("精选书单")
private AppletBooklistDTO appletBooklistDTO;
@ApiModelProperty("书单推荐")
private AppletOuterBooklistDTO appletOuterBooklistDTO;
@ApiModelProperty("资源是否已经被删除 0 未删除,1 已删除")
private Integer sourceDelete;
@ApiModelProperty("公众号id")
private Long accountSettingId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createDate;
@ApiModelProperty("是否删除 0 未删除 1删除")
private Integer isDelete;
@ApiModelProperty("应用或作品的跳转链接")
private String linkUrl;
@ApiModelProperty("上下架状态")
private Integer showState;
}
package com.pcloud.book.applet.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* (AppletRecord)实体类
*
* @author makejava
* @since 2020-08-27 15:49:54
*/
@Data
public class AppletRecord extends BaseEntity {
private static final long serialVersionUID = -82964720941123171L;
private Long id;
@ApiModelProperty("微信用户id")
private Long wechatUserId;
@ApiModelProperty("1资讯 2编辑群 3 模板群 4 作品 5 应用 6 书刊 7 好书推荐 8 精选书单")
private Integer recordType;
@ApiModelProperty("权益id")
private Long rightsSettingId;
@ApiModelProperty("书籍id")
private Long bookId;
@ApiModelProperty("渠道id")
private Long channelId;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("来源id")
private Long fromId;
@ApiModelProperty("来源名称")
private String fromName;
@ApiModelProperty("公众号id")
private Long accountSettingId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createDate;
@ApiModelProperty("是否删除 0 未删除 1删除")
private Integer isDelete;
@ApiModelProperty("应用或作品的跳转链接")
private String linkUrl;
}
\ No newline at end of file
package com.pcloud.book.applet.enums;
public enum AppletRecordTypeEnum {
// 1资讯
NEWS(1),
//编辑群
ADVISER_GROUP(2),
//模板群
MODEL_GROUP(3),
//第三方群
THIRD_GROUP(4),
//作品
PRODUCT(5),
//应用
APP(6),
//书刊
BOOK(7),
//好书推荐
BOOK_RECOMMEND(8),
//精选书单
BOOK_LIST(9);
public Integer value;
AppletRecordTypeEnum(Integer value) {
this.value = value;
}
}
package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.biz.AppletRecordBiz;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.book.applet.vo.AppletRecordQueryVO;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
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.RequestHeader;
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.Date;
import java.util.List;
/**
* (AppletRecord)表控制层
*
* @author makejava
* @since 2020-08-27 15:41:19
*/
@RestController("appletRecordFacade")
@RequestMapping("appletRecord")
public class AppletRecordFacade {
@Autowired
private AppletRecordBiz appletRecordBiz;
@ApiOperation("通过主键查询单条数据")
@GetMapping("getById")
public ResponseDto<?> getById(@CookieValue("userInfo") String userInfo, @RequestParam Long id) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletRecordBiz.getById(id));
}
@ApiOperation("分页查询")
@GetMapping("getList")
public ResponseDto<?> getList(@CookieValue("userInfo") String userInfo,
@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<>(appletRecordBiz.getList(currentPage, numPerPage));
}
@ApiOperation("新增")
@PostMapping("insert")
public ResponseDto<?> insert( @CookieValue("userInfo") String userInfo, @RequestBody AppletRecord appletRecord)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
Long accountSettingId = Cookie.getId(userInfo,Cookie._OFFICIAL_ACCOUNTS_ID);
appletRecord.setWechatUserId(wechatUserId);
appletRecord.setAccountSettingId(accountSettingId);
return new ResponseDto<>(appletRecordBiz.insert(appletRecord));
}
@ApiOperation("更新")
@PostMapping("update")
public ResponseDto<?> update( @CookieValue("userInfo") String userInfo, @RequestBody AppletRecord appletRecord) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
appletRecordBiz.update(appletRecord);
return new ResponseDto<>();
}
@ApiOperation("删除")
@GetMapping("deleteById")
public ResponseDto<?> deleteById( @CookieValue("userInfo") String userInfo,@RequestParam Long id) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null == id) {
throw BookBizException.PARAM_DELETION;
}
appletRecordBiz.deleteById(id);
return new ResponseDto<>();
}
@RequestMapping(value = "listAppletRecord", method = RequestMethod.POST)
public ResponseDto<PageBeanNew<AppletRecordDTO>> listAppletRecord(@CookieValue("userInfo") String userInfo,
@RequestBody AppletRecordQueryVO appletRecordQueryVO) {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
PageBeanNew<AppletRecordDTO> recordDTOPageBeanNew = appletRecordBiz.listAppletRecord(wechatUserId, appletRecordQueryVO.getDate(),
appletRecordQueryVO.getRecordTypes(), appletRecordQueryVO.getQueryName(), appletRecordQueryVO.getCurrentPage(), appletRecordQueryVO.getNumPerPage());
return new ResponseDto<>(recordDTOPageBeanNew);
}
}
\ No newline at end of file
package com.pcloud.book.applet.vo;
import com.pcloud.settlementcenter.record.dto.PartyRoleIncomeDto;
import io.swagger.models.auth.In;
import lombok.Data;
import java.util.List;
@Data
public class AppletRecordQueryVO {
private Integer currentPage;
private Integer numPerPage;
private String date;
private List<Integer> recordTypes;
private String queryName;
}
...@@ -10,9 +10,12 @@ import com.pcloud.appcenter.base.dto.AppPriceCacheDTO; ...@@ -10,9 +10,12 @@ import com.pcloud.appcenter.base.dto.AppPriceCacheDTO;
import com.pcloud.appcenter.cache.service.AppPriceCacheService; import com.pcloud.appcenter.cache.service.AppPriceCacheService;
import com.pcloud.audioapp.audioLesson.service.AudioLessonService; import com.pcloud.audioapp.audioLesson.service.AudioLessonService;
import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz; import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz;
import com.pcloud.book.applet.biz.AppletRecordBiz;
import com.pcloud.book.applet.biz.AppletUserBookcaseBiz; import com.pcloud.book.applet.biz.AppletUserBookcaseBiz;
import com.pcloud.book.applet.entity.AppletGroupSearchRecord; import com.pcloud.book.applet.entity.AppletGroupSearchRecord;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.book.applet.entity.AppletUserBookcase; import com.pcloud.book.applet.entity.AppletUserBookcase;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz; import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.constant.BookConstant; import com.pcloud.book.book.constant.BookConstant;
...@@ -434,6 +437,8 @@ public class BookGroupBizImpl implements BookGroupBiz { ...@@ -434,6 +437,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
@Autowired @Autowired
private PcloudGroupActivityBiz pcloudGroupActivityBiz; private PcloudGroupActivityBiz pcloudGroupActivityBiz;
@Autowired @Autowired
private AppletRecordBiz appletRecordBiz;
@Autowired
private ChannelConsr channelConsr; private ChannelConsr channelConsr;
private static final ThreadPoolExecutor PLATFORM_STATISTICS_EXPORT_THREAD = new ThreadPoolExecutor(2, 2, private static final ThreadPoolExecutor PLATFORM_STATISTICS_EXPORT_THREAD = new ThreadPoolExecutor(2, 2,
...@@ -4933,6 +4938,16 @@ public class BookGroupBizImpl implements BookGroupBiz { ...@@ -4933,6 +4938,16 @@ public class BookGroupBizImpl implements BookGroupBiz {
appletGroupSearchRecord.setChannelId(bookGroupDTO.getChannelId()); appletGroupSearchRecord.setChannelId(bookGroupDTO.getChannelId());
appletGroupSearchRecord.setWechatUserId(wechatUserId); appletGroupSearchRecord.setWechatUserId(wechatUserId);
appletGroupSearchRecordBiz.insert(appletGroupSearchRecord); appletGroupSearchRecordBiz.insert(appletGroupSearchRecord);
//足迹埋点
AppletRecord appletRecord = new AppletRecord();
appletRecord.setWechatUserId(wechatUserId);
appletRecord.setFromId(bookGroupDTO.getBookId());
appletRecord.setFromName(bookBiz.getBaseById(bookGroupDTO.getBookId()).getBookName());
appletRecord.setRecordType(AppletRecordTypeEnum.BOOK.value);
appletRecord.setBookId(bookGroupDTO.getBookId());
appletRecord.setAdviserId(bookGroupDTO.getCreateUser());
appletRecord.setChannelId(bookGroupDTO.getChannelId());
appletRecordBiz.insert(appletRecord);
} else if (bookAppletScene.getSceneId() != null) { } else if (bookAppletScene.getSceneId() != null) {
QrcodeSceneDto byId = qrcodeSceneConsr.getById(bookAppletScene.getSceneId()); QrcodeSceneDto byId = qrcodeSceneConsr.getById(bookAppletScene.getSceneId());
dto.setBookId(byId.getAdviserBookId()); dto.setBookId(byId.getAdviserBookId());
...@@ -4946,6 +4961,16 @@ public class BookGroupBizImpl implements BookGroupBiz { ...@@ -4946,6 +4961,16 @@ public class BookGroupBizImpl implements BookGroupBiz {
appletUserBookcase.setBookId(byId.getAdviserBookId()); appletUserBookcase.setBookId(byId.getAdviserBookId());
appletUserBookcase.setChannelId(byId.getChannelPartyId()); appletUserBookcase.setChannelId(byId.getChannelPartyId());
appletUserBookcaseBiz.addUserBook(appletUserBookcase); appletUserBookcaseBiz.addUserBook(appletUserBookcase);
//足迹埋点
AppletRecord appletRecord = new AppletRecord();
appletRecord.setWechatUserId(wechatUserId);
appletRecord.setFromId(byId.getAdviserBookId());
appletRecord.setFromName(bookBiz.getBaseById(byId.getAdviserBookId()).getBookName());
appletRecord.setRecordType(AppletRecordTypeEnum.BOOK.value);
appletRecord.setBookId(byId.getAdviserBookId());
appletRecord.setAdviserId(byId.getCreatedByUserLogin());
appletRecord.setChannelId(byId.getChannelPartyId());
appletRecordBiz.insert(appletRecord);
} }
return dto; return dto;
} }
......
...@@ -11,6 +11,7 @@ import com.pcloud.book.rightsSetting.entity.RightsNowPic; ...@@ -11,6 +11,7 @@ import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.book.rightsSetting.entity.RightsSetting; import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify; import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem; import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -157,4 +158,6 @@ public interface RightsSettingBiz { ...@@ -157,4 +158,6 @@ public interface RightsSettingBiz {
void deleteInvalidNews(List<Long> newArrayList); void deleteInvalidNews(List<Long> newArrayList);
Map<Long, RightsSettingDto> listByBookIds(List<Long> bookIds); Map<Long, RightsSettingDto> listByBookIds(List<Long> bookIds);
void fillGroupActivityHead(List<GroupActivity4AppletDTO> groupActivity4AppletList);
} }
...@@ -19,6 +19,7 @@ import com.pcloud.book.applet.dto.AppletOuterBooklistDTO; ...@@ -19,6 +19,7 @@ import com.pcloud.book.applet.dto.AppletOuterBooklistDTO;
import com.pcloud.book.applet.entity.AppletNews; import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.applet.entity.AppletUserBookcase; 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.AppletRecordTypeEnum;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookAdviserBiz; import com.pcloud.book.book.biz.BookAdviserBiz;
import com.pcloud.book.book.biz.BookBiz; import com.pcloud.book.book.biz.BookBiz;
...@@ -87,6 +88,7 @@ import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper; ...@@ -87,6 +88,7 @@ import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz; import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao; import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO; import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.book.skill.enums.ActivityGroupTypeEnum;
import com.pcloud.book.util.common.YesOrNoEnums; import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
...@@ -1014,6 +1016,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1014,6 +1016,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (groupActivity4AppletDTO == null) { if (groupActivity4AppletDTO == null) {
continue; continue;
} }
if (AppletRecordTypeEnum.ADVISER_GROUP.value.equals(groupActivity4AppletDTO.getGroupType())) {
groupActivity4AppletDTO.setGroupActivityId(null);
}
rightsSettingItem.getGroupActivity4AppletList().add(groupActivity4AppletDTO); rightsSettingItem.getGroupActivity4AppletList().add(groupActivity4AppletDTO);
} }
// 填充头像 // 填充头像
...@@ -1050,7 +1055,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1050,7 +1055,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} }
} }
private void fillGroupActivityHead(List<GroupActivity4AppletDTO> groupActivity4AppletList) { @Override
public void fillGroupActivityHead(List<GroupActivity4AppletDTO> groupActivity4AppletList) {
if (!ListUtils.isEmpty(groupActivity4AppletList)) { if (!ListUtils.isEmpty(groupActivity4AppletList)) {
for (GroupActivity4AppletDTO groupActivity4AppletDTO : groupActivity4AppletList) { for (GroupActivity4AppletDTO groupActivity4AppletDTO : groupActivity4AppletList) {
//第三方群获取头像 end add by Pansy //第三方群获取头像 end add by Pansy
......
...@@ -109,5 +109,7 @@ public interface PcloudGroupActivityBiz { ...@@ -109,5 +109,7 @@ public interface PcloudGroupActivityBiz {
void updateMediaId(PcloudGroupActivity pcloudGroupActivity); void updateMediaId(PcloudGroupActivity pcloudGroupActivity);
Map<Long, GroupActivity4AppletDTO> getByIds4NowRecord(List<Long> bookGroupClassifyIds, Integer adviserGroup);
QueryGroupActivityResponseVO getByActivityId(Long id); QueryGroupActivityResponseVO getByActivityId(Long id);
} }
...@@ -9,6 +9,7 @@ import com.pcloud.book.applet.dao.AppletLinkClickDao; ...@@ -9,6 +9,7 @@ import com.pcloud.book.applet.dao.AppletLinkClickDao;
import com.pcloud.book.applet.biz.AppletNewsBiz; import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.dto.AppletGroupManageDTO; import com.pcloud.book.applet.dto.AppletGroupManageDTO;
import com.pcloud.book.applet.dto.AppletGroupStatementDTO; import com.pcloud.book.applet.dto.AppletGroupStatementDTO;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz; import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dao.BookDao; import com.pcloud.book.book.dao.BookDao;
...@@ -731,4 +732,26 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz { ...@@ -731,4 +732,26 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
setLabelContent(Arrays.asList(responseVO)); setLabelContent(Arrays.asList(responseVO));
return responseVO; return responseVO;
} }
@Override
public Map<Long, GroupActivity4AppletDTO> getByIds4NowRecord(List<Long> bookGroupIds, Integer groupType) {
log.info("获取群数据adviserGroupIds:{},activityGroupIds:{}", bookGroupIds, groupType);
Map<Long, GroupActivity4AppletDTO> mapDto = new HashMap<Long, GroupActivity4AppletDTO>();
if (Objects.equals(AppletRecordTypeEnum.ADVISER_GROUP.value, groupType)){
mapDto = pcloudGroupActivityDao.getGroupClassifyByIds4Record(bookGroupIds); //查询第编辑端群
} else {
mapDto = pcloudGroupActivityDao.getByIds(bookGroupIds, null);
}
if(mapDto.isEmpty()){
return mapDto;
}
for(GroupActivity4AppletDTO groupActivity4AppletDTO: mapDto.values()){
String filterStr = StringUtilParent.replaceHtml(groupActivity4AppletDTO.getDesc());
String subStr = filterStr.length() > 60 ? filterStr.substring(0, 60) + "..." : filterStr;
groupActivity4AppletDTO.setCutDesc(subStr);
}
rightsSettingBiz.fillGroupActivityHead(Lists.newArrayList(mapDto.values()));
return mapDto;
}
} }
...@@ -40,4 +40,6 @@ public interface PcloudGroupActivityDao extends BaseDao<PcloudGroupActivity> { ...@@ -40,4 +40,6 @@ public interface PcloudGroupActivityDao extends BaseDao<PcloudGroupActivity> {
PcloudGroupActivity getById(Long id); PcloudGroupActivity getById(Long id);
QueryGroupActivityResponseVO getByActivityId(Long id); QueryGroupActivityResponseVO getByActivityId(Long id);
Map<Long, GroupActivity4AppletDTO> getGroupClassifyByIds4Record(List<Long> bookGroupIds);
} }
...@@ -115,5 +115,10 @@ public class PcloudGroupActivityDaoImpl extends BaseDaoImpl<PcloudGroupActivity> ...@@ -115,5 +115,10 @@ public class PcloudGroupActivityDaoImpl extends BaseDaoImpl<PcloudGroupActivity>
return getSessionTemplate().selectOne(getStatement("getByActivityId"), id); return getSessionTemplate().selectOne(getStatement("getByActivityId"), id);
} }
@Override
public Map<Long, GroupActivity4AppletDTO> getGroupClassifyByIds4Record(List<Long> bookGroupIds) {
return super.getSqlSession().selectMap(getStatement("getGroupClassifyByIds4Record"), bookGroupIds,"id");
}
} }
...@@ -56,4 +56,8 @@ public class ThreadPoolUtils { ...@@ -56,4 +56,8 @@ public class ThreadPoolUtils {
*/ */
public static final ExecutorService SEND_NOTIFY_POOL = new ThreadPoolExecutor(8, 8, 0L, TimeUnit.SECONDS, 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()); new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("send-notify-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
public static final ExecutorService FILL_APPLET_RECORD = new ThreadPoolExecutor(8,8,0L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("fill-applet-record-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
} }
...@@ -19,6 +19,22 @@ ...@@ -19,6 +19,22 @@
<result column="subject_label_id" property="subjectLabelId" jdbcType="BIGINT" /> <result column="subject_label_id" property="subjectLabelId" jdbcType="BIGINT" />
</resultMap> </resultMap>
<resultMap id="BaseResultMap4DTO" type="com.pcloud.book.applet.dto.AppletBooklistDTO" >
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="booklist_name" property="booklistName" jdbcType="VARCHAR" />
<result column="user_name" property="userName" jdbcType="VARCHAR" />
<result column="digest" property="digest" jdbcType="VARCHAR" />
<result column="display_pic" property="displayPic" jdbcType="VARCHAR" />
<result column="introduce_type" property="introduceType" jdbcType="INTEGER" />
<result column="introduce_content" property="introduceContent" jdbcType="VARCHAR" />
<result column="introduce_url" property="introduceUrl" jdbcType="VARCHAR" />
<result column="classify_id" property="classifyId" jdbcType="BIGINT" />
<result column="first_classify" property="firstClassify" jdbcType="BIGINT" />
<result column="second_classify" property="secondClassify" jdbcType="BIGINT" />
<result column="grade_label_id" property="gradeLabelId" jdbcType="BIGINT" />
<result column="subject_label_id" property="subjectLabelId" jdbcType="BIGINT" />
</resultMap>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
id, booklist_name, user_name, digest, display_pic, introduce_type, introduce_content, introduce_url, id, booklist_name, user_name, digest, display_pic, introduce_type, introduce_content, introduce_url,
classify_id, create_time, update_time, first_classify, second_classify, grade_label_id, subject_label_id classify_id, create_time, update_time, first_classify, second_classify, grade_label_id, subject_label_id
...@@ -113,7 +129,7 @@ ...@@ -113,7 +129,7 @@
FROM applet_booklist b FROM applet_booklist b
LEFT JOIN applet_booklist_config c ON b.id=c.booklist_id LEFT JOIN applet_booklist_config c ON b.id=c.booklist_id
LEFT JOIN applet_booklist_classify a ON b.classify_id=a.id LEFT JOIN applet_booklist_classify a ON b.classify_id=a.id
WHERE 1=1 WHERE 1=1 and b.is_delete = 0
<if test="name != null"> <if test="name != null">
AND b.booklist_name LIKE CONCAT("%", #{name} ,"%") AND b.booklist_name LIKE CONCAT("%", #{name} ,"%")
</if> </if>
...@@ -145,7 +161,7 @@ ...@@ -145,7 +161,7 @@
</select> </select>
<select id="getByClassifyId" parameterType="long" resultMap="BaseResultMap"> <select id="getByClassifyId" parameterType="long" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/> FROM applet_booklist WHERE classify_id=#{classifyId} SELECT <include refid="Base_Column_List"/> FROM applet_booklist WHERE classify_id=#{classifyId} and is_delete = 0
</select> </select>
<update id="updateBookSeq" parameterType="map"> <update id="updateBookSeq" parameterType="map">
...@@ -179,7 +195,7 @@ ...@@ -179,7 +195,7 @@
AND c.channel_id=a.CHANNEL_ID AND A.IS_DELETE = 0 AND c.channel_id=a.CHANNEL_ID AND A.IS_DELETE = 0
INNER JOIN BOOK B ON c.book_id = B.BOOK_ID AND B.IS_DELETE = 0 INNER JOIN BOOK B ON c.book_id = B.BOOK_ID AND B.IS_DELETE = 0
WHERE WHERE
c.booklist_id=#{booklistId} c.booklist_id=#{booklistId} and ap.is_delete = 0
ORDER BY c.seq ASC ORDER BY c.seq ASC
</select> </select>
...@@ -191,7 +207,7 @@ ...@@ -191,7 +207,7 @@
COUNT(c.id) bookCounts COUNT(c.id) bookCounts
FROM applet_booklist b FROM applet_booklist b
LEFT JOIN applet_booklist_config c ON b.id=c.booklist_id LEFT JOIN applet_booklist_config c ON b.id=c.booklist_id
WHERE 1=1 WHERE 1=1 and b.is_delete = 0
<if test="classifyId != null"> <if test="classifyId != null">
AND b.classify_id= #{classifyId} AND b.classify_id= #{classifyId}
</if> </if>
...@@ -300,4 +316,31 @@ ...@@ -300,4 +316,31 @@
<update id="updateDeleteState" parameterType="long">
update
applet_booklist
set
is_delete = 1
where
id = #{id}
</update>
<select id="getBookListMap" parameterType="list" resultMap="BaseResultMap4DTO">
SELECT
b.id id,
b.booklist_name,
b.user_name,
COUNT(c.id) bookCounts
FROM applet_booklist b
LEFT JOIN applet_booklist_config c ON b.id=c.booklist_id
WHERE
b.is_delete = 0
and
b.id in
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
group by b.id
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -168,7 +168,7 @@ ...@@ -168,7 +168,7 @@
<if test="classifySelect == 1"> <if test="classifySelect == 1">
LEFT JOIN applet_news_category category on n.id = category.applet_news_id LEFT JOIN applet_news_category category on n.id = category.applet_news_id
</if> </if>
WHERE 1=1 WHERE 1=1 and n.is_delete = 0
<if test="name != null"> <if test="name != null">
AND (n.news_name LIKE CONCAT("%",#{name},"%") OR n.url_number LIKE CONCAT("%",#{name},"%")) AND (n.news_name LIKE CONCAT("%",#{name},"%") OR n.url_number LIKE CONCAT("%",#{name},"%"))
</if> </if>
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
<if test="classifySelect == 1"> <if test="classifySelect == 1">
LEFT JOIN applet_news_category category on n.id = category.applet_news_id LEFT JOIN applet_news_category category on n.id = category.applet_news_id
</if> </if>
WHERE 1=1 WHERE 1=1 and n.is_delete = 0
<if test="cityCode != null"> <if test="cityCode != null">
AND n.city_code = #{cityCode} AND n.city_code = #{cityCode}
</if> </if>
...@@ -289,7 +289,7 @@ ...@@ -289,7 +289,7 @@
<select id="getCountByBusinessCardId" parameterType="long" resultType="long"> <select id="getCountByBusinessCardId" parameterType="long" resultType="long">
select count(1) select count(1)
from applet_news from applet_news
where business_card_id=#{businessCardId} where business_card_id=#{businessCardId} and is_delete = 0
</select> </select>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from applet_news news from applet_news news
where news.news_classify_id=#{newsClassifyId} where news.news_classify_id=#{newsClassifyId} and is_delete = 0
</select> </select>
<select id="getByNewsByTempletLabel" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletNewsDTO"> <select id="getByNewsByTempletLabel" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletNewsDTO">
...@@ -330,7 +330,7 @@ ...@@ -330,7 +330,7 @@
FROM applet_news n FROM applet_news n
LEFT JOIN applet_news_category category on n.id = category.applet_news_id LEFT JOIN applet_news_category category on n.id = category.applet_news_id
WHERE 1=1 WHERE 1=1
and n.show_state = 1 and n.show_state = 1 and n.is_delete = 0
<if test="firstClassify != null"> <if test="firstClassify != null">
and category.first_classify = #{firstClassify} and category.first_classify = #{firstClassify}
</if> </if>
...@@ -369,7 +369,7 @@ ...@@ -369,7 +369,7 @@
applet_news news applet_news news
LEFT JOIN applet_news_category category on news.id = category.applet_news_id LEFT JOIN applet_news_category category on news.id = category.applet_news_id
WHERE WHERE
news.show_state = 1 news.show_state = 1 and news.is_delete = 0
<if test="firstClassify!=null"> <if test="firstClassify!=null">
AND category.first_classify =#{firstClassify} AND category.first_classify =#{firstClassify}
</if> </if>
...@@ -460,8 +460,8 @@ ...@@ -460,8 +460,8 @@
</choose> </choose>
</select> </select>
<select id="getAppletNewsSourceCount" resultType="integer" parameterType="map"> <select id="getAppletNewsSourceCount" resultType="integer" parameterType="string">
SELECT COUNT(1) FROM applet_news SELECT COUNT(1) FROM applet_news WHERE source = #{source} and is_delete = 0
WHERE source = #{source} WHERE source = #{source}
<choose> <choose>
<when test="agentId != null"> <when test="agentId != null">
...@@ -498,6 +498,7 @@ ...@@ -498,6 +498,7 @@
WHERE jump_url = #{jumpUrl} WHERE jump_url = #{jumpUrl}
AND jump_type = 2 AND jump_type = 2
AND url_number IS NOT NULL AND url_number IS NOT NULL
and is_delete = 0
AND agent_id = #{agentId} AND agent_id = #{agentId}
LIMIT 1 LIMIT 1
</select> </select>
...@@ -507,7 +508,7 @@ ...@@ -507,7 +508,7 @@
SELECT id SELECT id
FROM applet_news FROM applet_news
WHERE WHERE
url_number = #{urlNumber} url_number = #{urlNumber} and is_delete = 0
<if test="id>0"> <if test="id>0">
AND id != #{id} AND id != #{id}
</if> </if>
...@@ -555,7 +556,7 @@ ...@@ -555,7 +556,7 @@
LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id
LEFT JOIN rights_setting_classify d ON n.rights_classify_id = d.id LEFT JOIN rights_setting_classify d ON n.rights_classify_id = d.id
LEFT JOIN applet_news_category category on n.id = category.applet_news_id LEFT JOIN applet_news_category category on n.id = category.applet_news_id
WHERE 1=1 WHERE 1=1 and n.is_delete = 0
<if test="name != null"> <if test="name != null">
AND (n.news_name LIKE CONCAT("%",#{name},"%") or n.url_number LIKE CONCAT("%",#{name},"%")) AND (n.news_name LIKE CONCAT("%",#{name},"%") or n.url_number LIKE CONCAT("%",#{name},"%"))
</if> </if>
...@@ -619,7 +620,7 @@ ...@@ -619,7 +620,7 @@
n.show_source showSource, n.show_source showSource,
n.show_link showLink n.show_link showLink
FROM applet_news n FROM applet_news n
WHERE n.show_state = 1 WHERE n.show_state = 1 and n.is_delete = 0
AND n.id IN AND n.id IN
<foreach collection="list" item="item" separator="," open="(" close=")" > <foreach collection="list" item="item" separator="," open="(" close=")" >
${item} ${item}
...@@ -657,7 +658,7 @@ ...@@ -657,7 +658,7 @@
n.show_link showLink n.show_link showLink
FROM applet_news n FROM applet_news n
LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id
WHERE n.show_state = 1 WHERE n.show_state = 1 and n.is_delete = 0
<if test="newsClassifyId >0"> <if test="newsClassifyId >0">
AND n.news_classify_id = #{newsClassifyId} AND n.news_classify_id = #{newsClassifyId}
</if> </if>
...@@ -749,7 +750,7 @@ ...@@ -749,7 +750,7 @@
<select id="getNewsIdListByCustomTagId" parameterType="long" resultType="long"> <select id="getNewsIdListByCustomTagId" parameterType="long" resultType="long">
SELECT id from applet_news SELECT id from applet_news
WHERE custom_tag_id = #{customTagId} WHERE custom_tag_id = #{customTagId} and is_delete = 0
ORDER BY create_time DESC ORDER BY create_time DESC
</select> </select>
...@@ -783,7 +784,7 @@ ...@@ -783,7 +784,7 @@
FROM applet_news n FROM applet_news n
LEFT JOIN applet_news_category category on n.id = category.applet_news_id LEFT JOIN applet_news_category category on n.id = category.applet_news_id
WHERE 1=1 WHERE 1=1
and n.show_state = 1 and n.show_state = 1 and n.is_delete = 0
<if test="firstClassify != null"> <if test="firstClassify != null">
and category.first_classify = #{firstClassify} and category.first_classify = #{firstClassify}
</if> </if>
...@@ -843,7 +844,8 @@ ...@@ -843,7 +844,8 @@
LEFT JOIN rights_setting_item i ON d.rights_setting_item_id = i.id LEFT JOIN rights_setting_item i ON d.rights_setting_item_id = i.id
LEFT JOIN rights_setting s ON s.id = i.rights_setting_id LEFT JOIN rights_setting s ON s.id = i.rights_setting_id
WHERE WHERE
s.rights_setting_type = 1 AND i.open_state = 1 AND i.rights_type = 'WEEK' AND i.rights_classify_id = 10 AND d.serve_type = 'NEWS' s.rights_setting_type = 1 and n.is_delete = 0
AND i.open_state = 1 AND i.rights_type = 'WEEK' AND i.rights_classify_id = 10 AND d.serve_type = 'NEWS'
<if test="firstClassify != null"> <if test="firstClassify != null">
and s.first_classify = #{firstClassify} and s.first_classify = #{firstClassify}
</if> </if>
...@@ -896,7 +898,7 @@ ...@@ -896,7 +898,7 @@
count(1) count(1)
FROM applet_news n FROM applet_news n
LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id
WHERE n.show_state = 1 WHERE n.show_state = 1 and n.is_delete = 0
<if test="newsClassifyId >0"> <if test="newsClassifyId >0">
AND n.news_classify_id = #{newsClassifyId} AND n.news_classify_id = #{newsClassifyId}
</if> </if>
...@@ -937,9 +939,56 @@ ...@@ -937,9 +939,56 @@
n.city_code cityCode, n.city_code cityCode,
n.show_link showLink n.show_link showLink
FROM applet_news n FROM applet_news n
WHERE n.show_state = 1 WHERE n.show_state = 1 and n.is_delete = 0
AND n.city_code = #{cityId} AND n.city_code = #{cityId}
ORDER BY n.update_time DESC ORDER BY n.update_time DESC
</select> </select>
<update id="deleteByNews" parameterType="list">
update
applet_news
set
is_delete = 1
where
id in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="getByIds4Record" resultType="com.pcloud.book.applet.dto.AppletNewsDTO">
SELECT
n.id,
n.news_name newsName,
n.source,
n.news_classify_id newsClassifyId,
n.pro_label_id proLabelId,
n.dep_label_id depLabelId,
n.pur_label_id purLabelId,
n.type,
n.digest,
n.pic1,
n.pic2,
n.pic3,
n.show_state showState,
n.create_time createTime,
n.first_classify firstClassify,
n.second_classify secondClassify,
n.grade_label_id gradeLabelId,
n.subject_label_id subjectLabelId,
n.rights_classify_id rightsClassifyId,
n.jump_type jumpType,
n.jump_url jumpUrl,
n.url_number urlNumber,
n.show_source showSource,
n.show_link showLink,
n.is_delete isDelete
FROM applet_news n
WHERE
n.id IN
<foreach collection="list" item="item" separator="," open="(" close=")" >
#{item}
</foreach>
</select>
</mapper> </mapper>
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
FROM FROM
applet_outer_booklist b applet_outer_booklist b
LEFT JOIN applet_outer_booklist_config c ON b.id = c.booklist_id LEFT JOIN applet_outer_booklist_config c ON b.id = c.booklist_id
WHERE 1=1 WHERE 1=1 and b.is_delete = 0
<if test="publish != null"> <if test="publish != null">
AND b.publish = #{publish} AND b.publish = #{publish}
</if> </if>
...@@ -117,6 +117,7 @@ ...@@ -117,6 +117,7 @@
FROM applet_outer_booklist FROM applet_outer_booklist
WHERE WHERE
publish IS NOT NULL publish IS NOT NULL
and is_delete = 0
<choose> <choose>
<when test="agentId != null"> <when test="agentId != null">
and agent_id = #{agentId} and agent_id = #{agentId}
...@@ -161,6 +162,8 @@ ...@@ -161,6 +162,8 @@
applet_outer_booklist b applet_outer_booklist b
LEFT JOIN applet_outer_booklist_config c ON b.id = c.booklist_id LEFT JOIN applet_outer_booklist_config c ON b.id = c.booklist_id
WHERE WHERE
b.is_delete = 0
and
b.id IN b.id IN
<foreach collection="list" item="item" separator="," open="(" close=")" > <foreach collection="list" item="item" separator="," open="(" close=")" >
${item} ${item}
...@@ -175,4 +178,12 @@ ...@@ -175,4 +178,12 @@
${item} ${item}
</foreach> </foreach>
</delete> </delete>
<update id="updateDeleteState" parameterType="long">
update
applet_outer_booklist
set is_delete = 1
where
id = #{id}
</update>
</mapper> </mapper>
\ No newline at end of file
<?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.applet.dao.impl.AppletRecordDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletRecord">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="record_type" property="recordType" jdbcType="TINYINT"/>
<result column="rights_setting_id" property="rightsSettingId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="from_id" property="fromId" jdbcType="BIGINT"/>
<result column="from_name" property="fromName" jdbcType="VARCHAR"/>
<result column="account_setting_id" property="accountSettingId" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="create_date" property="createDate" jdbcType="DATE"/>
<result column="is_delete" property="isDelete" jdbcType="TINYINT"/>
<result column="link_url" property="linkUrl" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="BaseResultMap4DTO" type="com.pcloud.book.applet.dto.AppletRecordDTO">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="record_type" property="recordType" jdbcType="TINYINT"/>
<result column="rights_setting_id" property="rightsSettingId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="from_id" property="fromId" jdbcType="BIGINT"/>
<result column="from_name" property="fromName" jdbcType="VARCHAR"/>
<result column="account_setting_id" property="accountSettingId" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="create_date" property="createDate" jdbcType="DATE"/>
<result column="is_delete" property="isDelete" jdbcType="TINYINT"/>
<result column="link_url" property="linkUrl" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, wechat_user_id, record_type, rights_setting_id, book_id, channel_id, adviser_id, from_id, from_name, account_setting_id,
create_time, create_date, is_delete, link_url
</sql>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_record
WHERE id = #{id}
</select>
<select id="getList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_record
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_record(
wechat_user_id,
record_type,
rights_setting_id,
book_id,
channel_id,
adviser_id,
from_id,
from_name,
account_setting_id,
create_time,
create_date,
is_delete,
link_url
) VALUES (
#{wechatUserId, jdbcType=BIGINT},
#{recordType, jdbcType=BOOLEAN},
#{rightsSettingId, jdbcType=BIGINT},
#{bookId, jdbcType=BIGINT},
#{channelId, jdbcType=BIGINT},
#{adviserId, jdbcType=BIGINT},
#{fromId, jdbcType=BIGINT},
#{fromName, jdbcType=VARCHAR},
#{accountSettingId, jdbcType=BIGINT},
now(),
DATE_FORMAT(now(),"%Y-%m-%d"),
0,
#{linkUrl}
)
</insert>
<insert id="batchInsert">
INSERT INTO applet_record (
wechat_user_id,
record_type,
rights_setting_id,
book_id,
channel_id,
adviser_id,
from_id,
from_name,
account_setting_id,
create_time,
create_date,
is_delete,
link_url
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.wechatUserId, jdbcType=BIGINT},
#{item.recordType, jdbcType=BOOLEAN},
#{item.rightsSettingId, jdbcType=BIGINT},
#{item.bookId, jdbcType=BIGINT},
#{item.channelId, jdbcType=BIGINT},
#{item.adviserId, jdbcType=BIGINT},
#{item.fromId, jdbcType=BIGINT},
#{item.fromName, jdbcType=VARCHAR},
#{item.accountSettingId, jdbcType=BIGINT},
now(),
DATE_FORMAT(now(),"%Y-%m-%d"),
0,
#{item.linkUrl}
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
UPDATE applet_record
<set>
<if test="wechatUserId != null">
wechat_user_id = #{wechatUserId},
</if>
<if test="recordType != null">
record_type = #{recordType},
</if>
<if test="rightsSettingId != null">
rights_setting_id = #{rightsSettingId},
</if>
<if test="bookId != null">
book_id = #{bookId},
</if>
<if test="channelId != null">
channel_id = #{channelId},
</if>
<if test="adviserId != null">
adviser_id = #{adviserId},
</if>
<if test="fromId != null">
from_id = #{fromId},
</if>
<if test="fromName != null and fromName != ''">
from_name = #{fromName},
</if>
<if test="accountSettingId != null">
account_setting_id = #{accountSettingId},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="createDate != null">
create_date = #{createDate},
</if>
<if test="isDelete != null">
is_delete = #{isDelete},
</if>
<if test="linkUrl != null">
link_url = #{linkUrl},
</if>
</set>
WHERE id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
DELETE FROM applet_record where id = #{id}
</delete>
<select id="listAppletRecord" parameterType="map" resultMap="BaseResultMap4DTO">
select
<include refid="Base_Column_List"/>
from
(
SELECT
<include refid="Base_Column_List"/>
FROM
`applet_record`
WHERE
is_delete = 0 and wechat_user_id = #{wechatUserId}
<if test="queryName != null">
and from_name like concat("%",#{queryName},"%")
</if>
<choose>
<when test="date != null">
and create_date = #{date}
</when>
<otherwise>
and create_date &gt; DATE_SUB(curdate(),INTERVAL 30 day)
</otherwise>
</choose>
<if test="recordTypes != null">
and record_type in
<foreach collection="recordTypes" index="index" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
ORDER BY
create_time DESC
LIMIT 9999
) a
<choose>
<when test="date != null">
group by from_id
</when>
<otherwise>
group by create_date, from_id
</otherwise>
</choose>
order by create_time desc
</select>
<select id="getBookMap" parameterType="list" resultType="com.pcloud.book.applet.dto.AppletUserBookcaseDTO">
SELECT
c.id id,
c.book_id bookId,
c.channel_id channelId,
c.adviser_id adviserId,
b.BOOK_NAME bookName,
b.COVER_IMG coverImg,
b.AUTHOR author,
b.PUBLISH publish,
a.SECOND_TEMPLET_ID secondTempletId,
a.TEMPLET_ID templetId,
d.join_group_type joinGroupType,
d.id bookGroupId,
b.ISBN isbn,
a.GRA_LABEL_ID gradeLabelId,
a.SUB_LABEL_ID subjectLabelId,
a.vol_label_id volLabelId,
IF(d.join_group_type=1 OR d.related_book_group_id>0,1,0) hasGroup,
r.id rightsSettingId,
r.count rightsSettingCount
FROM applet_record c
LEFT JOIN BOOK_ADVISER a ON c.book_id=a.BOOK_ID AND c.adviser_id=a.ADVISER_ID
AND c.channel_id=a.CHANNEL_ID AND a.IS_DELETE = 0
INNER JOIN BOOK b ON c.BOOK_ID = b.BOOK_ID AND b.IS_DELETE = 0
LEFT JOIN book_group d ON d.BOOK_ID = a.BOOK_ID
AND d.create_user = c.adviser_id
AND d.channel_id = c.channel_id
AND d.IS_DELETE = 0
LEFT JOIN rights_setting r ON c.rights_setting_id = r.id AND d.join_group_type=4 and r.show_state = 1 and r.rights_setting_type = 2
WHERE
c.is_delete = 0
and
c.id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</select>
<update id="updateDeleteState" parameterType="map">
update
applet_record
set
is_delete = 1
where
from_id = #{fromId}
and
record_type = #{recordType}
</update>
</mapper>
\ No newline at end of file
...@@ -324,7 +324,6 @@ ...@@ -324,7 +324,6 @@
<select id="getGroupClassifyByIds" resultType="com.pcloud.book.skill.dto.GroupActivity4AppletDTO"> <select id="getGroupClassifyByIds" resultType="com.pcloud.book.skill.dto.GroupActivity4AppletDTO">
SELECT SELECT
c.id, c.id,
a.id groupActivityId,
c.classify as `name`, c.classify as `name`,
c.classify_introduce AS `desc`, c.classify_introduce AS `desc`,
a.join_type AS joinType, a.join_type AS joinType,
...@@ -697,4 +696,30 @@ ...@@ -697,4 +696,30 @@
a.id = #{id} a.id = #{id}
</select> </select>
<select id="getGroupClassifyByIds4Record" resultType="com.pcloud.book.skill.dto.GroupActivity4AppletDTO">
SELECT
c.id,
c.classify as `name`,
c.classify_introduce AS `desc`,
c.classify AS groupName,
b.user_number userNumber,
b.classify_id classifyId,
c.book_group_id bookGroupId,
'GROUP' as serveType,
'2' as groupType,
c.id as serveId
FROM
book_group_classify c
LEFT JOIN pcloud_group_activity a ON a.book_group_classify_id = c.id
LEFT JOIN book_group_qrcode b on b.classify_id = c.id
where
IFNULL(b.is_delete,0) = 0
and
c.id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
${item}
</foreach>
GROUP BY c.id
ORDER BY c.id DESC
</select>
</mapper> </mapper>
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