fuliqi
2024-11-28 190a7928e5372cbe0965d851525581f01f3af372
business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -8,6 +8,7 @@
import com.ycl.common.utils.SecurityUtils;
import com.ycl.domain.entity.File;
import com.ycl.domain.entity.ProjectInfo;
import com.ycl.domain.form.DocumentInfoForm;
import com.ycl.domain.form.ProjectInfoForm;
import com.ycl.domain.query.ProjectInfoQuery;
import com.ycl.domain.vo.*;
@@ -81,7 +82,8 @@
        ProjectInfoForm.getEntityByForm(form,entity);
        Long userId = SecurityUtils.getUserId();
        entity.setUpdateBy(userId);
        //更新项目信息
        baseMapper.updateById(entity);
        List<File> fileList = form.getFileList();
        fileList.forEach(item->{
            item.setBusId(entity.getId());
@@ -94,8 +96,6 @@
        fileMapper.delete(fileQueryWrapper);
        //替换成现有
        fileService.saveBatch(fileList);
        //更新项目信息
        baseMapper.updateById(entity);
        return Result.ok("修改成功");
    }
@@ -211,4 +211,32 @@
        map.put("processExceptionProject", 0);
        return map;
    }
    @Override
    public Result docDetail(Integer id) {
        DocumentInfoForm documentInfoForm = new DocumentInfoForm();
        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
        fileQueryWrapper.eq("type",FileTypeEnum.DOCUMENT_INFO.getType());
        fileQueryWrapper.eq("bus_id",id);
        List<File> files = fileMapper.selectList(fileQueryWrapper);
        documentInfoForm.setFileList(files);
        return Result.ok().data(documentInfoForm);
    }
    @Override
    public Result addDoc(DocumentInfoForm form) {
        List<File> fileList = form.getFileList();
        fileList.forEach(item->{
            item.setBusId(form.getProjectId());
            item.setType(FileTypeEnum.DOCUMENT_INFO);
        });
        //删除原有文件
        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
        fileQueryWrapper.eq("type",FileTypeEnum.DOCUMENT_INFO.getType());
        fileQueryWrapper.eq("bus_id",form.getProjectId());
        fileMapper.delete(fileQueryWrapper);
        //替换成现有
        fileService.saveBatch(fileList);
        return Result.ok();
    }
}