From dbe98fab02eccf041b5ffdddadd7dc67275a4f90 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 15 Mar 2022 17:09:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/constant/MemoConstant.java | 12 +++ .../controller/MemoWorkDiaryController.java | 7 +- .../impl/MemoWorkDiaryServiceImpl.java | 75 +++++++++++++++++-- 3 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/MemoConstant.java diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/MemoConstant.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/MemoConstant.java new file mode 100644 index 0000000000..b8d5c841dd --- /dev/null +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/MemoConstant.java @@ -0,0 +1,12 @@ +package com.epmet.constant; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/3/15 16:56 + */ +public interface MemoConstant { + String WORK_DIARY = "work_diary"; + String CONCERN = "concern"; + String DIFFICULTY = "difficulty"; +} diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/MemoWorkDiaryController.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/MemoWorkDiaryController.java index 5d3415ca29..73ce22ac03 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/MemoWorkDiaryController.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/MemoWorkDiaryController.java @@ -59,18 +59,21 @@ public class MemoWorkDiaryController { @NoRepeatSubmit @PostMapping("save") - public Result save(@RequestBody MemoWorkDiaryDTO dto){ + public Result save(@LoginUser TokenDto tokenDto, @RequestBody MemoWorkDiaryDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + dto.setCustomerId(tokenDto.getCustomerId()); + dto.setCreatedBy(tokenDto.getUserId()); memoWorkDiaryService.save(dto); return new Result(); } @NoRepeatSubmit @PostMapping("update") - public Result update(@RequestBody MemoWorkDiaryDTO dto){ + public Result update(@LoginUser TokenDto tokenDto, @RequestBody MemoWorkDiaryDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + dto.setCustomerId(tokenDto.getCustomerId()); memoWorkDiaryService.update(dto); return new Result(); } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/MemoWorkDiaryServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/MemoWorkDiaryServiceImpl.java index 3ea93d5724..0fed05ec70 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/MemoWorkDiaryServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/MemoWorkDiaryServiceImpl.java @@ -4,22 +4,28 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.constant.MemoConstant; import com.epmet.dao.MemoWorkDiaryDao; +import com.epmet.dto.MemoAttachmentDTO; import com.epmet.dto.MemoAttrDTO; import com.epmet.dto.MemoWorkDiaryDTO; import com.epmet.dto.form.MemoWorkDiaryFormDTO; +import com.epmet.entity.MemoAttachmentEntity; import com.epmet.entity.MemoWorkDiaryEntity; import com.epmet.service.MemoAttachmentService; import com.epmet.service.MemoAttrService; import com.epmet.service.MemoWorkDiaryService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Arrays; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; /** * 备忘录-工作日志 @@ -46,7 +52,6 @@ public class MemoWorkDiaryServiceImpl extends BaseServiceImpl list(MemoWorkDiaryFormDTO formDTO) { List list = baseDao.getPage(formDTO); - return list; } @@ -54,12 +59,16 @@ public class MemoWorkDiaryServiceImpl extends BaseServiceImpl attachmentList = memoAttachmentService.getListByMemoId(formDTO.getId()); + dto.setAttachmentList(attachmentList); } - //获取附件列表 //更新阅读状态 if (NumConstant.ONE_STR.equals(formDTO.getReadFlag())) { MemoAttrDTO memoAttrDTO = new MemoAttrDTO(); @@ -75,6 +84,28 @@ public class MemoWorkDiaryServiceImpl extends BaseServiceImpl list = dto.getAttachmentList().stream().map(item -> { + MemoAttachmentEntity e = ConvertUtils.sourceToTarget(item, MemoAttachmentEntity.class); + e.setCustomerId(dto.getCustomerId()); + e.setRemindMsgId(entity.getId()); + e.setSort(i.getAndIncrement()); + return e; + }).collect(Collectors.toList()); + memoAttachmentService.insertBatch(list); + } } @Override @@ -82,13 +113,43 @@ public class MemoWorkDiaryServiceImpl extends BaseServiceImpl list = dto.getAttachmentList().stream().map(item -> { + MemoAttachmentEntity e = ConvertUtils.sourceToTarget(item, MemoAttachmentEntity.class); + e.setCustomerId(dto.getCustomerId()); + e.setRemindMsgId(dto.getId()); + e.setSort(i.getAndIncrement()); + return e; + }).collect(Collectors.toList()); + memoAttachmentService.insertBatch(list); + } } @Override @Transactional(rollbackFor = Exception.class) public void delete(String[] ids) { // 逻辑删除(@TableLogic 注解) - baseDao.deleteBatchIds(Arrays.asList(ids)); + List list = Arrays.asList(ids); + baseDao.deleteBatchIds(list); + memoAttrService.delete(ids); + list.forEach(id -> { + //删除附件 + memoAttachmentService.deleteByMemoId(id); + }); } } \ No newline at end of file