Commit 6c2dc8e4 by 田超

Merge branch 'feature/1004012' into 'master'

feat:[1004012] 足迹优化

See merge request rays/pcloud-book!1097
parents 91eabff9 ef56613b
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.entity.AppletRecordDayServe;
import com.pcloud.common.page.PageBeanNew;
/**
* (AppletRecordDayServe)表服务接口
*
* @author makejava
* @since 2020-12-09 16:04:08
*/
public interface AppletRecordDayServeBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
AppletRecordDayServe getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param appletRecordDayServe 实例对象
* @return 主键
*/
Long insert(AppletRecordDayServe appletRecordDayServe);
/**
* 修改数据
*
* @param appletRecordDayServe 实例对象
*/
void update(AppletRecordDayServe appletRecordDayServe);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
}
\ No newline at end of file
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.entity.AppletRecordServe;
import com.pcloud.common.page.PageBeanNew;
/**
* (AppletRecordServe)表服务接口
*
* @author makejava
* @since 2020-12-09 16:04:32
*/
public interface AppletRecordServeBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
AppletRecordServe getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param appletRecordServe 实例对象
* @return 主键
*/
Long insert(AppletRecordServe appletRecordServe);
/**
* 修改数据
*
* @param appletRecordServe 实例对象
*/
void update(AppletRecordServe appletRecordServe);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
}
\ No newline at end of file
......@@ -11,6 +11,8 @@ import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.AppletRecordBiz;
import com.pcloud.book.applet.dao.AppletBooklistDao;
import com.pcloud.book.applet.dao.AppletRecordDao;
import com.pcloud.book.applet.dao.AppletRecordDayServeDao;
import com.pcloud.book.applet.dao.AppletRecordServeDao;
import com.pcloud.book.applet.dto.AppletAppOrProductDTO;
import com.pcloud.book.applet.dto.AppletBooklistDTO;
import com.pcloud.book.applet.dto.AppletNewsDTO;
......@@ -19,6 +21,8 @@ import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.dto.BookDTO4Booklist;
import com.pcloud.book.applet.entity.AppletRecord;
import com.pcloud.book.applet.entity.AppletRecordDayServe;
import com.pcloud.book.applet.entity.AppletRecordServe;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.app.AppConsr;
......@@ -35,6 +39,7 @@ import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.BeanUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.string.StringUtil;
......@@ -44,6 +49,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
......@@ -86,6 +92,10 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired
private AppletBooklistDao appletBooklistDao;
@Autowired
private AppletRecordDayServeDao appletRecordDayServeDao;
@Autowired
private AppletRecordServeDao appletRecordServeDao;
@Override
@ParamLog("通过ID查询单条数据")
......@@ -108,9 +118,34 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
@Override
@ParamLog("新增足迹埋点")
@Transactional(rollbackFor = Exception.class)
public Long insert(AppletRecord appletRecord) {
insertCheck(appletRecord);
appletRecordDao.insert(appletRecord);
//判断日表是否有数据
AppletRecordDayServe appletRecordDayServe = new AppletRecordDayServe();
BeanUtils.copyProperties(appletRecord, appletRecordDayServe);
AppletRecordServe appletRecordServe = new AppletRecordServe();
BeanUtils.copyProperties(appletRecord, appletRecordServe);
AppletRecordDayServe appletRecordDayServe4Data = appletRecordDayServeDao.getByTypeAndServeId(appletRecord.getWechatUserId(), appletRecord.getRecordType(), appletRecord.getFromId(), DateUtil.today());
if (null != appletRecordDayServe4Data) {
//更新
appletRecordDayServe.setId(appletRecordDayServe4Data.getId());
appletRecordDayServeDao.update(appletRecordDayServe);
}else {
//新增
appletRecordDayServeDao.insert(appletRecordDayServe);
}
//判断总表是否有数据
AppletRecordServe appletRecordServe4Data = appletRecordServeDao.getByTypeAndServeId(appletRecord.getWechatUserId(), appletRecord.getRecordType(), appletRecord.getFromId());
if (null != appletRecordServe4Data) {
//更新
appletRecordServe.setId(appletRecordServe4Data.getId());
appletRecordServeDao.update(appletRecordServe);
}else {
//新增
appletRecordServeDao.insert(appletRecordServe);
}
return appletRecord.getId();
}
......@@ -149,14 +184,27 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
@ParamLog(value = "我的足迹", isAfterReturn = false)
public PageBeanNew<AppletRecordDTO> listAppletRecord(Long wechatUserId, String date, List<Integer> recordTypes, String queryName,
Integer currentPage, Integer numPerPage) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserId", wechatUserId);
paramMap.put("date", date);
paramMap.put("recordTypes", recordTypes);
paramMap.put("queryName", queryName);
PageBeanNew<AppletRecordDTO> listAppletRecord = appletRecordDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listAppletRecord");
List<AppletRecordDTO> recordList = listAppletRecord.getRecordList();
fillAppletRecord(recordList);
List<AppletRecordDTO> recordList = null;
PageBeanNew<AppletRecordDTO> listAppletRecord = new PageBeanNew<>();
Integer bookType = null;
if (StringUtil.isEmpty(date)) {
//从总表中查
listAppletRecord = appletRecordServeDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listAppletRecord");
bookType = YesOrNoNumEnum.NO.getValue();
} else {
//从天表中查
paramMap.put("date", date);
listAppletRecord = appletRecordDayServeDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listAppletRecord");
bookType = YesOrNoNumEnum.YES.getValue();
}
recordList = listAppletRecord.getRecordList();
fillAppletRecord(recordList, bookType);
return listAppletRecord;
}
......@@ -173,7 +221,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
return dateTimes.stream().filter(x -> !collect.contains(DateUtil.beginOfDay(x))).map(x -> DateUtil.format(x, DatePattern.NORM_DATE_FORMAT)).collect(Collectors.toList());
}
private void fillAppletRecord(List<AppletRecordDTO> recordList) {
private void fillAppletRecord(List<AppletRecordDTO> recordList, Integer bookType) {
if (ListUtils.isEmpty(recordList)) {
return;
}
......@@ -234,8 +282,10 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
if (!ListUtils.isEmpty(appIds)) {
appDtoMappFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appConsr.mapByIds4AuditPass(appIds));
}
if (!ListUtils.isEmpty(appletRecordDTOS4Book)) {
appletUserBookcaseDTOMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletRecordDao.getBookMap(appletRecordDTOS4Book));
if (!ListUtils.isEmpty(appletRecordDTOS4Book) && YesOrNoNumEnum.NO.getValue().equals(bookType)) {
appletUserBookcaseDTOMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletRecordServeDao.getBookMap(appletRecordDTOS4Book));
} else if (!ListUtils.isEmpty(appletRecordDTOS4Book) && YesOrNoNumEnum.YES.getValue().equals(bookType)){
appletUserBookcaseDTOMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletRecordDayServeDao.getBookMap(appletRecordDTOS4Book));
}
if (!ListUtils.isEmpty(bookRecommendIds)) {
appletOuterBooklistDTOMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletBooklistBiz.getByIds(bookRecommendIds));
......
package com.pcloud.book.applet.biz.impl;
import com.pcloud.book.applet.biz.AppletRecordDayServeBiz;
import com.pcloud.book.applet.dao.AppletRecordDayServeDao;
import com.pcloud.book.applet.entity.AppletRecordDayServe;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* (AppletRecordDayServe)表服务实现类
*
* @author makejava
* @since 2020-12-09 16:04:08
*/
@Service("appletRecordDayServeBiz")
public class AppletRecordDayServeBizImpl implements AppletRecordDayServeBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(AppletRecordDayServeBizImpl.class);
@Autowired
private AppletRecordDayServeDao appletRecordDayServeDao;
@Override
@ParamLog("通过ID查询单条数据")
public AppletRecordDayServe getById(Long id) {
return appletRecordDayServeDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Integer currentPage, Integer numPerPage) {
PageBeanNew pageBeanNew = appletRecordDayServeDao.listPageNew(new PageParam(currentPage, numPerPage), null, "getList");
List recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)) {
return pageBeanNew;
}
// 加载其它数据
return pageBeanNew;
}
@Override
@ParamLog("新增")
public Long insert(AppletRecordDayServe appletRecordDayServe) {
appletRecordDayServeDao.insert(appletRecordDayServe);
return appletRecordDayServe.getId();
}
@Override
@ParamLog("修改")
public void update(AppletRecordDayServe appletRecordDayServe) {
if (appletRecordDayServe == null || !NumberUtil.isNumber(appletRecordDayServe.getId())) {
throw BizException.PARAM_IS_NULL;
}
appletRecordDayServeDao.update(appletRecordDayServe);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
appletRecordDayServeDao.deleteById(id);
}
}
\ No newline at end of file
package com.pcloud.book.applet.biz.impl;
import com.pcloud.book.applet.biz.AppletRecordServeBiz;
import com.pcloud.book.applet.dao.AppletRecordServeDao;
import com.pcloud.book.applet.entity.AppletRecordServe;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* (AppletRecordServe)表服务实现类
*
* @author makejava
* @since 2020-12-09 16:04:33
*/
@Service("appletRecordServeBiz")
public class AppletRecordServeBizImpl implements AppletRecordServeBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(AppletRecordServeBizImpl.class);
@Autowired
private AppletRecordServeDao appletRecordServeDao;
@Override
@ParamLog("通过ID查询单条数据")
public AppletRecordServe getById(Long id) {
return appletRecordServeDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Integer currentPage, Integer numPerPage) {
PageBeanNew pageBeanNew = appletRecordServeDao.listPageNew(new PageParam(currentPage, numPerPage), null, "getList");
List recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)) {
return pageBeanNew;
}
// 加载其它数据
return pageBeanNew;
}
@Override
@ParamLog("新增")
public Long insert(AppletRecordServe appletRecordServe) {
appletRecordServeDao.insert(appletRecordServe);
return appletRecordServe.getId();
}
@Override
@ParamLog("修改")
public void update(AppletRecordServe appletRecordServe) {
if (appletRecordServe == null || !NumberUtil.isNumber(appletRecordServe.getId())) {
throw BizException.PARAM_IS_NULL;
}
appletRecordServeDao.update(appletRecordServe);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
appletRecordServeDao.deleteById(id);
}
}
\ No newline at end of file
package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.entity.AppletRecordDayServe;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* (AppletRecordDayServe)表数据库访问层
*
* @author makejava
* @since 2020-12-09 16:04:08
*/
public interface AppletRecordDayServeDao extends BaseDao<AppletRecordDayServe> {
/**
* 查询数据是否存在
* @param wechatUserId
* @param recordType
* @param fromId
* @param today
* @return
*/
AppletRecordDayServe getByTypeAndServeId(Long wechatUserId, Integer recordType, Long fromId, String today);
Map<Long, AppletUserBookcaseDTO> getBookMap(List<AppletRecordDTO> appletRecordDTOS4Book);
}
\ No newline at end of file
package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.entity.AppletRecordServe;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* (AppletRecordServe)表数据库访问层
*
* @author makejava
* @since 2020-12-09 16:04:32
*/
public interface AppletRecordServeDao extends BaseDao<AppletRecordServe> {
AppletRecordServe getByTypeAndServeId(Long wechatUserId, Integer recordType, Long fromId);
Map<Long, AppletUserBookcaseDTO> getBookMap(List<AppletRecordDTO> appletRecordDTOS4Book);
}
\ No newline at end of file
package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.AppletRecordDayServeDao;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.entity.AppletRecordDayServe;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* (AppletRecordDayServe)表数据库访问层
*
* @author makejava
* @since 2020-12-09 16:04:08
*/
@Repository("appletRecordDayServeDaoImpl")
public class AppletRecordDayServeDaoImpl extends BaseDaoImpl<AppletRecordDayServe> implements AppletRecordDayServeDao {
@Override
public AppletRecordDayServe getByTypeAndServeId(Long wechatUserId, Integer recordType, Long fromId, String today) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserId", wechatUserId);
paramMap.put("createDate", today);
paramMap.put("recordType", recordType);
paramMap.put("fromId", fromId);
return getSessionTemplate().selectOne(getStatement("getByTypeAndServeId"), paramMap);
}
@Override
public Map<Long, AppletUserBookcaseDTO> getBookMap(List<AppletRecordDTO> appletRecordDTOS4Book) {
return getSessionTemplate().selectMap(getStatement("getBookMap"), appletRecordDTOS4Book, "id");
}
}
\ No newline at end of file
package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.AppletRecordServeDao;
import com.pcloud.book.applet.dto.AppletRecordDTO;
import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.entity.AppletRecordServe;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* (AppletRecordServe)表数据库访问层
*
* @author makejava
* @since 2020-12-09 16:04:32
*/
@Repository("appletRecordServeDaoImpl")
public class AppletRecordServeDaoImpl extends BaseDaoImpl<AppletRecordServe> implements AppletRecordServeDao {
@Override
public AppletRecordServe getByTypeAndServeId(Long wechatUserId, Integer recordType, Long fromId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserId", wechatUserId);
paramMap.put("recordType", recordType);
paramMap.put("fromId", fromId);
return getSessionTemplate().selectOne(getStatement("getByTypeAndServeId"), paramMap);
}
@Override
public Map<Long, AppletUserBookcaseDTO> getBookMap(List<AppletRecordDTO> appletRecordDTOS4Book) {
return getSessionTemplate().selectMap(getStatement("getBookMap"), appletRecordDTOS4Book, "id");
}
}
\ No newline at end of file
package com.pcloud.book.applet.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* (AppletRecordDayServe)实体类
*
* @author makejava
* @since 2020-12-09 16:04:07
*/
@Data
public class AppletRecordDayServe extends BaseEntity {
private static final long serialVersionUID = -73199055227905231L;
private Long id;
@ApiModelProperty("微信用户id")
private Long wechatUserId;
@ApiModelProperty("1资讯 2编辑群 3 模板群 4第三方群 5 作品 6 应用 7 书刊 8 好书推荐 9 精选书单")
private Integer recordType;
@ApiModelProperty("权益id")
private Long rightsSettingId;
@ApiModelProperty("书籍id")
private Long bookId;
@ApiModelProperty("渠道id")
private Long channelId;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("来源id")
private Long fromId;
@ApiModelProperty("来源名称")
private String fromName;
@ApiModelProperty("跳转链接")
private String linkUrl;
@ApiModelProperty("公众号id")
private Long accountSettingId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createDate;
@ApiModelProperty("是否删除 0 未删除 1删除")
private Integer isDelete;
}
\ No newline at end of file
package com.pcloud.book.applet.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* (AppletRecordServe)实体类
*
* @author makejava
* @since 2020-12-09 16:04:32
*/
@Data
public class AppletRecordServe extends BaseEntity {
private static final long serialVersionUID = -16393062027493056L;
private Long id;
@ApiModelProperty("微信用户id")
private Long wechatUserId;
@ApiModelProperty("1资讯 2编辑群 3 模板群 4第三方群 5 作品 6 应用 7 书刊 8 好书推荐 9 精选书单")
private Integer recordType;
@ApiModelProperty("权益id")
private Long rightsSettingId;
@ApiModelProperty("书籍id")
private Long bookId;
@ApiModelProperty("渠道id")
private Long channelId;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("来源id")
private Long fromId;
@ApiModelProperty("来源名称")
private String fromName;
@ApiModelProperty("跳转链接")
private String linkUrl;
@ApiModelProperty("公众号id")
private Long accountSettingId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createDate;
@ApiModelProperty("是否删除 0 未删除 1删除")
private Integer isDelete;
}
\ No newline at end of file
package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.biz.AppletRecordDayServeBiz;
import com.pcloud.book.applet.entity.AppletRecordDayServe;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* (AppletRecordDayServe)表控制层
*
* @author makejava
* @since 2020-12-09 16:04:08
*/
@RestController("appletRecordDayServeFacade")
@RequestMapping("appletRecordDayServe")
public class AppletRecordDayServeFacade {
@Autowired
private AppletRecordDayServeBiz appletRecordDayServeBiz;
@ApiOperation("通过主键查询单条数据")
@GetMapping("getById")
public ResponseDto<?> getById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletRecordDayServeBiz.getById(id));
}
@ApiOperation("分页查询")
@GetMapping("getList")
public ResponseDto<?> getList(@RequestHeader("token") String token,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletRecordDayServeBiz.getList(currentPage, numPerPage));
}
@ApiOperation("新增")
@PostMapping("insert")
public ResponseDto<?> insert(@RequestHeader("token") String token, @RequestBody AppletRecordDayServe appletRecordDayServe)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletRecordDayServeBiz.insert(appletRecordDayServe));
}
@ApiOperation("更新")
@PostMapping("update")
public ResponseDto<?> update(@RequestHeader("token") String token, @RequestBody AppletRecordDayServe appletRecordDayServe) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
appletRecordDayServeBiz.update(appletRecordDayServe);
return new ResponseDto<>();
}
@ApiOperation("删除")
@GetMapping("deleteById")
public ResponseDto<?> deleteById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
if (null == id) {
throw BookBizException.PARAM_DELETION;
}
appletRecordDayServeBiz.deleteById(id);
return new ResponseDto<>();
}
}
\ No newline at end of file
package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.biz.AppletRecordServeBiz;
import com.pcloud.book.applet.entity.AppletRecordServe;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* (AppletRecordServe)表控制层
*
* @author makejava
* @since 2020-12-09 16:04:33
*/
@RestController("appletRecordServeFacade")
@RequestMapping("appletRecordServe")
public class AppletRecordServeFacade {
@Autowired
private AppletRecordServeBiz appletRecordServeBiz;
@ApiOperation("通过主键查询单条数据")
@GetMapping("getById")
public ResponseDto<?> getById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletRecordServeBiz.getById(id));
}
@ApiOperation("分页查询")
@GetMapping("getList")
public ResponseDto<?> getList(@RequestHeader("token") String token,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletRecordServeBiz.getList(currentPage, numPerPage));
}
@ApiOperation("新增")
@PostMapping("insert")
public ResponseDto<?> insert(@RequestHeader("token") String token, @RequestBody AppletRecordServe appletRecordServe)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletRecordServeBiz.insert(appletRecordServe));
}
@ApiOperation("更新")
@PostMapping("update")
public ResponseDto<?> update(@RequestHeader("token") String token, @RequestBody AppletRecordServe appletRecordServe) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
appletRecordServeBiz.update(appletRecordServe);
return new ResponseDto<>();
}
@ApiOperation("删除")
@GetMapping("deleteById")
public ResponseDto<?> deleteById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
if (null == id) {
throw BookBizException.PARAM_DELETION;
}
appletRecordServeBiz.deleteById(id);
return new ResponseDto<>();
}
}
\ 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.AppletRecordDayServeDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletRecordDayServe">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="record_type" property="recordType" jdbcType="INTEGER"/>
<result column="rights_setting_id" property="rightsSettingId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="from_id" property="fromId" jdbcType="BIGINT"/>
<result column="from_name" property="fromName" jdbcType="VARCHAR"/>
<result column="link_url" property="linkUrl" jdbcType="VARCHAR"/>
<result column="account_setting_id" property="accountSettingId" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="create_date" property="createDate" jdbcType="DATE"/>
<result column="is_delete" property="isDelete" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, wechat_user_id, record_type, rights_setting_id, book_id, channel_id, adviser_id, from_id, from_name, link_url, account_setting_id, create_time, create_date, is_delete
</sql>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_record_day_serve
WHERE id = #{id}
</select>
<select id="getList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_record_day_serve
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_record_day_serve(
wechat_user_id,
record_type,
rights_setting_id,
book_id,
channel_id,
adviser_id,
from_id,
from_name,
link_url,
account_setting_id,
create_time,
create_date
) VALUES (
#{wechatUserId, jdbcType=BIGINT},
#{recordType, jdbcType=INTEGER},
#{rightsSettingId, jdbcType=BIGINT},
#{bookId, jdbcType=BIGINT},
#{channelId, jdbcType=BIGINT},
#{adviserId, jdbcType=BIGINT},
#{fromId, jdbcType=BIGINT},
#{fromName, jdbcType=VARCHAR},
#{linkUrl, jdbcType=VARCHAR},
#{accountSettingId, jdbcType=BIGINT},
now(),
CURRENT_DATE()
)
</insert>
<insert id="batchInsert">
INSERT INTO applet_record_day_serve (
wechat_user_id,
record_type,
rights_setting_id,
book_id,
channel_id,
adviser_id,
from_id,
from_name,
link_url,
account_setting_id,
create_time,
create_date,
is_delete
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.wechatUserId, jdbcType=BIGINT},
#{item.recordType, jdbcType=INTEGER},
#{item.rightsSettingId, jdbcType=BIGINT},
#{item.bookId, jdbcType=BIGINT},
#{item.channelId, jdbcType=BIGINT},
#{item.adviserId, jdbcType=BIGINT},
#{item.fromId, jdbcType=BIGINT},
#{item.fromName, jdbcType=VARCHAR},
#{item.linkUrl, jdbcType=VARCHAR},
#{item.accountSettingId, jdbcType=BIGINT},
#{item.createTime, jdbcType=TIMESTAMP},
#{item.createDate, jdbcType=DATE},
#{item.isDelete, jdbcType=INTEGER}
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
UPDATE applet_record_day_serve
<set>
wechat_user_id = #{wechatUserId},
record_type = #{recordType},
rights_setting_id = #{rightsSettingId},
book_id = #{bookId},
channel_id = #{channelId},
adviser_id = #{adviserId},
from_id = #{fromId},
from_name = #{fromName},
link_url = #{linkUrl},
account_setting_id = #{accountSettingId},
create_time = now()
</set>
WHERE id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
DELETE FROM applet_record_day_serve where id = #{id}
</delete>
<select id="getByTypeAndServeId" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
applet_record_day_serve
where
wechat_user_id = #{wechatUserId}
and
create_date = #{createDate}
and
record_type = #{recordType}
and
from_id = #{fromId}
and
is_delete = 0
limit 1
</select>
<select id="listAppletRecord" parameterType="map" resultMap="com.pcloud.book.applet.dao.impl.AppletRecordDaoImpl.BaseResultMap4DTO">
SELECT
<include refid="Base_Column_List"/>
FROM
`applet_record_day_serve`
WHERE
is_delete = 0
and
wechat_user_id = #{wechatUserId}
and
create_date = #{date}
<if test="recordTypes != null">
and record_type in
<foreach collection="recordTypes" index="index" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
<if test="queryName != null">
and from_name like concat("%",#{queryName},"%")
</if>
ORDER BY
create_time DESC
</select>
<select id="getBookMap" parameterType="list" resultType="com.pcloud.book.applet.dto.AppletUserBookcaseDTO">
SELECT
c.id id,
c.book_id bookId,
c.channel_id channelId,
c.adviser_id adviserId,
b.BOOK_NAME bookName,
b.COVER_IMG coverImg,
b.AUTHOR author,
b.PUBLISH publish,
a.SECOND_TEMPLET_ID secondTempletId,
a.TEMPLET_ID templetId,
d.join_group_type joinGroupType,
d.id bookGroupId,
b.ISBN isbn,
a.GRA_LABEL_ID gradeLabelId,
a.SUB_LABEL_ID subjectLabelId,
a.vol_label_id volLabelId,
IF(d.join_group_type=1 OR d.related_book_group_id>0,1,0) hasGroup,
r.id rightsSettingId,
r.count rightsSettingCount
FROM applet_record_day_serve c
LEFT JOIN BOOK_ADVISER a ON c.book_id=a.BOOK_ID AND c.adviser_id=a.ADVISER_ID
AND c.channel_id=a.CHANNEL_ID
INNER JOIN BOOK b ON c.BOOK_ID = b.BOOK_ID AND b.IS_DELETE = 0
LEFT JOIN book_group d ON d.BOOK_ID = a.BOOK_ID
AND d.create_user = c.adviser_id
AND d.channel_id = c.channel_id
AND d.IS_DELETE = 0
LEFT JOIN rights_setting r ON c.rights_setting_id = r.id AND d.join_group_type=4 and r.show_state = 1 and r.rights_setting_type = 2
WHERE
a.IS_DELETE = 0
and
c.is_delete = 0
and
c.id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</select>
</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.AppletRecordServeDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletRecordServe">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="record_type" property="recordType" jdbcType="INTEGER"/>
<result column="rights_setting_id" property="rightsSettingId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="from_id" property="fromId" jdbcType="BIGINT"/>
<result column="from_name" property="fromName" jdbcType="VARCHAR"/>
<result column="link_url" property="linkUrl" jdbcType="VARCHAR"/>
<result column="account_setting_id" property="accountSettingId" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="create_date" property="createDate" jdbcType="DATE"/>
<result column="is_delete" property="isDelete" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, wechat_user_id, record_type, rights_setting_id, book_id, channel_id, adviser_id, from_id, from_name, link_url, account_setting_id, create_time, create_date, is_delete
</sql>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_record_serve
WHERE id = #{id}
</select>
<select id="getList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_record_serve
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_record_serve(
wechat_user_id,
record_type,
rights_setting_id,
book_id,
channel_id,
adviser_id,
from_id,
from_name,
link_url,
account_setting_id,
create_time,
create_date
) VALUES (
#{wechatUserId, jdbcType=BIGINT},
#{recordType, jdbcType=INTEGER},
#{rightsSettingId, jdbcType=BIGINT},
#{bookId, jdbcType=BIGINT},
#{channelId, jdbcType=BIGINT},
#{adviserId, jdbcType=BIGINT},
#{fromId, jdbcType=BIGINT},
#{fromName, jdbcType=VARCHAR},
#{linkUrl, jdbcType=VARCHAR},
#{accountSettingId, jdbcType=BIGINT},
now(),
CURRENT_DATE()
)
</insert>
<insert id="batchInsert">
INSERT INTO applet_record_serve (
wechat_user_id,
record_type,
rights_setting_id,
book_id,
channel_id,
adviser_id,
from_id,
from_name,
link_url,
account_setting_id,
create_time,
create_date,
is_delete
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.wechatUserId, jdbcType=BIGINT},
#{item.recordType, jdbcType=INTEGER},
#{item.rightsSettingId, jdbcType=BIGINT},
#{item.bookId, jdbcType=BIGINT},
#{item.channelId, jdbcType=BIGINT},
#{item.adviserId, jdbcType=BIGINT},
#{item.fromId, jdbcType=BIGINT},
#{item.fromName, jdbcType=VARCHAR},
#{item.linkUrl, jdbcType=VARCHAR},
#{item.accountSettingId, jdbcType=BIGINT},
#{item.createTime, jdbcType=TIMESTAMP},
#{item.createDate, jdbcType=DATE},
#{item.isDelete, jdbcType=INTEGER}
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
UPDATE applet_record_serve
<set>
wechat_user_id = #{wechatUserId},
record_type = #{recordType},
rights_setting_id = #{rightsSettingId},
book_id = #{bookId},
channel_id = #{channelId},
adviser_id = #{adviserId},
from_id = #{fromId},
from_name = #{fromName},
link_url = #{linkUrl},
account_setting_id = #{accountSettingId},
create_time = now(),
create_date = CURRENT_DATE()
</set>
WHERE id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
DELETE FROM applet_record_serve where id = #{id}
</delete>
<select id="getByTypeAndServeId" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
applet_record_serve
where
wechat_user_id = #{wechatUserId}
and
record_type = #{recordType}
and
from_id = #{fromId}
and
is_delete = 0
limit 1
</select>
<select id="listAppletRecord" parameterType="map" resultMap="com.pcloud.book.applet.dao.impl.AppletRecordDaoImpl.BaseResultMap4DTO">
SELECT
<include refid="Base_Column_List"/>
FROM
`applet_record_serve`
WHERE
is_delete = 0
and
wechat_user_id = #{wechatUserId}
<if test="recordTypes != null">
and record_type in
<foreach collection="recordTypes" index="index" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
and
create_date &gt; DATE_SUB(curdate(),INTERVAL 30 day)
<if test="queryName != null">
and from_name like concat("%",#{queryName},"%")
</if>
ORDER BY
create_time DESC
</select>
<select id="getBookMap" parameterType="list" resultType="com.pcloud.book.applet.dto.AppletUserBookcaseDTO">
SELECT
c.id id,
c.book_id bookId,
c.channel_id channelId,
c.adviser_id adviserId,
b.BOOK_NAME bookName,
b.COVER_IMG coverImg,
b.AUTHOR author,
b.PUBLISH publish,
a.SECOND_TEMPLET_ID secondTempletId,
a.TEMPLET_ID templetId,
d.join_group_type joinGroupType,
d.id bookGroupId,
b.ISBN isbn,
a.GRA_LABEL_ID gradeLabelId,
a.SUB_LABEL_ID subjectLabelId,
a.vol_label_id volLabelId,
IF(d.join_group_type=1 OR d.related_book_group_id>0,1,0) hasGroup,
r.id rightsSettingId,
r.count rightsSettingCount
FROM applet_record_serve c
LEFT JOIN BOOK_ADVISER a ON c.book_id=a.BOOK_ID AND c.adviser_id=a.ADVISER_ID
AND c.channel_id=a.CHANNEL_ID
INNER JOIN BOOK b ON c.BOOK_ID = b.BOOK_ID AND b.IS_DELETE = 0
LEFT JOIN book_group d ON d.BOOK_ID = a.BOOK_ID
AND d.create_user = c.adviser_id
AND d.channel_id = c.channel_id
AND d.IS_DELETE = 0
LEFT JOIN rights_setting r ON c.rights_setting_id = r.id AND d.join_group_type=4 and r.show_state = 1 and r.rights_setting_type = 2
WHERE
a.IS_DELETE = 0
and
c.is_delete = 0
and
c.id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</select>
</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