mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 16:05:08 +08:00
[feat] 新增文件转换
This commit is contained in:
@ -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());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user