From 246c1509dd966641bd6591bb341556b22a1d827a Mon Sep 17 00:00:00 2001 From: sugus <1020570875@qq.com> Date: Fri, 11 Jul 2025 16:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=9B=BE=E7=89=87=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aircraft/domain/AircraftDevice.java | 22 ++++++++ .../dto/LocalAttachmentMaterialDTO.java | 52 +++++++++++++++++++ .../java/com/aircraft/domain/S3Storage.java | 4 ++ .../dto/LocalAttachmentMaterialDTO.java | 50 ++++++++++++++++++ .../aircraft/rest/LocalStorageController.java | 47 ++++++++++------- .../aircraft/rest/S3StorageController.java | 2 +- .../service/impl/S3StorageServiceImpl.java | 1 + 7 files changed, 157 insertions(+), 21 deletions(-) create mode 100644 aircraft-system/src/main/java/com/aircraft/modules/system/domain/dto/LocalAttachmentMaterialDTO.java create mode 100644 aircraft-tools/src/main/java/com/aircraft/domain/dto/LocalAttachmentMaterialDTO.java diff --git a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/AircraftDevice.java b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/AircraftDevice.java index e7e853a..2e06b2e 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/AircraftDevice.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/AircraftDevice.java @@ -1,10 +1,15 @@ package com.aircraft.modules.aircraft.domain; +import com.aircraft.base.SysBaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import com.aircraft.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + /** *

* 飞行器设备表 @@ -23,46 +28,63 @@ public class AircraftDevice extends BaseEntity { /** * 主键id */ + @NotNull(groups = SysBaseEntity.Update.class) + @ApiModelProperty(value = "主键id") private Long id; /** * 飞行器名称 */ + @NotBlank + @ApiModelProperty(value = "飞行器名称") private String name; /** * 设备型号 */ + @NotBlank + @ApiModelProperty(value = "设备型号") private String model; /** * 品牌(DJI,SF) */ + @NotBlank + @ApiModelProperty(value = "品牌(DJI,SF)") private String brand; /** * 类型:0-载物飞行,1-载人飞行,2-其他 */ + @NotNull + @ApiModelProperty(value = "类型:0-载物飞行,1-载人飞行,2-其他") private Integer useType; /** * 区域id */ + @NotNull + @ApiModelProperty(value = "区域id") private Long areaId; /** * 景区id */ + @NotNull + @ApiModelProperty(value = "景区id") private Long scenicId; /** * 飞行员(负责人)id */ + @NotNull + @ApiModelProperty(value = "飞行员(负责人)id") private Long employeesId; /** * 备注 */ + @ApiModelProperty(value = "备注") private String remark; diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/dto/LocalAttachmentMaterialDTO.java b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/dto/LocalAttachmentMaterialDTO.java new file mode 100644 index 0000000..67af961 --- /dev/null +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/dto/LocalAttachmentMaterialDTO.java @@ -0,0 +1,52 @@ +package com.aircraft.modules.system.domain.dto; + + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 本地附件材料DTO + */ +@Data +public class LocalAttachmentMaterialDTO { + + + @ApiModelProperty(value = "id") + private Long id; + + /** + * 文件类型(jpg,png) + */ + @ApiModelProperty(value = "文件类型(jpg,png)") + private String fileType; + + /** + * 源文件名称 + */ + @ApiModelProperty(value = "源文件名称") + private String sourceFileName; + + + + /** + * 新文件名称 + */ + @ApiModelProperty(value = "新文件名称") + private String newFileName; + + + + /** + * 文件大小(字节) + */ + @ApiModelProperty(value = "文件大小(字节)") + private Long fileSize; + + + + /** + * 文件的全路径 + */ + @ApiModelProperty(value = "文件的全路径") + private String fileFullPath; +} diff --git a/aircraft-tools/src/main/java/com/aircraft/domain/S3Storage.java b/aircraft-tools/src/main/java/com/aircraft/domain/S3Storage.java index 4e72552..00d38b8 100644 --- a/aircraft-tools/src/main/java/com/aircraft/domain/S3Storage.java +++ b/aircraft-tools/src/main/java/com/aircraft/domain/S3Storage.java @@ -65,6 +65,10 @@ public class S3Storage extends SysBaseEntity implements Serializable { @ApiModelProperty(value = "文件路径") private String filePath; + @NotBlank + @ApiModelProperty(value = "文件全路径") + private String fileFullPath; + public void copy(S3Storage source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/aircraft-tools/src/main/java/com/aircraft/domain/dto/LocalAttachmentMaterialDTO.java b/aircraft-tools/src/main/java/com/aircraft/domain/dto/LocalAttachmentMaterialDTO.java new file mode 100644 index 0000000..781990e --- /dev/null +++ b/aircraft-tools/src/main/java/com/aircraft/domain/dto/LocalAttachmentMaterialDTO.java @@ -0,0 +1,50 @@ +package com.aircraft.domain.dto; + + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 本地附件材料DTO + */ +@Data +public class LocalAttachmentMaterialDTO { + + + @ApiModelProperty(value = "id") + private Long id; + + /** + * 文件类型(jpg,png) + */ + @ApiModelProperty(value = "文件类型(jpg,png)") + private String fileType; + + /** + * 源文件名称 + */ + @ApiModelProperty(value = "源文件名称") + private String sourceFileName; + + /** + * 新文件名称 + */ + @ApiModelProperty(value = "新文件名称") + private String newFileName; + + + + /** + * 文件大小(字节) + */ + @ApiModelProperty(value = "文件大小(字节)") + private Long fileSize; + + + + /** + * 文件的全路径 + */ + @ApiModelProperty(value = "文件的全路径") + private String fileFullPath; +} diff --git a/aircraft-tools/src/main/java/com/aircraft/rest/LocalStorageController.java b/aircraft-tools/src/main/java/com/aircraft/rest/LocalStorageController.java index b505d5d..dda84aa 100644 --- a/aircraft-tools/src/main/java/com/aircraft/rest/LocalStorageController.java +++ b/aircraft-tools/src/main/java/com/aircraft/rest/LocalStorageController.java @@ -15,6 +15,7 @@ */ package com.aircraft.rest; +import com.aircraft.domain.dto.LocalAttachmentMaterialDTO; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import com.aircraft.annotation.Log; @@ -63,37 +64,43 @@ public class LocalStorageController { @PostMapping @ApiOperation("上传文件") - public ResponseEntity createFile(@RequestParam String name, @RequestParam("file") MultipartFile file){ + public ResponseEntity createFile(@RequestParam String name, @RequestPart("file") MultipartFile file){ localStorageService.create(name, file); return new ResponseEntity<>(HttpStatus.CREATED); } @ApiOperation("上传图片") @PostMapping("/pictures") - public ResponseEntity uploadPicture(@RequestParam MultipartFile file){ + public ResponseEntity uploadPicture(@RequestPart("file") MultipartFile file){ // 判断文件是否为图片 String suffix = FileUtil.getExtensionName(file.getOriginalFilename()); if(!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))){ throw new BadRequestException("只能上传图片"); } - LocalStorage localStorage = localStorageService.create(null, file); - return new ResponseEntity<>(localStorage, HttpStatus.OK); + LocalStorage localStorage = localStorageService.create(file.getName(), file); + LocalAttachmentMaterialDTO localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO(); + localAttachmentMaterialDTO.setFileType(localStorage.getSuffix()); + localAttachmentMaterialDTO.setFileSize(file.getSize()); + localAttachmentMaterialDTO.setNewFileName(localStorage.getRealName()); + localAttachmentMaterialDTO.setSourceFileName(localStorage.getName()); + localAttachmentMaterialDTO.setFileFullPath(localStorage.getPath()); + return new ResponseEntity<>(localAttachmentMaterialDTO, HttpStatus.OK); } - @PutMapping - @Log("修改文件") - @ApiOperation("修改文件") - public ResponseEntity updateFile(@Validated @RequestBody LocalStorage resources){ - localStorageService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Log("删除文件") - @DeleteMapping - @ApiOperation("多选删除") - @PreAuthorize("@el.check('storage:del')") - public ResponseEntity deleteFile(@RequestBody Long[] ids) { - localStorageService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } +// @PutMapping +// @Log("修改文件") +// @ApiOperation("修改文件") +// public ResponseEntity updateFile(@Validated @RequestBody LocalStorage resources){ +// localStorageService.update(resources); +// return new ResponseEntity<>(HttpStatus.NO_CONTENT); +// } +// +// @Log("删除文件") +// @DeleteMapping +// @ApiOperation("多选删除") +// @PreAuthorize("@el.check('storage:del')") +// public ResponseEntity deleteFile(@RequestBody Long[] ids) { +// localStorageService.deleteAll(ids); +// return new ResponseEntity<>(HttpStatus.OK); +// } } \ No newline at end of file diff --git a/aircraft-tools/src/main/java/com/aircraft/rest/S3StorageController.java b/aircraft-tools/src/main/java/com/aircraft/rest/S3StorageController.java index e6af7ab..9f6d7fa 100644 --- a/aircraft-tools/src/main/java/com/aircraft/rest/S3StorageController.java +++ b/aircraft-tools/src/main/java/com/aircraft/rest/S3StorageController.java @@ -69,7 +69,7 @@ public class S3StorageController { @PostMapping @ApiOperation("上传文件") - public ResponseEntity uploadS3Storage(@RequestParam MultipartFile file){ + public ResponseEntity uploadS3Storage(@RequestPart("file") MultipartFile file){ S3Storage storage = s3StorageService.upload(file); Map map = new HashMap<>(3); map.put("id",storage.getId()); diff --git a/aircraft-tools/src/main/java/com/aircraft/service/impl/S3StorageServiceImpl.java b/aircraft-tools/src/main/java/com/aircraft/service/impl/S3StorageServiceImpl.java index c45cc25..829edbc 100644 --- a/aircraft-tools/src/main/java/com/aircraft/service/impl/S3StorageServiceImpl.java +++ b/aircraft-tools/src/main/java/com/aircraft/service/impl/S3StorageServiceImpl.java @@ -139,6 +139,7 @@ public class S3StorageServiceImpl extends ServiceImpl