Merge remote-tracking branch 'origin/master'

This commit is contained in:
wcy 2024-09-12 13:44:14 +08:00
commit 643258fecb
20 changed files with 157 additions and 174 deletions

View File

@ -56,7 +56,7 @@ public class SysUser extends BaseEntity
private String avatar;
/** 密码 */
private String password;
private transient String password;
/** 帐号状态0正常 1停用 */
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")

View File

@ -15,6 +15,7 @@ import com.bonus.sgzb.system.api.RemoteUserService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import com.bonus.sgzb.auth.service.SysLoginService;
import com.bonus.sgzb.common.core.domain.R;
@ -36,9 +37,11 @@ import java.util.Map;
@Slf4j
public class TokenController {
private final String USER_PASSWORD = "NwCc@2024*";
@Value("${sgzb.userPassword}")
private String USER_PASSWORD;
private final String privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKNPuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gAkM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWowcSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99EcvDQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthhYhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3UP8iWi1Qw0Y=";
@Value("${sgzb.privateKey}")
private String privateKey;
@Autowired
private TokenService tokenService;
@ -150,6 +153,8 @@ public class TokenController {
String captcha = redisService.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + uuid).toString();
if (StringUtils.isBlank(captcha)) {
// 删除验证码缓存
redisService.deleteObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
return R.fail("验证码超时,请重新刷新");
}

View File

@ -29,12 +29,12 @@ public class RegisterForms extends BaseEntity {
* 登录密码
*/
@ApiModelProperty(name = "userPassword", value = "登录密码")
private String userPassword;
private transient String userPassword;
/**
* 确认密码
*/
@ApiModelProperty(name = "againPassword", value = "确认密码")
private String againPassword;
private transient String againPassword;
/**
* 手机号码
*/
@ -83,13 +83,13 @@ public class RegisterForms extends BaseEntity {
/**
* 是否原有用户
*/
@ApiModelProperty(name = "isOriginalUser",value = "是否原有用户")
@ApiModelProperty(name = "isOriginalUser", value = "是否原有用户")
private Integer isOriginalUser;
/**
* 南网 外部关联Id(集成平台联调Id)
*/
@ApiModelProperty(name = "externalId",value = "南网外部关联Id(集成平台联调Id)")
@ApiModelProperty(name = "externalId", value = "南网外部关联Id(集成平台联调Id)")
private String externalId;
}

View File

@ -47,7 +47,7 @@ public class UserAccount extends BaseEntity {
/**
* 密码
*/
private String password;
private transient String password;
/**
* 电话
*/

View File

@ -4,11 +4,11 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 192.168.0.62:8848
server-addr: 192.168.0.119:8848
namespace: sgzb_nwjj
config:
# 配置中心地址
server-addr: 192.168.0.62:8848
server-addr: 192.168.0.119:8848
namespace: sgzb_nwjj
# 配置文件格式
file-extension: yml

View File

@ -1,10 +1,16 @@
package com.bonus.sgzb.common.core.constant;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* 通用常量信息
*
* @author ruoyi
*/
@Component
public class Constants
{
/**
@ -139,11 +145,6 @@ public class Constants
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework", "org.apache", "com.bonus.sgzb.common.core.utils.file" };
/**
* 系统初始密码
*/
public static final String USER_PASSWORD = "CqCc@2024*";
/**
* 系统初始密码
*/
@ -152,12 +153,17 @@ public class Constants
/**
* 加密公钥
*/
public static final String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==";
// public static final String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==";
/**
* 解密私钥
*/
public static final String privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKNPuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gAkM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWowcSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99EcvDQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthhYhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3UP8iWi1Qw0Y=";
public static String privateKey;
@Value("${sgzb.system.privateKey}")
public void setServerPort(String privateKey){
this.privateKey= privateKey;
}
public static final String INNER_PROTOCAL = "1"; //内部单位协议

View File

@ -1,5 +1,6 @@
package com.bonus.sgzb.common.core.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateUtils;
import java.text.*;
@ -14,6 +15,7 @@ import java.util.*;
* 日期工具类
* @author bns
*/
@Slf4j
public class DateTimeHelper {
@ -400,7 +402,7 @@ public class DateTimeHelper {
return result;
} catch (ParseException e) {
e.printStackTrace();
log.error("An error occurred", e);
}
return null;
}
@ -523,7 +525,7 @@ public class DateTimeHelper {
}
} catch (ParseException e) {
e.printStackTrace();
log.error("An error occurred", e);
}
return list;
}
@ -716,7 +718,7 @@ public class DateTimeHelper {
// 打印时间戳
return timeStamp;
} catch (ParseException e) {
e.printStackTrace();
log.error("An error occurred", e);
}
return 0;
}
@ -810,8 +812,8 @@ public class DateTimeHelper {
}
public static void main(String[] args) {
System.err.println(getTimeAfterThirtyDay());
System.err.println(getNowTime());
log.error(getTimeAfterThirtyDay());
log.error(getNowTime());
}
/**

View File

@ -194,7 +194,7 @@ public class ServletUtils
* @param response 渲染对象
* @param string 待渲染的字符串
*/
public static void renderString(HttpServletResponse response, String string)
/*public static void renderString(HttpServletResponse response, String string)
{
try
{
@ -207,7 +207,7 @@ public class ServletUtils
{
e.printStackTrace();
}
}
}*/
/**
* 是否是Ajax异步请求

View File

@ -1,5 +1,6 @@
package com.bonus.sgzb.common.core.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.io.*;
@ -14,6 +15,7 @@ import java.util.regex.Pattern;
/**
* @author bns
*/
@Slf4j
public class StringHelper {
private static final String hexString = "0123456789ABCDEF";
@ -74,7 +76,7 @@ public class StringHelper {
pfp.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error("unicodeToString error", e);
}
}
@ -91,7 +93,7 @@ public class StringHelper {
String content = new String(b.getBytes((long) 1, (int) b.length()), "UTF-8");
return content;
} catch (SQLException | UnsupportedEncodingException e) {
e.printStackTrace();
log.error("unicodeToString error", e);
}
return null;
}
@ -107,7 +109,7 @@ public class StringHelper {
return new String(content.getBytes("ISO_8859_1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error("unicodeToString error", e);
}
return content;
}

View File

@ -1,5 +1,7 @@
package com.bonus.sgzb.common.core.utils.bean;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@ -8,46 +10,47 @@ import java.util.regex.Pattern;
/**
* Bean 工具类
*
*
* @author ruoyi
*/
public class BeanUtils extends org.springframework.beans.BeanUtils
{
/** Bean方法名中属性名开始的下标 */
@Slf4j
public class BeanUtils extends org.springframework.beans.BeanUtils {
/**
* Bean方法名中属性名开始的下标
*/
private static final int BEAN_METHOD_PROP_INDEX = 3;
/** * 匹配getter方法的正则表达式 */
/**
* 匹配getter方法的正则表达式
*/
private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
/** * 匹配setter方法的正则表达式 */
/**
* 匹配setter方法的正则表达式
*/
private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)");
/**
* Bean属性复制工具方法
*
*
* @param dest 目标对象
* @param src 源对象
* @param src 源对象
*/
public static void copyBeanProp(Object dest, Object src)
{
try
{
public static void copyBeanProp(Object dest, Object src) {
try {
copyProperties(src, dest);
}
catch (Exception e)
{
e.printStackTrace();
} catch (Exception e) {
log.error("An error occurred", e);
}
}
/**
* 获取对象的setter方法
*
*
* @param obj 对象
* @return 对象的setter方法列表
*/
public static List<Method> getSetterMethods(Object obj)
{
public static List<Method> getSetterMethods(Object obj) {
// setter方法列表
List<Method> setterMethods = new ArrayList<Method>();
@ -56,11 +59,9 @@ public class BeanUtils extends org.springframework.beans.BeanUtils
// 查找setter方法
for (Method method : methods)
{
for (Method method : methods) {
Matcher m = SET_PATTERN.matcher(method.getName());
if (m.matches() && (method.getParameterTypes().length == 1))
{
if (m.matches() && (method.getParameterTypes().length == 1)) {
setterMethods.add(method);
}
}
@ -70,23 +71,20 @@ public class BeanUtils extends org.springframework.beans.BeanUtils
/**
* 获取对象的getter方法
*
*
* @param obj 对象
* @return 对象的getter方法列表
*/
public static List<Method> getGetterMethods(Object obj)
{
public static List<Method> getGetterMethods(Object obj) {
// getter方法列表
List<Method> getterMethods = new ArrayList<Method>();
// 获取所有方法
Method[] methods = obj.getClass().getMethods();
// 查找getter方法
for (Method method : methods)
{
for (Method method : methods) {
Matcher m = GET_PATTERN.matcher(method.getName());
if (m.matches() && (method.getParameterTypes().length == 0))
{
if (m.matches() && (method.getParameterTypes().length == 0)) {
getterMethods.add(method);
}
}
@ -97,14 +95,13 @@ public class BeanUtils extends org.springframework.beans.BeanUtils
/**
* 检查Bean方法名中的属性名是否相等<br>
* 如getName()和setName()属性名一样getName()和setAge()属性名不一样
*
*
* @param m1 方法名1
* @param m2 方法名2
* @return 属性名一样返回true否则返回false
*/
public static boolean isMethodPropEquals(String m1, String m2)
{
public static boolean isMethodPropEquals(String m1, String m2) {
return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
}
}

View File

@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
import com.bonus.sgzb.common.core.utils.GlobalConstants;
import com.bonus.sgzb.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
/**
@ -20,6 +21,7 @@ import org.apache.commons.lang3.ArrayUtils;
*
* @author ruoyi
*/
@Slf4j
public class FileUtils
{
/** 字符常量:斜杠 {@code '/'} */
@ -69,7 +71,7 @@ public class FileUtils
}
catch (IOException e1)
{
e1.printStackTrace();
log.error("关闭文件输出流失败", e1);
}
}
if (fis != null)
@ -80,7 +82,7 @@ public class FileUtils
}
catch (IOException e1)
{
e1.printStackTrace();
log.error("关闭文件输入流失败", e1);
}
}
}

View File

@ -159,7 +159,7 @@ public class EscapeUtil
return tmp.toString();
}
public static void main(String[] args)
/* public static void main(String[] args)
{
String html = "<script>alert(1);</script>";
String escape = EscapeUtil.escape(html);
@ -169,5 +169,5 @@ public class EscapeUtil
System.out.println("clean: " + EscapeUtil.clean(html));
System.out.println("escape: " + escape);
System.out.println("unescape: " + EscapeUtil.unescape(escape));
}
}*/
}

View File

@ -40,19 +40,22 @@ import com.bonus.sgzb.system.api.domain.SysOperLog;
/**
* 操作日志记录处理
*
*
* @author ruoyi
*/
@Aspect
@Component
public class LogAspect
{
public class LogAspect {
private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
/** 排除敏感属性字段 */
public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
/**
* 排除敏感属性字段
*/
public static final String[] EXCLUDE_PROPERTIES = {"password", "oldPassword", "newPassword", "confirmPassword"};
/** 计算操作消耗时间 */
/**
* 计算操作消耗时间
*/
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
private static ObjectMapper objectMapper = new ObjectMapper();
@ -67,8 +70,7 @@ public class LogAspect
* 处理请求前执行
*/
@Before(value = "@annotation(controllerLog)")
public void boBefore(JoinPoint joinPoint, Log controllerLog)
{
public void boBefore(JoinPoint joinPoint, Log controllerLog) {
TIME_THREADLOCAL.set(System.currentTimeMillis());
}
@ -78,8 +80,7 @@ public class LogAspect
* @param joinPoint 切点
*/
@AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult)
{
public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) {
if (controllerLog.businessType() == BusinessType.MATERIAL) {
handleMaterialLog(joinPoint, controllerLog, null, jsonResult);
} else {
@ -89,20 +90,17 @@ public class LogAspect
/**
* 拦截异常操作
*
*
* @param joinPoint 切点
* @param e 异常
* @param e 异常
*/
@AfterThrowing(value = "@annotation(controllerLog)", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e)
{
public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) {
handleLog(joinPoint, controllerLog, e, null);
}
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult)
{
try
{
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
try {
// *========数据库日志=========*//
SysOperLog operLog = new SysOperLog();
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
@ -111,13 +109,11 @@ public class LogAspect
operLog.setOperIp(ip);
operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
String username = SecurityUtils.getUsername();
if (StringUtils.isNotBlank(username))
{
if (StringUtils.isNotBlank(username)) {
operLog.setOperName(username);
}
if (e != null)
{
if (e != null) {
operLog.setStatus(BusinessStatus.FAIL.ordinal());
operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
}
@ -133,22 +129,16 @@ public class LogAspect
operLog.setCostTime(System.currentTimeMillis() - TIME_THREADLOCAL.get());
// 保存数据库
asyncLogService.saveSysLog(operLog);
}
catch (Exception exp)
{
} catch (Exception exp) {
// 记录本地异常日志
log.error("异常信息:{}", exp.getMessage());
exp.printStackTrace();
}
finally
{
} finally {
TIME_THREADLOCAL.remove();
}
}
protected void handleMaterialLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
try
{
try {
List<BmStorageLog> bmStorageLogList = new ArrayList<>();
// 处理设置注解上的参数
@ -161,8 +151,7 @@ public class LogAspect
bmStorageLog.setMethod(StringUtils.substring(Objects.requireNonNull(ServletUtils.getRequest()).getRequestURI(), 0, 255));
String username = SecurityUtils.getUsername();
R<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
if (ObjectUtils.isNotEmpty(userInfo))
{
if (ObjectUtils.isNotEmpty(userInfo)) {
bmStorageLog.setCreator(userInfo.getData().getSysUser().getNickName());
}
@ -183,35 +172,29 @@ public class LogAspect
bmStorageLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
HttpResult msgCode = objectMapper.readValue(bmStorageLog.getJsonResult(), HttpResult.class);
bmStorageLog.setResultCode(msgCode.getCode());
bmStorageLog.setStatus(msgCode.getCode()==200 ? 0 : 1);
bmStorageLog.setStatus(msgCode.getCode() == 200 ? 0 : 1);
bmStorageLog.setResultMsg(msgCode.getMsg());
}
}
// 保存数据库
asyncLogService.batchInsert(bmStorageLogList);
}
catch (Exception exp)
{
} catch (Exception exp) {
// 记录本地异常日志
log.error("异常信息:{}", exp.getMessage());
exp.printStackTrace();
}
finally
{
} finally {
TIME_THREADLOCAL.remove();
}
}
/**
* 获取注解中对方法的描述信息 用于Controller层注解
*
* @param log 日志
*
* @param log 日志
* @param operLog 操作日志
* @throws Exception
*/
public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception
{
public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception {
// 设置action动作
operLog.setBusinessType(log.businessType().ordinal());
// 设置标题
@ -219,14 +202,12 @@ public class LogAspect
// 设置操作人类别
operLog.setOperatorType(log.operatorType().ordinal());
// 是否需要保存request参数和值
if (log.isSaveRequestData())
{
if (log.isSaveRequestData()) {
// 获取参数的信息传入到数据库中
setRequestValue(joinPoint, operLog, log.excludeParamNames());
}
// 是否需要保存response参数和值
if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
{
if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) {
operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
}
}
@ -261,8 +242,8 @@ public class LogAspect
BmStorageLog bmStorageLog = new BmStorageLog();
bmStorageLog.setTypeId(Objects.isNull(maInputRecord.getTypeId()) ? 0 : maInputRecord.getTypeId().intValue());
bmStorageLog.setTypeName(maInputRecord.getMaCode());
bmStorageLog.setPostStoreNum(Objects.isNull(maInputRecord.getNum()) ? 0: maInputRecord.getNum().intValue());
bmStorageLog.setInNum(Objects.isNull(maInputRecord.getInputNum()) ? 0: maInputRecord.getInputNum().intValue());
bmStorageLog.setPostStoreNum(Objects.isNull(maInputRecord.getNum()) ? 0 : maInputRecord.getNum().intValue());
bmStorageLog.setInNum(Objects.isNull(maInputRecord.getInputNum()) ? 0 : maInputRecord.getInputNum().intValue());
bmStorageLog.setPreStoreNum(bmStorageLog.getPostStoreNum() - bmStorageLog.getInNum());
bmStorageLog.setTaskId(String.valueOf(maInputRecord.getTaskId()));
bmStorageLogList.add(bmStorageLog);
@ -285,7 +266,7 @@ public class LogAspect
// 领料出库
if (joinPoint.getArgs()[0] instanceof List &&
((List) joinPoint.getArgs()[0]).stream().noneMatch((o -> !(o instanceof LeaseOutDetails)))) {
List<LeaseOutDetails> leaseOutDetails = (List<LeaseOutDetails>)joinPoint.getArgs()[0];
List<LeaseOutDetails> leaseOutDetails = (List<LeaseOutDetails>) joinPoint.getArgs()[0];
for (LeaseOutDetails lod : leaseOutDetails) {
BmStorageLog bmStorageLog = new BmStorageLog();
bmStorageLog.setTaskId(String.valueOf(lod.getTaskId()));
@ -298,7 +279,7 @@ public class LogAspect
}
}
if (joinPoint.getArgs()[0] instanceof LeaseOutDetails) {
LeaseOutDetails lod = (LeaseOutDetails)joinPoint.getArgs()[0];
LeaseOutDetails lod = (LeaseOutDetails) joinPoint.getArgs()[0];
BmStorageLog bmStorageLog = new BmStorageLog();
bmStorageLog.setTaskId(String.valueOf(lod.getTaskId()));
bmStorageLog.setTypeId(lod.getTypeId());
@ -310,7 +291,7 @@ public class LogAspect
}
// 退料接收-完成退料
if (joinPoint.getArgs()[0] instanceof BackApplyInfo) {
BackApplyInfo bai = (BackApplyInfo)joinPoint.getArgs()[0];
BackApplyInfo bai = (BackApplyInfo) joinPoint.getArgs()[0];
BmStorageLog bmStorageLog = new BmStorageLog();
bmStorageLog.setTaskId(String.valueOf(bai.getTaskId()));
bmStorageLog.setTypeId(Integer.parseInt(bai.getTypeId()));
@ -352,7 +333,7 @@ public class LogAspect
/**
* 获取请求的参数放到log中
*
*
* @param operLog 操作日志
* @throws Exception 异常
*/
@ -360,7 +341,7 @@ public class LogAspect
String requestMethod = operLog.getRequestMethod();
Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
if (StringUtils.isEmpty(paramsMap)) {
if ((HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))){
if ((HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))) {
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
}
@ -372,22 +353,15 @@ public class LogAspect
/**
* 参数拼装
*/
private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames)
{
private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames) {
String params = "";
if (paramsArray != null && paramsArray.length > 0)
{
for (Object o : paramsArray)
{
if (StringUtils.isNotNull(o) && !isFilterObject(o))
{
try
{
if (paramsArray != null && paramsArray.length > 0) {
for (Object o : paramsArray) {
if (StringUtils.isNotNull(o) && !isFilterObject(o)) {
try {
String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter(excludeParamNames));
params += jsonObj.toString() + " ";
}
catch (Exception e)
{
} catch (Exception e) {
}
}
}
@ -398,38 +372,29 @@ public class LogAspect
/**
* 忽略敏感属性
*/
public PropertyPreExcludeFilter excludePropertyPreFilter(String[] excludeParamNames)
{
public PropertyPreExcludeFilter excludePropertyPreFilter(String[] excludeParamNames) {
return new PropertyPreExcludeFilter().addExcludes(ArrayUtils.addAll(EXCLUDE_PROPERTIES, excludeParamNames));
}
/**
* 判断是否需要过滤的对象
*
*
* @param o 对象信息
* @return 如果是需要过滤的对象则返回true否则返回false
*/
@SuppressWarnings("rawtypes")
public boolean isFilterObject(final Object o)
{
public boolean isFilterObject(final Object o) {
Class<?> clazz = o.getClass();
if (clazz.isArray())
{
if (clazz.isArray()) {
return clazz.getComponentType().isAssignableFrom(MultipartFile.class);
}
else if (Collection.class.isAssignableFrom(clazz))
{
} else if (Collection.class.isAssignableFrom(clazz)) {
Collection collection = (Collection) o;
for (Object value : collection)
{
for (Object value : collection) {
return value instanceof MultipartFile;
}
}
else if (Map.class.isAssignableFrom(clazz))
{
} else if (Map.class.isAssignableFrom(clazz)) {
Map map = (Map) o;
for (Object value : map.entrySet())
{
for (Object value : map.entrySet()) {
Map.Entry entry = (Map.Entry) value;
return entry.getValue() instanceof MultipartFile;
}

View File

@ -11,11 +11,11 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 192.168.0.62:8848
server-addr: 192.168.0.119:8848
namespace: sgzb_nwjj
config:
# 配置中心地址
server-addr: 192.168.0.62:8848
server-addr: 192.168.0.119:8848
namespace: sgzb_nwjj
# 配置文件格式
file-extension: yml

View File

@ -2,20 +2,23 @@ package com.bonus.sgzb.system.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.io.File;
import java.util.Arrays;
/**
* 通用映射配置
*
*
* @author ruoyi
*/
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
public class ResourcesConfig implements WebMvcConfigurer {
/**
* 上传文件存储在本地的根路径
*/
@ -29,13 +32,12 @@ public class ResourcesConfig implements WebMvcConfigurer
public String localFilePrefix;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
public void addResourceHandlers(ResourceHandlerRegistry registry) {
/** 本地文件上传路径 */
registry.addResourceHandler("/**")
.addResourceLocations("file:" + localFilePath + File.separator);
}
/**
* 开启跨域
*/
@ -46,6 +48,6 @@ public class ResourcesConfig implements WebMvcConfigurer
// 设置允许跨域请求的域名
.allowedOrigins("*")
// 设置允许的方法
.allowedMethods("*");
.allowedMethods("GET", "POST", "PUT", "DELETE");
}
}

View File

@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.system.config.RsaUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -39,7 +40,8 @@ import com.bonus.sgzb.system.service.ISysConfigService;
@RequestMapping("/config")
public class SysConfigController extends BaseController
{
private final String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==";
@Value("${sgzb.system.publicKey}")
private String publicKey;
private final String CONFIG_KEY = "sys.user.initPassword";
@Autowired
private ISysConfigService configService;

View File

@ -60,7 +60,7 @@ public class SysFileController {
ErrorCode.ATTACHMENT_UPLOAD_FAILED.getMessage());
}
}catch (Exception e){
e.printStackTrace();
log.error(e.getMessage());
}
if (file != null && file.getId() != 0){
return AjaxResult.success(file);
@ -91,7 +91,7 @@ public class SysFileController {
IOUtils.copy(inputStream, servletOutputStream);
response.flushBuffer();
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
} finally {
try {
if (servletOutputStream != null) {
@ -103,7 +103,7 @@ public class SysFileController {
// 召唤jvm的垃圾回收器
System.gc();
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
}
}

View File

@ -108,7 +108,7 @@ public class SysUserController extends BaseController {
util.exportExcel(response, list, "用户数据");
}
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
/* @Log(title = "用户管理", businessType = BusinessType.IMPORT)
@RequiresPermissions("system:user:import")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
@ -117,7 +117,7 @@ public class SysUserController extends BaseController {
String operName = SecurityUtils.getUsername();
String message = userService.importUser(userList, updateSupport, operName);
return success(message);
}
}*/
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException {

View File

@ -95,7 +95,7 @@ public class SysFileServiceImpl implements SysFileService {
dao.insertFileInfo(file);
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return file;
}
@ -141,7 +141,7 @@ public class SysFileServiceImpl implements SysFileService {
// 返回上传文件路径:https://ggkt-atguigu-1310644373.cos.ap-beijing.myqcloud.com/01.jpg
return "https://" + bucketName + "." + "cos" + "." + ConstantPropertiesUtil.END_POINT+".myqcloud.com" + "/" + key;
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return null;
}
@ -177,7 +177,7 @@ public class SysFileServiceImpl implements SysFileService {
dao.insertFileInfo(file);
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return file;
}
@ -194,7 +194,7 @@ public class SysFileServiceImpl implements SysFileService {
}
map.put("filePath", tmps);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return map;
}
@ -232,7 +232,7 @@ public class SysFileServiceImpl implements SysFileService {
fos.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
}
return url;
@ -271,7 +271,7 @@ public class SysFileServiceImpl implements SysFileService {
fos.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
}
return url;
@ -314,7 +314,7 @@ public class SysFileServiceImpl implements SysFileService {
}
length = cnWordsCount + noCnWordsCount;
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
} finally {
if (fileInputStream != null) {
fileInputStream.close();

View File

@ -15,11 +15,11 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 192.168.0.62:8848
server-addr: 192.168.0.119:8848
namespace: sgzb_nwjj
config:
# 配置中心地址
server-addr: 192.168.0.62:8848
server-addr: 192.168.0.119:8848
namespace: sgzb_nwjj
# 配置文件格式
file-extension: yml