From 28a1ae72981b9b6d65e1b25be60321a704d61a7c Mon Sep 17 00:00:00 2001 From: sugus <1020570875@qq.com> Date: Mon, 21 Jul 2025 14:04:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:quartz=E9=9B=86=E7=BE=A4=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/config/application.yml | 2 +- .../src/main/resources/logback.xml | 69 ++++++++++++++----- .../src/main/resources/spy.properties | 2 +- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/aircraft-system/src/main/resources/config/application.yml b/aircraft-system/src/main/resources/config/application.yml index dd8e39e..c1e5058 100644 --- a/aircraft-system/src/main/resources/config/application.yml +++ b/aircraft-system/src/main/resources/config/application.yml @@ -31,7 +31,7 @@ spring: check-template-location: false profiles: # 激活的环境,如果需要 quartz 分布式支持,需要修改 active: dev,quartz - active: dev + active: dev,quartz data: redis: repositories: diff --git a/aircraft-system/src/main/resources/logback.xml b/aircraft-system/src/main/resources/logback.xml index b44ba06..9bf75f9 100644 --- a/aircraft-system/src/main/resources/logback.xml +++ b/aircraft-system/src/main/resources/logback.xml @@ -1,29 +1,62 @@ - - elAdmin - - + - + + + + + + + + + + + + + + + + + + + INFO + - ${log.pattern} - ${log.charset} + + ${CONSOLE_LOG_PATTERN} - - + + + + + + ${FILE_PATH} + + + 15 + + + + 10MB + + + + 1GB + + + + ${LOG_PATTERN} + + + + + + - - - - - - - - - \ No newline at end of file + diff --git a/aircraft-system/src/main/resources/spy.properties b/aircraft-system/src/main/resources/spy.properties index c1b7584..81f7e36 100644 --- a/aircraft-system/src/main/resources/spy.properties +++ b/aircraft-system/src/main/resources/spy.properties @@ -15,6 +15,6 @@ outagedetectioninterval=2 # 是否过滤 Log filter=true # 过滤 Log 时所排除的 sql 关键字,以逗号分隔 -exclude=SELECT 1,INSERT INTO sys_log +exclude=SELECT 1,INSERT INTO sys_log,qrtz_ # 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset. excludecategories=info,debug,result,commit,resultset \ No newline at end of file From 071d9a97fd3745dbc6fa7699e12e982bdbdfe8b5 Mon Sep 17 00:00:00 2001 From: sugus <1020570875@qq.com> Date: Mon, 21 Jul 2025 15:04:02 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=E9=98=BF=E9=87=8C=E4=BA=91oss?= =?UTF-8?q?=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aircraft/domain/AircraftDevice.java | 4 +- .../aircraft/domain/AircraftInsurance.java | 4 +- .../impl/AircraftDeviceServiceImpl.java | 6 +- .../impl/AircraftInsuranceServiceImpl.java | 6 +- .../main/resources/config/application-dev.yml | 13 +- .../java/com/aircraft/config/AmzS3Config.java | 15 ++ ...ialDTO.java => AttachmentMaterialDTO.java} | 4 +- .../aircraft/rest/LocalStorageController.java | 218 +++++++++--------- .../aircraft/rest/S3StorageController.java | 103 ++++----- .../service/impl/S3StorageServiceImpl.java | 6 +- 10 files changed, 195 insertions(+), 184 deletions(-) rename aircraft-tools/src/main/java/com/aircraft/domain/dto/{LocalAttachmentMaterialDTO.java => AttachmentMaterialDTO.java} (92%) 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 0f24fce..49417f2 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,7 +1,7 @@ package com.aircraft.modules.aircraft.domain; import com.aircraft.base.BaseEntity; -import com.aircraft.domain.dto.LocalAttachmentMaterialDTO; +import com.aircraft.domain.dto.AttachmentMaterialDTO; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; @@ -96,6 +96,6 @@ public class AircraftDevice extends BaseEntity { @NotNull @TableField(exist = false) @ApiModelProperty(value = "设备图片") - private List deviceImages; + private List deviceImages; } diff --git a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/AircraftInsurance.java b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/AircraftInsurance.java index 5b37449..a634ed6 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/AircraftInsurance.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/AircraftInsurance.java @@ -1,7 +1,7 @@ package com.aircraft.modules.aircraft.domain; import com.aircraft.base.BaseEntity; -import com.aircraft.domain.dto.LocalAttachmentMaterialDTO; +import com.aircraft.domain.dto.AttachmentMaterialDTO; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; @@ -71,7 +71,7 @@ public class AircraftInsurance extends BaseEntity { @NotNull @TableField(exist = false) @ApiModelProperty(value = "保险附件") - private List insuranceAttachment; + private List insuranceAttachment; } diff --git a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftDeviceServiceImpl.java b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftDeviceServiceImpl.java index 45609d7..564fa97 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftDeviceServiceImpl.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftDeviceServiceImpl.java @@ -1,6 +1,6 @@ package com.aircraft.modules.aircraft.service.impl; -import com.aircraft.domain.dto.LocalAttachmentMaterialDTO; +import com.aircraft.domain.dto.AttachmentMaterialDTO; import com.aircraft.exception.BadRequestException; import com.aircraft.modules.aircraft.domain.AircraftDevice; import com.aircraft.modules.aircraft.domain.dto.AircraftDevicePageDTO; @@ -113,14 +113,14 @@ public class AircraftDeviceServiceImpl extends ServiceImpl deviceImages = attachmentMaterialService + List deviceImages = attachmentMaterialService .lambdaQuery() .eq(AttachmentMaterial::getBusinessType, BUSINESS_TYPE) .eq(AttachmentMaterial::getBusinessId, id) .list() .stream() .map(attachmentMaterial -> { - LocalAttachmentMaterialDTO localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO(); + AttachmentMaterialDTO localAttachmentMaterialDTO = new AttachmentMaterialDTO(); BeanUtils.copyProperties(attachmentMaterial, localAttachmentMaterialDTO); return localAttachmentMaterialDTO; }).toList(); diff --git a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftInsuranceServiceImpl.java b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftInsuranceServiceImpl.java index 6d19d1e..6cc6c47 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftInsuranceServiceImpl.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftInsuranceServiceImpl.java @@ -1,6 +1,6 @@ package com.aircraft.modules.aircraft.service.impl; -import com.aircraft.domain.dto.LocalAttachmentMaterialDTO; +import com.aircraft.domain.dto.AttachmentMaterialDTO; import com.aircraft.modules.aircraft.domain.AircraftInsurance; import com.aircraft.modules.aircraft.mapper.AircraftInsuranceMapper; import com.aircraft.modules.aircraft.service.AircraftInsuranceService; @@ -102,14 +102,14 @@ public class AircraftInsuranceServiceImpl extends ServiceImpl insuranceAttachment = attachmentMaterialService + List insuranceAttachment = attachmentMaterialService .lambdaQuery() .eq(AttachmentMaterial::getBusinessType, BUSINESS_TYPE) .eq(AttachmentMaterial::getBusinessId, id) .list() .stream() .map(attachmentMaterial -> { - LocalAttachmentMaterialDTO localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO(); + AttachmentMaterialDTO localAttachmentMaterialDTO = new AttachmentMaterialDTO(); BeanUtils.copyProperties(attachmentMaterial, localAttachmentMaterialDTO); return localAttachmentMaterialDTO; }).toList(); diff --git a/aircraft-system/src/main/resources/config/application-dev.yml b/aircraft-system/src/main/resources/config/application-dev.yml index b988150..627d652 100644 --- a/aircraft-system/src/main/resources/config/application-dev.yml +++ b/aircraft-system/src/main/resources/config/application-dev.yml @@ -127,15 +127,16 @@ file: amz: s3: # 地域 - region: test + region: cn-wulanchabu # 地域对应的 endpoint - endPoint: https://s3.test.com + endPoint: https://oss-cn-wulanchabu.aliyuncs.com # 访问的域名 - domain: https://s3.test.com + domain: https://aishangyun.oss-cn-wulanchabu.aliyuncs.com/ # 账号的认证信息,或者子账号的认证信息 - accessKey: 填写你的AccessKey - secretKey: 填写你的SecretKey + accessKey: LTAI5tRK1mszQC82s2rCkowq + secretKey: Ns8VAkRBauIuC207s3eGiqMrLbpF4e # 存储桶(Bucket) - defaultBucket: 填写你的存储桶名称 + defaultBucket: aishangyun + # 文件存储路径 timeformat: yyyy-MM \ No newline at end of file diff --git a/aircraft-tools/src/main/java/com/aircraft/config/AmzS3Config.java b/aircraft-tools/src/main/java/com/aircraft/config/AmzS3Config.java index ba8f960..9257cde 100644 --- a/aircraft-tools/src/main/java/com/aircraft/config/AmzS3Config.java +++ b/aircraft-tools/src/main/java/com/aircraft/config/AmzS3Config.java @@ -6,8 +6,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.auth.signer.AwsS3V4Signer; +import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; +import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3Client; +import software.amazon.awssdk.services.s3.S3Configuration; + import java.net.URI; /** @@ -72,6 +77,16 @@ public class AmzS3Config { return S3Client.builder().region(Region.of(region)) .endpointOverride(URI.create(endPoint)) .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey))) + .overrideConfiguration( + ClientOverrideConfiguration.builder() + .putAdvancedOption(SdkAdvancedClientOption.SIGNER, AwsS3V4Signer.create()) + .build() + ) + .serviceConfiguration( + S3Configuration.builder() + .chunkedEncodingEnabled(false) // 关闭chunked encoding + .build() + ) .build(); } } \ No newline at end of file diff --git a/aircraft-tools/src/main/java/com/aircraft/domain/dto/LocalAttachmentMaterialDTO.java b/aircraft-tools/src/main/java/com/aircraft/domain/dto/AttachmentMaterialDTO.java similarity index 92% rename from aircraft-tools/src/main/java/com/aircraft/domain/dto/LocalAttachmentMaterialDTO.java rename to aircraft-tools/src/main/java/com/aircraft/domain/dto/AttachmentMaterialDTO.java index 781990e..2ca7fad 100644 --- a/aircraft-tools/src/main/java/com/aircraft/domain/dto/LocalAttachmentMaterialDTO.java +++ b/aircraft-tools/src/main/java/com/aircraft/domain/dto/AttachmentMaterialDTO.java @@ -5,10 +5,10 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** - * 本地附件材料DTO + * 附件材料DTO */ @Data -public class LocalAttachmentMaterialDTO { +public class AttachmentMaterialDTO { @ApiModelProperty(value = "id") 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 6b25360..2634d60 100644 --- a/aircraft-tools/src/main/java/com/aircraft/rest/LocalStorageController.java +++ b/aircraft-tools/src/main/java/com/aircraft/rest/LocalStorageController.java @@ -1,112 +1,112 @@ -/* - * Copyright 2019-2025 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -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; -import com.aircraft.domain.LocalStorage; -import com.aircraft.exception.BadRequestException; -import com.aircraft.service.LocalStorageService; -import com.aircraft.domain.dto.LocalStorageQueryCriteria; -import com.aircraft.utils.FileUtil; -import com.aircraft.utils.PageResult; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** -* @author Zheng Jie -* @date 2019-09-05 -*/ -@RestController -@RequiredArgsConstructor -@Api(tags = "工具:本地存储管理") -@RequestMapping("/api/localStorage") -public class LocalStorageController { - - private final LocalStorageService localStorageService; - - @GetMapping - @ApiOperation("查询文件") - @PreAuthorize("@el.check('storage:list')") - public ResponseEntity> queryFile(LocalStorageQueryCriteria criteria){ - Page page = new Page<>(criteria.getPage(), criteria.getSize()); - return new ResponseEntity<>(localStorageService.queryAll(criteria,page),HttpStatus.OK); - } - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('storage:list')") - public void exportFile(HttpServletResponse response, LocalStorageQueryCriteria criteria) throws IOException { - localStorageService.download(localStorageService.queryAll(criteria), response); - } - - @PostMapping - @ApiOperation("上传文件") - public ResponseEntity createFile(@RequestPart("file") MultipartFile file){ - LocalStorage localStorage = localStorageService.create(file.getOriginalFilename(), file); - LocalAttachmentMaterialDTO localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO(); - localAttachmentMaterialDTO.setFileType(localStorage.getSuffix()); - localAttachmentMaterialDTO.setFileSize(file.getSize()); - localAttachmentMaterialDTO.setNewFileName(localStorage.getRealName()); - localAttachmentMaterialDTO.setSourceFileName(localStorage.getName()); - localAttachmentMaterialDTO.setFileFullPath("/file/" + localStorage.getType() + "/" + localStorage.getRealName()); - return new ResponseEntity<>(localAttachmentMaterialDTO, HttpStatus.OK); - } - - @ApiOperation("上传图片") - @PostMapping("/pictures") - 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(file.getOriginalFilename(), file); - LocalAttachmentMaterialDTO localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO(); - localAttachmentMaterialDTO.setFileType(localStorage.getSuffix()); - localAttachmentMaterialDTO.setFileSize(file.getSize()); - localAttachmentMaterialDTO.setNewFileName(localStorage.getRealName()); - localAttachmentMaterialDTO.setSourceFileName(localStorage.getName()); - localAttachmentMaterialDTO.setFileFullPath("/file/" + localStorage.getType() + "/" + localStorage.getRealName()); - 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); +///* +// * Copyright 2019-2025 Zheng Jie +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +//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; +//import com.aircraft.domain.LocalStorage; +//import com.aircraft.exception.BadRequestException; +//import com.aircraft.service.LocalStorageService; +//import com.aircraft.domain.dto.LocalStorageQueryCriteria; +//import com.aircraft.utils.FileUtil; +//import com.aircraft.utils.PageResult; +//import org.springframework.http.HttpStatus; +//import org.springframework.http.ResponseEntity; +//import org.springframework.security.access.prepost.PreAuthorize; +//import org.springframework.validation.annotation.Validated; +//import org.springframework.web.bind.annotation.*; +//import io.swagger.annotations.*; +//import org.springframework.web.multipart.MultipartFile; +//import javax.servlet.http.HttpServletResponse; +//import java.io.IOException; +// +///** +//* @author Zheng Jie +//* @date 2019-09-05 +//*/ +//@RestController +//@RequiredArgsConstructor +//@Api(tags = "工具:本地存储管理") +//@RequestMapping("/api/localStorage") +//public class LocalStorageController { +// +// private final LocalStorageService localStorageService; +// +// @GetMapping +// @ApiOperation("查询文件") +// @PreAuthorize("@el.check('storage:list')") +// public ResponseEntity> queryFile(LocalStorageQueryCriteria criteria){ +// Page page = new Page<>(criteria.getPage(), criteria.getSize()); +// return new ResponseEntity<>(localStorageService.queryAll(criteria,page),HttpStatus.OK); // } // -// @Log("删除文件") -// @DeleteMapping -// @ApiOperation("多选删除") -// @PreAuthorize("@el.check('storage:del')") -// public ResponseEntity deleteFile(@RequestBody Long[] ids) { -// localStorageService.deleteAll(ids); -// return new ResponseEntity<>(HttpStatus.OK); +// @ApiOperation("导出数据") +// @GetMapping(value = "/download") +// @PreAuthorize("@el.check('storage:list')") +// public void exportFile(HttpServletResponse response, LocalStorageQueryCriteria criteria) throws IOException { +// localStorageService.download(localStorageService.queryAll(criteria), response); // } -} \ No newline at end of file +// +// @PostMapping +// @ApiOperation("上传文件") +// public ResponseEntity createFile(@RequestPart("file") MultipartFile file){ +// LocalStorage localStorage = localStorageService.create(file.getOriginalFilename(), file); +// LocalAttachmentMaterialDTO localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO(); +// localAttachmentMaterialDTO.setFileType(localStorage.getSuffix()); +// localAttachmentMaterialDTO.setFileSize(file.getSize()); +// localAttachmentMaterialDTO.setNewFileName(localStorage.getRealName()); +// localAttachmentMaterialDTO.setSourceFileName(localStorage.getName()); +// localAttachmentMaterialDTO.setFileFullPath("/file/" + localStorage.getType() + "/" + localStorage.getRealName()); +// return new ResponseEntity<>(localAttachmentMaterialDTO, HttpStatus.OK); +// } +// +// @ApiOperation("上传图片") +// @PostMapping("/pictures") +// 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(file.getOriginalFilename(), file); +// LocalAttachmentMaterialDTO localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO(); +// localAttachmentMaterialDTO.setFileType(localStorage.getSuffix()); +// localAttachmentMaterialDTO.setFileSize(file.getSize()); +// localAttachmentMaterialDTO.setNewFileName(localStorage.getRealName()); +// localAttachmentMaterialDTO.setSourceFileName(localStorage.getName()); +// localAttachmentMaterialDTO.setFileFullPath("/file/" + localStorage.getType() + "/" + localStorage.getRealName()); +// 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); +//// } +//} \ 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 9f6d7fa..87ffefc 100644 --- a/aircraft-tools/src/main/java/com/aircraft/rest/S3StorageController.java +++ b/aircraft-tools/src/main/java/com/aircraft/rest/S3StorageController.java @@ -15,27 +15,18 @@ */ package com.aircraft.rest; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.aircraft.domain.dto.AttachmentMaterialDTO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import com.aircraft.annotation.Log; import com.aircraft.config.AmzS3Config; import com.aircraft.domain.S3Storage; -import com.aircraft.domain.dto.S3StorageQueryCriteria; import com.aircraft.service.S3StorageService; -import com.aircraft.utils.PageResult; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; /** * amz S3 协议云存储管理 @@ -51,55 +42,57 @@ public class S3StorageController { private final AmzS3Config amzS3Config; private final S3StorageService s3StorageService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('storage:list')") - public void exportS3Storage(HttpServletResponse response, S3StorageQueryCriteria criteria) throws IOException { - s3StorageService.download(s3StorageService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询文件") - @PreAuthorize("@el.check('storage:list')") - public ResponseEntity> queryS3Storage(S3StorageQueryCriteria criteria){ - Page page = new Page<>(criteria.getPage(), criteria.getSize()); - return new ResponseEntity<>(s3StorageService.queryAll(criteria, page),HttpStatus.OK); - } +// +// @ApiOperation("导出数据") +// @GetMapping(value = "/download") +// @PreAuthorize("@el.check('storage:list')") +// public void exportS3Storage(HttpServletResponse response, S3StorageQueryCriteria criteria) throws IOException { +// s3StorageService.download(s3StorageService.queryAll(criteria), response); +// } +// +// @GetMapping +// @ApiOperation("查询文件") +// @PreAuthorize("@el.check('storage:list')") +// public ResponseEntity> queryS3Storage(S3StorageQueryCriteria criteria){ +// Page page = new Page<>(criteria.getPage(), criteria.getSize()); +// return new ResponseEntity<>(s3StorageService.queryAll(criteria, page),HttpStatus.OK); +// } @PostMapping @ApiOperation("上传文件") - public ResponseEntity uploadS3Storage(@RequestPart("file") MultipartFile file){ + public ResponseEntity uploadS3Storage(@RequestPart("file") MultipartFile file){ S3Storage storage = s3StorageService.upload(file); - Map map = new HashMap<>(3); - map.put("id",storage.getId()); - map.put("errno",0); - map.put("data",new String[]{amzS3Config.getDomain() + "/" + storage.getFilePath()}); - return new ResponseEntity<>(map,HttpStatus.OK); + AttachmentMaterialDTO attachmentMaterialDTO = new AttachmentMaterialDTO(); + attachmentMaterialDTO.setFileType(storage.getFileType()); + attachmentMaterialDTO.setFileSize(file.getSize()); + attachmentMaterialDTO.setNewFileName(storage.getFileRealName()); + attachmentMaterialDTO.setSourceFileName(storage.getFileName()); + attachmentMaterialDTO.setFileFullPath(storage.getFileFullPath()); + return new ResponseEntity<>(attachmentMaterialDTO, HttpStatus.OK); } - @Log("下载文件") - @ApiOperation("下载文件") - @GetMapping(value = "/download/{id}") - public ResponseEntity downloadS3Storage(@PathVariable Long id){ - Map map = new HashMap<>(1); - S3Storage storage = s3StorageService.getById(id); - if (storage == null) { - map.put("message", "文件不存在或已被删除"); - return new ResponseEntity<>(map, HttpStatus.NOT_FOUND); - } - // 仅适合公开文件访问,私有文件可以使用服务中的 privateDownload 方法 - String url = amzS3Config.getDomain() + "/" + storage.getFilePath(); - map.put("url", url); - return new ResponseEntity<>(map,HttpStatus.OK); - } - - @Log("删除多个文件") - @DeleteMapping - @ApiOperation("删除多个文件") - @PreAuthorize("@el.check('storage:del')") - public ResponseEntity deleteAllS3Storage(@RequestBody List ids) { - s3StorageService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } +// @Log("下载文件") +// @ApiOperation("下载文件") +// @GetMapping(value = "/download/{id}") +// public ResponseEntity downloadS3Storage(@PathVariable Long id){ +// Map map = new HashMap<>(1); +// S3Storage storage = s3StorageService.getById(id); +// if (storage == null) { +// map.put("message", "文件不存在或已被删除"); +// return new ResponseEntity<>(map, HttpStatus.NOT_FOUND); +// } +// // 仅适合公开文件访问,私有文件可以使用服务中的 privateDownload 方法 +// String url = amzS3Config.getDomain() + "/" + storage.getFilePath(); +// map.put("url", url); +// return new ResponseEntity<>(map,HttpStatus.OK); +// } +// +// @Log("删除多个文件") +// @DeleteMapping +// @ApiOperation("删除多个文件") +// @PreAuthorize("@el.check('storage:del')") +// public ResponseEntity deleteAllS3Storage(@RequestBody List ids) { +// s3StorageService.deleteAll(ids); +// return new ResponseEntity<>(HttpStatus.OK); +// } } 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 829edbc..f955133 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 @@ -33,6 +33,8 @@ import org.apache.commons.io.IOUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.aircraft.utils.PageUtil; + +import java.io.InputStream; import java.util.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; @@ -129,9 +131,9 @@ public class S3StorageServiceImpl extends ServiceImpl Date: Mon, 21 Jul 2025 15:12:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E2=80=9D/=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aircraft-system/src/main/resources/config/application-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aircraft-system/src/main/resources/config/application-dev.yml b/aircraft-system/src/main/resources/config/application-dev.yml index 627d652..91a7d91 100644 --- a/aircraft-system/src/main/resources/config/application-dev.yml +++ b/aircraft-system/src/main/resources/config/application-dev.yml @@ -131,7 +131,7 @@ amz: # 地域对应的 endpoint endPoint: https://oss-cn-wulanchabu.aliyuncs.com # 访问的域名 - domain: https://aishangyun.oss-cn-wulanchabu.aliyuncs.com/ + domain: https://aishangyun.oss-cn-wulanchabu.aliyuncs.com # 账号的认证信息,或者子账号的认证信息 accessKey: LTAI5tRK1mszQC82s2rCkowq secretKey: Ns8VAkRBauIuC207s3eGiqMrLbpF4e