init:删除无用配置

This commit is contained in:
zhangzq
2025-06-25 17:22:19 +08:00
parent a39ac4e6f3
commit cc3376f60d
7 changed files with 44 additions and 23 deletions

View File

@@ -57,8 +57,7 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(value = NotLoginException.class)
public ResponseEntity<ApiError> notLoginException(Exception e) {
// log.error(ThrowableUtil.getStackTrace(e));
log.error("token超时:-------------------------------------" + e.getMessage());
log.error(ThrowableUtil.getStackTrace(e));
return buildResponseEntity(ApiError.error(401, "token 失效"));
}

View File

@@ -13,19 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.common.domain.aspect;
package org.nl.common.logging.aspect;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import io.netty.util.internal.ThrowableUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.nl.common.utils.*;
import org.nl.common.utils.IPUtil;
import org.nl.common.utils.IdUtil;
import org.nl.common.utils.RequestHolder;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.lucene.LuceneAppender;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;
@@ -58,6 +59,7 @@ public class LogAspect {
*/
@Around("@annotation(logInfo)")
public Object logAround(ProceedingJoinPoint joinPoint,org.nl.common.logging.annotation.Log logInfo) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
String params = getParameter(method, joinPoint.getArgs());
@@ -72,6 +74,11 @@ public class LogAspect {
try {
log.info("[--request--][请求接口:{}][请求参数:{}]",url,params);
result = joinPoint.proceed();
// //是否把日志存到日志表
// if (logInfo.isAddLogTable()) {
// Log log = new Log("INFO", System.currentTimeMillis() - comming);
// logService.save(getUsername(), StringUtils.getBrowser(request), requestIp, joinPoint, log);
// }
}catch (Exception ex){
StringBuffer errorStack = new StringBuffer();

View File

@@ -2,8 +2,8 @@ package org.nl.common.utils;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.utils.dto.CurrentUser;
@@ -24,14 +24,22 @@ public class SecurityUtils {
*/
public static CurrentUser getCurrentUser() {
try {
JSONObject json = (JSONObject) StpUtil.getExtra("loginInfo");
if (ObjectUtil.isNotEmpty(json)) {
return json.toBean(CurrentUser.class);
Object loginInfo = StpUtil.getExtra("loginInfo");
if (loginInfo==null){
CurrentUser currentUser = new CurrentUser();
currentUser.setId("2");
currentUser.setPresonName("外部系统用户");
currentUser.setUsername("admin");
return currentUser;
}
return JSONObject.parseObject(String.valueOf(loginInfo),CurrentUser.class);
} catch (Exception e) {
return CurrentUser.getDefaultUser();
CurrentUser currentUser = new CurrentUser();
currentUser.setId("2");
currentUser.setPresonName("外部系统用户");
currentUser.setUsername("admin");
return currentUser;
}
return CurrentUser.getDefaultUser();
}
/**
@@ -49,7 +57,11 @@ public class SecurityUtils {
* @return 系统用户名称
*/
public static String getCurrentNickName() {
return getCurrentUser().getPresonName();
CurrentUser user = getCurrentUser();
if (user!=null){
return user.getPresonName();
}
return null;
}
/**
@@ -62,11 +74,12 @@ public class SecurityUtils {
}
/**
* 获取系统用户Id
*
* @return 系统用户Id
* 获取系统用户部门Id
* @return 用户部门现在1n该方法禁用
*/
@Deprecated
public static Long getDeptId() {
// return getCurrentUser().getUser().getDept().getId();
return 1L;
}
@@ -76,10 +89,10 @@ public class SecurityUtils {
* @return 权限列表
*/
public static List<String> getCurrentUserPermissions() {
JSONObject json = (JSONObject) StpUtil.getExtra("loginInfo");
JSONObject json =JSONObject.parseObject(String.valueOf(StpUtil.getExtra("loginInfo")));
JSONArray permissions = json.getJSONArray("permissions");
if (permissions.size() > 0) {
return permissions.toList(String.class);
return permissions.toJavaList(String.class);
}
return null;
}