mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-17 19:06:39 +08:00
v2.0 修改下登录提示语
This commit is contained in:
parent
cc590abc9e
commit
340dc1950c
@ -0,0 +1,38 @@
|
||||
package net.lab1024.sa.admin.config;
|
||||
|
||||
import net.lab1024.sa.common.common.domain.RequestUser;
|
||||
import net.lab1024.sa.common.common.util.SmartRequestUtil;
|
||||
import net.lab1024.sa.common.module.support.jwe.JweAspect;
|
||||
import net.lab1024.sa.common.module.support.jwe.JweUserKey;
|
||||
import net.lab1024.sa.common.module.support.operatelog.core.OperateLogAspect;
|
||||
import net.lab1024.sa.common.module.support.operatelog.core.OperateLogConfig;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 操作日志切面 配置
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022-05-30 21:22:12
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net )
|
||||
*/
|
||||
@Configuration
|
||||
public class JweAspectConfig {
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*/
|
||||
@Bean
|
||||
public JweAspect jweConfig() {
|
||||
return new JweAspect((request -> {
|
||||
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||
JweUserKey userKey = new JweUserKey();
|
||||
userKey.setUserId(requestUser.getUserId());
|
||||
userKey.setUserName(requestUser.getUserName());
|
||||
userKey.setExtData(requestUser.getUserType().getValue().toString());
|
||||
return userKey;
|
||||
}));
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class LoginForm extends CaptchaForm {
|
||||
|
||||
@ApiModelProperty("密码")
|
||||
@NotBlank(message = "密码不能为空")
|
||||
@Pattern(regexp = SmartVerificationUtil.PWD_REGEXP, message = "请输入8-15位密码(数字|大小写字母|小数点)")
|
||||
@Pattern(regexp = SmartVerificationUtil.PWD_REGEXP, message = "请输入6-15位密码(数字|大小写字母|小数点)")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "登录终端")
|
||||
|
@ -1,56 +0,0 @@
|
||||
package net.lab1024.sa.common.common.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
* @description:
|
||||
* @date 2022/11/25 9:32 上午
|
||||
*/
|
||||
public class SmartUrlMatcherUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 当前请求是与urlPatterns中的匹配
|
||||
* @param urlPatterns
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static Boolean contain(List<String> urlPatterns, HttpServletRequest request) {
|
||||
if (CollectionUtils.isEmpty(urlPatterns)) {
|
||||
return false;
|
||||
}
|
||||
String uri = request.getRequestURI();
|
||||
for (String urlPattern : urlPatterns) {
|
||||
AntPathMatcher antPathMatcher = new AntPathMatcher();
|
||||
boolean match = antPathMatcher.match(urlPattern, uri);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> ignoreUrlList = Lists.newArrayList();
|
||||
ignoreUrlList.add("/swagger-ui.html");
|
||||
ignoreUrlList.add("/swagger-resources/**");
|
||||
ignoreUrlList.add("/*/api-docs");
|
||||
|
||||
String uri = "/v2/api-docs?group=Admin";
|
||||
for (String urlPattern : ignoreUrlList) {
|
||||
AntPathMatcher antPathMatcher = new AntPathMatcher();
|
||||
boolean match = antPathMatcher.match(urlPattern, uri);
|
||||
if (match) {
|
||||
System.out.println(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package net.lab1024.sa.common.config;
|
||||
|
||||
import net.lab1024.sa.common.common.interceptor.AbstractInterceptor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
@ -27,9 +27,6 @@ public class MvcConfig implements WebMvcConfigurer {
|
||||
@Autowired(required = false)
|
||||
private List<HandlerInterceptor> interceptorList;
|
||||
|
||||
@Value("${file.storage.local.path}")
|
||||
private String localPath;
|
||||
|
||||
@Override
|
||||
public void addInterceptors (InterceptorRegistry registry) {
|
||||
if (CollectionUtils.isEmpty(interceptorList)) {
|
||||
@ -42,8 +39,7 @@ public class MvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/preview/**")
|
||||
.addResourceLocations("file:" + localPath);
|
||||
registry.addResourceHandler("/preview/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import net.lab1024.sa.common.common.exception.BusinessException;
|
||||
import org.springframework.beans.TypeMismatchException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
@ -76,6 +77,15 @@ public class GlobalExceptionHandler {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限异常
|
||||
*/
|
||||
@ResponseBody
|
||||
@ExceptionHandler({AccessDeniedException.class})
|
||||
public ResponseDTO<?> permissionExceptionHandler(AccessDeniedException e) {
|
||||
return ResponseDTO.error(UserErrorCode.NO_PERMISSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
|
@ -1,32 +0,0 @@
|
||||
package net.lab1024.sa.common.handler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.common.common.code.UserErrorCode;
|
||||
import net.lab1024.sa.common.common.domain.ResponseDTO;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* [ 全局异常拦截 ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @date 2020/8/25 11:57
|
||||
*/
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
@ConditionalOnClass(AccessDeniedException.class)
|
||||
public class SecurityExceptionHandler {
|
||||
|
||||
/**
|
||||
* 权限异常
|
||||
*/
|
||||
@ResponseBody
|
||||
@ExceptionHandler({AccessDeniedException.class})
|
||||
public ResponseDTO<?> permissionExceptionHandler(AccessDeniedException e) {
|
||||
return ResponseDTO.error(UserErrorCode.NO_PERMISSION);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user