|
@@ -1,8 +1,20 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.diagbot.entity.IntroduceInfo;
|
|
|
+import com.diagbot.entity.IntroduceMap;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.IntroduceMapServiceImpl;
|
|
|
+import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.IntroduceMapVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
/**
|
|
|
* @Description:
|
|
|
* @Author:zhaops
|
|
@@ -10,4 +22,53 @@ import org.springframework.stereotype.Component;
|
|
|
*/
|
|
|
@Component
|
|
|
public class IntroduceMapFacade extends IntroduceMapServiceImpl {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IntroduceInfoFacade introduceInfoFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存标签提示信息映射关系
|
|
|
+ *
|
|
|
+ * @param introduceMapVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean saveRecord(IntroduceMapVO introduceMapVO) {
|
|
|
+ IntroduceInfo introduceInfo = introduceInfoFacade.getById(introduceMapVO.getIntroduceId());
|
|
|
+ if (introduceInfo == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息未添加");
|
|
|
+ } else if (introduceInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息已删除");
|
|
|
+ }
|
|
|
+ QueryWrapper<IntroduceMap> introduceMapQueryWrapper = new QueryWrapper<>();
|
|
|
+ introduceMapQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ eq("question_id", introduceMapVO.getQuestionId()).
|
|
|
+ eq("type", introduceMapVO.getType()).
|
|
|
+ eq("introduce_id", introduceMapVO.getIntroduceId());
|
|
|
+ IntroduceMap introduceMap = this.getOne(introduceMapQueryWrapper);
|
|
|
+ UpdateWrapper<IntroduceMap> introduceMapUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ if (introduceMap == null) {
|
|
|
+ //删除该标签关联的提示信息,插入新的提示信息
|
|
|
+ introduceMapUpdateWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ eq("question_id", introduceMapVO.getQuestionId()).
|
|
|
+ eq("type", introduceMapVO.getType()).
|
|
|
+ set("is_deleted", IsDeleteEnum.Y.getKey()).
|
|
|
+ set("gmt_modified", new Date()).
|
|
|
+ set("modifier", UserUtils.getCurrentPrincipleID());
|
|
|
+ this.update(new IntroduceMap(), introduceMapUpdateWrapper);
|
|
|
+
|
|
|
+ //插入新的关系
|
|
|
+ introduceMap = new IntroduceMap();
|
|
|
+ introduceMap.setQuestionId(introduceMapVO.getQuestionId());
|
|
|
+ introduceMap.setIntroduceId(introduceMapVO.getIntroduceId());
|
|
|
+ introduceMap.setType(introduceMapVO.getType());
|
|
|
+ introduceMap.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
+ introduceMap.setGmtCreate(new Date());
|
|
|
+ } else {
|
|
|
+ //已有关系更新时间
|
|
|
+ introduceMap.setGmtModified(new Date());
|
|
|
+ introduceMap.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(introduceMap);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|