From 795ac1120ee6899e29189e68d7fe513af5902c70 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 4 Aug 2020 15:41:22 +0800 Subject: [PATCH] =?UTF-8?q?latest=5Fact=5Finfo=E6=96=B0=E5=A2=9Eact=5Finfo?= =?UTF-8?q?=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/dto/LatestActInfoDTO.java | 4 ++++ .../com/epmet/dto/form/work/RePublishFormDTO.java | 5 +++++ .../main/java/com/epmet/dao/LatestActInfoDao.java | 11 +++++++++++ .../java/com/epmet/entity/LatestActInfoEntity.java | 5 ++++- .../epmet/service/impl/WorkActDraftServiceImpl.java | 5 +++++ .../com/epmet/service/impl/WorkActServiceImpl.java | 13 ++++++++++++- .../src/main/resources/db/migration/epmet_heart.sql | 3 ++- .../src/main/resources/mapper/LatestActInfoDao.xml | 9 +++++++++ 8 files changed, 52 insertions(+), 3 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActInfoDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActInfoDTO.java index 68c34830cf..0d0824fdfd 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActInfoDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActInfoDTO.java @@ -209,4 +209,8 @@ public class LatestActInfoDTO implements Serializable { */ private String delFlag; + /** + * 数据库新增ACT_INFO_ID字段,act_info.id + */ + private String actInfoId; } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java index d29b3460e2..06208c4564 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java @@ -32,6 +32,11 @@ public class RePublishFormDTO implements Serializable { @Size(min=1,message = "活动详情不能为空",groups = {AddUserShowGroup.class}) private List actContent; + /** + * 发布之前,如果点击了预览,此列有值 + */ + private String actDraftId; + /** * 活动id */ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActInfoDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActInfoDao.java index caf1adf16f..958598534d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActInfoDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActInfoDao.java @@ -22,6 +22,7 @@ import com.epmet.dto.result.work.ActPreviewResultDTO; import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; import com.epmet.entity.LatestActInfoEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 最近一次编辑的活动信息 @@ -67,4 +68,14 @@ public interface LatestActInfoDao extends BaseDao { * @Date 2020/7/27 17:10 **/ int updateToDelById(String id); + + /** + * @return int + * @param actDraftId + * @param actInfoId + * @author yinzuomei + * @description + * @Date 2020/8/4 15:26 + **/ + int updateActInfoId(@Param("actDraftId") String actDraftId, @Param("actInfoId") String actInfoId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActInfoEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActInfoEntity.java index df12c12dc0..706cf0668b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActInfoEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActInfoEntity.java @@ -178,5 +178,8 @@ public class LatestActInfoEntity extends BaseEpmetEntity { * 审核开关:1报名人员需要人工审核0不需要 */ private Boolean auditSwitch; - + /** + * 数据库新增ACT_INFO_ID字段,act_info.id + */ + private String actInfoId; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java index 0375e16a36..e622f5f9fb 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java @@ -165,6 +165,11 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { logger.info("修改活动草稿actDraftId",formDTO.getActDraftId()); latestActInfoDTO.setId(formDTO.getActDraftId()); } + //如果是重新编辑活动进来的,保存草稿的时候,记录活动id的关系 + if(StringUtils.isNotBlank(formDTO.getActId())){ + logger.info("重新编辑活动act_id="+formDTO.getActId()); + latestActInfoDTO.setActInfoId(formDTO.getActId()); + } latestActInfoDTO.setCustomerId(formDTO.getCustomerId()); //活动标题 latestActInfoDTO.setTitle(formDTO.getTitle()); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java index 02e047bf58..1936de361d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java @@ -93,6 +93,9 @@ public class WorkActServiceImpl implements WorkActService { private ActGrantPointLogDao actGrantPointLogDao; @Autowired private UserKindnessTimeLogDao userKindnessTimeLogDao; + @Autowired + private LatestActInfoDao latestActInfoDao; + /** * @return void * @author yinzuomei @@ -151,7 +154,11 @@ public class WorkActServiceImpl implements WorkActService { logger.info("发布活动,审核成功"); actInfoDao.insert(actInfoEntity); - + //如果用户之前点击了预览,需要去更新草稿表里的act_info_id,记录草稿和活动的关系 + if(StringUtils.isNotBlank(formDTO.getActDraftId())){ + logger.info("更新latest_act_info表的act_info_id字段"); + latestActInfoDao.updateActInfoId(formDTO.getActDraftId(),actInfoEntity.getId()); + } List actContentEntityList=this.constructActContent(formDTO.getActContent(),actInfoEntity.getId()); for(ActContentEntity actContentEntity:actContentEntityList){ actContentDao.insert(actContentEntity); @@ -1216,6 +1223,10 @@ public class WorkActServiceImpl implements WorkActService { /*if(rePublishFormDTO.getNoticePassedPeople()){ this.noticePassedPeople(originalActInfo,newActInfoEntity); }*/ + //如果用户在重新发布之前点击了预览,需要去更新草稿表里的act_info_id,记录草稿和活动的关系 + if(StringUtils.isNotBlank(rePublishFormDTO.getActDraftId())){ + latestActInfoDao.updateActInfoId(rePublishFormDTO.getActDraftId(),newActInfoEntity.getId()); + } return publishActResultDTO; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/epmet_heart.sql b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/epmet_heart.sql index 7cc204d675..dcfead8989 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/epmet_heart.sql +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/epmet_heart.sql @@ -11,7 +11,7 @@ Target Server Version : 50728 File Encoding : 65001 - Date: 31/07/2020 17:50:23 + Date: 04/08/2020 15:40:16 */ SET NAMES utf8mb4; @@ -420,6 +420,7 @@ CREATE TABLE `latest_act_info` ( `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新人', `UPDATED_TIME` datetime(0) NOT NULL COMMENT '更新时间', `DEL_FLAG` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标识', + `ACT_INFO_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'act_info.id', PRIMARY KEY (`ID`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '最近一次编辑的活动信息' ROW_FORMAT = Compact; diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml index a2e33b2245..f0904b26a4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml @@ -39,6 +39,7 @@ + @@ -50,6 +51,7 @@ WHERE lai.DEL_FLAG = '0' AND lai.CREATED_BY = #{userId} + AND (lai.act_info_id is null or trim(lai.act_info_id) ='') @@ -123,4 +125,11 @@ update latest_act_info set DEL_FLAG='1' where id=#{id} + + + + UPDATE latest_act_info + SET ACT_INFO_ID = #{actInfoId} + WHERE id = #{actDraftId} + \ No newline at end of file