Browse Source

提示信息

Zhaops 6 years ago
parent
commit
d54b0df6f0

+ 17 - 0
icssman-service/src/main/java/com/diagbot/facade/IntroduceDetailFacade.java

@@ -1,8 +1,13 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.entity.IntroduceDetail;
+import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.service.impl.IntroduceDetailServiceImpl;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+
 /**
  * @Description:
  * @Author:zhaops
@@ -10,4 +15,16 @@ import org.springframework.stereotype.Component;
  */
 @Component
 public class IntroduceDetailFacade extends IntroduceDetailServiceImpl {
+
+    /**
+     * 获取提示信息明细
+     * @param introduceId
+     * @return
+     */
+    public List<IntroduceDetail> getByIntroduceId(Long introduceId) {
+        QueryWrapper<IntroduceDetail> introduceDetailQueryWrapper = new QueryWrapper<>();
+        introduceDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
+                eq("introduce_id", introduceId);
+        return this.list(introduceDetailQueryWrapper);
+    }
 }

+ 61 - 0
icssman-service/src/main/java/com/diagbot/facade/IntroduceMapFacade.java

@@ -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;
+    }
 }

+ 22 - 0
icssman-service/src/main/java/com/diagbot/vo/IntroduceMapVO.java

@@ -0,0 +1,22 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:标签与提示信息映射关系入参
+ * @Author:zhaops
+ * @time: 2018/11/16 16:45
+ */
+@Getter
+@Setter
+public class IntroduceMapVO {
+    @NotNull(message = "请输入标签id")
+    private Long questionId;
+    @NotNull(message = "请输入提示信息id")
+    private Long introduceId;
+    @NotNull(message = "请输入标签类型")
+    private Integer type;
+}

+ 22 - 0
icssman-service/src/main/java/com/diagbot/web/IntroduceDetailController.java

@@ -1,9 +1,20 @@
 package com.diagbot.web;
 
 
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.IntroduceDetail;
+import com.diagbot.facade.IntroduceDetailFacade;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * <p>
  * 提示信息明细 前端控制器
@@ -14,6 +25,17 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("/introduceDetail")
+@Api(value = "提示信息明细维护相关API", tags = { "提示信息明细维护相关API" })
 public class IntroduceDetailController {
+    @Autowired
+    IntroduceDetailFacade introduceDetailFacade;
 
+    @ApiOperation(value = "获取提示信息明细信息[by:zhaops]",
+            notes = "introduceId: 提示信息id,必填")
+    @PostMapping("/getByIntroduceId")
+    @SysLogger("getByIntroduceId")
+    public RespDTO<Boolean> getByIntroduceId(@RequestParam Long introduceId) {
+        List<IntroduceDetail> data = introduceDetailFacade.getByIntroduceId(introduceId);
+        return RespDTO.onSuc(data);
+    }
 }

+ 23 - 0
icssman-service/src/main/java/com/diagbot/web/IntroduceMapController.java

@@ -1,6 +1,15 @@
 package com.diagbot.web;
 
 
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.IntroduceMapFacade;
+import com.diagbot.vo.IntroduceMapVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -14,6 +23,20 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("/introduceMap")
+@Api(value = "提示信息与标签映射关系维护相关API", tags = { "提示信息与标签映射关系维护相关API" })
 public class IntroduceMapController {
 
+    @Autowired
+    IntroduceMapFacade introduceMapFacade;
+
+    @ApiOperation(value = "保存标签提示信息映射关系[by:zhaops]",
+            notes = "questionId: 标签id,必填" +
+                    "introduceId: 提示信息id,必填" +
+                    "type: 标签类型,必填")
+    @PostMapping("/saveRecord")
+    @SysLogger("saveRecord")
+    public RespDTO<Boolean> saveRecord(@RequestBody IntroduceMapVO introduceMapVO) {
+        Boolean data = introduceMapFacade.saveRecord(introduceMapVO);
+        return RespDTO.onSuc(data);
+    }
 }