配置更新、代码优化

This commit is contained in:
attiya 2025-12-16 11:39:58 +08:00
parent 4ad52b73c5
commit 9fefb4869c
3 changed files with 17 additions and 18 deletions

View File

@ -1,6 +1,7 @@
package com.cdzy.user.config; package com.cdzy.user.config;
import com.alibaba.nacos.shaded.com.google.gson.JsonSyntaxException; import com.alibaba.nacos.shaded.com.google.gson.JsonSyntaxException;
import com.cdzy.common.ex.EbikeException;
import com.cdzy.common.model.response.JsonResult; import com.cdzy.common.model.response.JsonResult;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.ConstraintViolationException; import jakarta.validation.ConstraintViolationException;
@ -105,10 +106,24 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
@ExceptionHandler @ExceptionHandler
public JsonResult<?> exp(HttpServletRequest request, Exception e) { public JsonResult<?> exp(HttpServletRequest request, EbikeException e) {
// LogFactory.getLog(super.getClass()).error(e.getMessage(), e); // LogFactory.getLog(super.getClass()).error(e.getMessage(), e);
log.error(request.getServletPath(), e); log.error(request.getServletPath(), e);
return JsonResult.failed(e.getMessage()); return JsonResult.failed(e.getMessage());
} }
/**
* 处理其他类型异常
* @param request 请求
* @param e 异常
* @return 结果
*/
@ResponseBody
@ExceptionHandler
public JsonResult<?> exp(HttpServletRequest request, Exception e) {
// LogFactory.getLog(super.getClass()).error(e.getMessage(), e);
log.error(request.getServletPath(), e);
return JsonResult.failed("系统内部发生错误,请联系工作人员");
}
} }

View File

@ -25,7 +25,7 @@ public class EbikeRealNameSignDto {
public Map<String, String> toMap() { public Map<String, String> toMap() {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("name", this.name); map.put("name", this.name);
map.put("idCard", this.idCard); map.put("idcard", this.idCard);
map.put("timestamp", this.timestamp); map.put("timestamp", this.timestamp);
return map; return map;
} }

View File

@ -61,22 +61,6 @@ spring:
mybatis-flex: mybatis-flex:
mapper-locations: classpath:mapper/*.xml mapper-locations: classpath:mapper/*.xml
############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: Authorization
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: true
# token 风格默认可取值uuid、simple-uuid、random-32、random-64、random-128、tik
token-style: random-32
# 是否输出操作日志
is-log: true
#微信小程序 #微信小程序
wechat: wechat: