BCE临时使用

This commit is contained in:
2025-07-24 00:32:49 +08:00
parent 477554cb35
commit eb61058fd1
8 changed files with 185 additions and 7 deletions

View File

@@ -21,5 +21,5 @@ public interface SourceService {
ApiResponse<Integer> update(SourceEntity source);
ApiResponse cutVideo(Long id);
ApiResponse<String> uploadAndUpdateUrl(Long id, org.springframework.web.multipart.MultipartFile file);
String uploadAndUpdateUrl(Long id, org.springframework.web.multipart.MultipartFile file);
}

View File

@@ -2,6 +2,7 @@ package com.ycwl.basic.service.pc.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycwl.basic.exception.BaseException;
import com.ycwl.basic.mapper.SourceMapper;
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
@@ -24,6 +25,8 @@ import java.net.URL;
import java.util.Collections;
import java.util.List;
import static com.ycwl.basic.constant.StorageConstant.PHOTO_PATH;
/**
* @Author:longbinbin
* @Date:2024/12/3 15:49
@@ -145,14 +148,14 @@ public class SourceServiceImpl implements SourceService {
}
@Override
public ApiResponse<String> uploadAndUpdateUrl(Long id, MultipartFile file) {
public String uploadAndUpdateUrl(Long id, MultipartFile file) {
SourceRespVO source = sourceMapper.getById(id);
if (source == null) {
return ApiResponse.fail("该素材不存在");
throw new BaseException("该素材不存在");
}
try {
IStorageAdapter adapter = scenicService.getScenicStorageAdapter(source.getScenicId());
String uploadedUrl = adapter.uploadFile(file, "source", String.valueOf(id));
String uploadedUrl = adapter.uploadFile(file, PHOTO_PATH, id + "_q_.jpg");
SourceEntity sourceUpd = new SourceEntity();
sourceUpd.setId(id);
@@ -160,12 +163,12 @@ public class SourceServiceImpl implements SourceService {
int updateResult = sourceMapper.update(sourceUpd);
if (updateResult > 0) {
return ApiResponse.success(uploadedUrl);
return uploadedUrl;
} else {
return ApiResponse.fail("更新URL失败");
throw new BaseException("更新URL失败");
}
} catch (Exception e) {
return ApiResponse.fail("文件上传失败: " + e.getMessage());
throw new BaseException("文件上传失败: " + e.getMessage());
}
}
}