贴皮文件上传接口支持只传文件不更新贴皮

This commit is contained in:
gaoqr
2026-07-08 18:00:20 +08:00
parent bec9f04c86
commit bab76a31f3
2 changed files with 7 additions and 5 deletions
@@ -117,7 +117,7 @@ public class VeneerController {
@PostMapping("/pic") @PostMapping("/pic")
@Operation(summary = "上传贴皮照片") @Operation(summary = "上传贴皮照片")
@OperateLog(logArgs = false, type = CREATE) @OperateLog(logArgs = false, type = CREATE)
public CommonResult<Long> uploadVeneerPic(@RequestParam("id") Long id, public CommonResult<Long> uploadVeneerPic(@RequestParam(value = "id", required = false) Long id,
@RequestPart(value = "file") MultipartFile file) throws IOException { @RequestPart(value = "file") MultipartFile file) throws IOException {
return success(veneerService.uploadPic(id, file)); return success(veneerService.uploadPic(id, file));
} }
@@ -128,7 +128,7 @@ public class VeneerServiceImpl implements VeneerService {
@Override @Override
public Long uploadPic(Long id, MultipartFile file) throws IOException { public Long uploadPic(Long id, MultipartFile file) throws IOException {
if (ObjectUtil.isNull(validateExist(id))) { if (ObjectUtil.isNotNull(id) && ObjectUtil.isNull(validateExist(id))) {
throw new ServiceException(VENEER_NOT_EXIST); throw new ServiceException(VENEER_NOT_EXIST);
} }
@@ -143,9 +143,11 @@ public class VeneerServiceImpl implements VeneerService {
organizationDTO = details.getData(); organizationDTO = details.getData();
} }
Long fileId = fileApi.createFileAndReturnId(file.getBytes(), String.format("%s-veneer-pic-file-%s.%s", organizationDTO.getName(), LocalDateTimeUtil.format(LocalDateTime.now(), PURE_DATETIME_PATTERN), getFileExtension(file.getOriginalFilename()))); Long fileId = fileApi.createFileAndReturnId(file.getBytes(), String.format("%s-veneer-pic-file-%s.%s", organizationDTO.getName(), LocalDateTimeUtil.format(LocalDateTime.now(), PURE_DATETIME_PATTERN), getFileExtension(file.getOriginalFilename())));
veneerMapper.update(new LambdaUpdateWrapper<VeneerDO>() if (ObjectUtil.isNotNull(id)) {
.eq(VeneerDO::getId, id) veneerMapper.update(new LambdaUpdateWrapper<VeneerDO>()
.set(VeneerDO::getFileId, fileId)); .eq(VeneerDO::getId, id)
.set(VeneerDO::getFileId, fileId));
}
return fileId; return fileId;
} }