Zhaops пре 6 година
родитељ
комит
996396d515

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

@@ -3,12 +3,19 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.diagbot.entity.IntroduceDetail;
+import com.diagbot.entity.IntroduceInfo;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.IntroduceDetailServiceImpl;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.UserUtils;
+import com.diagbot.vo.IntroduceDetailSingleVO;
+import com.diagbot.vo.IntroduceDetailVO;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -18,6 +25,8 @@ import java.util.List;
  */
 @Component
 public class IntroduceDetailFacade extends IntroduceDetailServiceImpl {
+    @Autowired
+    private IntroduceInfoFacade introduceInfoFacade;
 
     /**
      * 获取提示信息明细
@@ -32,6 +41,66 @@ public class IntroduceDetailFacade extends IntroduceDetailServiceImpl {
         return this.list(introduceDetailQueryWrapper);
     }
 
+    /**
+     * 获取单条提示信息明细
+     *
+     * @param id
+     * @return
+     */
+    public IntroduceDetail getRecordById(Long id) {
+        IntroduceDetail detail = super.getById(id);
+        if (detail == null) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息明细不存在");
+        } else if (detail.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息明细已删除");
+        }
+        return detail;
+    }
+
+    /**
+     * 单条明细保存
+     *
+     * @param detailSingleVO
+     * @return
+     */
+    public Boolean saveRecord(IntroduceDetailSingleVO detailSingleVO) {
+        if (detailSingleVO.getIntroduceId() == null || detailSingleVO.getIntroduceId().equals(0L)) {
+            throw new CommonException(CommonErrorCode.PARAM_ERROR, "请输入提示信息id");
+        }
+        IntroduceInfo introduceInfo = introduceInfoFacade.getById(detailSingleVO.getIntroduceId());
+        if (introduceInfo == null) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息不存在");
+        } else if (introduceInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息已删除");
+        }
+
+        String userId = UserUtils.getCurrentPrincipleID();
+        Date now = DateUtil.now();
+        IntroduceDetail detail = super.getById(detailSingleVO.getId());
+        if (!(detail == null || detail.getIsDeleted().equals(IsDeleteEnum.Y.getKey()))) {
+            detail.setIsDeleted(IsDeleteEnum.Y.getKey());
+            detail.setModifier(userId);
+            detail.setGmtModified(now);
+            this.updateById(detail);
+        }
+        detail = new IntroduceDetail();
+        detail.setIsReason(detailSingleVO.getIsReason());
+        detail.setTitle(detailSingleVO.getTitle());
+        detail.setOrderNo(detailSingleVO.getOrderNo());
+        detail.setText(detailSingleVO.getText());
+        detail.setContent(detailSingleVO.getContent());
+        detail.setIntroduceId(detailSingleVO.getIntroduceId());
+        detail.setPosition(detailSingleVO.getPosition());
+        detail.setCreator(userId);
+        detail.setGmtCreate(now);
+        detail.setModifier(userId);
+        detail.setGmtModified(now);
+
+        this.saveOrUpdate(detail);
+
+        return true;
+    }
+
     /**
      * 单条删除提示信息明细 逻辑删除
      *

+ 19 - 0
icssman-service/src/main/java/com/diagbot/vo/IntroduceDetailSingleVO.java

@@ -0,0 +1,19 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/1/4 15:43
+ */
+@Getter
+@Setter
+public class IntroduceDetailSingleVO extends IntroduceDetailVO {
+    @NotNull(message = "请输入提示信息id")
+    private Long introduceId;
+    private Long id;
+}

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

@@ -5,11 +5,13 @@ import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.IntroduceDetail;
 import com.diagbot.facade.IntroduceDetailFacade;
+import com.diagbot.vo.IntroduceDetailSingleVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 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.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -41,6 +43,30 @@ public class IntroduceDetailController {
         return RespDTO.onSuc(data);
     }
 
+    @ApiOperation(value = "获取单条提示信息明细[by:zhaops]",
+            notes = "id: 提示信息明细id,必填")
+    @PostMapping("/getById")
+    @SysLogger("getById")
+    public RespDTO<IntroduceDetail> getById(@RequestParam Long id) {
+        IntroduceDetail data = introduceDetailFacade.getRecordById(id);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "保存单条明细信息[by:zhaops]",
+            notes = "introdueId: 提示信息id,必填<br>" +
+                    "id: 提示信息明细id<br>" +
+                    "title:提示信息标题<br>" +
+                    "content:提示信息<br>" +
+                    "text:提示信息-纯文本<br>" +
+                    "orderNo:排序号<br>" +
+                    "position:显示位置<br>")
+    @PostMapping("/saveRecord")
+    @SysLogger("saveRecord")
+    public RespDTO<Boolean> saveRecord(@RequestBody IntroduceDetailSingleVO introduceDetailSingleVO) {
+        Boolean data = introduceDetailFacade.saveRecord(introduceDetailSingleVO);
+        return RespDTO.onSuc(data);
+    }
+
     @ApiOperation(value = "删除单条提示信息明细[by:zhaops]",
             notes = "id: id,必填")
     @PostMapping("/deleteRecord")

+ 1 - 1
icssman-service/src/main/java/com/diagbot/web/IntroduceInfoController.java

@@ -46,7 +46,7 @@ public class IntroduceInfoController {
             notes = "id: 修改时带id,新增时为空<br>" +
                     "name: 名称,必填<br>" +
                     "remark:备注<br>" +
-                    "detailVOList:提示信息明细列表" +
+                    "detailVOList:提示信息明细列表<br>" +
                     "title:提示信息标题<br>" +
                     "content:提示信息<br>" +
                     "text:提示信息-纯文本<br>" +