更新了写真预约特殊产品处理
This commit is contained in:
parent
074f4fd742
commit
6c916c9c43
|
@ -11,7 +11,6 @@ import com.cultural.heritage.model.entity.User;
|
||||||
import com.cultural.heritage.model.enums.FileUploadBizEnum;
|
import com.cultural.heritage.model.enums.FileUploadBizEnum;
|
||||||
import com.cultural.heritage.service.file.IHweiYunOBSService;
|
import com.cultural.heritage.service.file.IHweiYunOBSService;
|
||||||
import com.cultural.heritage.service.user.UserService;
|
import com.cultural.heritage.service.user.UserService;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -26,8 +25,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/file")
|
@RequestMapping("/file")
|
||||||
|
@ -144,36 +141,6 @@ public class FileController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/upload/only")
|
|
||||||
@Operation(summary = "单独文件上传(只返回url)", description = "参数:file,文件对象(multipartFile),权限:所有人,方法名:uploadServerFile")
|
|
||||||
public Object uploadOnlyServerFile(@RequestPart("file")MultipartFile multipartFile, HttpServletRequest request) {
|
|
||||||
//
|
|
||||||
// 校验文件
|
|
||||||
validFile(multipartFile, null);
|
|
||||||
// 文件目录:根据业务、用户来划分
|
|
||||||
String uuid = RandomStringUtils.randomAlphabetic(8);
|
|
||||||
String filename = uuid + "-" + multipartFile.getOriginalFilename();
|
|
||||||
String filepath = String.format("/%s/%s/%s", "single", "yt", filename);
|
|
||||||
|
|
||||||
// 判断目录是否存在
|
|
||||||
File file = new File(FileConstant.SERVER_UPLOAD_DIR, filepath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
// 创建目录
|
|
||||||
boolean mkdirs = file.mkdirs();
|
|
||||||
if (!mkdirs) {
|
|
||||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//返回可访问地址
|
|
||||||
String url = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath);
|
|
||||||
Map<String, String> map = new HashMap<>();
|
|
||||||
map.put("url", url);
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Object obj = gson.fromJson(gson.toJson(map), Object.class);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user