1.手动批量上传文件夹图像到项目增加信息

This commit is contained in:
cuizhibin 2025-08-02 17:10:54 +08:00
parent 0d10667ef3
commit c76c3a8f7c
3 changed files with 7 additions and 7 deletions

View File

@ -25,7 +25,7 @@ public interface ImageService extends IService<ImageEntity> {
List<ImageReq> batchUploadDefectImage(String partId, String imageSource, ImageCollectReq collectReq, MultipartFile[] files);
List<ImageReq> uploadProjectBatch(String projectId, String imageSource, MultipartFile[] files);
List<ImageReq> uploadProjectBatch(String projectId, String imageSource, ImageCollectReq collectReq, MultipartFile[] files);
List<String> batchUploadCommonImage(String imageSource, ImageWorkReq imageWorkReq, MultipartFile[] file) throws IOException;

View File

@ -161,7 +161,7 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
if (!file.isEmpty()) {
try {
String path = temPathPrefix + file.getOriginalFilename();
FileUtil.writeBytes(file.getBytes(),path);
FileUtil.writeFromStream(file.getInputStream(),path);
String fileDownPath = FilePathEnum.IMAGE_TEMP.getFileDownPath(path);
ImageReq imageReq = imageRespBuilder(path, fileDownPath);
imageReq.setImageId(IdUtil.simpleUUID());
@ -185,7 +185,7 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
@SneakyThrows
@Override
public List<ImageReq> uploadProjectBatch(String projectId, String imageSource, MultipartFile[] files) {
public List<ImageReq> uploadProjectBatch(String projectId, String imageSource, ImageCollectReq collectReq, MultipartFile[] files) {
if (Objects.isNull(projectService.getById(projectId))) {
throw new ServiceException(Message.PROJECT_ID_IS_NOT_EXIST);
}
@ -202,13 +202,13 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
List<ImageReq> list = new ArrayList<>(files.length);
List<ImageEntity> imageList = new ArrayList<>();
ImageCollectEntity imageCollect = new ImageCollectEntity();
ImageCollectEntity imageCollect = Optional.ofNullable(BeanUtil.copyProperties(collectReq, ImageCollectEntity.class)).orElse(new ImageCollectEntity());
imageCollect.setCollectId(IdUtil.simpleUUID());
imageCollect.setCollectorId(StpUtil.getLoginIdAsString());
imageCollect.setCollectorName(userService.getById(StpUtil.getLoginIdAsString()).getName());
for (MultipartFile multipartFile : files) {
String absolutePath = path_prefix + multipartFile.getOriginalFilename();
FileUtil.writeBytes(multipartFile.getBytes(),absolutePath);
FileUtil.writeFromStream(multipartFile.getInputStream(),absolutePath);
String fileDownPath = FilePathEnum.IMAGE.getFileDownPath(absolutePath);
ImageEntity imageEntity = new ImageEntity();
try {

View File

@ -57,8 +57,8 @@ public class ImageController {
@ApiOperation(value = "手动批量上传文件夹图像到项目", httpMethod = "POST")
@PostMapping("/{projectId}/{imageSource}/upload-batch")
public Result<List<ImageReq>> uploadProjectBatch(@PathVariable String projectId, @PathVariable String imageSource, @RequestParam("files") MultipartFile[] files) {
return Result.ok(imageService.uploadProjectBatch(projectId, imageSource, files));
public Result<List<ImageReq>> uploadProjectBatch(@PathVariable String projectId, @PathVariable String imageSource, ImageCollectReq collectReq, @RequestParam("files") MultipartFile[] files) {
return Result.ok(imageService.uploadProjectBatch(projectId, imageSource, collectReq, files));
}
@ApiOperation(value = "上传图像", httpMethod = "POST")