09-22-优化安装包文件上传

This commit is contained in:
2025-09-22 20:56:02 +08:00
parent a2167e8227
commit 5b6d3bf758

View File

@ -42,8 +42,20 @@ public class SysPackageController {
@Transactional @Transactional
@GetMapping("/uploadNewVersion") @GetMapping("/uploadNewVersion")
public R<SysPackage> uploadNewVersion(String version, String type, MultipartFile file) { public R<SysPackage> uploadNewVersion(String version, String type, MultipartFile file) {
SysOssVo path = sysOssService.upload(file);
String originalFileName = "apk/package/app-release.apk"; String originalFileName = "apk/package/app-release.apk";
//覆盖失败,先删除文件
LambdaQueryWrapper<SysPackage> lambdaQueryWrapper =new LambdaQueryWrapper<>();
lambdaQueryWrapper.orderByDesc(SysPackage::getCreateTime);
List<SysPackage> list = sysPackageService.list(lambdaQueryWrapper);
if (list != null && !list.isEmpty()){
SysPackage first = list.getFirst();
Boolean b = sysOssService.deleteWithValidByIds(List.of(first.getFileId()), false);
if (!b){
return R.fail("删除文件失败");
}
}
SysOssVo upload = sysOssService.upload(file, originalFileName); SysOssVo upload = sysOssService.upload(file, originalFileName);
if (upload == null){ if (upload == null){
return R.fail("上传失败"); return R.fail("上传失败");