Commit 2b7a5f6d by 田超

Merge branch 'feature/answerBookName' into 'master'

feat: [none] 答案增加书名显示

See merge request rays/pcloud-book!1198
parents e90d316c 26f7b0cd
......@@ -50,4 +50,13 @@ public class ServeCollectDTO {
@ApiModelProperty("是否被收藏")
private Integer isCollected;
@ApiModelProperty("图书ID")
private Long bookId;
@ApiModelProperty("渠道ID")
private Long channelId;
@ApiModelProperty("编辑ID")
private Long adviserId;
}
......@@ -2,6 +2,7 @@ package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.dto.AppletAppOrProductDTO;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletTrackDTO;
import com.pcloud.book.applet.dto.ReadBookRecordDTO;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.common.page.PageBeanNew;
......@@ -109,4 +110,13 @@ public interface AppletRecordBiz {
* @param recordTypes 类型
*/
void addFootstep(Long wechatUserId, Integer fromType, String typeName, List<Integer> recordTypes);
/**
* 小程序埋点
*
* @param wechatUserId 用户ID
* @param officialAccountsId officialAccountsId
* @param trackDTO 埋点信息
*/
void track(Long wechatUserId, Long officialAccountsId, AppletTrackDTO trackDTO);
}
......@@ -23,6 +23,7 @@ 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.AppletTrackDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.dto.BookDTO4Booklist;
import com.pcloud.book.applet.dto.ReadBookRecordDTO;
......@@ -30,10 +31,14 @@ import com.pcloud.book.applet.entity.AppletFootstepRecord;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.book.applet.entity.AppletRecordDayServe;
import com.pcloud.book.applet.entity.AppletRecordServe;
import com.pcloud.book.applet.entity.AppletTrack;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.applet.mapper.AppletFootstepRecordMapper;
import com.pcloud.book.applet.mapper.AppletTrackMapper;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
......@@ -75,6 +80,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
......@@ -121,6 +127,10 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
private WeworkTeacherBiz weworkTeacherBiz;
@Autowired
private AppletFootstepRecordMapper appletFootstepRecordMapper;
@Autowired
private BookDao bookDao;
@Autowired
private AppletTrackMapper appletTrackMapper;
@Override
@ParamLog("通过ID查询单条数据")
......@@ -395,6 +405,20 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
appletFootstepRecordMapper.insert(appletFootstepRecord);
}
@Override
public void track(Long wechatUserId, Long officialAccountsId, AppletTrackDTO trackDTO) {
AppletTrack track = new AppletTrack();
track.setWechatUserId(wechatUserId);
track.setOfficialAccountsId(officialAccountsId);
track.setPage(trackDTO.getPage());
track.setTrackType(trackDTO.getTrackType());
track.setElementName(trackDTO.getElementName());
track.setExtJson(trackDTO.getExtJson());
track.setVersion(trackDTO.getVersion());
track.setRemark(trackDTO.getRemark());
appletTrackMapper.insert(track);
}
private void HandleTypeCode4ListDay(List<AppletRecordDTO> recordList) {
fillTypeCode(recordList);
appletRecordDayServeDao.batchUpdate(recordList);
......@@ -432,25 +456,34 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
}
//根据不同的类型填充不同的数据
List<Long> newsIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.NEWS.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
map(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());
map(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());
map(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());
map(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());
map(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());
map(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());
map(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(AppletRecordDTO::getFromId).distinct().collect(Collectors.toList());
List<Long> wxWorkTeacherIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.WX_WORK_TEACHER.value.equals(appletRecordDTO.getRecordType())).
map(appletRecordDTO -> appletRecordDTO.getFromId()).distinct().collect(Collectors.toList());
map(AppletRecordDTO::getFromId).distinct().collect(Collectors.toList());
List<Long> bookIds = recordList.stream().filter(appletRecordDTO -> AppletRecordTypeEnum.PRODUCT.value.equals(appletRecordDTO.getRecordType()) || AppletRecordTypeEnum.APP.value.equals(appletRecordDTO.getRecordType()))
.map(AppletRecordDTO::getBookId).distinct().collect(Collectors.toList());
Map<Long, BookDto> bookDtoMap;
CompletableFuture<Map<Long, BookDto>> bookDtoMapFuture = null;
if (CollUtil.isNotEmpty(bookIds)) {
bookDtoMapFuture = CompletableFuture.supplyAsync(() ->
Optional.ofNullable(bookDao.getMapByIds(bookIds)).orElse(new HashMap<>()), ThreadPoolUtils.FILL_APPLET_RECORD);
}
//资源map
Map<Long, AppletNewsDTO> newsDtoMap = new HashMap<>();
Future<Map<Long, AppletNewsDTO>> newsDtoMapFuture = null;
......@@ -504,6 +537,18 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
if (!ListUtils.isEmpty(wxWorkTeacherIds)) {
wxWorkTeacherDTOHashMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> weworkTeacherBiz.getWxWorkTeacherByIds(wxWorkTeacherIds));
}
// 应用作品类型的答案补充书名和封面
bookDtoMap = Optional.ofNullable(bookDtoMapFuture).map(future -> {
Map<Long, BookDto> map = null;
try {
map = future.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.warn("[AppletRecordBizImpl.fillAppletRecord] 异步获取图书信息失败", e);
}
return map;
}).orElse(new HashMap<>());
//存储已经删除群的群分类; 精选文章类型并且跳转链接包含qrcode.5rs.me
Iterator<AppletRecordDTO> iterator = recordList.iterator();
while (iterator.hasNext()) {
......@@ -522,9 +567,17 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
//填充第三方群信息
fillGroup4Record(groupDtoMap4ThirdGroup, groupDtoMap4ThirdGroupFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.PRODUCT.value, appletRecordDTO.getRecordType())) {
if ("ANSWER".equals(appletRecordDTO.getTypeCode())) {
appletRecordDTO.setBookName(Optional.ofNullable(bookDtoMap.get(appletRecordDTO.getBookId())).map(BookDto::getBookName).orElse(""));
appletRecordDTO.setCoverImg(Optional.ofNullable(bookDtoMap.get(appletRecordDTO.getBookId())).map(BookDto::getCoverImg).orElse(""));
}
//填充作品信息
fillProduct4Record(productDtoMap, productDtoMapFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.APP.value, appletRecordDTO.getRecordType())) {
if ("ANSWER".equals(appletRecordDTO.getTypeCode())) {
appletRecordDTO.setBookName(Optional.ofNullable(bookDtoMap.get(appletRecordDTO.getBookId())).map(BookDto::getBookName).orElse(""));
appletRecordDTO.setCoverImg(Optional.ofNullable(bookDtoMap.get(appletRecordDTO.getBookId())).map(BookDto::getCoverImg).orElse(""));
}
//填充应用信息
fillApp4Record(appDtoMap, appDtoMappFuture, appletRecordDTO);
} else if (Objects.equals(AppletRecordTypeEnum.BOOK.value, appletRecordDTO.getRecordType())) {
......
......@@ -5,28 +5,31 @@ import cn.hutool.core.map.MapUtil;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.app.dto.AppTypeDto;
import com.pcloud.appcenter.app.entity.AppType;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.ServeCollectBiz;
import com.pcloud.book.applet.dao.ServeCollectDao;
import com.pcloud.book.applet.dto.*;
import com.pcloud.book.applet.dto.AppletAppOrProductDTO;
import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.dto.AppletTaskDTO;
import com.pcloud.book.applet.dto.CollectionTypeNameAndCountDTO;
import com.pcloud.book.applet.dto.ServeCollectDTO;
import com.pcloud.book.applet.entity.ServeCollect;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.applet.enums.CollectionTypeEnum;
import com.pcloud.book.applet.vo.CollectionTypeNameCodeClassifyVO;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.skill.entity.PcloudResourceItem;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.enums.AppTypeEnum;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
......@@ -35,23 +38,23 @@ import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.readercenter.rmall.constants.RmallContants;
import com.pcloud.readercenter.rmall.entity.RmallBookMoneyRecord;
import com.pcloud.readercenter.rmall.enums.MoneyReceiveTypeEnum;
import com.pcloud.readercenter.rmall.service.RmallBookMoneyRecordService;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.ProductTypeDto;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pcloud.readercenter.rmall.service.RmallBookMoneyRecordService;
import com.pcloud.readercenter.rmall.entity.RmallBookMoneyRecord;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
......@@ -83,6 +86,8 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
private RmallBookMoneyRecordService rmallBookMoneyRecordService;
@Autowired
private ReaderConsr readerConsr;
@Autowired
private BookDao bookDao;
@Override
......@@ -108,18 +113,30 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
}
private void fillServes(List<ServeCollect> recordList) {
List<Long> serveIds = recordList.stream().map(e -> e.getServeId()).collect(Collectors.toList());
List<Long> serveIds = recordList.stream().map(ServeCollect::getServeId).collect(Collectors.toList());
if (ListUtils.isEmpty(serveIds)) {
return;
}
//根据不同的类型填充不同的数据
List<Long> newsIds = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.NEWS.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).distinct().collect(Collectors.toList());
map(ServeCollect::getServeId).distinct().collect(Collectors.toList());
List<Long> productIds = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.PRODUCT.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).distinct().collect(Collectors.toList());
map(ServeCollect::getServeId).distinct().collect(Collectors.toList());
List<Long> appIds = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.APP.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).distinct().collect(Collectors.toList());
map(ServeCollect::getServeId).distinct().collect(Collectors.toList());
List<Long> bookIds = recordList.stream().filter(serveCollect ->
AppletRecordTypeEnum.APP.value.equals(serveCollect.getServeType()) || AppletRecordTypeEnum.PRODUCT.value.equals(serveCollect.getServeType())
).map(ServeCollect::getBookId).distinct().collect(Collectors.toList());
Map<Long, BookDto> bookDtoMap;
CompletableFuture<Map<Long, BookDto>> bookDtoMapFuture = null;
if (CollUtil.isNotEmpty(bookIds)) {
bookDtoMapFuture = CompletableFuture.supplyAsync(() ->
Optional.ofNullable(bookDao.getMapByIds(bookIds)).orElse(new HashMap<>()), ThreadPoolUtils.FILL_APPLET_RECORD);
}
//资源map
Map<Long, AppletNewsDTO> newsDtoMap = new HashMap<>();
Future<Map<Long, AppletNewsDTO>> newsDtoMapFuture = null;
......@@ -137,6 +154,16 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
appDtoMappFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appConsr.mapByIds4AuditPass(appIds));
}
bookDtoMap = Optional.ofNullable(bookDtoMapFuture).map(future -> {
Map<Long, BookDto> map = null;
try {
map = future.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.warn("[AppletRecordBizImpl.fillAppletRecord] 异步获取图书信息失败", e);
}
return map;
}).orElse(new HashMap<>());
//存储已经删除群的群分类; 精选文章类型并且跳转链接包含qrcode.5rs.me
Iterator<ServeCollect> iterator = recordList.iterator();
while (iterator.hasNext()) {
......@@ -145,9 +172,17 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
//填充资讯信息
filllAppletNews4Collect(newsDtoMap, newsDtoMapFuture, serveCollect);
} else if (Objects.equals(AppletRecordTypeEnum.PRODUCT.value, serveCollect.getServeType())) {
if ("ANSWER".equals(serveCollect.getServeTypeCode())) {
serveCollect.setBookName(Optional.ofNullable(bookDtoMap.get(serveCollect.getBookId())).map(BookDto::getBookName).orElse(""));
serveCollect.setCoverImg(Optional.ofNullable(bookDtoMap.get(serveCollect.getBookId())).map(BookDto::getCoverImg).orElse(""));
}
//填充作品信息
fillProduct4Collect(productDtoMap, productDtoMapFuture, serveCollect);
} else if (Objects.equals(AppletRecordTypeEnum.APP.value, serveCollect.getServeType())) {
if ("ANSWER".equals(serveCollect.getServeTypeCode())) {
serveCollect.setBookName(Optional.ofNullable(bookDtoMap.get(serveCollect.getBookId())).map(BookDto::getBookName).orElse(""));
serveCollect.setCoverImg(Optional.ofNullable(bookDtoMap.get(serveCollect.getBookId())).map(BookDto::getCoverImg).orElse(""));
}
//填充应用信息
fillApp4Collect(appDtoMap, appDtoMappFuture, serveCollect);
}
......
......@@ -93,4 +93,10 @@ public class AppletRecordDTO {
@ApiModelProperty("应用、作品类型或资讯来源名称")
private String typeName;
@ApiModelProperty("书名")
private String bookName;
@ApiModelProperty("图书封面")
private String coverImg;
}
package com.pcloud.book.applet.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 小程序埋点信息
*
* @author guiq
* @version 1.0
* @since 2021年2月5日
*/
@Data
@ApiModel("小程序埋点信息")
public class AppletTrackDTO {
@ApiModelProperty("页面")
private String page;
@ApiModelProperty("埋点类型")
private String trackType;
@ApiModelProperty("埋点元素名称")
private String elementName;
@ApiModelProperty("额外的业务参数json字符串形式")
private String extJson;
@ApiModelProperty("小程序版本信息")
private String version;
@ApiModelProperty("备注")
private String remark;
}
package com.pcloud.book.applet.entity;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* applet_track
* @author
*/
@Data
public class AppletTrack implements Serializable {
/**
* PrimaryKey
*/
private Long id;
/**
* 用户ID
*/
private Long wechatUserId;
/**
* official_accounts_id
*/
private Long officialAccountsId;
/**
* 页面信息
*/
private String page;
/**
* 埋点类型
*/
private String trackType;
/**
* 元素名称
*/
private String elementName;
/**
* 扩展参数json串
*/
private String extJson;
/**
* 版本信息
*/
private String version;
/**
* 备注信息
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -6,7 +6,6 @@ import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds;
import java.util.Date;
......@@ -65,5 +64,19 @@ public class ServeCollect extends BaseEntity {
private AppletNewsDTO appletNewsDTO;
@ApiModelProperty("图书ID")
private Long bookId;
@ApiModelProperty("渠道ID")
private Long channelId;
@ApiModelProperty("编辑ID")
private Long adviserId;
@ApiModelProperty("书名")
private String bookName;
@ApiModelProperty("封面")
private String coverImg;
}
\ No newline at end of file
......@@ -3,10 +3,12 @@ package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.biz.AppletRecordBiz;
import com.pcloud.book.applet.dto.AddFootstepDto;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletTrackDTO;
import com.pcloud.book.applet.dto.ReadBookRecordDTO;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.book.applet.vo.AppletRecordQueryVO;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
......@@ -142,5 +144,16 @@ public class AppletRecordFacade {
return new ResponseDto<>();
}
@ApiOperation("小程序信息埋点接口")
@PostMapping("/track")
public ResponseDto<Void> track(@CookieValue("userInfo") String userInfo,
@RequestBody AppletTrackDTO trackDTO){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
Long officialAccountsId = Cookie.getId(userInfo, Cookie._OFFICIAL_ACCOUNTS_ID);
ThreadPoolUtils.OTHER_POOL.execute(()->{
appletRecordBiz.track(wechatUserId, officialAccountsId, trackDTO);
});
return new ResponseDto<>();
}
}
\ No newline at end of file
package com.pcloud.book.applet.mapper;
import com.pcloud.book.applet.entity.AppletTrack;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
@Mapper
@Component
public interface AppletTrackMapper {
int deleteByPrimaryKey(Long id);
int insert(AppletTrack record);
int insertSelective(AppletTrack record);
AppletTrack selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AppletTrack record);
int updateByPrimaryKey(AppletTrack record);
}
\ No newline at end of file
......@@ -42,7 +42,7 @@
</insert>
<select id="getAggrStatis" resultType="com.pcloud.book.applet.dto.AppletRecordDTO">
SELECT record_type recordType, from_id fromId, any(from_name) fromName, any(link_url) linkUrl,
SELECT record_type recordType, from_id fromId, any(from_name) fromName, any(link_url) linkUrl, any(book_id) bookId, any(type_code) typeCode,
COUNT(id) clickCount, COUNT(DISTINCT wechat_user_id) userCount
FROM applet_record
<where>
......
<?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.mapper.AppletTrackMapper">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletTrack">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="wechat_user_id" jdbcType="BIGINT" property="wechatUserId" />
<result column="official_accounts_id" jdbcType="BIGINT" property="officialAccountsId" />
<result column="page" jdbcType="VARCHAR" property="page" />
<result column="track_type" jdbcType="VARCHAR" property="trackType" />
<result column="element_name" jdbcType="VARCHAR" property="elementName" />
<result column="ext_json" jdbcType="VARCHAR" property="extJson" />
<result column="version" jdbcType="VARCHAR" property="version" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, wechat_user_id, official_accounts_id, page, track_type, element_name, ext_json,
version, remark, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from applet_track
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from applet_track
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.applet.entity.AppletTrack" useGeneratedKeys="true">
insert into applet_track (wechat_user_id, official_accounts_id, page,
track_type, element_name, ext_json,
version, remark, create_time
)
values (#{wechatUserId,jdbcType=BIGINT}, #{officialAccountsId,jdbcType=BIGINT}, #{page,jdbcType=VARCHAR},
#{trackType,jdbcType=VARCHAR}, #{elementName,jdbcType=VARCHAR}, #{extJson,jdbcType=VARCHAR},
#{version,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, NOW()
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.applet.entity.AppletTrack" useGeneratedKeys="true">
insert into applet_track
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="wechatUserId != null">
wechat_user_id,
</if>
<if test="officialAccountsId != null">
official_accounts_id,
</if>
<if test="page != null">
page,
</if>
<if test="trackType != null">
track_type,
</if>
<if test="elementName != null">
element_name,
</if>
<if test="extJson != null">
ext_json,
</if>
<if test="version != null">
version,
</if>
<if test="remark != null">
remark,
</if>
create_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="wechatUserId != null">
#{wechatUserId,jdbcType=BIGINT},
</if>
<if test="officialAccountsId != null">
#{officialAccountsId,jdbcType=BIGINT},
</if>
<if test="page != null">
#{page,jdbcType=VARCHAR},
</if>
<if test="trackType != null">
#{trackType,jdbcType=VARCHAR},
</if>
<if test="elementName != null">
#{elementName,jdbcType=VARCHAR},
</if>
<if test="extJson != null">
#{extJson,jdbcType=VARCHAR},
</if>
<if test="version != null">
#{version,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
NOW()
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.applet.entity.AppletTrack">
update applet_track
<set>
<if test="wechatUserId != null">
wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
</if>
<if test="officialAccountsId != null">
official_accounts_id = #{officialAccountsId,jdbcType=BIGINT},
</if>
<if test="page != null">
page = #{page,jdbcType=VARCHAR},
</if>
<if test="trackType != null">
track_type = #{trackType,jdbcType=VARCHAR},
</if>
<if test="elementName != null">
element_name = #{elementName,jdbcType=VARCHAR},
</if>
<if test="extJson != null">
ext_json = #{extJson,jdbcType=VARCHAR},
</if>
<if test="version != null">
version = #{version,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.applet.entity.AppletTrack">
update applet_track
set wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
official_accounts_id = #{officialAccountsId,jdbcType=BIGINT},
page = #{page,jdbcType=VARCHAR},
track_type = #{trackType,jdbcType=VARCHAR},
element_name = #{elementName,jdbcType=VARCHAR},
ext_json = #{extJson,jdbcType=VARCHAR},
version = #{version,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
......@@ -17,6 +17,9 @@
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="collect_day" property="collectDay" jdbcType="DATE"/>
<result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
</resultMap>
<resultMap id="BaseResultMap4DTO" type="com.pcloud.book.applet.dto.ServeCollectDTO">
......@@ -32,11 +35,14 @@
<result column="is_delete" property="isDelete" jdbcType="INTEGER"/>
<result column="collect_day" property="collectDay" jdbcType="DATE"/>
<result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
id, wechat_user_id, serve_id, serve_name,serve_type, serve_code,serve_type_code ,serve_type_name, link_url, is_delete, create_time, update_time, collect_day,
pic_url
pic_url, book_id, adviser_id, channel_id
</sql>
<select id="getById" resultMap="BaseResultMap">
......@@ -74,7 +80,10 @@
is_delete,
create_time,
update_time,
collect_day
collect_day,
book_id,
adviser_id,
channel_id
) VALUES (
#{wechatUserId, jdbcType=BIGINT},
#{serveId, jdbcType=BIGINT},
......@@ -87,11 +96,17 @@
#{isDelete, jdbcType=INTEGER},
now(),
now(),
CURDATE()
CURDATE(),
#{bookId, jdbcType=BIGINT},
#{adviserId, jdbcType=BIGINT},
#{channelId, jdbcType=BIGINT}
) on duplicate key
update
update_time = now(),
collect_day = CURDATE()
collect_day = CURDATE(),
book_id =#{bookId, jdbcType=BIGINT},
adviser_id =#{adviserId, jdbcType=BIGINT},
channel_id =#{channelId, jdbcType=BIGINT}
<if test="isDelete != null">
, is_delete = #{isDelete}
</if>
......@@ -107,7 +122,10 @@
is_delete,
create_time,
update_time,
collect_day
collect_day,
book_id,
adviser_id,
channel_id
) VALUES
<foreach collection="list" item="item" separator=",">
(
......@@ -119,7 +137,10 @@
#{item.isDelete, jdbcType=INTEGER},
now(),
now(),
CURDATE()
CURDATE(),
#{bookId, jdbcType=BIGINT},
#{adviserId, jdbcType=BIGINT},
#{channelId, jdbcType=BIGINT}
)
</foreach>
</insert>
......
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