1.附件增加业务类型
This commit is contained in:
parent
f63e40a79a
commit
06b8996a60
|
@ -0,0 +1,49 @@
|
||||||
|
package com.dite.znpt.enums;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: gaoxiong
|
||||||
|
* @Date: 2025/4/24 21:25
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum AttachBusinessTypeEnum {
|
||||||
|
PROJECT_TASK("PROJECT_TASK", "项目任务"),
|
||||||
|
;
|
||||||
|
private final String code;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
AttachBusinessTypeEnum(String code, String desc){
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AttachBusinessTypeEnum getByCode(String code){
|
||||||
|
for (AttachBusinessTypeEnum e : AttachBusinessTypeEnum.values() ) {
|
||||||
|
if(e.code.equals(code)){
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDescByCode(String code){
|
||||||
|
AttachBusinessTypeEnum e = getByCode(code);
|
||||||
|
return null == e ? null : e.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<JSONObject> listAll(){
|
||||||
|
List<JSONObject> list = new ArrayList<>(AttachBusinessTypeEnum.values().length);
|
||||||
|
for (AttachBusinessTypeEnum e : AttachBusinessTypeEnum.values() ) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.set(e.code, e.desc);
|
||||||
|
list.add(jsonObject);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.dite.znpt.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.dite.znpt.domain.entity.AttachInfoEntity;
|
import com.dite.znpt.domain.entity.AttachInfoEntity;
|
||||||
|
import com.dite.znpt.enums.AttachBusinessTypeEnum;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -37,7 +38,15 @@ public interface AttachInfoService extends IService<AttachInfoEntity> {
|
||||||
* @author huise23
|
* @author huise23
|
||||||
* @date 2025/04/11 23:17
|
* @date 2025/04/11 23:17
|
||||||
**/
|
**/
|
||||||
void deleteByBusinessIds(List<String> businessIds, String businessType);
|
void deleteByBusinessId(String businessId, AttachBusinessTypeEnum typeEnum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述:删除附件信息
|
||||||
|
*
|
||||||
|
* @author huise23
|
||||||
|
* @date 2025/04/11 23:17
|
||||||
|
**/
|
||||||
|
void deleteByBusinessIds(List<String> businessIds, AttachBusinessTypeEnum typeEnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能描述:更新附件关联的业务id
|
* 功能描述:更新附件关联的业务id
|
||||||
|
@ -45,6 +54,6 @@ public interface AttachInfoService extends IService<AttachInfoEntity> {
|
||||||
* @author huise23
|
* @author huise23
|
||||||
* @date 2025/04/11 23:17
|
* @date 2025/04/11 23:17
|
||||||
**/
|
**/
|
||||||
void updateBusinessIdByAttachIds(String businessId, List<String> attachIds);
|
void updateBusinessIdByAttachIds(String businessId, List<String> attachIds, AttachBusinessTypeEnum typeEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
package com.dite.znpt.service.impl;
|
package com.dite.znpt.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.dite.znpt.domain.entity.AttachInfoEntity;
|
import com.dite.znpt.domain.entity.AttachInfoEntity;
|
||||||
|
import com.dite.znpt.enums.AttachBusinessTypeEnum;
|
||||||
import com.dite.znpt.enums.FilePathEnum;
|
import com.dite.znpt.enums.FilePathEnum;
|
||||||
import com.dite.znpt.service.AttachInfoService;
|
import com.dite.znpt.service.AttachInfoService;
|
||||||
import com.dite.znpt.mapper.FileInfoMapper;
|
import com.dite.znpt.mapper.FileInfoMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.dite.znpt.util.PageUtil;
|
import com.dite.znpt.util.PageUtil;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -53,7 +57,7 @@ public class AttachInfoServiceImpl extends ServiceImpl<FileInfoMapper, AttachInf
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public List<String> saveData(String businessType, MultipartFile[] files) {
|
public List<String> saveData(String businessType, MultipartFile[] files) {
|
||||||
String temPathPrefix = FilePathEnum.ATTACH.getFileAbsolutePath().concat(DateUtil.today()).concat(FileUtil.FILE_SEPARATOR);
|
String temPathPrefix = FilePathEnum.ATTACH.getFileAbsolutePath().concat(businessType).concat(FileUtil.FILE_SEPARATOR).concat(DateUtil.today()).concat(FileUtil.FILE_SEPARATOR);
|
||||||
if (!FileUtil.exist(temPathPrefix)) {
|
if (!FileUtil.exist(temPathPrefix)) {
|
||||||
FileUtil.mkdir(temPathPrefix);
|
FileUtil.mkdir(temPathPrefix);
|
||||||
}
|
}
|
||||||
|
@ -76,15 +80,19 @@ public class AttachInfoServiceImpl extends ServiceImpl<FileInfoMapper, AttachInf
|
||||||
/**
|
/**
|
||||||
* 功能描述:删除附件信息
|
* 功能描述:删除附件信息
|
||||||
*
|
*
|
||||||
* @param businessIds 业务id
|
* @param businessId 业务id
|
||||||
* @param businessType 业务类型
|
* @param typeEnum 业务类型
|
||||||
* @author huise23
|
* @author huise23
|
||||||
* @date 2025/04/11 23:17
|
* @date 2025/04/11 23:17
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void deleteByBusinessIds(List<String> businessIds, String businessType) {
|
public void deleteByBusinessId(String businessId, AttachBusinessTypeEnum typeEnum) {
|
||||||
|
deleteByBusinessIds(ListUtil.toList(businessId), typeEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteByBusinessIds(List<String> businessIds, AttachBusinessTypeEnum typeEnum) {
|
||||||
lambdaUpdate().in(AttachInfoEntity::getBusinessId, businessIds)
|
lambdaUpdate().in(AttachInfoEntity::getBusinessId, businessIds)
|
||||||
.eq(StrUtil.isNotEmpty(businessType), AttachInfoEntity::getBusinessType, businessType).remove();
|
.eq(AttachInfoEntity::getBusinessType, typeEnum.getCode()).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,10 +104,15 @@ public class AttachInfoServiceImpl extends ServiceImpl<FileInfoMapper, AttachInf
|
||||||
* @date 2025/04/11 23:17
|
* @date 2025/04/11 23:17
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateBusinessIdByAttachIds(String businessId, List<String> attachIds) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateBusinessIdByAttachIds(String businessId, List<String> attachIds, AttachBusinessTypeEnum typeEnum) {
|
||||||
|
baseMapper.delete(Wrappers.<AttachInfoEntity>lambdaUpdate().eq(AttachInfoEntity::getBusinessId, businessId)
|
||||||
|
.eq(AttachInfoEntity::getBusinessType, typeEnum.getCode()));
|
||||||
if (CollUtil.isEmpty(attachIds)) {
|
if (CollUtil.isEmpty(attachIds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lambdaUpdate().in(AttachInfoEntity::getAttachId, attachIds).set(AttachInfoEntity::getBusinessId, businessId).update();
|
lambdaUpdate().in(AttachInfoEntity::getAttachId, attachIds)
|
||||||
|
.eq(AttachInfoEntity::getBusinessType, typeEnum.getCode())
|
||||||
|
.set(AttachInfoEntity::getBusinessId, businessId).update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.dite.znpt.domain.vo.ProjectTaskListReq;
|
||||||
import com.dite.znpt.domain.vo.ProjectTaskResp;
|
import com.dite.znpt.domain.vo.ProjectTaskResp;
|
||||||
import com.dite.znpt.domain.vo.ProjectTaskReq;
|
import com.dite.znpt.domain.vo.ProjectTaskReq;
|
||||||
import com.dite.znpt.domain.vo.ProjectTaskStartReq;
|
import com.dite.znpt.domain.vo.ProjectTaskStartReq;
|
||||||
|
import com.dite.znpt.enums.AttachBusinessTypeEnum;
|
||||||
import com.dite.znpt.enums.ProjectTaskStateEnum;
|
import com.dite.znpt.enums.ProjectTaskStateEnum;
|
||||||
import com.dite.znpt.exception.ServiceException;
|
import com.dite.znpt.exception.ServiceException;
|
||||||
import com.dite.znpt.mapper.ProjectTaskGroupMapper;
|
import com.dite.znpt.mapper.ProjectTaskGroupMapper;
|
||||||
|
@ -97,7 +98,7 @@ public class ProjectTaskServiceImpl extends ServiceImpl<ProjectTaskMapper, Proje
|
||||||
ProjectTaskEntity entity = BeanUtil.copyProperties(projectTaskReq, ProjectTaskEntity.class);
|
ProjectTaskEntity entity = BeanUtil.copyProperties(projectTaskReq, ProjectTaskEntity.class);
|
||||||
checkTask(projectTaskReq);
|
checkTask(projectTaskReq);
|
||||||
save(entity);
|
save(entity);
|
||||||
attachInfoService.updateBusinessIdByAttachIds(entity.getTaskId(), projectTaskReq.getAttachFileIds());
|
attachInfoService.updateBusinessIdByAttachIds(entity.getTaskId(), projectTaskReq.getAttachFileIds(), AttachBusinessTypeEnum.PROJECT_TASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +114,7 @@ public class ProjectTaskServiceImpl extends ServiceImpl<ProjectTaskMapper, Proje
|
||||||
ProjectTaskEntity entity = BeanUtil.copyProperties(projectTaskReq, ProjectTaskEntity.class);
|
ProjectTaskEntity entity = BeanUtil.copyProperties(projectTaskReq, ProjectTaskEntity.class);
|
||||||
checkTask(projectTaskReq);
|
checkTask(projectTaskReq);
|
||||||
updateById(entity);
|
updateById(entity);
|
||||||
attachInfoService.updateBusinessIdByAttachIds(projectTaskReq.getTaskId(), projectTaskReq.getAttachFileIds());
|
attachInfoService.updateBusinessIdByAttachIds(projectTaskReq.getTaskId(), projectTaskReq.getAttachFileIds(), AttachBusinessTypeEnum.PROJECT_TASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,8 +180,10 @@ public class ProjectTaskServiceImpl extends ServiceImpl<ProjectTaskMapper, Proje
|
||||||
* @date 2025/06/25 17:21
|
* @date 2025/06/25 17:21
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteById(String taskId) {
|
public void deleteById(String taskId) {
|
||||||
removeById(taskId);
|
removeById(taskId);
|
||||||
|
attachInfoService.deleteByBusinessId(taskId, AttachBusinessTypeEnum.PROJECT_TASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,8 +194,11 @@ public class ProjectTaskServiceImpl extends ServiceImpl<ProjectTaskMapper, Proje
|
||||||
* @date 2025/06/25 17:21
|
* @date 2025/06/25 17:21
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteByGroupId(String groupId) {
|
public void deleteByGroupId(String groupId) {
|
||||||
lambdaUpdate().eq(ProjectTaskEntity::getTaskGroupId, groupId).remove();
|
List<String> list = lambdaQuery().eq(ProjectTaskEntity::getTaskGroupId, groupId).list().stream().map(ProjectTaskEntity::getTaskId).toList();
|
||||||
|
attachInfoService.deleteByBusinessIds(list, AttachBusinessTypeEnum.PROJECT_TASK);
|
||||||
|
baseMapper.deleteByIds(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,14 +22,14 @@ public class AttachInfoController {
|
||||||
private AttachInfoService attachInfoService;
|
private AttachInfoService attachInfoService;
|
||||||
|
|
||||||
@ApiOperation(value = "新增附件信息", httpMethod = "POST")
|
@ApiOperation(value = "新增附件信息", httpMethod = "POST")
|
||||||
@PostMapping
|
@PostMapping("/{businessType}")
|
||||||
public Result<String> add(@RequestParam("businessType") String businessType, @RequestParam("file") MultipartFile file) {
|
public Result<String> add(@PathVariable("businessType") String businessType, @RequestParam("file") MultipartFile file) {
|
||||||
return Result.ok(attachInfoService.saveData(businessType, new MultipartFile[]{file}).get(0));
|
return Result.ok(attachInfoService.saveData(businessType, new MultipartFile[]{file}).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "批量新增附件信息", httpMethod = "POST")
|
@ApiOperation(value = "批量新增附件信息", httpMethod = "POST")
|
||||||
@PostMapping("/batch")
|
@PostMapping("/batch/{businessType}")
|
||||||
public Result<List<String>> add(@RequestParam("businessType") String businessType, @RequestParam("files") MultipartFile[] files) {
|
public Result<List<String>> add(@PathVariable("businessType") String businessType, @RequestParam("files") MultipartFile[] files) {
|
||||||
return Result.ok(attachInfoService.saveData(businessType, files));
|
return Result.ok(attachInfoService.saveData(businessType, files));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,5 +151,11 @@ public class CommonController {
|
||||||
return Result.ok(InsuranceStatusEnum.listAll());
|
return Result.ok(InsuranceStatusEnum.listAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "查询附件业务类型", httpMethod = "GET")
|
||||||
|
@GetMapping("/list/attach_business_type")
|
||||||
|
public Result<?> listAttachBusinessType(){
|
||||||
|
return Result.ok(AttachBusinessTypeEnum.listAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue