更新了写真预约特殊产品处理
This commit is contained in:
parent
3c656d8a4d
commit
0e5bc9d778
|
@ -114,6 +114,40 @@ public class FileController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/upload/single")
|
||||
@Operation(summary = "单独文件上传", description = "参数:file,文件对象(multipartFile),权限:所有人,方法名:uploadServerFile")
|
||||
public BaseResponse<String> uploadSingleServerFile(@RequestPart("file")MultipartFile multipartFile, HttpServletRequest request) {
|
||||
//
|
||||
// 校验文件
|
||||
validFile(multipartFile, null);
|
||||
// 校验用户是否登录
|
||||
User loginUser = userService.getLoginUser(request);
|
||||
if (loginUser == null) {
|
||||
throw new BusinessException(ErrorCode.NOT_LOGIN_ERROR, "未登录");
|
||||
}
|
||||
// 文件目录:根据业务、用户来划分
|
||||
String uuid = RandomStringUtils.randomAlphabetic(8);
|
||||
String filename = uuid + "-" + multipartFile.getOriginalFilename();
|
||||
String filepath = String.format("/%s/%s/%s", "single", loginUser.getId(), 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);
|
||||
return ResultUtils.success(url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 校验文件
|
||||
*
|
||||
|
|
|
@ -9,6 +9,17 @@ spring:
|
|||
maximum-pool-size: 20
|
||||
max-lifetime: 120000
|
||||
|
||||
# 测试环境
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://123.249.108.160:3306/feiyi?serverTimezone=Asia/Shanghai
|
||||
# username: feiyi
|
||||
# password: 123456asd
|
||||
# hikari:
|
||||
# maximum-pool-size: 20
|
||||
# max-lifetime: 120000
|
||||
|
||||
|
||||
|
||||
rabbitmq:
|
||||
host: 123.249.108.160
|
||||
port: 5672
|
||||
|
@ -21,12 +32,6 @@ spring:
|
|||
|
||||
|
||||
|
||||
# 测试环境
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://123.249.108.160:3306/feiyi?serverTimezone=Asia/Shanghai
|
||||
# username: feiyi
|
||||
# password: 123456asd
|
||||
|
||||
|
||||
data:
|
||||
redis:
|
||||
|
|
Loading…
Reference in New Issue
Block a user