init:删除无用配置
This commit is contained in:
@@ -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 失效"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 用户部门现在1:n,该方法禁用
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowCredentials(true);
|
||||
config.setAllowCredentials(false);
|
||||
config.addAllowedOrigin("*");
|
||||
config.addAllowedHeader("*");
|
||||
config.addAllowedMethod("*");
|
||||
|
||||
@@ -36,6 +36,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
|
||||
//
|
||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(excludes); // 白名单
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.wf.captcha.base.Captcha;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.RedisUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.common.utils.dto.CurrentUser;
|
||||
@@ -45,6 +46,7 @@ public class AuthorizationController {
|
||||
|
||||
|
||||
@PostMapping(value = "/login")
|
||||
@Log
|
||||
public ResponseEntity<Object> login(@RequestBody JSONObject authMap, HttpServletRequest request) throws Exception {
|
||||
if (ObjectUtil.isEmpty(authMap)){
|
||||
return ResponseEntity.noContent().build();
|
||||
|
||||
@@ -28,10 +28,10 @@ const user = {
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
// const rememberMe = userInfo.rememberMe
|
||||
const rememberMe = userInfo.rememberMe
|
||||
return new Promise((resolve, reject) => {
|
||||
login(userInfo.username, userInfo.password, userInfo.code, userInfo.uuid).then(res => {
|
||||
// setToken(res.token, rememberMe)
|
||||
setToken(res.token, rememberMe)
|
||||
commit('SET_TOKEN', res.token)
|
||||
setUserInfo(res.user, commit)
|
||||
// 第一次加载菜单时用到, 具体见 src 目录下的 permission.js
|
||||
@@ -82,7 +82,6 @@ export const logOut = (commit) => {
|
||||
}
|
||||
|
||||
export const setUserInfo = (res, commit) => {
|
||||
console.log(res)
|
||||
// 如果没有任何权限,则赋予一个默认的权限,避免请求死循环
|
||||
if (res.roles && res.roles.length > 0) {
|
||||
commit('SET_ROLES', res.roles)
|
||||
|
||||
Reference in New Issue
Block a user