mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-01 19:24:57 +08:00
[feat] 新增文件转换
This commit is contained in:
parent
73156a9cfa
commit
a25b771856
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.framework.common.util.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.FileDTO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hhyykk
|
||||
* @description
|
||||
* @date 2024/7/9
|
||||
*/
|
||||
public class FileUtils {
|
||||
|
||||
/**
|
||||
* 文件数组转成JSON字符串
|
||||
* @param fileDTOList 文件
|
||||
* @return JSON字符串
|
||||
*/
|
||||
public static String covertFileToJSONString(List<FileDTO> fileDTOList) {
|
||||
if (ObjectUtils.isNotEmpty(fileDTOList)) {
|
||||
return JSON.toJSONString(fileDTOList);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON字符串转成文件数组
|
||||
* @param fileJsonString JSON字符串
|
||||
* @return 文件数组
|
||||
*/
|
||||
public static List<FileDTO> covertJSONStringToFile(String fileJsonString) {
|
||||
if (ObjectUtils.isNotEmpty(fileJsonString)) {
|
||||
return JSON.parseArray(fileJsonString, FileDTO.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.framework.common.util.object;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@ -58,5 +60,4 @@ public class BeanUtils {
|
||||
}
|
||||
return new PageResult<>(list, source.getTotal());
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.FileDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.file.FileUtils;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -70,7 +72,11 @@ public class ProjectController {
|
||||
@PreAuthorize("@ss.hasPermission('pms:project:query')")
|
||||
public CommonResult<ProjectRespDetailVO> getProject(@RequestParam("id") Long id) {
|
||||
ProjectDetailDO project = projectService.getProjectDetail(id);
|
||||
return success(BeanUtils.toBean(project, ProjectRespDetailVO.class));
|
||||
ProjectRespDetailVO vo = new ProjectRespDetailVO();
|
||||
org.springframework.beans.BeanUtils.copyProperties(project, vo, "reviewFileUrl", "winFileUrl");
|
||||
vo.setReviewFileUrl(FileUtils.covertJSONStringToFile(project.getReviewFileUrl()));
|
||||
vo.setWinFileUrl(FileUtils.covertJSONStringToFile(project.getWinFileUrl()));
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@ -22,7 +22,6 @@ import java.util.List;
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ProjectRespDetailVO {
|
||||
@Schema(description = "id", example = "11213")
|
||||
// @ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
|
@ -1,7 +1,10 @@
|
||||
package cn.iocoder.yudao.module.pms.dal.dataobject.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.FileDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hhyykk
|
||||
* @description
|
||||
|
@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.pms.service.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.ProcessStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.FileDTO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.file.FileUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
||||
@ -12,12 +14,15 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.mysql.project.ProjectMapper;
|
||||
import cn.iocoder.yudao.module.pms.enums.ProjectTypeEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstants.PROJECT_NOT_EXISTS;
|
||||
@ -45,6 +50,9 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
public Long createProject(Long loginUserId, ProjectSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ProjectDO project = BeanUtils.toBean(createReqVO, ProjectDO.class);
|
||||
|
||||
project.setReviewFileUrl(FileUtils.covertFileToJSONString(createReqVO.getReviewFileUrl()));
|
||||
project.setWinFileUrl(FileUtils.covertFileToJSONString(createReqVO.getWinFileUrl()));
|
||||
projectMapper.insert(project);
|
||||
// 启动流程
|
||||
if (createReqVO.getId() == null) {
|
||||
@ -70,6 +78,8 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
}
|
||||
// 更新
|
||||
ProjectDO updateObj = BeanUtils.toBean(updateReqVO, ProjectDO.class);
|
||||
updateObj.setReviewFileUrl(FileUtils.covertFileToJSONString(updateReqVO.getReviewFileUrl()));
|
||||
updateObj.setWinFileUrl(FileUtils.covertFileToJSONString(updateReqVO.getWinFileUrl()));
|
||||
projectMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@ -147,5 +157,4 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
return prefix + String.format("%04d", lastNumber);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user