修复文件上传大小限制问题
This commit is contained in:
@ -1,13 +1,10 @@
|
||||
package com.coscoshipping.ebtp.system;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ -16,6 +13,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
@MapperScan({"com.coscoshipping.ebtp.system.**.dao", "com.chinaunicom.mall.ebtp.**.dao" })
|
||||
@ComponentScan(basePackages = { "com.coscoshipping.ebtp.system.*", "com.chinaunicom.mall.ebtp.cloud.*",
|
||||
"com.chinaunicom.mall.ebtp.*" })
|
||||
@EnableDiscoveryClient
|
||||
public class SysManagerEbtpProjectApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -23,16 +21,4 @@ public class SysManagerEbtpProjectApplication {
|
||||
System.out.println("启动成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Grafana 注册项
|
||||
*
|
||||
* @param applicationName 应用名称, 用于grafana应用列表
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MeterRegistryCustomizer<MeterRegistry> configurer(
|
||||
@Value("${spring.application.name}") String applicationName) {
|
||||
return (registry) -> registry.config().commonTags("application", applicationName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -103,21 +103,25 @@ public class FileController extends BaseController {
|
||||
@RequestParam(required = false, value = "objectTable") String objectTable,
|
||||
@RequestParam(required = false, value = "objectParam") String objectParam,
|
||||
@RequestParam(defaultValue = "file", value = "objectType") String objectType,
|
||||
@RequestParam(value = "multipartFiles") MultipartFile... multipartFiles)
|
||||
throws Exception {
|
||||
@RequestParam(value = "multipartFiles") MultipartFile... multipartFiles) {
|
||||
if (StringUtils.isEmpty(appCode) || StringUtils.isEmpty(String.valueOf(objectId))) {
|
||||
return new BaseResponse<List<AnnexAndStorageVO>>(400, false, ResponseEnum.REQUEST_ERROR.getMsg(), null);
|
||||
}
|
||||
List<AnnexAndStorageVO> annexAndStorageVOs = new ArrayList<>();
|
||||
if (multipartFiles != null && multipartFiles.length > 0) {
|
||||
for (MultipartFile file : multipartFiles) {
|
||||
List<AnnexAndStorageVO> annexAndStorageVOList = this.fileService.uploadFile(file, appCode, objectId, objectTable, objectType, objectParam);
|
||||
annexAndStorageVOs.addAll(annexAndStorageVOList);
|
||||
try {
|
||||
if (multipartFiles != null && multipartFiles.length > 0) {
|
||||
for (MultipartFile file : multipartFiles) {
|
||||
List<AnnexAndStorageVO> annexAndStorageVOList = this.fileService.uploadFile(file, appCode, objectId, objectTable, objectType, objectParam);
|
||||
annexAndStorageVOs.addAll(annexAndStorageVOList);
|
||||
}
|
||||
return ok(annexAndStorageVOs);
|
||||
} else {
|
||||
return new BaseResponse<>(400, false, ResponseEnum.FILE_NOT_EXIST_OR_REQUEST_ERROR.getMsg(), null);
|
||||
}
|
||||
return ok(annexAndStorageVOs);
|
||||
} else {
|
||||
return new BaseResponse<>(400, false, ResponseEnum.FILE_NOT_EXIST_OR_REQUEST_ERROR.getMsg(), null);
|
||||
} catch (Exception e) {
|
||||
return new BaseResponse<>(400, false, e.getMessage(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -389,8 +393,8 @@ public class FileController extends BaseController {
|
||||
* @Date 创建时间: 2021/6/24
|
||||
*/
|
||||
@GetMapping("/getDownload")
|
||||
public BaseResponse<Boolean> getDownload(@RequestParam("fileId") String fileId,HttpServletResponse httpServletResponse ,@RequestParam("documentSecretKey") String documentSecretKey){
|
||||
return fileService.getDownload(fileId,httpServletResponse,documentSecretKey);
|
||||
public BaseResponse<Boolean> getDownload(@RequestParam("fileId") String fileId, HttpServletResponse httpServletResponse, @RequestParam("documentSecretKey") String documentSecretKey) {
|
||||
return fileService.getDownload(fileId, httpServletResponse, documentSecretKey);
|
||||
}
|
||||
|
||||
|
||||
@ -401,7 +405,7 @@ public class FileController extends BaseController {
|
||||
* @Date 创建时间: 2021/6/24
|
||||
*/
|
||||
@GetMapping("/getSecretKey")
|
||||
public BaseResponse<String> getSecretKey(){
|
||||
public BaseResponse<String> getSecretKey() {
|
||||
return fileService.getSecretKey();
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class LoginController {
|
||||
return BaseResponse.success(result);
|
||||
|
||||
}
|
||||
@ApiOperation("账号登录")
|
||||
@ApiOperation("专家账号登录")
|
||||
@PostMapping("/accountLogin/expert")
|
||||
public BaseResponse idcardExpertLogin(HttpServletResponse response,@RequestBody LoginUserVo vo) {
|
||||
if(captchaGenerator.checkCaptcha(vo.getIdentifying(),vo.getEncryptValue())){
|
||||
@ -81,7 +81,7 @@ public class LoginController {
|
||||
return BaseResponse.success(null);
|
||||
}
|
||||
}
|
||||
@ApiOperation("账号登录")
|
||||
@ApiOperation("供应商账号登录")
|
||||
@PostMapping("/accountLogin/supplier")
|
||||
public BaseResponse idcardSupplierLogin(HttpServletResponse response,@RequestBody LoginUserVo vo) {
|
||||
if(captchaGenerator.checkCaptcha(vo.getIdentifying(),vo.getEncryptValue())){
|
||||
|
@ -86,7 +86,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
@Value("${login.password.publickey}")
|
||||
private String publickey;
|
||||
@Value("${login.token.time_limit}")
|
||||
private String valid_time_limit;
|
||||
private String validTimeLimit;
|
||||
@Value("${login.reset_password}")
|
||||
private String resetPassword;
|
||||
@Resource
|
||||
@ -190,7 +190,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
userinfoRedisTemplate.opsForValue().set(
|
||||
REDIS_USER_KEY + token,
|
||||
baseCacheUser,
|
||||
Long.parseLong(valid_time_limit),
|
||||
Long.parseLong(validTimeLimit),
|
||||
TimeUnit.HOURS);
|
||||
|
||||
// 5. 记录登录成功日志
|
||||
@ -255,6 +255,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
|
||||
// 检查是否为首次登录
|
||||
boolean isFirstLogin = user.getFirstLogin() != null && user.getFirstLogin() == 1;
|
||||
String userId = user.getUserId().toString();
|
||||
if (isFirstLogin) {
|
||||
// 首次登录需要强制修改密码,返回特殊状态
|
||||
BaseSelf baseSelf = userSupplierLogin(user);
|
||||
@ -263,7 +264,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
// 记录首次登录日志
|
||||
long loginTime = System.currentTimeMillis() - startTime;
|
||||
sysLoginLogService.recordLoginSuccess(
|
||||
user.getUserId().toString(),
|
||||
userId,
|
||||
user.getName(),
|
||||
user.getUsername(),
|
||||
SysLoginLog.USER_TYPE_SUPPLIER,
|
||||
@ -283,27 +284,51 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
|
||||
BaseSelf baseSelf = userSupplierLogin(user);
|
||||
|
||||
// 1. 查询角色信息
|
||||
List<AuthorityEntity> authorityList = baseUserMapper.selectRoleByUserId(userId);
|
||||
|
||||
// 2. 组装BaseCacheUser
|
||||
BaseCacheUser baseCacheUser = new BaseCacheUser();
|
||||
baseCacheUser.setUserId(userId);
|
||||
baseCacheUser.setFullName(user.getName());
|
||||
baseCacheUser.setLoginName(user.getName());
|
||||
baseCacheUser.setMobilePhone(user.getMobile());
|
||||
baseCacheUser.setOfficePhone(user.getMobile());
|
||||
baseCacheUser.setSex(user.getSex() != null ? user.getSex().toString() : null);
|
||||
baseCacheUser.setEmailAddress(user.getEmail());
|
||||
baseCacheUser.setUserType("0");
|
||||
baseCacheUser.setAuthorityList(authorityList);
|
||||
// 角色ID字符串拼接
|
||||
if (authorityList != null && !authorityList.isEmpty()) {
|
||||
StringBuilder roleIds = new StringBuilder();
|
||||
for (AuthorityEntity ae : authorityList) {
|
||||
if (roleIds.length() > 0)
|
||||
roleIds.append(",");
|
||||
roleIds.append(ae.getRoleId());
|
||||
}
|
||||
baseCacheUser.setRoleIds(roleIds.toString());
|
||||
}
|
||||
|
||||
// 存入redis
|
||||
// String token = baseSelf.getToken();
|
||||
// userinfoRedisTemplate.opsForValue().set(
|
||||
// REDIS_USER_KEY + token,
|
||||
// baseCacheUser,
|
||||
// Long.parseLong(valid_time_limit),
|
||||
// TimeUnit.HOURS);
|
||||
String token = baseSelf.getToken();
|
||||
userinfoRedisTemplate.opsForValue().set(
|
||||
REDIS_USER_KEY + token,
|
||||
baseCacheUser,
|
||||
Long.parseLong(validTimeLimit),
|
||||
TimeUnit.HOURS);
|
||||
|
||||
// 记录登录成功日志
|
||||
long loginTime = System.currentTimeMillis() - startTime;
|
||||
sysLoginLogService.recordLoginSuccess(
|
||||
user.getUserId().toString(),
|
||||
user.getName(),
|
||||
user.getUsername(),
|
||||
SysLoginLog.USER_TYPE_SUPPLIER,
|
||||
loginIp,
|
||||
baseSelf.getToken(),
|
||||
loginTime,
|
||||
userAgent,
|
||||
false
|
||||
);
|
||||
userId,
|
||||
user.getName(),
|
||||
user.getUsername(),
|
||||
SysLoginLog.USER_TYPE_SUPPLIER,
|
||||
loginIp,
|
||||
baseSelf.getToken(),
|
||||
loginTime,
|
||||
userAgent,
|
||||
false);
|
||||
|
||||
return baseSelf;
|
||||
} catch (BadPaddingException e) {
|
||||
@ -663,7 +688,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
BaseUserToken userToken = tokenList.get(0);
|
||||
CommonExceptionEnum.LOGIN_EXPIRATION.assertStringNotNullByKey("", tokenList.get(0).getUserObject());
|
||||
SecurityEntity securityEntity = JSON.parseObject(userToken.getUserObject(), SecurityEntity.class);
|
||||
userToken.setValidTime(LocalDateTime.now().plusMinutes(Long.valueOf(valid_time_limit)));
|
||||
userToken.setValidTime(LocalDateTime.now().plusMinutes(Long.valueOf(validTimeLimit)));
|
||||
|
||||
this.baseUserTokenService.saveOrUpdate(userToken);
|
||||
|
||||
|
@ -6,6 +6,10 @@ server:
|
||||
spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 30MB
|
||||
max-request-size: 100MB
|
||||
cloud:
|
||||
feign:
|
||||
client:
|
||||
@ -16,8 +20,6 @@ spring:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.110.231:8848
|
||||
namespace: seata
|
||||
group: SEATA_GROUP
|
||||
aop:
|
||||
auto: true #开启spring的aop配置
|
||||
proxy-target-class: true
|
||||
|
Reference in New Issue
Block a user