|
@@ -1,13 +1,25 @@
|
|
|
package com.migao.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.migao.config.authority.LoginUtils;
|
|
|
+import com.migao.config.response.ResponseBean;
|
|
|
+import com.migao.config.response.ResponseBuilder;
|
|
|
+import com.migao.entity.po.DemandAttachment;
|
|
|
import com.migao.entity.po.DemandLibrary;
|
|
|
+import com.migao.entity.po.User;
|
|
|
+import com.migao.entity.vo.req.DemandLibraryInsertReq;
|
|
|
+import com.migao.entity.vo.req.DemandLibraryUpdateReq;
|
|
|
+import com.migao.mapper.DemandAttachmentMapper;
|
|
|
import com.migao.mapper.DemandLibraryMapper;
|
|
|
import com.migao.service.DemandLibraryService;
|
|
|
+import com.migao.util.EntityUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+
|
|
|
/**
|
|
|
* @author dingsong
|
|
|
*/
|
|
@@ -15,4 +27,73 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
@Service
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public class DemandLibraryServiceImpl extends ServiceImpl<DemandLibraryMapper, DemandLibrary> implements DemandLibraryService {
|
|
|
+ @Resource
|
|
|
+ DemandLibraryMapper demandLibraryMap;
|
|
|
+ @Resource
|
|
|
+ DemandAttachmentMapper demandAttachmentMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<?> insert(DemandLibraryInsertReq demandLibrary) {
|
|
|
+ //获取当前登录用户的信息
|
|
|
+ User user = LoginUtils.getUser();
|
|
|
+
|
|
|
+ //首先提交子项目信息
|
|
|
+ DemandLibrary dic1 = EntityUtils.copyProperties(demandLibrary,DemandLibrary.class);
|
|
|
+ dic1.setSubmitTime(LocalDateTime.now());
|
|
|
+ dic1.setDeleted(0);
|
|
|
+ dic1.setCreateUserId(user.getId());
|
|
|
+
|
|
|
+ DemandLibrary dic = EntityUtils.copyProperties(demandLibrary,DemandLibrary.class);
|
|
|
+ dic.setSubmitTime(LocalDateTime.now());
|
|
|
+ dic.setDeleted(0);
|
|
|
+ dic.setCreateUserId(user.getId());
|
|
|
+ demandLibraryMap.insert(dic);
|
|
|
+
|
|
|
+ for(Integer i : demandLibrary.getFileId()){
|
|
|
+ DemandAttachment demandAttachment = DemandAttachment
|
|
|
+ .builder()
|
|
|
+ .demandId(dic.getId())
|
|
|
+ .fileId(i)
|
|
|
+ .deleted(0)
|
|
|
+ .createTime(LocalDateTime.now())
|
|
|
+ .createUserId(user.getId())
|
|
|
+ .build();
|
|
|
+ demandAttachmentMapper.insert(demandAttachment);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResponseBuilder.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<?> deleteById(Integer id) {
|
|
|
+ DemandLibrary dic = demandLibraryMap.selectById(id);
|
|
|
+ dic.setDeleted(1);
|
|
|
+ demandLibraryMap.updateById(dic);
|
|
|
+ return ResponseBuilder.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<?> update(DemandLibraryUpdateReq libraryUpdateReq) {
|
|
|
+ //获取当前登录用户的信息
|
|
|
+ User user = LoginUtils.getUser();
|
|
|
+
|
|
|
+ DemandLibrary dic = EntityUtils.copyProperties(libraryUpdateReq,DemandLibrary.class);
|
|
|
+ dic.setSubmitTime(LocalDateTime.now());
|
|
|
+ demandLibraryMap.updateById(dic);
|
|
|
+
|
|
|
+ for(Integer i : libraryUpdateReq.getFileId()){
|
|
|
+ DemandAttachment demandAttachment = DemandAttachment
|
|
|
+ .builder()
|
|
|
+ .demandId(dic.getId())
|
|
|
+ .fileId(i)
|
|
|
+ .deleted(0)
|
|
|
+ .createTime(LocalDateTime.now())
|
|
|
+ .createUserId(user.getId())
|
|
|
+ .build();
|
|
|
+ demandAttachmentMapper.insert(demandAttachment);
|
|
|
+ }
|
|
|
+ return ResponseBuilder.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|