Commit 4004a935 by pansy

feat: [1003442] 资讯文章内第三方链接做成模板形式管理

parent 47d8f7c6
package com.pcloud.book.applet.dto; package com.pcloud.book.applet.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -84,4 +83,8 @@ public class AppletNewsVO extends BaseDto { ...@@ -84,4 +83,8 @@ public class AppletNewsVO extends BaseDto {
@ApiModelProperty("选取的服务") @ApiModelProperty("选取的服务")
List<AppletNewsServeDTO> appletNewsServeList; List<AppletNewsServeDTO> appletNewsServeList;
@ApiModelProperty("选取的服务")
List<AppletThirdResourcesDTO> thirdResourcesRelations;
} }
package com.pcloud.book.applet.dto;
import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AppletThirdResourcesDTO extends BaseDto {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("第三方资源编号")
private String number;
@ApiModelProperty("类型 0:小程序, 1:链接")
private Long type;
@ApiModelProperty("第三方资源名称")
private String name;
@ApiModelProperty("小程序id")
private String appletsId;
@ApiModelProperty("来源")
private String source;
@ApiModelProperty("宣传图片")
private String resourceImgUrl;
@ApiModelProperty("链接")
private String url;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建人")
private Long creator;
@ApiModelProperty("修改人")
private Long updator;
}
\ No newline at end of file
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.dto.AppletThirdResourcesDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
import com.pcloud.common.page.PageBeanNew;
public interface AppletThirdResourcesBiz {
AppletThirdResourcesDTO getAnalysisDetail(Long thirdResourcesId);
PageBeanNew<AppletThirdResourcesDTO> getListThirdResourcesAnalysis(String keyValue, String source,
String resourcesType, Integer browseQty, Integer clickQty, Integer currentPage, Integer numPerPage);
void addServiceRecord(AppletThirdResourcesClick thirdResourcesClick);
AppletThirdResourcesDTO getNewsTrendChart(Long newsId);
PageBeanNew<AppletThirdResources> getThirdResources(Long type, String source, String keyValue, Integer currentPage,
Integer numPerPage);
void deleteAppletsById(Long id);
void updateThirdResources(AppletThirdResourcesDTO thirdResourcesDTO);
AppletThirdResources getAppletsById(Long id);
void createThirdResources(AppletThirdResourcesDTO thirdResourcesDTO);
}
...@@ -13,6 +13,8 @@ import com.pcloud.book.applet.dao.AppletNewsClassifyDao; ...@@ -13,6 +13,8 @@ import com.pcloud.book.applet.dao.AppletNewsClassifyDao;
import com.pcloud.book.applet.dao.AppletNewsCommentDao; import com.pcloud.book.applet.dao.AppletNewsCommentDao;
import com.pcloud.book.applet.dao.AppletNewsDao; import com.pcloud.book.applet.dao.AppletNewsDao;
import com.pcloud.book.applet.dao.AppletNewsServeDao; import com.pcloud.book.applet.dao.AppletNewsServeDao;
import com.pcloud.book.applet.dao.AppletThirdResourcesDao;
import com.pcloud.book.applet.dao.AppletThirdResourcesRelationDao;
import com.pcloud.book.applet.dao.AppletUserBookcaseDao; import com.pcloud.book.applet.dao.AppletUserBookcaseDao;
import com.pcloud.book.applet.dto.AppletNewsCategoryDTO; import com.pcloud.book.applet.dto.AppletNewsCategoryDTO;
import com.pcloud.book.applet.dto.AppletNewsClassifyDTO; import com.pcloud.book.applet.dto.AppletNewsClassifyDTO;
...@@ -21,6 +23,7 @@ import com.pcloud.book.applet.dto.AppletNewsCustomTagDTO; ...@@ -21,6 +23,7 @@ import com.pcloud.book.applet.dto.AppletNewsCustomTagDTO;
import com.pcloud.book.applet.dto.AppletNewsDTO; import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.dto.AppletNewsServeDTO; 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.PvuvDTO; import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletBusinessCard; import com.pcloud.book.applet.entity.AppletBusinessCard;
import com.pcloud.book.applet.entity.AppletLinkClick; import com.pcloud.book.applet.entity.AppletLinkClick;
...@@ -31,6 +34,8 @@ import com.pcloud.book.applet.entity.AppletNewsClassifyUser; ...@@ -31,6 +34,8 @@ import com.pcloud.book.applet.entity.AppletNewsClassifyUser;
import com.pcloud.book.applet.entity.AppletNewsComment; import com.pcloud.book.applet.entity.AppletNewsComment;
import com.pcloud.book.applet.entity.AppletNewsCustomTag; import com.pcloud.book.applet.entity.AppletNewsCustomTag;
import com.pcloud.book.applet.entity.AppletNewsServe; import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesRelation;
import com.pcloud.book.applet.entity.AppletUserBookcase; import com.pcloud.book.applet.entity.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;
...@@ -110,6 +115,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -110,6 +115,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
private AppletBusinessCardDao appletBusinessCardDao; private AppletBusinessCardDao appletBusinessCardDao;
@Autowired @Autowired
private AppletNewsCategoryDao appletNewsCategoryDao; private AppletNewsCategoryDao appletNewsCategoryDao;
@Autowired
private AppletThirdResourcesRelationDao thirdResourcesRelationDao;
@Autowired
private AppletThirdResourcesDao thirdResourcesDao;
@Override @Override
public void deleteCategoryById(Long id) { public void deleteCategoryById(Long id) {
...@@ -174,11 +183,28 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -174,11 +183,28 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
//保存咨询类别 //保存咨询类别
this.saveAppletNewsCategory(appletNews.getAppletNewsCategoryList(), appletNews.getId()); this.saveAppletNewsCategory(appletNews.getAppletNewsCategoryList(), appletNews.getId());
// 保存选取的服务 // 保存选取的服务
this.saveAppletNewsServe(appletNews.getAppletNewsServeList(), appletNews.getId()); // this.saveAppletNewsServe(appletNews.getAppletNewsServeList(), appletNews.getId());
this.updateSource(null,appletNews.getSource()); //保存第三方资源
this.saveThirdResources(appletNews.getThirdResourcesRelations(), appletNews.getId());
this.updateSource(null, appletNews.getSource());
return appletNews.getId(); return appletNews.getId();
} }
private void saveThirdResources(List<AppletThirdResourcesRelation> thirdResourcesRelations, Long appletNewsId) {
if (ListUtils.isEmpty(thirdResourcesRelations)) {
return;
}
// 删除旧数据
thirdResourcesRelationDao.deleteByAppletNewsId(appletNewsId);
if (ListUtils.isEmpty(thirdResourcesRelations)) {
return;
}
for (AppletThirdResourcesRelation dto : thirdResourcesRelations) {
dto.setFromId(appletNewsId);
}
thirdResourcesRelationDao.insert(thirdResourcesRelations);
}
private void saveAppletNewsCategory(List<AppletNewsCategory> categoryList, Long newsId) { private void saveAppletNewsCategory(List<AppletNewsCategory> categoryList, Long newsId) {
if (ListUtils.isEmpty(categoryList)) { if (ListUtils.isEmpty(categoryList)) {
return; return;
...@@ -197,38 +223,39 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -197,38 +223,39 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
/** /**
* 保存选取的服务 * 保存选取的服务
* @param appletNewsServeList * @param appletNewsServeList
* @param appletNewsId * @param
*/ */
private void saveAppletNewsServe(List<AppletNewsServe> appletNewsServeList, Long appletNewsId) { // private void saveAppletNewsServe(List<AppletNewsServe> appletNewsServeList, Long appletNewsId) {
// 删除旧数据 // // 删除旧数据
appletNewsServeDao.deleteByAppletNewsId(appletNewsId); // appletNewsServeDao.deleteByAppletNewsId(appletNewsId);
if(ListUtils.isEmpty(appletNewsServeList)){ // if (ListUtils.isEmpty(appletNewsServeList)) {
return; // return;
} // }
for (AppletNewsServe appletNewsServe : appletNewsServeList) { // for (AppletNewsServe appletNewsServe : appletNewsServeList) {
appletNewsServe.setAppletNewsId(appletNewsId); // appletNewsServe.setAppletNewsId(appletNewsId);
} // }
this.checkAppletNewsServe(appletNewsServeList); // this.checkAppletNewsServe(appletNewsServeList);
appletNewsServeDao.insert(appletNewsServeList); // appletNewsServeDao.insert(appletNewsServeList);
} // }
private void checkAppletNewsServe(List<AppletNewsServe> appletNewsServeList) { private void checkAppletNewsServe(List<AppletNewsServe> appletNewsServeList) {
for (AppletNewsServe appletNewsServe : appletNewsServeList) { for (AppletNewsServe appletNewsServe : appletNewsServeList) {
if(!AppletNewsServeTypeEnum.LINK.code.equals(appletNewsServe.getServeType())){ if (!AppletNewsServeTypeEnum.LINK.code.equals(appletNewsServe.getServeType())) {
continue; continue;
} }
if(StringUtil.isEmpty(appletNewsServe.getTitle())){ if (StringUtil.isEmpty(appletNewsServe.getTitle())) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "标题不能为空"); throw new BizException(BizException.PARAM_IS_NULL.getCode(), "标题不能为空");
} }
if(StringUtil.isEmpty(appletNewsServe.getPicUrl())){ if (StringUtil.isEmpty(appletNewsServe.getPicUrl())) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "导图不能为空"); throw new BizException(BizException.PARAM_IS_NULL.getCode(), "导图不能为空");
} }
if(StringUtil.isEmpty(appletNewsServe.getLinkUrl())){ if (StringUtil.isEmpty(appletNewsServe.getLinkUrl())) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "跳转链接不能为空"); throw new BizException(BizException.PARAM_IS_NULL.getCode(), "跳转链接不能为空");
} }
} }
long appletCount = appletNewsServeList.stream().filter(x -> AppletNewsServeTypeEnum.APPLET.code.equals(x.getServeType())).count(); long appletCount = appletNewsServeList.stream()
if(appletCount > 3){ .filter(x -> AppletNewsServeTypeEnum.APPLET.code.equals(x.getServeType())).count();
if (appletCount > 3) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "第三方小程序数量不能大于3个"); throw new BizException(BizException.PARAM_IS_NULL.getCode(), "第三方小程序数量不能大于3个");
} }
} }
...@@ -236,33 +263,35 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -236,33 +263,35 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateAppletNews(AppletNews appletNews) { public void updateAppletNews(AppletNews appletNews) {
if (null == appletNews.getId()){ if (null == appletNews.getId()) {
throw new BookBizException(BookBizException.ERROR,"id为空"); throw new BookBizException(BookBizException.ERROR, "id为空");
} }
if (urlNumberExist(appletNews)){ if (urlNumberExist(appletNews)) {
throw new BookBizException(BookBizException.ERROR,"链接编号重复"); throw new BookBizException(BookBizException.ERROR, "链接编号重复");
} }
if(appletNews.getBusinessCardType()!= null && appletNews.getBusinessCardType()==0){ if (appletNews.getBusinessCardType() != null && appletNews.getBusinessCardType() == 0) {
AppletBusinessCard appletBusinessCard = new AppletBusinessCard(); AppletBusinessCard appletBusinessCard = new AppletBusinessCard();
BeanUtils.copyProperties(appletNews,appletBusinessCard); BeanUtils.copyProperties(appletNews, appletBusinessCard);
if (appletNews.getBusinessCardId() == null){ if (appletNews.getBusinessCardId() == null) {
Long businessId = appletBusinessCardDao.insert(appletBusinessCard); Long businessId = appletBusinessCardDao.insert(appletBusinessCard);
appletNews.setBusinessCardId(businessId); appletNews.setBusinessCardId(businessId);
}else { } else {
appletBusinessCard.setId(appletNews.getBusinessCardId()); appletBusinessCard.setId(appletNews.getBusinessCardId());
Long businessId = appletBusinessCardDao.update(appletBusinessCard); Long businessId = appletBusinessCardDao.update(appletBusinessCard);
} }
} }
if (null == appletNews.getNewsClassifyId()) { if (null == appletNews.getNewsClassifyId()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"更新时栏目不能为空"); throw new BookBizException(BookBizException.PARAM_IS_NULL, "更新时栏目不能为空");
} }
AppletNews beforeNews = appletNewsDao.getById(appletNews.getId()); AppletNews beforeNews = appletNewsDao.getById(appletNews.getId());
rightsSettingBiz.setClassifyAndLabel(appletNews); rightsSettingBiz.setClassifyAndLabel(appletNews);
appletNewsDao.update(appletNews); appletNewsDao.update(appletNews);
this.saveAppletNewsServe(appletNews.getAppletNewsServeList(), appletNews.getId()); // this.saveAppletNewsServe(appletNews.getAppletNewsServeList(), appletNews.getId());
this.updateSource(beforeNews.getSource(), appletNews.getSource()); this.updateSource(beforeNews.getSource(), appletNews.getSource());
//保存咨询分类 //保存咨询分类
this.saveAppletNewsCategory(appletNews.getAppletNewsCategoryList(), appletNews.getId()); this.saveAppletNewsCategory(appletNews.getAppletNewsCategoryList(), appletNews.getId());
//保存第三方资源
this.saveThirdResources(appletNews.getThirdResourcesRelations(), appletNews.getId());
JedisClusterUtils.del(AppletConstants.HOME_NEWS_LIST); JedisClusterUtils.del(AppletConstants.HOME_NEWS_LIST);
} }
...@@ -282,8 +311,8 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -282,8 +311,8 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
@Override @Override
public PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name, public PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name,
Long firstClassify,Long secondClassify,Long gradeLabelId, Long firstClassify, Long secondClassify, Long gradeLabelId,
Long subjectLabelId,Long rightsClassifyId,String source,Integer showState, Long newsClassifyId, Long subjectLabelId, Long rightsClassifyId, String source, Integer showState, Long newsClassifyId,
Long customTagId) { Long customTagId) {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("name", name); paramMap.put("name", name);
...@@ -307,7 +336,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -307,7 +336,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
paramMap.put("secondClassify", classify.getSecondClassify()); paramMap.put("secondClassify", classify.getSecondClassify());
paramMap.put("gradeLabelId", classify.getGradeLabelId()); paramMap.put("gradeLabelId", classify.getGradeLabelId());
paramMap.put("subjectLabelId", classify.getSubjectLabelId()); paramMap.put("subjectLabelId", classify.getSubjectLabelId());
}else { } else {
paramMap.put("gradeLabelId", gradeLabelId); paramMap.put("gradeLabelId", gradeLabelId);
paramMap.put("subjectLabelId", subjectLabelId); paramMap.put("subjectLabelId", subjectLabelId);
if (null != gradeLabelId || null != subjectLabelId) { if (null != gradeLabelId || null != subjectLabelId) {
...@@ -330,7 +359,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -330,7 +359,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
return; return;
} }
List<Long> labelIds = new ArrayList<>(); List<Long> labelIds = new ArrayList<>();
for(AppletNewsDTO appletNewsDTO : recordList){ for (AppletNewsDTO appletNewsDTO : recordList) {
if (null != appletNewsDTO.getProLabelId()) { if (null != appletNewsDTO.getProLabelId()) {
labelIds.add(appletNewsDTO.getProLabelId()); labelIds.add(appletNewsDTO.getProLabelId());
} }
...@@ -341,7 +370,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -341,7 +370,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
labelIds.add(appletNewsDTO.getPurLabelId()); labelIds.add(appletNewsDTO.getPurLabelId());
} }
} }
if (!ListUtils.isEmpty(labelIds)){ if (!ListUtils.isEmpty(labelIds)) {
Map<Long, String> labelMap = labelConsr.getLabelName(labelIds); Map<Long, String> labelMap = labelConsr.getLabelName(labelIds);
if (!MapUtils.isEmpty(labelMap)) { if (!MapUtils.isEmpty(labelMap)) {
for(AppletNewsDTO appletNewsDTO : recordList){ for(AppletNewsDTO appletNewsDTO : recordList){
...@@ -542,18 +571,35 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -542,18 +571,35 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if (null!=appletNews){ if (null!=appletNews){
BeanUtils.copyProperties(appletNews,appletNewsDTO); BeanUtils.copyProperties(appletNews,appletNewsDTO);
} }
this.fillAppletNewsServe(appletNewsDTO); // this.fillAppletNewsServe(appletNewsDTO);
this.fillBrowseCount(Lists.newArrayList(appletNewsDTO)); this.fillBrowseCount(Lists.newArrayList(appletNewsDTO));
fillLabel(Arrays.asList(appletNewsDTO)); fillLabel(Arrays.asList(appletNewsDTO));
//填充类别集合 //填充类别集合
fillCategory(Arrays.asList(appletNewsDTO)); fillCategory(Arrays.asList(appletNewsDTO));
//填充第三方资源
fillThirdResources(Arrays.asList(appletNewsDTO));
fillBusinessCard(appletNewsDTO); fillBusinessCard(appletNewsDTO);
return appletNewsDTO; return appletNewsDTO;
} }
private void fillThirdResources(List<AppletNewsDTO> appletNewsDTOList) {
if (ListUtils.isEmpty(appletNewsDTOList)) {
return;
}
for (AppletNewsDTO newsDTO : appletNewsDTOList) {
Long newsId = newsDTO.getId();
List<AppletThirdResources> thirdResourcesList = thirdResourcesDao.getThirdResourcesByNewsId(newsId);
if (ListUtils.isEmpty(thirdResourcesList)) {
continue;
}
newsDTO.setThirdResourcesRelations(thirdResourcesList);
}
}
private void fillCategory(List<AppletNewsDTO> appletNewsDTOList) { private void fillCategory(List<AppletNewsDTO> appletNewsDTOList) {
if (ListUtils.isEmpty(appletNewsDTOList)) { if (ListUtils.isEmpty(appletNewsDTOList)) {
return; return;
...@@ -638,14 +684,14 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -638,14 +684,14 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
* 填充第三方服务 * 填充第三方服务
* @param appletNewsDTO * @param appletNewsDTO
*/ */
private void fillAppletNewsServe(AppletNewsDTO appletNewsDTO) { // private void fillAppletNewsServe(AppletNewsDTO appletNewsDTO) {
List<AppletNewsServeDTO> appletNewsServeList = appletNewsServeDao.getByAppletNewsId(appletNewsDTO.getId()); // List<AppletNewsServeDTO> appletNewsServeList = appletNewsServeDao.getByAppletNewsId(appletNewsDTO.getId());
if(ListUtils.isEmpty(appletNewsServeList)){ // if (ListUtils.isEmpty(appletNewsServeList)) {
appletNewsDTO.setAppletNewsServeList(Lists.newArrayList()); // appletNewsDTO.setAppletNewsServeList(Lists.newArrayList());
} // }
this.fillPersonalApplet(appletNewsServeList); // this.fillPersonalApplet(appletNewsServeList);
appletNewsDTO.setAppletNewsServeList(appletNewsServeList); // appletNewsDTO.setAppletNewsServeList(appletNewsServeList);
} // }
/** /**
* 填充小程序相关数据 * 填充小程序相关数据
...@@ -710,7 +756,6 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -710,7 +756,6 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
for (Long id : appletNewsClassifyVO.getAppletNewsIds()){ for (Long id : appletNewsClassifyVO.getAppletNewsIds()){
this.saveAppletNewsCategory(appletNewsClassifyVO.getCategoryDTOList(), id); this.saveAppletNewsCategory(appletNewsClassifyVO.getCategoryDTOList(), id);
} }
appletNewsDao.batchUpdateClassify(appletNewsClassifyVO); appletNewsDao.batchUpdateClassify(appletNewsClassifyVO);
} }
...@@ -737,7 +782,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -737,7 +782,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
BeanUtils.copyProperties(appletNews, appletNewsVO); BeanUtils.copyProperties(appletNews, appletNewsVO);
} }
// 填充第三方服务 // 填充第三方服务
this.fillAppletNewsServe(appletNewsVO); // this.fillAppletNewsServe(appletNewsVO);
//填充第三方资源
fillThirdResources(appletNewsVO);
return appletNewsVO; return appletNewsVO;
} }
...@@ -745,13 +793,27 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -745,13 +793,27 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
* 填充第三方服务 * 填充第三方服务
* @param appletNewsVO * @param appletNewsVO
*/ */
private void fillAppletNewsServe(AppletNewsVO appletNewsVO) { // private void fillAppletNewsServe(AppletNewsVO appletNewsVO) {
List<AppletNewsServeDTO> appletNewsServeList = appletNewsServeDao.getByAppletNewsId(appletNewsVO.getId()); // List<AppletNewsServeDTO> appletNewsServeList = appletNewsServeDao.getByAppletNewsId(appletNewsVO.getId());
if(ListUtils.isEmpty(appletNewsServeList)){ // if(ListUtils.isEmpty(appletNewsServeList)){
appletNewsVO.setAppletNewsServeList(Lists.newArrayList()); // appletNewsVO.setAppletNewsServeList(Lists.newArrayList());
// }
// this.fillPersonalApplet(appletNewsServeList);
// appletNewsVO.setAppletNewsServeList(appletNewsServeList);
// }
private void fillThirdResources(AppletNewsVO appletNewsVO) {
Long newsId = appletNewsVO.getId();
List<AppletThirdResources> thirdResourcesList = thirdResourcesDao.getThirdResourcesByNewsId(newsId);
if (ListUtils.isEmpty(thirdResourcesList)) {
return;
} }
this.fillPersonalApplet(appletNewsServeList); List<AppletThirdResourcesDTO> dtoList = new ArrayList<>();
appletNewsVO.setAppletNewsServeList(appletNewsServeList); AppletThirdResourcesDTO dto = null;
com.pcloud.common.utils.BeanUtils
.copyListProperties(thirdResourcesList, dtoList, AppletThirdResourcesDTO.class);
appletNewsVO.setThirdResourcesRelations(dtoList);
} }
@Override @Override
......
package com.pcloud.book.applet.biz.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pcloud.book.applet.biz.AppletThirdResourcesBiz;
import com.pcloud.book.applet.dao.AppletLinkClickDao;
import com.pcloud.book.applet.dao.AppletNewsDao;
import com.pcloud.book.applet.dao.AppletThirdResourcesClickDao;
import com.pcloud.book.applet.dao.AppletThirdResourcesDao;
import com.pcloud.book.applet.dto.AppletChartDateDTO;
import com.pcloud.book.applet.dto.AppletThirdResourcesDTO;
import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
import com.pcloud.book.applet.enums.DataRecordTypeEnum;
import com.pcloud.book.applet.enums.DataTypeEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service("appletThirdResourcesBiz")
public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
@Autowired
private AppletThirdResourcesDao thirdResourcesDao;
@Autowired
private AppletLinkClickDao appletLinkClickDao;
@Autowired
private AppletThirdResourcesClickDao thirdResourcesClickDao;
@Autowired
private AppletNewsDao appletNewsDao;
@Override
public PageBeanNew<AppletThirdResourcesDTO> getListThirdResourcesAnalysis(String keyValue, String source,
String resourcesType, Integer browseQty, Integer clickQty, Integer currentPage, Integer numPerPage) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("keyValue", keyValue);
paramMap.put("source", source);
paramMap.put("resourcesType", resourcesType);
PageBeanNew<AppletThirdResourcesDTO> pageBeanNew = thirdResourcesDao.listPageNew(
new PageParam(currentPage, numPerPage), paramMap, "getListThirdResourcesAnalysis");
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
}
//填充浏览量点击量信息
fillBrowseAndClickQty(pageBeanNew.getRecordList(), browseQty, clickQty);
//填充配置点信息
fillConfigPoint(pageBeanNew.getRecordList());
return pageBeanNew;
}
private void fillConfigPoint(List<AppletThirdResourcesDTO> recordList) {
if (ListUtils.isEmpty(recordList)) {
return;
}
for (AppletThirdResourcesDTO dto : recordList) {
if (dto != null && !StringUtil.isEmpty(dto.getNewsNumber())) {
String[] points = dto.getNewsNumber().split(",");
dto.setConfigPointList(points);
}
}
}
private void fillBrowseAndClickQty(List<AppletThirdResourcesDTO> recordList, Integer browseQty, Integer clickQty) {
if (ListUtils.isEmpty(recordList)) {
return;
}
if (null != browseQty && browseQty.intValue() > 1) { //等于1 值查询当天数据。大于1时,从昨天开始倒推7天,所以要+1
browseQty += 1;
}
if (null != clickQty && clickQty.intValue() > 1) {
clickQty += 1;
}
List<Long> ids = recordList.stream().filter(s -> s != null).map(AppletThirdResourcesDTO::getId).distinct()
.collect(Collectors.toList());
Map<Long, PvuvDTO> clickMap = thirdResourcesClickDao
.mapPVUV(DataTypeEnum.news.code, DataRecordTypeEnum.click.code, ids, clickQty);
Map<Long, PvuvDTO> browseMap = thirdResourcesClickDao
.mapPVUV(DataTypeEnum.news.code, DataRecordTypeEnum.browse.code, ids, browseQty);
for (AppletThirdResourcesDTO dto : recordList) {
Long thirdResourcesId = dto.getId();
if (!MapUtils.isEmpty(clickMap) && clickMap.containsKey(thirdResourcesId)) {
PvuvDTO pvuvDTO = clickMap.get(thirdResourcesId);
dto.setClickPVUV(pvuvDTO.getPv() + "/" + pvuvDTO.getUv());
dto.setClickCount(pvuvDTO.getPv());
} else {
dto.setClickPVUV("0/0");
dto.setClickCount(0);
}
if (!MapUtils.isEmpty(browseMap) && browseMap.containsKey(thirdResourcesId)) {
PvuvDTO pvuvDTO = browseMap.get(thirdResourcesId);
dto.setBrowsePVUV(pvuvDTO.getPv() + "/" + pvuvDTO.getUv());
} else {
dto.setBrowsePVUV("0/0");
}
}
}
@Override
public void addServiceRecord(AppletThirdResourcesClick thirdResourcesClick) {
thirdResourcesClickDao.insert(thirdResourcesClick);
}
@Override
public AppletThirdResourcesDTO getAnalysisDetail(Long thirdResourcesId) {
AppletThirdResourcesDTO thirdResourcesDTO = new AppletThirdResourcesDTO();
List<AppletChartDateDTO> checkList = thirdResourcesClickDao
.mapPVUVByMonth(DataRecordTypeEnum.click.code, thirdResourcesId);
List<AppletChartDateDTO> browseList = thirdResourcesClickDao
.mapPVUVByMonth(DataRecordTypeEnum.browse.code, thirdResourcesId);
thirdResourcesDTO.setClickList(checkList);
thirdResourcesDTO.setBrowseList(browseList);
return thirdResourcesDTO;
}
@Override
public AppletThirdResourcesDTO getNewsTrendChart(Long newsId) {
AppletThirdResourcesDTO thirdResourcesDTO = new AppletThirdResourcesDTO();
List<AppletChartDateDTO> checkList = appletLinkClickDao
.mapPVUVByMonth(DataTypeEnum.news.code, DataRecordTypeEnum.click.code, newsId);
List<AppletChartDateDTO> browseList = appletLinkClickDao
.mapPVUVByMonth(DataTypeEnum.news.code, DataRecordTypeEnum.browse.code, newsId);
thirdResourcesDTO.setClickList(checkList);
thirdResourcesDTO.setBrowseList(browseList);
return thirdResourcesDTO;
}
@Override
public PageBeanNew<AppletThirdResources> getThirdResources(Long type, String source, String keyValue,
Integer currentPage, Integer numPerPage) {
Map<String, Object> map = new HashMap<>();
map.put("type", type);
map.put("source", source);
map.put("keyValue", keyValue);
return thirdResourcesDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getThirdResources");
}
@Override
public void deleteAppletsById(Long id) {
thirdResourcesDao.deleteById(id);
}
@Override
public void updateThirdResources(AppletThirdResourcesDTO thirdResourcesDTO) {
AppletThirdResources thirdResources = new AppletThirdResources();
Boolean exist = appletNewsDao.newsSourceExist(thirdResourcesDTO.getSource());
if (!exist) {
appletNewsDao.insertSource(thirdResourcesDTO.getSource());
}
if (!StringUtil.isEmpty(thirdResourcesDTO.getNumber())) {
AppletThirdResources existThirdResources = thirdResourcesDao
.exitThirResources(thirdResourcesDTO.getNumber());
if (existThirdResources != null && existThirdResources.getId() != null
&& Long.compare(existThirdResources.getId(), thirdResourcesDTO.getId()) != 0) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "编号重复");
}
}
BeanUtils.copyProperties(thirdResourcesDTO, thirdResources);
thirdResourcesDao.update(thirdResources);
}
@Override
public AppletThirdResources getAppletsById(Long id) {
return thirdResourcesDao.getById(id);
}
@Override
public void createThirdResources(AppletThirdResourcesDTO thirdResourcesDTO) {
AppletThirdResources thirdResources = new AppletThirdResources();
Boolean exist = appletNewsDao.newsSourceExist(thirdResourcesDTO.getSource());
if (!exist) {
appletNewsDao.insertSource(thirdResourcesDTO.getSource());
}
if (!StringUtil.isEmpty(thirdResourcesDTO.getNumber())) {
AppletThirdResources existThirdResources = thirdResourcesDao
.exitThirResources(thirdResourcesDTO.getNumber());
if (existThirdResources != null && existThirdResources.getId() != null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "编号重复");
}
}
BeanUtils.copyProperties(thirdResourcesDTO, thirdResources);
thirdResourcesDao.insert(thirdResources);
}
}
package com.pcloud.book.applet.dao; package com.pcloud.book.applet.dao;
import java.util.List;
import java.util.Map;
import com.pcloud.book.applet.dto.AppletChartDateDTO;
import com.pcloud.book.applet.dto.PvuvDTO; import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletLinkClick; import com.pcloud.book.applet.entity.AppletLinkClick;
import com.pcloud.common.core.dao.BaseDao; import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/** /**
* 小程序资讯/券库点击埋点(AppletLinkClick)表数据库访问层 * 小程序资讯/券库点击埋点(AppletLinkClick)表数据库访问层
* *
* @author makejava * @author makejava
* @since 2020-05-11 11:41:35 * @since 2020-05-11 11:41:35
*/ */
public interface AppletLinkClickDao extends BaseDao<AppletLinkClick>{ public interface AppletLinkClickDao extends BaseDao<AppletLinkClick> {
/**
* 趋势图数据
*/
List<AppletChartDateDTO> mapPVUVByMonth(Integer typeId, Integer recordType, Long newsId);
/** /**
* 点击量浏览量pvuv * 点击量浏览量pvuv
*
* @author:zhuyajie * @author:zhuyajie
* @date:2020/5/12 10:44 * @date:2020/5/12 10:44 * @param null update: 增加参数intervalDaya(间隔天数) 2020/07/17 pansy
* * @param null
* update: 增加参数intervalDaya(间隔天数) 2020/07/17 pansy
*/ */
Map<Long,PvuvDTO> mapPVUV(Integer typeId, Integer recordType, List<Long> fromIds,Integer intervalDaya); Map<Long, PvuvDTO> mapPVUV(Integer typeId, Integer recordType, List<Long> fromIds, Integer intervalDaya);
/** /**
* 优惠券使用量 * 优惠券使用量
*
* @author:zhuyajie * @author:zhuyajie
* @date:2020/5/12 10:44 * @date:2020/5/12 10:44 * @param null
* * @param null
*/ */
Map<Long,PvuvDTO> mapCouponUseCount(List<Long> fromIds); Map<Long, PvuvDTO> mapCouponUseCount(List<Long> fromIds);
} }
\ No newline at end of file
...@@ -53,7 +53,7 @@ public interface AppletNewsDao extends BaseDao<AppletNews> { ...@@ -53,7 +53,7 @@ public interface AppletNewsDao extends BaseDao<AppletNews> {
/** /**
*新增资讯来源 *新增资讯来源
*/ */
void insertSource(String source); int insertSource(String source);
/** /**
*资讯来源列表 *资讯来源列表
*/ */
......
package com.pcloud.book.applet.dao;
import java.util.List;
import java.util.Map;
import com.pcloud.book.applet.dto.AppletChartDateDTO;
import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
import com.pcloud.common.core.dao.BaseDao;
public interface AppletThirdResourcesClickDao extends BaseDao<AppletThirdResourcesClick> {
Map<Long, PvuvDTO> mapPVUV(Integer typeId, Integer recordType, List<Long> fromIds, Integer intervalDaya);
/**
* 趋势图数据
*/
List<AppletChartDateDTO> mapPVUVByMonth(Integer recordType, Long newsId);
}
package com.pcloud.book.applet.dao;
import java.util.List;
import java.util.Map;
import com.pcloud.book.applet.dto.AppletConfigPointDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesRelation;
import com.pcloud.common.core.dao.BaseDao;
public interface AppletThirdResourcesDao extends BaseDao<AppletThirdResources> {
AppletThirdResources exitThirResources(String resourcesNumber);
List<AppletThirdResources> getThirdResourcesByNewsId(Long newsId);
Map<Long, AppletConfigPointDTO> getConfigPoint(List<Long> thirdResourcesId);
}
package com.pcloud.book.applet.dao;
import java.util.List;
import com.pcloud.book.applet.entity.AppletThirdResourcesRelation;
import com.pcloud.common.core.dao.BaseDao;
public interface AppletThirdResourcesRelationDao extends BaseDao<AppletThirdResourcesRelation> {
void deleteByAppletNewsId(Long newsId);
}
package com.pcloud.book.applet.dao.impl; package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.AppletLinkClickDao; import com.pcloud.book.applet.dao.AppletLinkClickDao;
import com.pcloud.book.applet.dto.AppletChartDateDTO;
import com.pcloud.book.applet.dto.PvuvDTO; import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletLinkClick; import com.pcloud.book.applet.entity.AppletLinkClick;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
...@@ -22,12 +23,21 @@ import java.util.Map; ...@@ -22,12 +23,21 @@ import java.util.Map;
public class AppletLinkClickDaoImpl extends BaseDaoImpl<AppletLinkClick> implements AppletLinkClickDao { public class AppletLinkClickDaoImpl extends BaseDaoImpl<AppletLinkClick> implements AppletLinkClickDao {
@Override @Override
public List<AppletChartDateDTO> mapPVUVByMonth(Integer typeId, Integer recordType, Long newsId){
Map<String,Object> map = new HashMap<>();
map.put("newsId",newsId);
map.put("recordType",recordType);
map.put("typeId",typeId);
return getSessionTemplate().selectList(getStatement("mapPVUVByMonth"),map);
}
@Override
public Map<Long, PvuvDTO> mapPVUV(Integer typeId, Integer recordType, List<Long> fromIds,Integer intervalDaya) { public Map<Long, PvuvDTO> mapPVUV(Integer typeId, Integer recordType, List<Long> fromIds,Integer intervalDaya) {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("list",fromIds); map.put("list",fromIds);
map.put("recordType",recordType); map.put("recordType",recordType);
map.put("typeId",typeId); map.put("typeId",typeId);
map.put("intervalDaya",intervalDaya); // map.put("intervalDaya",intervalDaya);
return getSessionTemplate().selectMap(getStatement("mapPVUV"),map,"fromId"); return getSessionTemplate().selectMap(getStatement("mapPVUV"),map,"fromId");
} }
......
...@@ -65,8 +65,8 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet ...@@ -65,8 +65,8 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet
} }
@Override @Override
public void insertSource(String source) { public int insertSource(String source) {
getSessionTemplate().insert(getStatement("insertSource"),source); return getSessionTemplate().insert(getStatement("insertSource"),source);
} }
@Override @Override
......
package com.pcloud.book.applet.dao.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Component;
import com.pcloud.book.applet.dao.AppletThirdResourcesClickDao;
import com.pcloud.book.applet.dto.AppletChartDateDTO;
import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
import com.pcloud.common.core.dao.BaseDaoImpl;
@Component
public class AppletThirdResourcesClickDaoImpl extends BaseDaoImpl<AppletThirdResourcesClick> implements
AppletThirdResourcesClickDao {
@Override
public Map<Long, PvuvDTO> mapPVUV(Integer typeId, Integer recordType, List<Long> ids, Integer intervalDaya) {
Map<String, Object> map = new HashMap<>();
map.put("list", ids);
map.put("recordType", recordType);
map.put("typeId", typeId);
map.put("intervalDaya", intervalDaya);
return getSessionTemplate().selectMap(getStatement("mapPVUV"), map, "fromId");
}
@Override
public List<AppletChartDateDTO> mapPVUVByMonth(Integer recordType, Long thirdResourcesId) {
Map<String, Object> map = new HashMap<>();
map.put("thirdResourcesId", thirdResourcesId);
map.put("recordType", recordType);
return getSessionTemplate().selectList(getStatement("mapPVUVByMonth"), map);
}
}
package com.pcloud.book.applet.dao.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.pcloud.book.applet.dao.AppletThirdResourcesDao;
import com.pcloud.book.applet.dto.AppletConfigPointDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.common.core.dao.BaseDaoImpl;
@Repository("appletThirdResourcesDao")
public class AppletThirdResourcesDaoImpl extends BaseDaoImpl<AppletThirdResources> implements
AppletThirdResourcesDao {
@Override
public AppletThirdResources exitThirResources(String resourcesNumber) {
Map<String, Object> map = new HashMap<>();
map.put("resourceNumber", resourcesNumber);
return getSessionTemplate().selectOne(getStatement("exitThirResources"), map);
}
@Override
public List<AppletThirdResources> getThirdResourcesByNewsId(Long newsId) {
return getSessionTemplate().selectList(getStatement("getThirdResourcesByNewsId"), newsId);
}
@Override
public Map<Long, AppletConfigPointDTO> getConfigPoint(List<Long> thirdResourcesIds) {
Map<String, Object> map = new HashMap<>();
map.put("list", thirdResourcesIds);
return getSessionTemplate().selectMap(getStatement("getConfigPoint"), map, "thirdResourcesId");
}
}
package com.pcloud.book.applet.dao.impl;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.pcloud.book.applet.dao.AppletThirdResourcesRelationDao;
import com.pcloud.book.applet.entity.AppletThirdResourcesRelation;
import com.pcloud.common.core.dao.BaseDaoImpl;
@Repository("appletThirdResourcesRelationDao")
public class AppletThirdResourcesRelationDaoImpl extends BaseDaoImpl<AppletThirdResourcesRelation> implements
AppletThirdResourcesRelationDao {
@Override
public void deleteByAppletNewsId(Long newsId) {
getSessionTemplate().delete(getStatement("deleteByAppletNewsId"), newsId);
}
}
package com.pcloud.book.applet.dto;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AppletChartDateDTO extends BaseDto {
@ApiModelProperty("创建时间")
private String createDate;
@ApiModelProperty("数量")
private Integer pv;
@ApiModelProperty("数量")
private Integer uv;
}
package com.pcloud.book.applet.dto;
import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("第三方资源")
public class AppletConfigPointDTO extends BaseDto {
@ApiModelProperty("thirdResourcesId")
private Long thirdResourcesId;
@ApiModelProperty("配置点")
private String newsNumber;
}
package com.pcloud.book.applet.dto; package com.pcloud.book.applet.dto;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesRelation;
import com.pcloud.common.dto.BaseDto; import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
@ApiModel("小程序资讯") @ApiModel("小程序资讯")
...@@ -132,4 +134,8 @@ public class AppletNewsDTO extends BaseDto { ...@@ -132,4 +134,8 @@ public class AppletNewsDTO extends BaseDto {
@ApiModelProperty("类别") @ApiModelProperty("类别")
private List<AppletNewsCategoryDTO> categoryList; private List<AppletNewsCategoryDTO> categoryList;
@ApiModelProperty("第三方资源")
List<AppletThirdResources> thirdResourcesRelations;
} }
package com.pcloud.book.applet.dto;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("第三方资源")
public class AppletThirdResourcesDTO extends BaseDto {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("咨询id")
private Long fromId;
@ApiModelProperty("第三方资源编号")
private String number;
@ApiModelProperty("类型 0:小程序, 1:链接")
private Long type;
@ApiModelProperty("第三方资源名称")
private String name;
@ApiModelProperty("小程序id")
private String appletsId;
@ApiModelProperty("来源")
private String source;
@ApiModelProperty("宣传图片")
private String resourceImgUrl;
@ApiModelProperty("链接")
private String url;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建人")
private Long creator;
@ApiModelProperty("修改人")
private Long updator;
@ApiModelProperty("点击次数")
private Integer clickCount;
@ApiModelProperty("点击量pv/uv")
private String clickPVUV;
@ApiModelProperty("浏览量pv/uv")
private String browsePVUV;
private String newsIds;
private String newsNumber;
@ApiModelProperty("配置点")
private String[] configPointList;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
protected Date createTime;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
protected Date updateTime;
private List<AppletChartDateDTO> clickList;
private List<AppletChartDateDTO> browseList;
}
...@@ -104,4 +104,7 @@ public class AppletNews extends BaseTempletClassify { ...@@ -104,4 +104,7 @@ public class AppletNews extends BaseTempletClassify {
@ApiModelProperty("咨询类别") @ApiModelProperty("咨询类别")
List<AppletNewsCategory> appletNewsCategoryList; List<AppletNewsCategory> appletNewsCategoryList;
@ApiModelProperty("第三方资源")
List<AppletThirdResourcesRelation> thirdResourcesRelations;
} }
package com.pcloud.book.applet.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AppletThirdResources extends BaseEntity {
@ApiModelProperty("第三方资源编号")
private String number;
@ApiModelProperty("类型 0:小程序, 1:链接")
private Long type;
@ApiModelProperty("第三方资源名称")
private String name;
@ApiModelProperty("小程序id")
private String appletsId;
@ApiModelProperty("来源")
private String source;
@ApiModelProperty("宣传图片")
private String resourceImgUrl;
@ApiModelProperty("链接")
private String url;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建人")
private Long creator;
@ApiModelProperty("修改人")
private Long updator;
}
\ No newline at end of file
package com.pcloud.book.applet.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AppletThirdResourcesClick extends BaseEntity {
private Long id;
private Long wechatUserId;
@ApiModelProperty("第三方资源id")
private String thirdResourcesId;
@ApiModelProperty("第三方资源名称")
private String thirdResourcesName;
private String link;
@ApiModelProperty("1:点击,2:浏览")
private Integer recordType;
}
\ No newline at end of file
package com.pcloud.book.applet.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AppletThirdResourcesRelation extends BaseEntity {
@ApiModelProperty("第三方资源编号")
private Long thirdResourcesId;
private Long fromId;
private String resourcesName;
private String resourcesNumber;
}
\ No newline at end of file
package com.pcloud.book.applet.facade;
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 com.pcloud.book.advertising.entity.AdvertisingLinkClick;
import com.pcloud.book.applet.biz.AppletThirdResourcesBiz;
import com.pcloud.book.applet.dto.AppletThirdResourcesDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.dto.ResponseDto;
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 com.pcloud.readercenter.wechat.exception.WechatUserException;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController("appletThirdResourcesFacade")
@RequestMapping("appletThirdResources")
public class AppletThirdResourcesFacade {
@Autowired
private AppletThirdResourcesBiz thirdResourcesBiz;
@ApiOperation(value = "第三方资源埋点", httpMethod = "POST")
@PostMapping(value = "addClickRecord")
public ResponseDto<?> addClickRecord(@CookieValue("userInfo") String userInfo,
@RequestBody @ApiParam AppletThirdResourcesClick thirdResourcesClick) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == thirdResourcesClick || null == thirdResourcesClick.getThirdResourcesId()) {
throw new WechatUserException(WechatUserException.FIELD_IS_NULL, "缺失参数");
}
thirdResourcesClick.setWechatUserId(wechatUserId);
thirdResourcesBiz.addServiceRecord(thirdResourcesClick);
return new ResponseDto<>();
}
@ApiOperation("获取第三方分析列表")
@GetMapping("getListThirdResourcesAnalysis")
public ResponseDto<?> getListThirdResourcesAnalysis(@RequestHeader("token") String token,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页数量") Integer numPerPage,
@RequestParam(value = "keyValue", required = false) @ApiParam("关键字") String keyValue,
@RequestParam(value = "source", required = false) @ApiParam("来源") String source,
@RequestParam(value = "resourcesType", required = false) @ApiParam("类型") String resourcesType,
@RequestParam(value = "browseQty", required = false) @ApiParam("浏览量") Integer browseQty,
@RequestParam(value = "clickQty", required = false) @ApiParam("点击量") Integer clickQty)
throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
PageBeanNew<AppletThirdResourcesDTO> result = thirdResourcesBiz
.getListThirdResourcesAnalysis(keyValue, source, resourcesType, browseQty, clickQty, currentPage,
numPerPage);
return new ResponseDto<>(result);
}
@ApiOperation("获取第三方近一月趋势图数据")
@GetMapping("getAnalysisDetail")
public ResponseDto<?> getAnalysisDetail(@RequestHeader("token") String token,
@RequestParam(value = "thirdResourcesId") @ApiParam("识别号") Long thirdResourcesId)
throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
AppletThirdResourcesDTO result = thirdResourcesBiz.getAnalysisDetail(thirdResourcesId);
return new ResponseDto<>(result);
}
@ApiOperation("获取咨询近一月趋势图数据")
@GetMapping("getNewsTrendChart")
public ResponseDto<?> getNewsTrendChart(@RequestHeader("token") String token,
@RequestParam(value = "newsId") @ApiParam("咨询唯一识别号") Long newsId) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
AppletThirdResourcesDTO result = thirdResourcesBiz.getNewsTrendChart(newsId);
return new ResponseDto<>(result);
}
@ApiOperation("查询第三方资源")
@GetMapping("getThirdResources")
public ResponseDto<?> getThirdResources(@RequestHeader("token") String token,
@RequestParam(value = "type", required = false) @ApiParam("类型") Long type,
@RequestParam(value = "source", required = false) @ApiParam("来源") String source,
@RequestParam(value = "keyValue", required = false) @ApiParam("关键字") String keyValue,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页数量") Integer numPerPage) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
if (null == currentPage || null == numPerPage) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少分页参数");
}
PageBeanNew<AppletThirdResources> pageBeanNew = thirdResourcesBiz
.getThirdResources(type, source, keyValue, currentPage, numPerPage);
return new ResponseDto<>(pageBeanNew);
}
@ApiOperation("删除第三方资源")
@GetMapping("deleteThirdResources")
public ResponseDto<?> deleteThirdResources(@RequestHeader("token") String token, @RequestParam("id") @ApiParam("id") Long id)
throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
thirdResourcesBiz.deleteAppletsById(id);
return new ResponseDto<>();
}
@ApiOperation("修改第三方咨询信息")
@PostMapping("updateThirdResources")
public ResponseDto<?> updateThirdResources(@RequestHeader("token") String token,
@RequestBody @ApiParam AppletThirdResourcesDTO thirdResourcesDTO) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
if (thirdResourcesDTO != null && thirdResourcesDTO.getId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺失主键id");
}
thirdResourcesBiz.updateThirdResources(thirdResourcesDTO);
return new ResponseDto<>();
}
@ApiOperation("根据id获取第三方资源信息")
@GetMapping("getThirdResourcesById")
public ResponseDto<?> getThirdResourcesById(@RequestHeader("token") String token,
@RequestParam(value = "id", required = true) @ApiParam("第三方资源id") Long id
) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
AppletThirdResources result = thirdResourcesBiz.getAppletsById(id);
return new ResponseDto<>(result);
}
@ApiOperation("创建第三方资源")
@PostMapping("createThirdResources")
public ResponseDto<?> createThirdResources(@RequestHeader("token") String token,
@RequestBody @ApiParam AppletThirdResourcesDTO thirdResourcesDTO) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
if (thirdResourcesDTO != null && Long.compare(thirdResourcesDTO.getType(), 0) == 0
&& thirdResourcesDTO.getAppletsId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺失小程序id");
}
thirdResourcesBiz.createThirdResources(thirdResourcesDTO);
return new ResponseDto<>();
}
}
\ No newline at end of file
...@@ -154,7 +154,7 @@ public class SomeUserScanBookGroupListener { ...@@ -154,7 +154,7 @@ public class SomeUserScanBookGroupListener {
sendEmailDto.setToEmail(emails.get(0)); sendEmailDto.setToEmail(emails.get(0));
emails = emails.subList(1, emails.size()); emails = emails.subList(1, emails.size());
String ccEmail = String.join(",", emails); String ccEmail = String.join(",", emails);
sendEmailDto.setCcEmail(ccEmail); // sendEmailDto.setCcEmail(ccEmail);
} else { } else {
sendEmailDto.setToEmail(emails.get(0)); sendEmailDto.setToEmail(emails.get(0));
} }
......
...@@ -17,11 +17,46 @@ ...@@ -17,11 +17,46 @@
values (#{wechatUserId}, #{typeId}, #{fromId}, #{recordType}, NOW(),NOW()) values (#{wechatUserId}, #{typeId}, #{fromId}, #{recordType}, NOW(),NOW())
</insert> </insert>
<select id="getListThirdResourcesAnalysis" parameterType="map"
resultType="com.pcloud.book.applet.dto.AppletThirdResourcesDTO">
SELECT
id,
resource_number number,
resource_type type,
resource_name name,
app_Id appletsId,
resource_source source,
resource_img_url resourceImgUrl,
resource_url url,
remark,
create_time createTime,
update_time updateTime,
creator,
updator
FROM
applet_third_resources n
WHERE
1 = 1
<if test="keyValue != null">
AND (n.resource_number LIKE CONCAT("%",#{keyValue},"%") or n.resource_name LIKE CONCAT("%",#{keyValue},"%"))
</if>
<if test="source != null">
AND n.resource_source = #{source}
</if>
<if test="resourcesType != null">
AND n.resource_type = #{resourcesType}
</if>
GROUP BY
n.id
ORDER BY
n.update_time DESC
</select>
<select id="mapPVUV" parameterType="map" resultType="com.pcloud.book.applet.dto.PvuvDTO"> <select id="mapPVUV" parameterType="map" resultType="com.pcloud.book.applet.dto.PvuvDTO">
SELECT SELECT
from_id fromId, from_id fromId,
COUNT(1) pv, COUNT(1) pv,
-- COUNT(DISTINCT wechat_user_id,create_date) uv -- COUNT(DISTINCT wechat_user_id,create_date) uv
COUNT(DISTINCT wechat_user_id) uv COUNT(DISTINCT wechat_user_id) uv
FROM applet_link_click FROM applet_link_click
WHERE type_id = #{typeId} WHERE type_id = #{typeId}
...@@ -31,11 +66,38 @@ ...@@ -31,11 +66,38 @@
#{item} #{item}
</foreach> </foreach>
<if test="intervalDaya != null"> <if test="intervalDaya != null">
AND create_date between DATE_SUB(CURDATE(),INTERVAL #{intervalDaya} DAY) and DATE_SUB(CURDATE(),INTERVAL 1 DAY) AND date_format(create_time ,'%Y-%m-%d' ) between DATE_SUB(CURDATE(),INTERVAL #{intervalDaya} DAY) and DATE_SUB(CURDATE(),INTERVAL 1
DAY)
</if> </if>
GROUP BY from_id GROUP BY from_id
</select> </select>
<select id="mapPVUVByMonth" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletChartDateDTO">
SELECT b.createDate,IFNULL(aa.pv,0) pv,IFNULL(aa.uv,0) uv from
(SELECT
create_date createDate,
COUNT(1) pv,
COUNT(DISTINCT wechat_user_id) uv
FROM applet_link_click
WHERE type_id = #{typeId}
AND record_type = #{recordType}
and from_id= #{newsId}
AND create_date between date_add(CURDATE(), interval -1 month) and DATE_SUB(CURDATE(),INTERVAL 1 DAY)
GROUP BY create_date
) aa
RIGHT JOIN
(select a.Date as createDate from
(select curdate() - INTERVAL (a.a + (10 * b.a) + (100 * c.a)) DAY as Date from
(select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as a
cross join
(select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as b
cross join
(select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
) a
where a.Date between DATE_SUB(CURDATE(), INTERVAL 30 DAY) and DATE_SUB(CURDATE(),INTERVAL 1 DAY))b ON b.createDate = aa.createDate
ORDER BY b.createDate asc
</select>
<select id="mapCouponUseCount" parameterType="map" resultType="com.pcloud.book.applet.dto.PvuvDTO"> <select id="mapCouponUseCount" parameterType="map" resultType="com.pcloud.book.applet.dto.PvuvDTO">
SELECT SELECT
from_id fromId, from_id fromId,
......
...@@ -400,7 +400,7 @@ ...@@ -400,7 +400,7 @@
</foreach> </foreach>
</delete> </delete>
<select id="insertSource" parameterType="string"> <select id="insertSource" parameterType="string" resultType="int">
INSERT INTO applet_news_source (source) VALUES (#{source}) INSERT INTO applet_news_source (source) VALUES (#{source})
</select> </select>
...@@ -492,9 +492,9 @@ ...@@ -492,9 +492,9 @@
<if test="subjectLabelId != null"> <if test="subjectLabelId != null">
AND category.subject_label_id = #{subjectLabelId} AND category.subject_label_id = #{subjectLabelId}
</if> </if>
<if test="linkOnly == 1"> <!-- <if test="linkOnly == 1">-->
and n.jump_type = 2 <!-- and n.jump_type = 2-->
</if> <!-- </if>-->
<if test="rightsClassifyId!=null"> <if test="rightsClassifyId!=null">
AND n.rights_classify_id =#{rightsClassifyId} AND n.rights_classify_id =#{rightsClassifyId}
</if> </if>
......
<?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.AppletThirdResourcesDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletThirdResources">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="resource_number" property="number" jdbcType="VARCHAR"/>
<result column="resource_type" property="type" jdbcType="TINYINT"/>
<result column="resource_name" property="name" jdbcType="VARCHAR"/>
<result column="app_Id" property="appletsId" jdbcType="VARCHAR"/>
<result column="resource_source" property="source" jdbcType="VARCHAR"/>
<result column="resource_img_url" property="resourceImgUrl" jdbcType="VARCHAR"/>
<result column="resource_url" property="url" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="BIGINT"/>
<result column="updator" property="updator" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,resource_number,resource_type,resource_name,app_Id,resource_source,resource_img_url,resource_url,remark,create_time,update_time,creator,updator
</sql>
<select id="getConfigPoint" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletConfigPointDTO">
SELECT
ralation.third_resources_id thirdResourcesId,
GROUP_CONCAT(news.url_number) newsNumber
FROM
applet_third_resources_relation ralation
LEFT JOIN applet_news news ON ralation.from_id = news.id
WHERE ralation.third_resources_id in
<foreach collection="list" item="item" index="index" separator="," close=")" open="(">
#{item}
</foreach>
</select>
<select id="exitThirResources" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from applet_third_resources
where 1=1
and resource_number = #{resourceNumber}
order by update_time desc
limit 1
</select>
<select id="getThirdResources" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from applet_third_resources
where 1=1
<if test="type!=null">
and resource_type=#{type}
</if>
<if test="source!=null">
and resource_source=#{source}
</if>
<if test="keyValue!=null">
and (resource_number LIKE concat('%',#{keyValue},'%') OR resource_name LIKE concat('%',#{keyValue},'%'))
</if>
order by update_time desc
</select>
<select id="getById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from applet_third_resources where id=#{id}
</select>
<select id="getThirdResourcesByNewsId" parameterType="Long" resultType="com.pcloud.book.applet.dto.AppletThirdResourcesDTO">
SELECT
relation.from_id fromId,
third.id,
third.app_Id appletsId,
third.resource_name name,
third.resource_number number,
third.resource_type type,
third.resource_img_url resourceImgUrl,
third.resource_url url
FROM
applet_third_resources_relation relation
LEFT JOIN applet_third_resources third ON relation.third_resources_id = third.id
where relation.from_id = #{newsId}
</select>
<select id="getListThirdResourcesAnalysis" parameterType="map"
resultType="com.pcloud.book.applet.dto.AppletThirdResourcesDTO">
SELECT * from(
SELECT
n.id,
n.resource_number number,
n.resource_type type,
n.resource_name name,
n.app_Id appletsId,
n.resource_source source,
n.resource_img_url resourceImgUrl,
n.resource_url url,
n.remark,
n.create_time createTime,
n.update_time updateTime,
n.creator,
n.updator,
GROUP_CONCAT(case when news.id != ' ' THEN news.id else null END) newsIds,
GROUP_CONCAT(case when news.url_number != ' ' THEN news.url_number else null END) newsNumber
FROM
applet_third_resources n
LEFT JOIN applet_third_resources_relation ralation ON n.id = ralation.third_resources_id
LEFT JOIN applet_news news ON ralation.from_id = news.id
WHERE
1 = 1
<if test="source != null">
AND n.resource_source = #{source}
</if>
<if test="resourcesType != null">
AND n.resource_type = #{resourcesType}
</if>
GROUP BY
n.id
ORDER BY
n.update_time DESC
)result where 1 = 1
<if test="keyValue != null">
AND (result.number LIKE CONCAT("%",#{keyValue},"%") or result.name LIKE CONCAT("%",#{keyValue},"%") or result.newsNumber LIKE CONCAT("%",#{keyValue},"%"))
</if>
</select>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletThirdResources" useGeneratedKeys="true"
keyProperty="id">
insert into applet_third_resources ( resource_number,resource_type,resource_name,
app_Id,resource_source,resource_img_url,
resource_url,remark,create_time,
update_time,creator,updator
)
values (#{number,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{name,jdbcType=VARCHAR},
#{appletsId,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR}, #{resourceImgUrl,jdbcType=VARCHAR},
#{url,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, now(),
now(), #{creator,jdbcType=BIGINT}, #{updator,jdbcType=BIGINT}
)
</insert>
<update id="update" parameterType="com.pcloud.book.applet.entity.AppletThirdResources">
update applet_third_resources
<set>
<if test="number != null">
resource_number = #{number,jdbcType=VARCHAR},
</if>
<if test="type != null">
resource_type = #{type,jdbcType=TINYINT},
</if>
<if test="name != null">
resource_name = #{name,jdbcType=VARCHAR},
</if>
<if test="appletsId != null">
app_Id = #{appletsId,jdbcType=VARCHAR},
</if>
<if test="source != null">
resource_source = #{source,jdbcType=VARCHAR},
</if>
<if test="resourceImgUrl != null">
resource_img_url = #{resourceImgUrl,jdbcType=VARCHAR},
</if>
<if test="url != null">
resource_url = #{url,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
update_time = NOW(),
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<delete id="deleteById">
delete from applet_third_resources where id=#{id}
</delete>
</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.AppletThirdResourcesClickDaoImpl">
<resultMap type="com.pcloud.book.applet.entity.AppletThirdResourcesClick" id="AppletLinkClickMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="wechatUserId" column="wechat_user_id" jdbcType="INTEGER"/>
<result property="thirdResourcesId" column="third_resources_id" jdbcType="INTEGER"/>
<result property="thirdResourcesName" column="third_resources_name" jdbcType="VARCHAR"/>
<result property="link" column="link" jdbcType="VARCHAR"/>
<result property="recordType" column="record_type" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into applet_thirdresources_click_record(wechat_user_id, third_resources_id, third_resources_name, link,record_type, create_time, update_time)
values (#{wechatUserId}, #{thirdResourcesId}, #{thirdResourcesName}, #{link}, #{recordType}, now(), now())
</insert>
<select id="mapPVUV" parameterType="map" resultType="com.pcloud.book.applet.dto.PvuvDTO">
SELECT
third_resources_id fromId,
COUNT(1) pv,
COUNT(DISTINCT wechat_user_id) uv
FROM applet_thirdresources_click_record
WHERE 1=1
AND record_type = #{recordType}
AND third_resources_id in
<foreach collection="list" item="item" index="index" separator="," close=")" open="(">
#{item}
</foreach>
<if test="intervalDaya != null">
AND date_format(create_time ,'%Y-%m-%d') between DATE_SUB(CURDATE(),INTERVAL #{intervalDaya} DAY) and DATE_SUB(CURDATE(),INTERVAL 1
DAY)
</if>
GROUP BY third_resources_id
</select>
<select id="mapPVUVByMonth" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletChartDateDTO">
SELECT b.createDate,IFNULL(aa.pv,0) pv,IFNULL(aa.uv,0) uv from
(SELECT
DATE_FORMAT(create_time,'%Y-%m-%d') createDate,
COUNT(1) pv,
COUNT(DISTINCT wechat_user_id) uv
FROM applet_thirdresources_click_record
WHERE 1=1
AND record_type = #{recordType}
and third_resources_id= #{thirdResourcesId}
AND create_time between date_add(CURDATE(), interval -1 month) and DATE_SUB(CURDATE(),INTERVAL -1 DAY)
GROUP BY third_resources_id,DATE_FORMAT(create_time,'%Y-%m-%d')
) aa
RIGHT JOIN
(select a.Date as createDate from
(select curdate() - INTERVAL (a.a + (10 * b.a) + (100 * c.a)) DAY as Date from
(select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as a
cross join
(select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as b
cross join
(select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
) a
where a.Date between DATE_SUB(CURDATE(), INTERVAL 30 DAY) and DATE_SUB(CURDATE(),INTERVAL 1 DAY))b ON b.createDate = aa.createDate
ORDER BY b.createDate asc
</select>
</mapper>
<?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.AppletThirdResourcesRelationDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletThirdResourcesRelation">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="third_resources_id" property="thirdResourcesId" jdbcType="BIGINT"/>
<result column="from_id" property="fromId" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletThirdResourcesRelation" useGeneratedKeys="true"
keyProperty="id">
insert into applet_third_resources_relation ( third_resources_id,from_id,create_time)
values (#{thirdResourcesId,jdbcType=BIGINT}, #{fromId,jdbcType=BIGINT},now())
</insert>
<!--批量插入-->
<insert id="batchInsert" parameterType="com.pcloud.book.applet.entity.AppletThirdResourcesRelation" useGeneratedKeys="true" keyProperty="id">
insert into applet_third_resources_relation ( third_resources_id,from_id,create_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.thirdResourcesId,jdbcType=BIGINT}, #{item.fromId,jdbcType=BIGINT},now())
</foreach>
</insert>
<delete id="deleteByAppletNewsId">
delete from applet_third_resources_relation where from_id=#{id}
</delete>
</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