|
@@ -58,7 +58,9 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.ResourceUtils;
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
+import vip.xiaonuo.auth.core.pojo.SaBaseLoginUser;
|
|
|
import vip.xiaonuo.auth.core.util.StpClientUtil;
|
|
|
+import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
import vip.xiaonuo.common.annotation.CommonNoRepeat;
|
|
|
import vip.xiaonuo.common.annotation.CommonWrapper;
|
|
|
import vip.xiaonuo.common.cache.CommonCacheOperator;
|
|
@@ -108,29 +110,17 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
/* 微信相关的 */
|
|
|
"/wx/**",
|
|
|
/* 静态资源 */
|
|
|
- "/favicon.ico",
|
|
|
- "/doc.html",
|
|
|
- "/webjars/**",
|
|
|
- "/v3/api-docs/**",
|
|
|
- "/druid/**",
|
|
|
+ "/favicon.ico", "/doc.html", "/webjars/**", "/v3/api-docs/**", "/druid/**",
|
|
|
/* 移动端静态资源 */
|
|
|
"/mobile/**",
|
|
|
|
|
|
/* 认证相关 */
|
|
|
- "/auth/c/getPicCaptcha",
|
|
|
- "/auth/c/getPhoneValidCode",
|
|
|
- "/auth/c/doLogin",
|
|
|
- "/auth/c/doLoginByPhone",
|
|
|
+ "/auth/c/getPicCaptcha", "/auth/c/getPhoneValidCode", "/auth/c/doLogin", "/auth/c/doLoginByPhone",
|
|
|
|
|
|
- "/auth/b/getPicCaptcha",
|
|
|
- "/auth/b/getPhoneValidCode",
|
|
|
- "/auth/b/doLogin",
|
|
|
- "/auth/mini/doLogin",
|
|
|
- "/auth/b/doLoginByPhone",
|
|
|
+ "/auth/b/getPicCaptcha", "/auth/b/getPhoneValidCode", "/auth/b/doLogin", "/auth/mini/doLogin", "/auth/b/doLoginByPhone",
|
|
|
|
|
|
/* 三方登录相关 */
|
|
|
- "/auth/third/render",
|
|
|
- "/auth/third/callback",
|
|
|
+ "/auth/third/render", "/auth/third/callback",
|
|
|
|
|
|
/* 系统基础配置 */
|
|
|
"/dev/config/sysBaseList",
|
|
@@ -142,62 +132,17 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
"/dev/file/download",
|
|
|
|
|
|
/* 用户个人中心相关 */
|
|
|
- "/sys/userCenter/getPicCaptcha",
|
|
|
- "/sys/userCenter/findPasswordGetPhoneValidCode",
|
|
|
- "/sys/userCenter/findPasswordGetEmailValidCode",
|
|
|
- "/sys/userCenter/findPasswordByPhone",
|
|
|
- "/sys/userCenter/findPasswordByEmail"
|
|
|
- };
|
|
|
+ "/sys/userCenter/getPicCaptcha", "/sys/userCenter/findPasswordGetPhoneValidCode", "/sys/userCenter/findPasswordGetEmailValidCode", "/sys/userCenter/findPasswordByPhone", "/sys/userCenter/findPasswordByEmail"};
|
|
|
|
|
|
/**
|
|
|
* 仅超管使用的接口地址集合
|
|
|
*/
|
|
|
- private static final String[] SUPER_PERMISSION_PATH_ARR = {
|
|
|
- "/auth/session/**",
|
|
|
- "/auth/third/page",
|
|
|
- "/client/user/**",
|
|
|
- "/sys/org/**",
|
|
|
- "/sys/position/**",
|
|
|
- "/sys/button/**",
|
|
|
- "/sys/menu/**",
|
|
|
- "/sys/module/**",
|
|
|
- "/sys/role/**",
|
|
|
- "/sys/user/**",
|
|
|
- "/sys/index/bizDataCount",
|
|
|
- "/sys/index/opDataCount",
|
|
|
- "/sys/index/toolDataCount",
|
|
|
- "/dev/config/**",
|
|
|
- "/dev/dict/**",
|
|
|
- "/dev/email/page",
|
|
|
- "/dev/email/delete",
|
|
|
- "/dev/email/detail",
|
|
|
- "/dev/file/page",
|
|
|
- "/dev/file/list",
|
|
|
- "/dev/file/delete",
|
|
|
- "/dev/file/detail",
|
|
|
- "/dev/job/**",
|
|
|
- "/dev/log/**",
|
|
|
- "/dev/message/page",
|
|
|
- "/dev/message/delete",
|
|
|
- "/dev/message/detail",
|
|
|
- "/dev/monitor/**",
|
|
|
- "/dev/sms/page",
|
|
|
- "/dev/sms/delete",
|
|
|
- "/dev/sms/detail",
|
|
|
- "/dev/slideshow/**",
|
|
|
- "/gen/basic/**",
|
|
|
- "/gen/config/**",
|
|
|
- "/mobile/menu/**",
|
|
|
- "/mobile/module/**",
|
|
|
- };
|
|
|
+ private static final String[] SUPER_PERMISSION_PATH_ARR = {"/auth/session/**", "/auth/third/page", "/client/user/**", "/sys/org/**", "/sys/position/**", "/sys/button/**", "/sys/menu/**", "/sys/module/**", "/sys/role/**", "/sys/user/**", "/sys/index/bizDataCount", "/sys/index/opDataCount", "/sys/index/toolDataCount", "/dev/config/**", "/dev/dict/**", "/dev/email/page", "/dev/email/delete", "/dev/email/detail", "/dev/file/page", "/dev/file/list", "/dev/file/delete", "/dev/file/detail", "/dev/job/**", "/dev/log/**", "/dev/message/page", "/dev/message/delete", "/dev/message/detail", "/dev/monitor/**", "/dev/sms/page", "/dev/sms/delete", "/dev/sms/detail", "/dev/slideshow/**", "/gen/basic/**", "/gen/config/**", "/mobile/menu/**", "/mobile/module/**",};
|
|
|
|
|
|
/**
|
|
|
* B端要排除的,相当于C端要认证的
|
|
|
*/
|
|
|
- private static final String[] CLIENT_USER_PERMISSION_PATH_ARR = {
|
|
|
- "/auth/c/**",
|
|
|
- "/client/c/**"
|
|
|
- };
|
|
|
+ private static final String[] CLIENT_USER_PERMISSION_PATH_ARR = {"/auth/c/**", "/client/c/**"};
|
|
|
|
|
|
/**
|
|
|
* 注册跨域过滤器
|
|
@@ -263,8 +208,8 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
// 如果是预检请求,则立即返回到前端
|
|
|
SaRouter.match(SaHttpMethod.OPTIONS)
|
|
|
// OPTIONS预检请求,不做处理
|
|
|
- .free(r -> {})
|
|
|
- .back();
|
|
|
+ .free(r -> {
|
|
|
+ }).back();
|
|
|
})
|
|
|
|
|
|
// 异常处理
|
|
@@ -272,7 +217,7 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
// 由于过滤器中抛出的异常不进入全局异常处理,所以必须提供[异常处理函数]来处理[认证函数]里抛出的异常
|
|
|
// 在[异常处理函数]里的返回值,将作为字符串输出到前端,此处统一转为JSON输出前端
|
|
|
SaResponse saResponse = SaHolder.getResponse();
|
|
|
- saResponse.setHeader(Header.CONTENT_TYPE.getValue(), ContentType.JSON + ";charset=" + CharsetUtil.UTF_8);
|
|
|
+ saResponse.setHeader(Header.CONTENT_TYPE.getValue(), ContentType.JSON + ";charset=" + CharsetUtil.UTF_8);
|
|
|
return GlobalExceptionUtil.getCommonResult((Exception) e);
|
|
|
});
|
|
|
}
|
|
@@ -352,7 +297,7 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
// 获取该接口缓存的限流数据,跟当前ip以及登录用户有关
|
|
|
String cacheKey = COMMON_REPEAT_SUBMIT_CACHE_KEY + CommonIpAddressUtil.getIp(request) + StrUtil.COLON;
|
|
|
Object loginId = StpUtil.getLoginIdDefaultNull();
|
|
|
- if(ObjectUtil.isNotEmpty(loginId)) {
|
|
|
+ if (ObjectUtil.isNotEmpty(loginId)) {
|
|
|
cacheKey = cacheKey + Convert.toStr(loginId) + StrUtil.COLON + url;
|
|
|
} else {
|
|
|
cacheKey = cacheKey + url;
|
|
@@ -360,14 +305,14 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
Object cacheObj = commonCacheOperator.get(cacheKey);
|
|
|
if (ObjectUtil.isNotEmpty(cacheObj)) {
|
|
|
JSONObject cacheJsonObject = JSONUtil.parseObj(cacheObj);
|
|
|
- if(cacheJsonObject.containsKey(url)) {
|
|
|
+ if (cacheJsonObject.containsKey(url)) {
|
|
|
JSONObject existRepeatJsonObject = cacheJsonObject.getJSONObject(url);
|
|
|
// 如果与上次参数一致,且时间间隔小于要求的限流时长,则判定为重复提交
|
|
|
if (jsonObject.getStr("repeatParam").equals(existRepeatJsonObject.getStr("repeatParam"))) {
|
|
|
long interval = jsonObject.getLong("repeatTime") - existRepeatJsonObject.getLong("repeatTime");
|
|
|
- if(interval < commonNoRepeat.interval()) {
|
|
|
+ if (interval < commonNoRepeat.interval()) {
|
|
|
long secondsParam = (commonNoRepeat.interval() - interval) / 1000;
|
|
|
- if(secondsParam > 0) {
|
|
|
+ if (secondsParam > 0) {
|
|
|
throw new CommonException("请求过于频繁,请" + CommonTimeFormatUtil.formatSeconds(secondsParam) + "后再试");
|
|
|
}
|
|
|
}
|
|
@@ -540,7 +485,7 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
return "dm";
|
|
|
} else if (url.contains("jdbc:kingbase")) {
|
|
|
return "kingbase";
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
return "mysql";
|
|
|
}
|
|
|
} finally {
|
|
@@ -558,21 +503,36 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
@Component
|
|
|
public static class CustomMetaObjectHandler implements MetaObjectHandler {
|
|
|
|
|
|
- /** 删除标志 */
|
|
|
+ /**
|
|
|
+ * 删除标志
|
|
|
+ */
|
|
|
private static final String DELETE_FLAG = "deleteFlag";
|
|
|
|
|
|
- /** 创建人 */
|
|
|
+ /**
|
|
|
+ * 创建人
|
|
|
+ */
|
|
|
private static final String CREATE_USER = "createUser";
|
|
|
|
|
|
- /** 创建时间 */
|
|
|
+ /**
|
|
|
+ * 创建时间
|
|
|
+ */
|
|
|
private static final String CREATE_TIME = "createTime";
|
|
|
|
|
|
- /** 更新人 */
|
|
|
+ /**
|
|
|
+ * 更新人
|
|
|
+ */
|
|
|
private static final String UPDATE_USER = "updateUser";
|
|
|
|
|
|
- /** 更新时间 */
|
|
|
+ /**
|
|
|
+ * 更新时间
|
|
|
+ */
|
|
|
private static final String UPDATE_TIME = "updateTime";
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建人机构
|
|
|
+ */
|
|
|
+ private static final String CREATE_ORG = "createOrg";
|
|
|
+
|
|
|
@Override
|
|
|
public void insertFill(MetaObject metaObject) {
|
|
|
try {
|
|
@@ -581,21 +541,32 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
if (ObjectUtil.isNull(deleteFlag)) {
|
|
|
setFieldValByName(DELETE_FLAG, EnumUtil.toString(CommonDeleteFlagEnum.NOT_DELETE), metaObject);
|
|
|
}
|
|
|
- } catch (ReflectionException ignored) { }
|
|
|
+ } catch (ReflectionException ignored) {
|
|
|
+ }
|
|
|
try {
|
|
|
//为空则设置createUser
|
|
|
Object createUser = metaObject.getValue(CREATE_USER);
|
|
|
if (ObjectUtil.isNull(createUser)) {
|
|
|
setFieldValByName(CREATE_USER, this.getUserId(), metaObject);
|
|
|
}
|
|
|
- } catch (ReflectionException ignored) { }
|
|
|
+ } catch (ReflectionException ignored) {
|
|
|
+ }
|
|
|
try {
|
|
|
//为空则设置createTime
|
|
|
Object createTime = metaObject.getValue(CREATE_TIME);
|
|
|
if (ObjectUtil.isNull(createTime)) {
|
|
|
setFieldValByName(CREATE_TIME, DateTime.now(), metaObject);
|
|
|
}
|
|
|
- } catch (ReflectionException ignored) { }
|
|
|
+ } catch (ReflectionException ignored) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ //为空则设置createOrg
|
|
|
+ Object createOrg = metaObject.getValue(CREATE_ORG);
|
|
|
+ if (ObjectUtil.isNull(createOrg)) {
|
|
|
+ setFieldValByName(CREATE_ORG, this.getOrgId(), metaObject);
|
|
|
+ }
|
|
|
+ } catch (ReflectionException ignored) {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -603,11 +574,13 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
try {
|
|
|
//设置updateUser
|
|
|
setFieldValByName(UPDATE_USER, this.getUserId(), metaObject);
|
|
|
- } catch (ReflectionException ignored) { }
|
|
|
+ } catch (ReflectionException ignored) {
|
|
|
+ }
|
|
|
try {
|
|
|
//设置updateTime
|
|
|
setFieldValByName(UPDATE_TIME, DateTime.now(), metaObject);
|
|
|
- } catch (ReflectionException ignored) { }
|
|
|
+ } catch (ReflectionException ignored) {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -634,8 +607,31 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
|
|
return "-1";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取机构id
|
|
|
+ */
|
|
|
+ private String getOrgId() {
|
|
|
+ try {
|
|
|
+ try {
|
|
|
+ String loginId = StpUtil.getLoginIdAsString();
|
|
|
+ SaBaseLoginUser loginUser = StpLoginUserUtil.getLoginUser();
|
|
|
+ System.out.println("OrgId: " + loginUser.getOrgId());
|
|
|
+ if (ObjectUtil.isNotEmpty(loginUser) && ObjectUtil.isNotEmpty(loginUser.getOrgId())) {
|
|
|
+ return loginUser.getOrgId();
|
|
|
+ } else {
|
|
|
+ return "-1";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return "-1";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return "-1";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 注册数据变化事件中心 事件发布器
|
|
|
*
|