|
@@ -0,0 +1,135 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.diagbot.entity.IntroduceDetail;
|
|
|
+import com.diagbot.entity.IntroduceInfo;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.service.impl.IntroduceInfoServiceImpl;
|
|
|
+import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.IntroducePageVO;
|
|
|
+import com.diagbot.vo.IntroduceVO;
|
|
|
+import io.swagger.models.auth.In;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @Author:zhaops
|
|
|
+ * @time: 2018/11/16 14:30
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ IntroduceMapFacade introduceMapFacade;
|
|
|
+ @Autowired
|
|
|
+ IntroduceDetailFacade introduceDetailFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存提示信息(新增or修改)
|
|
|
+ *
|
|
|
+ * @param introduceVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean saveIntroduce(IntroduceVO introduceVO) {
|
|
|
+ IntroduceInfo introduceInfo = new IntroduceInfo();
|
|
|
+ if (!(introduceVO.getId() == null)) {
|
|
|
+ introduceInfo = this.getById(introduceVO.getId());
|
|
|
+ introduceInfo.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ introduceInfo.setGmtModified(new Date());
|
|
|
+ } else {
|
|
|
+ introduceInfo.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
+ introduceInfo.setGmtCreate(new Date());
|
|
|
+ }
|
|
|
+ introduceInfo.setName(introduceVO.getName());
|
|
|
+ introduceInfo.setRemark(introduceVO.getRemark());
|
|
|
+
|
|
|
+ //明细信息不更新,每次都删除重新插入
|
|
|
+ //删除已有明细
|
|
|
+ if (!(introduceInfo.getId() == null)) {
|
|
|
+ UpdateWrapper<IntroduceDetail> detailUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ detailUpdateWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ eq("introduce_id", introduceInfo.getId()).
|
|
|
+ set("is_deleted", IsDeleteEnum.Y.getKey()).
|
|
|
+ set("gmt_modified", new Date()).
|
|
|
+ set("modifier", UserUtils.getCurrentPrincipleID());
|
|
|
+ introduceDetailFacade.update(new IntroduceDetail(), detailUpdateWrapper);
|
|
|
+ }
|
|
|
+ //插入新的明细记录
|
|
|
+ introduceDetailFacade.saveOrUpdateBatch(introduceVO.getDetailList());
|
|
|
+
|
|
|
+ //更新提示信息
|
|
|
+ this.saveOrUpdate(introduceInfo);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单条删除提示信息
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean deleteRecord(Long id) {
|
|
|
+ //删除明细
|
|
|
+ UpdateWrapper<IntroduceDetail> introduceDetailUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ introduceDetailUpdateWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ eq("introduce_id", id).
|
|
|
+ set("is_deleted", IsDeleteEnum.Y.getKey()).
|
|
|
+ set("gmt_modified", new Date()).
|
|
|
+ set("modifier", UserUtils.getCurrentPrincipleID());
|
|
|
+ introduceDetailFacade.update(new IntroduceDetail(), introduceDetailUpdateWrapper);
|
|
|
+
|
|
|
+ UpdateWrapper<IntroduceInfo> introduceInfoUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ introduceInfoUpdateWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ eq("id", id).
|
|
|
+ set("is_deleted", IsDeleteEnum.Y.getKey()).
|
|
|
+ set("gmt_modified", new Date()).
|
|
|
+ set("modifier", UserUtils.getCurrentPrincipleID());
|
|
|
+ this.update(new IntroduceInfo(), introduceInfoUpdateWrapper);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除提示信息
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean deleteRecords(Long[] ids) {
|
|
|
+ //删除明细
|
|
|
+ UpdateWrapper<IntroduceDetail> introduceDetailUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ introduceDetailUpdateWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ in("introduce_id", ids).
|
|
|
+ set("is_deleted", IsDeleteEnum.Y.getKey()).
|
|
|
+ set("gmt_modified", new Date()).
|
|
|
+ set("modifier", UserUtils.getCurrentPrincipleID());
|
|
|
+ introduceDetailFacade.update(new IntroduceDetail(), introduceDetailUpdateWrapper);
|
|
|
+ UpdateWrapper<IntroduceInfo> introduceInfoUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ introduceInfoUpdateWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ in("id", ids).
|
|
|
+ set("is_deleted", IsDeleteEnum.Y.getKey()).
|
|
|
+ set("gmt_modified", new Date()).
|
|
|
+ set("modifier", UserUtils.getCurrentPrincipleID());
|
|
|
+ this.update(new IntroduceInfo(), introduceInfoUpdateWrapper);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询提示信息,可带等于条件
|
|
|
+ *
|
|
|
+ * @param introducePageVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<IntroduceInfo> getPageByMap(IntroducePageVO introducePageVO) {
|
|
|
+ QueryWrapper<IntroduceInfo> introduceInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ for (Map.Entry<String, Object> entry : introducePageVO.getMap().entrySet()) {
|
|
|
+ introduceInfoQueryWrapper.eq(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ IPage<IntroduceInfo> introduceInfoIPage = this.page(introducePageVO, introduceInfoQueryWrapper);
|
|
|
+ return introduceInfoIPage;
|
|
|
+ }
|
|
|
+}
|