|
@@ -1,13 +1,30 @@
|
|
|
package com.migao.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.migao.entity.po.DocumentSharing;
|
|
|
-import com.migao.mapper.DocumentSharingMapper;
|
|
|
+import com.migao.config.authority.LoginUtils;
|
|
|
+import com.migao.config.response.*;
|
|
|
+import com.migao.entity.po.*;
|
|
|
+import com.migao.entity.vo.req.DocumentSharingInsertReq;
|
|
|
+import com.migao.entity.vo.req.DocumentSharingQueryReq;
|
|
|
+import com.migao.entity.vo.req.DocumentSharingUpdateReq;
|
|
|
+import com.migao.entity.vo.res.DemandAttachmentRes;
|
|
|
+import com.migao.entity.vo.res.DocumentSharingPageQueryRes;
|
|
|
+import com.migao.entity.vo.res.DocumentSharingQueryRes;
|
|
|
+import com.migao.mapper.*;
|
|
|
import com.migao.service.DocumentSharingService;
|
|
|
+import com.migao.util.EntityUtils;
|
|
|
+import com.migao.util.ProjectNoUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+
|
|
|
/**
|
|
|
* @author dingsong
|
|
|
*/
|
|
@@ -15,4 +32,268 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
@Service
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public class DocumentSharingServiceImpl extends ServiceImpl<DocumentSharingMapper, DocumentSharing> implements DocumentSharingService {
|
|
|
+ @Resource
|
|
|
+ DocumentSharingMapper documentSharingMa;
|
|
|
+ @Resource
|
|
|
+ ProjectTypeMapper projectTypeMapper;
|
|
|
+ @Resource
|
|
|
+ ProjectStageMapper projectStageMapper;
|
|
|
+ @Resource
|
|
|
+ DictionaryMapper dictionaryMapper;
|
|
|
+ @Resource
|
|
|
+ FileInfoMapper fileInfoMapper;
|
|
|
+ @Resource
|
|
|
+ UserMapper userMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<?> insert(DocumentSharingInsertReq doc) {
|
|
|
+ //获取当前登录用户的信息
|
|
|
+ User user = LoginUtils.getUser();
|
|
|
+
|
|
|
+ //提交文档共享
|
|
|
+ DocumentSharing documentSharing = EntityUtils.copyProperties(doc,DocumentSharing.class);
|
|
|
+ //文档编码
|
|
|
+ documentSharing.setDocumentCode(ProjectNoUtil.getCode());
|
|
|
+ //是否删除
|
|
|
+ documentSharing.setDeleted(0);
|
|
|
+ //创建时间
|
|
|
+ documentSharing.setCreateTime(LocalDateTime.now());
|
|
|
+ //用户id
|
|
|
+ documentSharing.setCreateUserId(user.getId());
|
|
|
+ documentSharingMa.insert(documentSharing);
|
|
|
+
|
|
|
+ return ResponseBuilder.ok(200,"新增成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<?> deleteById(String id) {
|
|
|
+ Integer idInt = Integer.parseInt(id);
|
|
|
+ DocumentSharing documentSharing = documentSharingMa.selectById(idInt);
|
|
|
+ documentSharing.setDeleted(1);
|
|
|
+ documentSharingMa.updateById(documentSharing);
|
|
|
+
|
|
|
+ return ResponseBuilder.ok(200,"删除成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<?> update(DocumentSharingUpdateReq documentSharingUpdateReq) {
|
|
|
+ //获取当前登录用户的信息
|
|
|
+ User user = LoginUtils.getUser();
|
|
|
+ //通过id查询文档共享更新之前的记录
|
|
|
+ DocumentSharing documentSharingOne = documentSharingMa.selectById(documentSharingUpdateReq.getId());
|
|
|
+ //然后查询是否有附件记录以及附件更新记录
|
|
|
+ if(documentSharingOne.getFileId() != null && documentSharingUpdateReq.getFileId()!=null){
|
|
|
+ //如果附件有更新就把之前的附件状态改为删除
|
|
|
+ FileInfo fileInfo = fileInfoMapper.selectById(documentSharingOne.getFileId());
|
|
|
+ fileInfo.setDeleted(1);
|
|
|
+ fileInfoMapper.updateById(fileInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ DocumentSharing documentSharing = EntityUtils.copyProperties(documentSharingUpdateReq,DocumentSharing.class);
|
|
|
+ documentSharing.setCreateTime(LocalDateTime.now());
|
|
|
+ documentSharing.setCreateUserId(user.getId());
|
|
|
+ documentSharingMa.updateById(documentSharing);
|
|
|
+ return ResponseBuilder.ok(200,"更新成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<DocumentSharingQueryRes> findById(String id) {
|
|
|
+ Integer idInt = Integer.parseInt(id);
|
|
|
+ DocumentSharing documentSharing = documentSharingMa.selectById(idInt);
|
|
|
+
|
|
|
+ //附件基本信息
|
|
|
+ FileInfo fileInfo = fileInfoMapper.selectById(documentSharing.getFileId());
|
|
|
+ DemandAttachmentRes demandAttachmentRes = new DemandAttachmentRes();
|
|
|
+ demandAttachmentRes.setId(fileInfo.getId());
|
|
|
+ demandAttachmentRes.setName(fileInfo.getName());
|
|
|
+ demandAttachmentRes.setSubmitter(userMapper.selectById(fileInfo.getCreateUserId()).getName());
|
|
|
+ demandAttachmentRes.setCreateTime(fileInfo.getCreateTime());
|
|
|
+
|
|
|
+ DocumentSharingQueryRes documentSharingQueryRes = DocumentSharingQueryRes
|
|
|
+ .builder()
|
|
|
+ .id(documentSharing.getId())
|
|
|
+ .documentCode(documentSharing.getDocumentCode())
|
|
|
+ .documentName(documentSharing.getDocumentName())
|
|
|
+ .projectType(projectTypeMapper.selectById(documentSharing.getProjectTypeId()).getValue())
|
|
|
+ .projectPhase(projectStageMapper.selectById(documentSharing.getProjectPhaseId()).getName())
|
|
|
+ .documentFormat(dictionaryMapper.selectById(documentSharing.getDocumentFormatId()).getValue())
|
|
|
+ .mustProjectType(documentSharing.getMustProjectType())
|
|
|
+ .submitter(documentSharing.getSubmitter())
|
|
|
+ .deleted(documentSharing.getDeleted())
|
|
|
+ .createTime(documentSharing.getCreateTime())
|
|
|
+ .demandAttachmentRes(demandAttachmentRes)
|
|
|
+ .build();
|
|
|
+ return ResponseBuilder.ok(documentSharingQueryRes);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<PageBeanOne<DocumentSharingPageQueryRes>> pageQueryAll(BasePageRequest basePageRequest) {
|
|
|
+ Integer page = basePageRequest.getPage();
|
|
|
+ page = page == null ? 1 : page <= 0 ? 1 : page;
|
|
|
+ Integer size = basePageRequest.getSize();
|
|
|
+ size = size == null ? 10 : size <= 0 ? 10 : size;
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DocumentSharing> defaultQueryWrapper = Wrappers.<DocumentSharing>lambdaQuery();
|
|
|
+ defaultQueryWrapper.orderByDesc(DocumentSharing::getCreateTime);
|
|
|
+
|
|
|
+ Page<DocumentSharing> all = documentSharingMa.selectPage(new Page<>(page, size),defaultQueryWrapper);
|
|
|
+
|
|
|
+ return ResponseBuilderOne.ok(
|
|
|
+ all,
|
|
|
+ element -> {
|
|
|
+ DocumentSharingPageQueryRes docSharingPageQueryRes = DocumentSharingPageQueryRes
|
|
|
+ .builder()
|
|
|
+ .id(element.getId())
|
|
|
+ .documentCode(element.getDocumentCode())
|
|
|
+ .documentName(element.getDocumentName())
|
|
|
+ .projectType(projectTypeMapper.selectById(element.getProjectTypeId()).getValue())
|
|
|
+ .projectPhase(projectStageMapper.selectById(element.getProjectPhaseId()).getName())
|
|
|
+ .documentFormat(dictionaryMapper.selectById(element.getDocumentFormatId()).getValue())
|
|
|
+ .mustProjectType(element.getMustProjectType())
|
|
|
+ .submitter(element.getSubmitter())
|
|
|
+ .deleted(element.getDeleted())
|
|
|
+ .createTime(element.getCreateTime())
|
|
|
+ .build();
|
|
|
+ return docSharingPageQueryRes;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<PageBeanOne<DocumentSharingPageQueryRes>> pageQueryById(BasePageRequest basePageRequest) {
|
|
|
+ //获取当前登录用户的信息
|
|
|
+ User user = LoginUtils.getUser();
|
|
|
+
|
|
|
+ Integer page = basePageRequest.getPage();
|
|
|
+ page = page == null ? 1 : page <= 0 ? 1 : page;
|
|
|
+ Integer size = basePageRequest.getSize();
|
|
|
+ size = size == null ? 10 : size <= 0 ? 10 : size;
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DocumentSharing> defaultQueryWrapper = Wrappers.<DocumentSharing>lambdaQuery();
|
|
|
+ defaultQueryWrapper.eq(DocumentSharing::getCreateUserId,user.getId());
|
|
|
+ defaultQueryWrapper.orderByDesc(DocumentSharing::getCreateTime);
|
|
|
+
|
|
|
+ Page<DocumentSharing> all = documentSharingMa.selectPage(new Page<>(page, size),defaultQueryWrapper);
|
|
|
+
|
|
|
+ return ResponseBuilderOne.ok(
|
|
|
+ all,
|
|
|
+ element -> {
|
|
|
+ DocumentSharingPageQueryRes docSharingPageQueryRes = DocumentSharingPageQueryRes
|
|
|
+ .builder()
|
|
|
+ .id(element.getId())
|
|
|
+ .documentCode(element.getDocumentCode())
|
|
|
+ .documentName(element.getDocumentName())
|
|
|
+ .projectType(projectTypeMapper.selectById(element.getProjectTypeId()).getValue())
|
|
|
+ .projectPhase(projectStageMapper.selectById(element.getProjectPhaseId()).getName())
|
|
|
+ .documentFormat(dictionaryMapper.selectById(element.getDocumentFormatId()).getValue())
|
|
|
+ .mustProjectType(element.getMustProjectType())
|
|
|
+ .submitter(element.getSubmitter())
|
|
|
+ .deleted(element.getDeleted())
|
|
|
+ .createTime(element.getCreateTime())
|
|
|
+ .build();
|
|
|
+ return docSharingPageQueryRes;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<PageBeanOne<DocumentSharingPageQueryRes>> pageQueryOne(DocumentSharingQueryReq documentSharingQuery) {
|
|
|
+ Integer page = documentSharingQuery.getPage();
|
|
|
+ page = page == null ? 1 : page <= 0 ? 1 : page;
|
|
|
+ Integer size = documentSharingQuery.getSize();
|
|
|
+ size = size == null ? 10 : size <= 0 ? 10 : size;
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DocumentSharing> defaultQueryWrapper = Wrappers.<DocumentSharing>lambdaQuery();
|
|
|
+ if(StringUtils.isNotBlank(documentSharingQuery.getKey())){
|
|
|
+ //文档编码
|
|
|
+ defaultQueryWrapper.like(DocumentSharing::getDocumentCode,documentSharingQuery.getKey());
|
|
|
+ //文档名称
|
|
|
+ LambdaQueryWrapper<DocumentSharing> or1 = defaultQueryWrapper.or();
|
|
|
+ or1.like(DocumentSharing::getDocumentName,documentSharingQuery.getKey());
|
|
|
+ //必须项目类型
|
|
|
+ LambdaQueryWrapper<DocumentSharing> or2 = or1.or();
|
|
|
+ or2.like(DocumentSharing::getMustProjectType,documentSharingQuery.getKey());
|
|
|
+ //提交人
|
|
|
+ LambdaQueryWrapper<DocumentSharing> or3 = or2.or();
|
|
|
+ or3.like(DocumentSharing::getSubmitter,documentSharingQuery.getKey());
|
|
|
+ }
|
|
|
+ defaultQueryWrapper.orderByDesc(DocumentSharing::getCreateTime);
|
|
|
+
|
|
|
+
|
|
|
+ Page<DocumentSharing> all = documentSharingMa.selectPage(new Page<>(page, size),defaultQueryWrapper);
|
|
|
+
|
|
|
+ return ResponseBuilderOne.ok(
|
|
|
+ all,
|
|
|
+ element -> {
|
|
|
+ DocumentSharingPageQueryRes docSharingPageQueryRes = DocumentSharingPageQueryRes
|
|
|
+ .builder()
|
|
|
+ .id(element.getId())
|
|
|
+ .documentCode(element.getDocumentCode())
|
|
|
+ .documentName(element.getDocumentName())
|
|
|
+ .projectType(projectTypeMapper.selectById(element.getProjectTypeId()).getValue())
|
|
|
+ .projectPhase(projectStageMapper.selectById(element.getProjectPhaseId()).getName())
|
|
|
+ .documentFormat(dictionaryMapper.selectById(element.getDocumentFormatId()).getValue())
|
|
|
+ .mustProjectType(element.getMustProjectType())
|
|
|
+ .submitter(element.getSubmitter())
|
|
|
+ .deleted(element.getDeleted())
|
|
|
+ .createTime(element.getCreateTime())
|
|
|
+ .build();
|
|
|
+ return docSharingPageQueryRes;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBean<PageBeanOne<DocumentSharingPageQueryRes>> pageQueryOneById(DocumentSharingQueryReq documentSharingQuery) {
|
|
|
+ //获取当前登录用户的信息
|
|
|
+ User user = LoginUtils.getUser();
|
|
|
+
|
|
|
+ Integer page = documentSharingQuery.getPage();
|
|
|
+ page = page == null ? 1 : page <= 0 ? 1 : page;
|
|
|
+ Integer size = documentSharingQuery.getSize();
|
|
|
+ size = size == null ? 10 : size <= 0 ? 10 : size;
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DocumentSharing> defaultQueryWrapper = Wrappers.<DocumentSharing>lambdaQuery();
|
|
|
+ defaultQueryWrapper.eq(DocumentSharing::getCreateUserId,user.getId());
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(documentSharingQuery.getKey())){
|
|
|
+ //文档编码
|
|
|
+ defaultQueryWrapper.like(DocumentSharing::getDocumentCode,documentSharingQuery.getKey());
|
|
|
+ //文档名称
|
|
|
+ LambdaQueryWrapper<DocumentSharing> or1 = defaultQueryWrapper.or();
|
|
|
+ or1.like(DocumentSharing::getDocumentName,documentSharingQuery.getKey());
|
|
|
+ //必须项目类型
|
|
|
+ LambdaQueryWrapper<DocumentSharing> or2 = or1.or();
|
|
|
+ or2.like(DocumentSharing::getMustProjectType,documentSharingQuery.getKey());
|
|
|
+ //提交人
|
|
|
+ LambdaQueryWrapper<DocumentSharing> or3 = or2.or();
|
|
|
+ or3.like(DocumentSharing::getSubmitter,documentSharingQuery.getKey());
|
|
|
+ }
|
|
|
+ defaultQueryWrapper.orderByDesc(DocumentSharing::getCreateTime);
|
|
|
+
|
|
|
+
|
|
|
+ Page<DocumentSharing> all = documentSharingMa.selectPage(new Page<>(page, size),defaultQueryWrapper);
|
|
|
+
|
|
|
+ return ResponseBuilderOne.ok(
|
|
|
+ all,
|
|
|
+ element -> {
|
|
|
+ DocumentSharingPageQueryRes docSharingPageQueryRes = DocumentSharingPageQueryRes
|
|
|
+ .builder()
|
|
|
+ .id(element.getId())
|
|
|
+ .documentCode(element.getDocumentCode())
|
|
|
+ .documentName(element.getDocumentName())
|
|
|
+ .projectType(projectTypeMapper.selectById(element.getProjectTypeId()).getValue())
|
|
|
+ .projectPhase(projectStageMapper.selectById(element.getProjectPhaseId()).getName())
|
|
|
+ .documentFormat(dictionaryMapper.selectById(element.getDocumentFormatId()).getValue())
|
|
|
+ .mustProjectType(element.getMustProjectType())
|
|
|
+ .submitter(element.getSubmitter())
|
|
|
+ .deleted(element.getDeleted())
|
|
|
+ .createTime(element.getCreateTime())
|
|
|
+ .build();
|
|
|
+ return docSharingPageQueryRes;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|