Commit a3f2d6b4 by 吴博

1002655服务期推送

parent 3ea9516c
......@@ -210,6 +210,13 @@
</dependency>
<dependency>
<groupId>com.pcloud.facade</groupId>
<artifactId>pcloud-facade-erp</artifactId>
<version>${pcloud-facade.version}</version>
</dependency>
<dependency>
<groupId>fakepath</groupId>
<artifactId>jbarcode</artifactId>
<version>0.2.8</version>
......@@ -298,6 +305,7 @@
<artifactId>sentry-logback</artifactId>
<version>1.7.30</version>
</dependency>
</dependencies>
<build>
......
package com.pcloud.book.custom.biz;
import com.pcloud.book.custom.dto.CustomTimeControlDTO;
import com.pcloud.book.custom.dto.CustomTimeControlPageDTO;
import com.pcloud.common.page.PageBeanNew;
public interface CustomTimeControlBiz {
Integer createCustomTimeControl(CustomTimeControlDTO customTimeControlDTO);
void updateCustomTimeControl(CustomTimeControlDTO customTimeControlDTO);
PageBeanNew<CustomTimeControlPageDTO> getCustomTimeControlPage(String taskName, Integer currentPage, Integer numPerPage);
CustomTimeControlDTO getCustomTimeControlById(Integer id);
void deleteCustomTimeControlById(Integer id);
}
package com.pcloud.book.custom.biz.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.custom.biz.CustomTimeControlBiz;
import com.pcloud.book.custom.check.CustomCheck;
import com.pcloud.book.custom.dao.CustomTimeControlDao;
import com.pcloud.book.custom.dto.CustomTimeControlDTO;
import com.pcloud.book.custom.dto.CustomTimeControlPageDTO;
import com.pcloud.book.custom.entity.CustomTimeControl;
import com.pcloud.book.custom.entity.CustomTimeControlBook;
import com.pcloud.book.custom.entity.CustomTimeControlReply;
import com.pcloud.book.custom.mapper.CustomTimeControlBookMapper;
import com.pcloud.book.custom.mapper.CustomTimeControlReplyMapper;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.erp.project.dto.ProjectInfoDTO;
import com.pcloud.erp.project.service.ProjectService;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
@Component
@Slf4j
public class CustomTimeControlBizImpl implements CustomTimeControlBiz {
@Autowired
private CustomTimeControlDao customTimeControlMapper;
@Autowired
private CustomTimeControlBookMapper customTimeControlBookMapper;
@Autowired
private CustomTimeControlReplyMapper customTimeControlReplyMapper;
@Autowired
private CustomCheck customCheck;
@Autowired
private ProjectService projectService;
@Override
@Transactional
@ParamLog("新增定制服务读书计划")
public Integer createCustomTimeControl(CustomTimeControlDTO customTimeControlDTO) {
customCheck.createCustomTimeControlCheck(customTimeControlDTO);
Integer id = insertCustomTimeControl(customTimeControlDTO.getTimeControlTaskId());
if (null == id){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"定制读书计划id不能为空!");
}
insertCustomTimeControlReply(id,customTimeControlDTO.getReplyList4Subscribe(),customTimeControlDTO.getReplyList4Unsubscribe());
insertCustomTimeControlBook(id,customTimeControlDTO.getRelatedBooks());
return id;
}
private void insertCustomTimeControlBook(Integer id, List<CustomTimeControlBook> relatedBooks) {
if (!ListUtils.isEmpty(relatedBooks)){
relatedBooks.forEach(e -> e.setCustomTimeControlId(id));
customTimeControlBookMapper.batchInsert(relatedBooks);
}
}
private void insertCustomTimeControlReply(Integer id, List<CustomTimeControlReply> replyList4Subscribe, List<CustomTimeControlReply> replyList4Unsubscribe) {
List<CustomTimeControlReply> customTimeControlReplies = new ArrayList<>();
if (!ListUtils.isEmpty(replyList4Subscribe)){
customTimeControlReplies.addAll(replyList4Subscribe);
}
if (!ListUtils.isEmpty(replyList4Unsubscribe)){
customTimeControlReplies.addAll(replyList4Unsubscribe);
}
if (!ListUtils.isEmpty(customTimeControlReplies)){
customTimeControlReplies.forEach(e ->e.setCustomTimeControlId(id));
customTimeControlReplyMapper.batchInsert(customTimeControlReplies);
}
}
private Integer insertCustomTimeControl(Integer timeControlTaskId) {
CustomTimeControl customTimeControl = new CustomTimeControl();
customTimeControl.setTimeControlTaskId(timeControlTaskId);
customTimeControl.setCreateTime(new Date());
customTimeControlMapper.insert(customTimeControl);
return Integer.valueOf(customTimeControl.getId().toString());
}
@Override
@Transactional
@ParamLog("更新定制服务读书计划")
public void updateCustomTimeControl(CustomTimeControlDTO customTimeControlDTO) {
customCheck.updateCustomTimeControlCheck(customTimeControlDTO);
Integer id = customTimeControlDTO.getId();
updateCustomTimeControl(id,customTimeControlDTO.getTimeControlTaskId());
updateCustomTimeControlReply(id, customTimeControlDTO.getReplyList4Subscribe(), customTimeControlDTO.getReplyList4Unsubscribe());
updateCustomTimeControlBook(id, customTimeControlDTO.getRelatedBooks());
}
@Override
@ParamLog("获取定制服务读书计划分页列表")
public PageBeanNew<CustomTimeControlPageDTO> getCustomTimeControlPage(String taskName, Integer currentPage, Integer numPerPage) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("taskName",taskName);
PageBeanNew<CustomTimeControlPageDTO> customTimeControlPage = customTimeControlMapper.
listPageNew(new PageParam(currentPage,numPerPage),paramMap,"getCustomTimeControlPage");
if (null != customTimeControlPage && !ListUtils.isEmpty(customTimeControlPage.getRecordList())){
List<Integer> customTimeControlIds = customTimeControlPage.getRecordList().stream().map(e -> e.getId()).collect(Collectors.toList());
List<CustomTimeControlPageDTO> customTimeControlPageDTOS = customTimeControlBookMapper.getBooKCountList(customTimeControlIds);
Map<Integer,Integer> booKCountMap =
customTimeControlPageDTOS.stream().collect(Collectors.toMap(CustomTimeControlPageDTO::getId, CustomTimeControlPageDTO::getRelatedBookCount));
if (MapUtils.isNotEmpty(booKCountMap)){
customTimeControlPage.getRecordList().stream().forEach(e -> {
e.setRelatedBookCount(null == booKCountMap.get(e.getId()) ? 0 : booKCountMap.get(e.getId()));
});
}
customTimeControlPage.getRecordList().stream().forEach(e -> {
e.setShortTaskIntroduce(StringUtilParent.replaceHtml(e.getTaskIntroduce()));
});
}
return customTimeControlPage;
}
@Override
public CustomTimeControlDTO getCustomTimeControlById(Integer id) {
CustomTimeControlDTO customTimeControlDTO = customTimeControlMapper.getCustomTimeControlById(id);
List<CustomTimeControlBook> customTimeControlBooks = customTimeControlDTO.getRelatedBooks();
if (null != customTimeControlDTO && !ListUtils.isEmpty(customTimeControlBooks)){
List<String> bookIds = customTimeControlBooks.stream().map(e -> e.getBookId()).collect(Collectors.toList());
Map<String, ProjectInfoDTO> projectMap = null;
try {
projectMap = ResponseHandleUtil.parseMap(projectService.getProjectInfoBySerialNumbers(bookIds),String.class, ProjectInfoDTO.class);
} catch (Exception e) {
log.error("获取erp书籍信息失败");
}
if (MapUtils.isNotEmpty(projectMap)){
for (CustomTimeControlBook e : customTimeControlBooks) {
e.setBookName(null == projectMap.get(e.getBookId()) ? "" : projectMap.get(e.getBookId()).getBookName());
e.setErpBookId(null == projectMap.get(e.getBookId()) ? null : Integer.valueOf(projectMap.get(e.getBookId()).getProjectId().toString()));
}
}
}
return customTimeControlDTO;
}
@Override
@Transactional
public void deleteCustomTimeControlById(Integer id) {
customTimeControlMapper.deleteByPrimaryKey(id);
customTimeControlReplyMapper.deleteByCustomTimeControlId(id);
customTimeControlBookMapper.deleteByCustomTimeControlId(id);
}
private void updateCustomTimeControl(Integer id, Integer timeControlTaskId) {
CustomTimeControl customTimeControl = new CustomTimeControl();
customTimeControl.setId(Long.valueOf(id.toString()));
customTimeControl.setTimeControlTaskId(timeControlTaskId);
customTimeControl.setUpdateTime(new Date());
customTimeControlMapper.updateByPrimaryKeySelective(customTimeControl);
}
private void updateCustomTimeControlReply(Integer id, List<CustomTimeControlReply> replyList4Subscribe, List<CustomTimeControlReply> replyList4Unsubscribe) {
customTimeControlReplyMapper.deleteByCustomTimeControlId(id);
List<CustomTimeControlReply> customTimeControlReplies = new ArrayList<>();
if (!ListUtils.isEmpty(replyList4Subscribe)){
customTimeControlReplies.addAll(replyList4Subscribe);
}
if (!ListUtils.isEmpty(replyList4Unsubscribe)){
customTimeControlReplies.addAll(replyList4Unsubscribe);
}
if (!ListUtils.isEmpty(customTimeControlReplies)){
customTimeControlReplies.forEach(e ->e.setCustomTimeControlId(id));
customTimeControlReplyMapper.batchInsert(customTimeControlReplies);
}
}
private void updateCustomTimeControlBook(Integer id, List<CustomTimeControlBook> relatedBooks) {
customTimeControlBookMapper.deleteByCustomTimeControlId(id);
if (!ListUtils.isEmpty(relatedBooks)){
relatedBooks.forEach(e -> e.setCustomTimeControlId(id));
customTimeControlBookMapper.batchInsert(relatedBooks);
}
}
}
package com.pcloud.book.custom.check;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.custom.dto.CustomTimeControlDTO;
import com.pcloud.book.custom.entity.CustomTimeControlBook;
import com.pcloud.book.custom.entity.CustomTimeControlReply;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("定制参数校验")
public class CustomCheck {
@ParamLog("新增技能参数校验")
public void createCustomTimeControlCheck(CustomTimeControlDTO customTimeControlDTO) {
if (customTimeControlDTO==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数为空!");
}
if (customTimeControlDTO.getTimeControlTaskId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"读书计划id不能为空!");
}
checkReply(customTimeControlDTO.getReplyList4Subscribe());
checkReply(customTimeControlDTO.getReplyList4Unsubscribe());
checkBook(customTimeControlDTO.getRelatedBooks());
}
private void checkBook(List<CustomTimeControlBook> relatedBooks) {
if (ListUtils.isEmpty(relatedBooks)){
return;
}
if (relatedBooks.size() > 10){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "关联书籍不能超过10本!");
}
for(CustomTimeControlBook customTimeControlBook : relatedBooks){
if (null == customTimeControlBook.getBookId()){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "bookid不能为空!");
}
if (null == customTimeControlBook.getReadType()){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "readType不能为空!");
}
}
}
private void checkReply(List<CustomTimeControlReply> list){
if (ListUtils.isEmpty(list)){
return;
}
if (list.size() > 3){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "回复条数不能超过3条!");
}
for (CustomTimeControlReply reply :list){
if (reply==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复不能为空!");
}
if (null == reply.getSubType()){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "订阅回复类型不能为空!");
}
if (null == reply.getReplyType()){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "回复类型不能为空!");
}
Integer type = reply.getReplyType();
if (ReplyTypeEnum.TEXT.value.equals(type) && StringUtil.isEmpty(reply.getContent())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "内容不能为空!");
}
if (ReplyTypeEnum.IMAGE.value.equals(type) && StringUtil.isEmpty(reply.getPicUrl())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "图片地址不能为空!");
}
if (ReplyTypeEnum.APP.value.equals(type) && (StringUtil.isEmpty(reply.getServeType()) || reply.getServeId() == null || StringUtil.isEmpty(reply.getLinkUrl()))) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "应用或作品id和类型、链接不能为空!");
}
if (ReplyTypeEnum.RESOURCE.value.equals(type) && reply.getResourceId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "资源id不能为空!");
}
}
}
@ParamLog("修改技能校验")
public void updateCustomTimeControlCheck(CustomTimeControlDTO customTimeControlDTO) {
if (customTimeControlDTO.getId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"id不能为空!");
}
createCustomTimeControlCheck(customTimeControlDTO);
}
}
package com.pcloud.book.custom.dao;
import com.pcloud.book.custom.dto.CustomTimeControlDTO;
import com.pcloud.book.custom.dto.CustomTimeControlPageDTO;
import com.pcloud.book.custom.entity.CustomTimeControl;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface CustomTimeControlDao extends BaseDao<CustomTimeControl> {
int deleteByPrimaryKey(Integer id);
CustomTimeControl selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(CustomTimeControl record);
int updateByPrimaryKey(CustomTimeControl record);
List<CustomTimeControlPageDTO> getCustomTimeControlPage(String taskName);
CustomTimeControlDTO getCustomTimeControlById(Integer id);
}
\ No newline at end of file
package com.pcloud.book.custom.dao.impl;
import com.pcloud.book.custom.dao.CustomTimeControlDao;
import com.pcloud.book.custom.dto.CustomTimeControlDTO;
import com.pcloud.book.custom.dto.CustomTimeControlPageDTO;
import com.pcloud.book.custom.entity.CustomTimeControl;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository("customTimeControlDao")
public class CustomTimeControlDaoImpl extends BaseDaoImpl<CustomTimeControl> implements CustomTimeControlDao {
@Override
public int deleteByPrimaryKey(Integer id) {
return getSessionTemplate().delete(getStatement("deleteByPrimaryKey"),id);
}
@Override
public CustomTimeControl selectByPrimaryKey(Integer id) {
return getSessionTemplate().selectOne(getStatement("selectByPrimaryKey"),id);
}
@Override
public int updateByPrimaryKeySelective(CustomTimeControl record) {
return getSessionTemplate().update(getStatement("updateByPrimaryKeySelective"),record);
}
@Override
public int updateByPrimaryKey(CustomTimeControl record) {
return getSessionTemplate().update(getStatement("updateByPrimaryKey"),record);
}
@Override
public List<CustomTimeControlPageDTO> getCustomTimeControlPage(String taskName) {
return getSessionTemplate().selectList(getStatement("getCustomTimeControlPage"),taskName);
}
@Override
public CustomTimeControlDTO getCustomTimeControlById(Integer id) {
return getSessionTemplate().selectOne(getStatement("getCustomTimeControlById"),id);
}
}
package com.pcloud.book.custom.dto;
import com.pcloud.book.custom.entity.CustomTimeControlBook;
import com.pcloud.book.custom.entity.CustomTimeControlReply;
import java.util.List;
import lombok.Data;
@Data
public class CustomTimeControlDTO {
private Integer id;
private Integer timeControlTaskId;
private List<CustomTimeControlReply> replyList4Subscribe;
private List<CustomTimeControlReply> replyList4Unsubscribe;
private List<CustomTimeControlBook> relatedBooks;
}
package com.pcloud.book.custom.dto;
import lombok.Data;
@Data
public class CustomTimeControlPageDTO {
private Integer id;
private Integer timeControlTaskId;
private String taskName;
private String taskIntroduce;
private Integer relatedBookCount;
private String shortTaskIntroduce;
}
package com.pcloud.book.custom.entity;
import com.pcloud.common.entity.BaseEntity;
import lombok.Data;
@Data
public class CustomTimeControl extends BaseEntity {
private Integer timeControlTaskId;
}
\ No newline at end of file
package com.pcloud.book.custom.entity;
import java.util.Date;
public class CustomTimeControlBook {
private Integer id;
private Integer customTimeControlId;
private String bookId;
private Byte readType;
private Date createTime;
private Date updateTime;
private String bookName;
private Integer erpBookId;
public Integer getErpBookId() {
return erpBookId;
}
public void setErpBookId(Integer erpBookId) {
this.erpBookId = erpBookId;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getCustomTimeControlId() {
return customTimeControlId;
}
public void setCustomTimeControlId(Integer customTimeControlId) {
this.customTimeControlId = customTimeControlId;
}
public String getBookId() {
return bookId;
}
public void setBookId(String bookId) {
this.bookId = bookId;
}
public Byte getReadType() {
return readType;
}
public void setReadType(Byte readType) {
this.readType = readType;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.pcloud.book.custom.entity;
import java.util.Date;
public class CustomTimeControlReply {
private Integer id;
private Integer customTimeControlId;
private Integer subType;
private Integer replyType;
private String content;
private String description;
private String linkUrl;
private String picUrl;
private Integer serveId;
private String serveType;
private Integer resourceId;
private Date createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getCustomTimeControlId() {
return customTimeControlId;
}
public void setCustomTimeControlId(Integer customTimeControlId) {
this.customTimeControlId = customTimeControlId;
}
public Integer getSubType() {
return subType;
}
public void setSubType(Integer subType) {
this.subType = subType;
}
public Integer getReplyType() {
return replyType;
}
public void setReplyType(Integer replyType) {
this.replyType = replyType;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public String getLinkUrl() {
return linkUrl;
}
public void setLinkUrl(String linkUrl) {
this.linkUrl = linkUrl == null ? null : linkUrl.trim();
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl == null ? null : picUrl.trim();
}
public Integer getServeId() {
return serveId;
}
public void setServeId(Integer serveId) {
this.serveId = serveId;
}
public String getServeType() {
return serveType;
}
public void setServeType(String serveType) {
this.serveType = serveType == null ? null : serveType.trim();
}
public Integer getResourceId() {
return resourceId;
}
public void setResourceId(Integer resourceId) {
this.resourceId = resourceId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
package com.pcloud.book.custom.facade;
import com.pcloud.book.custom.biz.CustomTimeControlBiz;
import com.pcloud.book.custom.dto.CustomTimeControlDTO;
import com.pcloud.book.custom.dto.CustomTimeControlPageDTO;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew;
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;
import io.swagger.annotations.ApiParam;
@RequestMapping("customTimeControl")
@RestController("customTimeControlFacade")
public class CustomTimeControlFacade {
@Autowired
private CustomTimeControlBiz customTimeControlBiz;
@PostMapping("createCustomTimeControl")
ResponseDto<?> createCustomTimeControl(@RequestHeader("token") String token, @RequestBody CustomTimeControlDTO customTimeControlDTO){
return new ResponseDto<>(customTimeControlBiz.createCustomTimeControl(customTimeControlDTO));
}
@PostMapping("updateCustomTimeControl")
ResponseDto<?> updateCustomTimeControl(@RequestHeader("token") String token, @RequestBody CustomTimeControlDTO customTimeControlDTO){
customTimeControlBiz.updateCustomTimeControl(customTimeControlDTO);
return new ResponseDto<>();
}
@GetMapping("getCustomTimeControlPage")
ResponseDto<PageBeanNew<CustomTimeControlPageDTO>> getCustomTimeControlPage(@RequestHeader("token") String token,
@RequestParam(value = "taskName",required = false) String taskName,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage){
return new ResponseDto<PageBeanNew<CustomTimeControlPageDTO>>( customTimeControlBiz.getCustomTimeControlPage(taskName,currentPage,numPerPage));
}
@GetMapping("getCustomTimeControlById")
ResponseDto<CustomTimeControlDTO> getCustomTimeControlById(@RequestHeader("token") String token,@RequestParam("id") Integer id){
return new ResponseDto<CustomTimeControlDTO>(customTimeControlBiz.getCustomTimeControlById(id));
}
@GetMapping("deleteCustomTimeControlById")
ResponseDto<?> deleteCustomTimeControlById(@RequestHeader("token") String token, @RequestParam("id") Integer id){
customTimeControlBiz.deleteCustomTimeControlById(id);
return new ResponseDto<>();
}
}
package com.pcloud.book.custom.mapper;
import com.pcloud.book.custom.dto.CustomTimeControlPageDTO;
import com.pcloud.book.custom.entity.CustomTimeControlBook;
import org.apache.ibatis.annotations.MapKey;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
public interface CustomTimeControlBookMapper {
int deleteByPrimaryKey(Integer id);
int insert(CustomTimeControlBook record);
int insertSelective(CustomTimeControlBook record);
CustomTimeControlBook selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(CustomTimeControlBook record);
int updateByPrimaryKey(CustomTimeControlBook record);
void batchInsert(List<CustomTimeControlBook> relatedBooks);
void deleteByCustomTimeControlId(Integer id);
@MapKey("id")
Map<Integer, CustomTimeControlPageDTO> getBooKCountMap(List<Integer> customTimeControlIds);
List<CustomTimeControlPageDTO> getBooKCountList(List<Integer> customTimeControlIds);
}
\ No newline at end of file
package com.pcloud.book.custom.mapper;
import com.pcloud.book.custom.entity.CustomTimeControlReply;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public interface CustomTimeControlReplyMapper {
int deleteByPrimaryKey(Integer id);
int insert(CustomTimeControlReply record);
int insertSelective(CustomTimeControlReply record);
CustomTimeControlReply selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(CustomTimeControlReply record);
int updateByPrimaryKey(CustomTimeControlReply record);
void batchInsert(List<CustomTimeControlReply> customTimeControlReplies);
void deleteByCustomTimeControlId(Integer id);
}
\ No newline at end of file
......@@ -42,6 +42,8 @@ mybatis:
check-config-location: true
config-location: classpath:mybatis/mybatis-config.xml
hystrix:
command:
default:
......
<?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.custom.mapper.CustomTimeControlBookMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.custom.entity.CustomTimeControlBook" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="custom_time_control_id" property="customTimeControlId" jdbcType="INTEGER" />
<result column="book_id" property="bookId" jdbcType="VARCHAR" />
<result column="read_type" property="readType" jdbcType="TINYINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, custom_time_control_id, book_id, read_type, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from custom_time_control_book
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from custom_time_control_book
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pcloud.book.custom.entity.CustomTimeControlBook" >
insert into custom_time_control_book (id, custom_time_control_id, book_id,
read_type, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{customTimeControlId,jdbcType=INTEGER}, #{bookId,jdbcType=VARCHAR},
#{readType,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.custom.entity.CustomTimeControlBook" >
insert into custom_time_control_book
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="customTimeControlId != null" >
custom_time_control_id,
</if>
<if test="bookId != null" >
book_id,
</if>
<if test="readType != null" >
read_type,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="customTimeControlId != null" >
#{customTimeControlId,jdbcType=INTEGER},
</if>
<if test="bookId != null" >
#{bookId,jdbcType=VARCHAR},
</if>
<if test="readType != null" >
#{readType,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.custom.entity.CustomTimeControlBook">
insert into custom_time_control_book (custom_time_control_id, book_id,
read_type, create_time, update_time
)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.customTimeControlId,jdbcType=INTEGER}, #{item.bookId,jdbcType=VARCHAR},
#{item.readType,jdbcType=TINYINT}, now(), #{item.updateTime,jdbcType=TIMESTAMP}
)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.custom.entity.CustomTimeControlBook" >
update custom_time_control_book
<set >
<if test="customTimeControlId != null" >
custom_time_control_id = #{customTimeControlId,jdbcType=INTEGER},
</if>
<if test="bookId != null" >
book_id = #{bookId,jdbcType=VARCHAR},
</if>
<if test="readType != null" >
read_type = #{readType,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.custom.entity.CustomTimeControlBook" >
update custom_time_control_book
set custom_time_control_id = #{customTimeControlId,jdbcType=INTEGER},
book_id = #{bookId,jdbcType=VARCHAR},
read_type = #{readType,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getCountByCustomTimeControlId" parameterType="integer" resultType="integer">
select
count(id)
from
custom_time_control_book
where
custom_time_control_id = #{_parameter}
</select>
<select id="getBookListByCustomTimeControlId" parameterType="integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
custom_time_control_book
where
custom_time_control_id = #{_parameter}
</select>
<delete id="deleteByCustomTimeControlId" parameterType="integer">
delete
from
custom_time_control_book
where
custom_time_control_id = #{id}
</delete>
<select id="getBooKCountMap" parameterType="list" resultType="com.pcloud.book.custom.dto.CustomTimeControlPageDTO" >
select
custom_time_control_id id
count(id) relatedBookCount
from
custom_time_control_book
where
custom_time_control_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getBooKCountList" parameterType="list" resultType="com.pcloud.book.custom.dto.CustomTimeControlPageDTO" >
select
custom_time_control_id id,
count(id) relatedBookCount
from
custom_time_control_book
where
custom_time_control_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
group by custom_time_control_id
</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.custom.dao.impl.CustomTimeControlDaoImpl" >
<resultMap id="BaseResultMap" type="com.pcloud.book.custom.entity.CustomTimeControl" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="time_control_task_id" property="timeControlTaskId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<resultMap id="PageResultMap" type="com.pcloud.book.custom.dto.CustomTimeControlPageDTO">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="time_control_task_id" property="timeControlTaskId" jdbcType="INTEGER" />
<result column="task_name" property="taskName" jdbcType="VARCHAR"/>
<result column="task_introduce" property="taskIntroduce" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="DTOResultMap" type="com.pcloud.book.custom.dto.CustomTimeControlDTO">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="time_control_task_id" property="timeControlTaskId" jdbcType="INTEGER" />
<collection property="relatedBooks" column="id"
select="com.pcloud.book.custom.mapper.CustomTimeControlBookMapper.getBookListByCustomTimeControlId"/>
<collection property="replyList4Subscribe" column="id"
select="com.pcloud.book.custom.mapper.CustomTimeControlReplyMapper.getSubscribeReplyList"/>
<collection property="replyList4Unsubscribe" column="id"
select="com.pcloud.book.custom.mapper.CustomTimeControlReplyMapper.getUnSubscribeReplyList"/>
</resultMap>
<sql id="Base_Column_List" >
id, time_control_task_id, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from custom_time_control
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from custom_time_control
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pcloud.book.custom.entity.CustomTimeControl" useGeneratedKeys="true" keyProperty="id" flushCache="true" >
insert into custom_time_control (id, time_control_task_id, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{timeControlTaskId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.custom.entity.CustomTimeControl" >
update custom_time_control
<set >
<if test="timeControlTaskId != null" >
time_control_task_id = #{timeControlTaskId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.custom.entity.CustomTimeControl" >
update custom_time_control
set time_control_task_id = #{timeControlTaskId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getCustomTimeControlPage" parameterType="map" resultMap="PageResultMap">
select
c.id,
c.time_control_task_id,
t.task_name,
t.task_introduce
from
custom_time_control c
left join time_control_task t on c.time_control_task_id = t.task_id
<where>
<if test="taskName != null">
t.task_name like concat("%",#{taskName},"%")
</if>
</where>
order by c.create_time desc
</select>
<select id="getCustomTimeControlById" parameterType="integer" resultMap="DTOResultMap">
select
c.id,
c.time_control_task_id
from
custom_time_control c
where id = #{id}
</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.custom.mapper.CustomTimeControlReplyMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.custom.entity.CustomTimeControlReply" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="custom_time_control_id" property="customTimeControlId" jdbcType="INTEGER" />
<result column="sub_type" property="subType" jdbcType="INTEGER" />
<result column="reply_type" property="replyType" jdbcType="INTEGER" />
<result column="content" property="content" jdbcType="VARCHAR" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="link_url" property="linkUrl" jdbcType="VARCHAR" />
<result column="pic_url" property="picUrl" jdbcType="VARCHAR" />
<result column="serve_id" property="serveId" jdbcType="INTEGER" />
<result column="serve_type" property="serveType" jdbcType="VARCHAR" />
<result column="resource_id" property="resourceId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, custom_time_control_id, sub_type, reply_type, content, description, link_url,
pic_url, serve_id, serve_type, resource_id, create_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from custom_time_control_reply
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from custom_time_control_reply
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply" >
insert into custom_time_control_reply (id, custom_time_control_id, sub_type,
reply_type, content, description,
link_url, pic_url, serve_id,
serve_type, resource_id, create_time
)
values (#{id,jdbcType=INTEGER}, #{customTimeControlId,jdbcType=INTEGER}, #{subType,jdbcType=INTEGER},
#{replyType,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{linkUrl,jdbcType=VARCHAR}, #{picUrl,jdbcType=VARCHAR}, #{serveId,jdbcType=INTEGER},
#{serveType,jdbcType=VARCHAR}, #{resourceId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply" >
insert into custom_time_control_reply
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="customTimeControlId != null" >
custom_time_control_id,
</if>
<if test="subType != null" >
sub_type,
</if>
<if test="replyType != null" >
reply_type,
</if>
<if test="content != null" >
content,
</if>
<if test="description != null" >
description,
</if>
<if test="linkUrl != null" >
link_url,
</if>
<if test="picUrl != null" >
pic_url,
</if>
<if test="serveId != null" >
serve_id,
</if>
<if test="serveType != null" >
serve_type,
</if>
<if test="resourceId != null" >
resource_id,
</if>
<if test="createTime != null" >
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="customTimeControlId != null" >
#{customTimeControlId,jdbcType=INTEGER},
</if>
<if test="subType != null" >
#{subType,jdbcType=INTEGER},
</if>
<if test="replyType != null" >
#{replyType,jdbcType=INTEGER},
</if>
<if test="content != null" >
#{content,jdbcType=VARCHAR},
</if>
<if test="description != null" >
#{description,jdbcType=VARCHAR},
</if>
<if test="linkUrl != null" >
#{linkUrl,jdbcType=VARCHAR},
</if>
<if test="picUrl != null" >
#{picUrl,jdbcType=VARCHAR},
</if>
<if test="serveId != null" >
#{serveId,jdbcType=INTEGER},
</if>
<if test="serveType != null" >
#{serveType,jdbcType=VARCHAR},
</if>
<if test="resourceId != null" >
#{resourceId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply">
insert into custom_time_control_reply (custom_time_control_id, sub_type,
reply_type, content, description,
link_url, pic_url, serve_id,
serve_type, resource_id, create_time
)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.customTimeControlId,jdbcType=INTEGER}, #{item.subType,jdbcType=INTEGER},
#{item.replyType,jdbcType=INTEGER}, #{item.content,jdbcType=VARCHAR}, #{item.description,jdbcType=VARCHAR},
#{item.linkUrl,jdbcType=VARCHAR}, #{item.picUrl,jdbcType=VARCHAR}, #{item.serveId,jdbcType=INTEGER},
#{item.serveType,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=INTEGER}, now()
)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply" >
update custom_time_control_reply
<set >
<if test="customTimeControlId != null" >
custom_time_control_id = #{customTimeControlId,jdbcType=INTEGER},
</if>
<if test="subType != null" >
sub_type = #{subType,jdbcType=INTEGER},
</if>
<if test="replyType != null" >
reply_type = #{replyType,jdbcType=INTEGER},
</if>
<if test="content != null" >
content = #{content,jdbcType=VARCHAR},
</if>
<if test="description != null" >
description = #{description,jdbcType=VARCHAR},
</if>
<if test="linkUrl != null" >
link_url = #{linkUrl,jdbcType=VARCHAR},
</if>
<if test="picUrl != null" >
pic_url = #{picUrl,jdbcType=VARCHAR},
</if>
<if test="serveId != null" >
serve_id = #{serveId,jdbcType=INTEGER},
</if>
<if test="serveType != null" >
serve_type = #{serveType,jdbcType=VARCHAR},
</if>
<if test="resourceId != null" >
resource_id = #{resourceId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply" >
update custom_time_control_reply
set custom_time_control_id = #{customTimeControlId,jdbcType=INTEGER},
sub_type = #{subType,jdbcType=INTEGER},
reply_type = #{replyType,jdbcType=INTEGER},
content = #{content,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
link_url = #{linkUrl,jdbcType=VARCHAR},
pic_url = #{picUrl,jdbcType=VARCHAR},
serve_id = #{serveId,jdbcType=INTEGER},
serve_type = #{serveType,jdbcType=VARCHAR},
resource_id = #{resourceId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getSubscribeReplyList" parameterType="integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
custom_time_control_reply
where
custom_time_control_id = #{_parameter}
and
sub_type = 1
</select>
<select id="getUnSubscribeReplyList" parameterType="integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
custom_time_control_reply
where
custom_time_control_id = #{_parameter}
and
sub_type = 2
</select>
<delete id="deleteByCustomTimeControlId" parameterType="integer">
delete
from
custom_time_control_reply
where
custom_time_control_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