~
This commit is contained in:
@@ -42,7 +42,6 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 登录Service接口实现类
|
||||
*
|
||||
*
|
||||
* @date 2021/12/23 21:52
|
||||
*/
|
||||
@Service
|
||||
@@ -52,6 +51,8 @@ public class AuthServiceImpl implements AuthService {
|
||||
|
||||
private static final String AUTH_VALID_CODE_CACHE_KEY = "auth-validCode:";
|
||||
|
||||
private static final String LOGIN_ERROR_TIMES_KEY_PREFIX = "login-error-times:";
|
||||
|
||||
@Resource(name = "loginUserApi")
|
||||
private SaBaseLoginUserApi loginUserApi;
|
||||
|
||||
@@ -180,6 +181,8 @@ public class AuthServiceImpl implements AuthService {
|
||||
|
||||
@Override
|
||||
public String doLogin(AuthAccountPasswordLoginParam authAccountPasswordLoginParam, String type) {
|
||||
// 判断账号是否被封禁
|
||||
isDisableTime(authAccountPasswordLoginParam.getAccount());
|
||||
// 获取账号
|
||||
String account = authAccountPasswordLoginParam.getAccount();
|
||||
// 获取密码
|
||||
@@ -227,8 +230,12 @@ public class AuthServiceImpl implements AuthService {
|
||||
throw new CommonException(AuthExceptionEnum.ACCOUNT_ERROR.getValue());
|
||||
}
|
||||
if (!saBaseLoginUser.getPassword().equals(passwordHash)) {
|
||||
// 记录登录次数 和 过期时间
|
||||
saveLoginTimes(account);
|
||||
throw new CommonException(AuthExceptionEnum.PWD_ERROR.getValue());
|
||||
}
|
||||
// 删除redis 中的key
|
||||
clearLoginErrorTimes(account);
|
||||
// 执行B端登录
|
||||
return execLoginB(saBaseLoginUser, device);
|
||||
} else {
|
||||
@@ -276,6 +283,53 @@ public class AuthServiceImpl implements AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否封禁状态
|
||||
* 如果被封禁了,执行以下逻辑,返回前端还需等待的时间
|
||||
*/
|
||||
private void isDisableTime(String userAccount) {
|
||||
// disableTime = -2表示未被封禁
|
||||
long disableTime = StpUtil.getDisableTime(userAccount);
|
||||
if (disableTime > 0) {
|
||||
if (disableTime > 60) {
|
||||
throw new CommonException(userAccount + "账号已被封禁, 请再"+ disableTime/60+ "分钟后重新尝试登录!!");
|
||||
}
|
||||
throw new CommonException(userAccount + "账号已被封禁, 请再"+ disableTime+ "秒后重新尝试登录!!");
|
||||
}
|
||||
}
|
||||
|
||||
// redis中保存登录错误次数
|
||||
private void saveLoginTimes(String userAccount){
|
||||
String loginErrorKey = LOGIN_ERROR_TIMES_KEY_PREFIX + userAccount;
|
||||
Integer number = (Integer) commonCacheOperator.get(loginErrorKey);
|
||||
if (number == null) {
|
||||
// 如果redis中没有保存,代表失败第一次
|
||||
number = 2;
|
||||
commonCacheOperator.put(loginErrorKey, number,5 * 60);
|
||||
return;
|
||||
}
|
||||
if (number < 5) {
|
||||
number++;
|
||||
commonCacheOperator.put(loginErrorKey, number,5 * 60);
|
||||
return;
|
||||
}
|
||||
// 第五次封禁账号,第六次进入isDisableTime方法,返回用户还需等待时间
|
||||
StpUtil.disable(userAccount, 5 * 60);
|
||||
// 删除redis 中的key
|
||||
clearLoginErrorTimes(userAccount);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录成功、清空登录次数
|
||||
* @param userAccount 账号
|
||||
*/
|
||||
private void clearLoginErrorTimes(String userAccount) {
|
||||
String loginErrorKey = LOGIN_ERROR_TIMES_KEY_PREFIX + userAccount;
|
||||
// 删除redis中的key
|
||||
commonCacheOperator.remove(loginErrorKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行B端登录
|
||||
*
|
||||
|
@@ -118,7 +118,12 @@ public class AuthSessionServiceImpl implements AuthSessionService {
|
||||
} else {
|
||||
authSessionPageResult.setSessionTimeout(CommonTimeFormatUtil.formatSeconds(saSession.getTimeout()));
|
||||
}
|
||||
List<AuthSessionPageResult.TokenSignInfo> tokenInfoList = saSession.getTokenSignList().stream().map(tokenSign -> {
|
||||
List<AuthSessionPageResult.TokenSignInfo> tokenInfoList = saSession.getTokenSignList().stream()
|
||||
.filter(tokenSign -> {
|
||||
long tokenTimeout = SaManager.getSaTokenDao().getTimeout(StpUtil.stpLogic.splicingKeyTokenValue(tokenSign.getValue()));
|
||||
return tokenTimeout != -2; // 过滤掉tokenTimeout为-2的元素
|
||||
})
|
||||
.map(tokenSign -> {
|
||||
AuthSessionPageResult.TokenSignInfo tokenSignInfo = new AuthSessionPageResult.TokenSignInfo();
|
||||
tokenSignInfo.setTokenValue(tokenSign.getValue());
|
||||
tokenSignInfo.setTokenDevice(tokenSign.getDevice());
|
||||
@@ -137,7 +142,8 @@ public class AuthSessionServiceImpl implements AuthSessionService {
|
||||
}
|
||||
}
|
||||
return tokenSignInfo;
|
||||
}).collect(Collectors.toList());
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
authSessionPageResult.setTokenCount(tokenInfoList.size());
|
||||
authSessionPageResult.setTokenSignList(tokenInfoList);
|
||||
return authSessionPageResult;
|
||||
@@ -175,7 +181,10 @@ public class AuthSessionServiceImpl implements AuthSessionService {
|
||||
} else {
|
||||
authSessionPageResult.setSessionTimeout(CommonTimeFormatUtil.formatSeconds(saSession.getTimeout()));
|
||||
}
|
||||
List<AuthSessionPageResult.TokenSignInfo> tokenInfoList = saSession.getTokenSignList().stream().map(tokenSign -> {
|
||||
List<AuthSessionPageResult.TokenSignInfo> tokenInfoList = saSession.getTokenSignList().stream().filter(tokenSign -> {
|
||||
long tokenTimeout = SaManager.getSaTokenDao().getTimeout(StpUtil.stpLogic.splicingKeyTokenValue(tokenSign.getValue()));
|
||||
return tokenTimeout != -2; // 过滤掉tokenTimeout为-2的元素
|
||||
}).map(tokenSign -> {
|
||||
AuthSessionPageResult.TokenSignInfo tokenSignInfo = new AuthSessionPageResult.TokenSignInfo();
|
||||
tokenSignInfo.setTokenValue(tokenSign.getValue());
|
||||
tokenSignInfo.setTokenDevice(tokenSign.getDevice());
|
||||
|
@@ -52,8 +52,8 @@ public class BizDictServiceImpl extends ServiceImpl<BizDictMapper, BizDict> impl
|
||||
queryWrapper.lambda().select(BizDict::getId, BizDict::getParentId, BizDict::getCategory, BizDict::getDictLabel,
|
||||
BizDict::getDictValue, BizDict::getSortCode).eq(BizDict::getCategory, BizDictCategoryEnum.BIZ.getValue());
|
||||
if (ObjectUtil.isNotEmpty(bizDictPageParam.getParentId())) {
|
||||
queryWrapper.lambda().eq(BizDict::getParentId, bizDictPageParam.getParentId())
|
||||
.or().eq(BizDict::getId, bizDictPageParam.getParentId());
|
||||
queryWrapper.lambda().and(q -> q.eq(BizDict::getParentId, bizDictPageParam.getParentId())
|
||||
.or().eq(BizDict::getId, bizDictPageParam.getParentId()));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(bizDictPageParam.getSearchKey())) {
|
||||
queryWrapper.lambda().like(BizDict::getDictLabel, bizDictPageParam.getSearchKey());
|
||||
|
@@ -120,8 +120,8 @@ public class BizUserServiceImpl extends ServiceImpl<BizUserMapper, BizUser> impl
|
||||
public Page<BizUser> page(BizUserPageParam bizUserPageParam) {
|
||||
QueryWrapper<BizUser> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(bizUserPageParam.getSearchKey())) {
|
||||
queryWrapper.lambda().like(BizUser::getAccount, bizUserPageParam.getSearchKey()).or()
|
||||
.like(BizUser::getName, bizUserPageParam.getSearchKey());
|
||||
queryWrapper.lambda().and(q -> q.like(BizUser::getAccount, bizUserPageParam.getSearchKey())
|
||||
.or().like(BizUser::getName, bizUserPageParam.getSearchKey()));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(bizUserPageParam.getOrgId())) {
|
||||
queryWrapper.lambda().eq(BizUser::getOrgId, bizUserPageParam.getOrgId());
|
||||
@@ -412,9 +412,9 @@ public class BizUserServiceImpl extends ServiceImpl<BizUserMapper, BizUser> impl
|
||||
queryWrapper.lambda().in(BizUser::getId, StrUtil.split(bizUserExportParam.getUserIds(), StrUtil.COMMA));
|
||||
} else {
|
||||
if (ObjectUtil.isNotEmpty(bizUserExportParam.getSearchKey())) {
|
||||
queryWrapper.lambda().like(BizUser::getAccount, bizUserExportParam.getSearchKey())
|
||||
queryWrapper.lambda().and(q -> q.like(BizUser::getAccount, bizUserExportParam.getSearchKey())
|
||||
.or().like(BizUser::getName, bizUserExportParam.getSearchKey())
|
||||
.or().like(BizUser::getPhone, bizUserExportParam.getSearchKey());
|
||||
.or().like(BizUser::getPhone, bizUserExportParam.getSearchKey()));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(bizUserExportParam.getUserStatus())) {
|
||||
queryWrapper.lambda().eq(BizUser::getUserStatus, bizUserExportParam.getUserStatus());
|
||||
|
@@ -52,8 +52,8 @@ public class DevDictServiceImpl extends ServiceImpl<DevDictMapper, DevDict> impl
|
||||
queryWrapper.lambda().select(DevDict::getId, DevDict::getParentId, DevDict::getCategory, DevDict::getDictLabel,
|
||||
DevDict::getDictValue, DevDict::getSortCode);
|
||||
if (ObjectUtil.isNotEmpty(devDictPageParam.getParentId())) {
|
||||
queryWrapper.lambda().eq(DevDict::getParentId, devDictPageParam.getParentId())
|
||||
.or().eq(DevDict::getId, devDictPageParam.getParentId());
|
||||
queryWrapper.lambda().and(q -> q.eq(DevDict::getParentId, devDictPageParam.getParentId())
|
||||
.or().eq(DevDict::getId, devDictPageParam.getParentId()));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(devDictPageParam.getCategory())) {
|
||||
queryWrapper.lambda().eq(DevDict::getCategory, devDictPageParam.getCategory());
|
||||
|
@@ -35,7 +35,7 @@ public class DevSmsTencentUtil {
|
||||
/**
|
||||
* 初始化操作的客户端
|
||||
*
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/1/5 23:24
|
||||
*/
|
||||
private static void initClient() {
|
||||
@@ -77,7 +77,7 @@ public class DevSmsTencentUtil {
|
||||
* @param templateCode 短信服务控制台配置且审核通过的模板编码
|
||||
* @param templateParam 短信模板变量对应的顺序。支持传入多个参数,逗号拼接,示例:"张三,15038****76,进行中"
|
||||
* @return 发送的结果信息集合 com.tencentcloudapi.sms.v20210111.models.SendStatus
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/2/24 13:42
|
||||
**/
|
||||
public static String sendSms(String sdkAppId, String phoneNumbers, String signName, String templateCode, String templateParam) {
|
||||
@@ -86,8 +86,8 @@ public class DevSmsTencentUtil {
|
||||
if(ObjectUtil.isEmpty(sdkAppId)) {
|
||||
// sdkAppId为空,则获取默认sdkAppId
|
||||
DevConfigApi devConfigApi = SpringUtil.getBean(DevConfigApi.class);
|
||||
signName = devConfigApi.getValueByKey(SNOWY_SMS_TENCENT_DEFAULT_SDK_APP_ID_KEY);
|
||||
if(ObjectUtil.isEmpty(signName)) {
|
||||
sdkAppId = devConfigApi.getValueByKey(SNOWY_SMS_TENCENT_DEFAULT_SDK_APP_ID_KEY);
|
||||
if(ObjectUtil.isEmpty(sdkAppId)) {
|
||||
throw new CommonException("腾讯云短信操作客户端未正确配置:sdkAppId为空");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="container snowy-shadow">
|
||||
<uni-forms ref="formRef" :model="formData" label-position="top" :rules="rules" validate-trigger="blur" labelWidth="100px">
|
||||
<uni-forms ref="formRef" :model="formData" label-position="top" :rules="rules" validate-trigger="blur" labelWidth="auto">
|
||||
<% for(var i = 0; i < configList.~size; i++) { %>
|
||||
<% if(!configList[i].needTableId && configList[i].whetherAddUpdate && configList[i].fieldNameCamelCase != 'tenantId') { %>
|
||||
<% if(configList[i].effectType == 'input') { %>
|
||||
@@ -36,7 +36,7 @@
|
||||
<% } %>
|
||||
</uni-forms>
|
||||
<% if (dfcWhether == 'Y') { %>
|
||||
<uni-forms ref="dynamicFormRef" :model="dynamicFormData" label-position="top" labelWidth="75px">
|
||||
<uni-forms ref="dynamicFormRef" :model="dynamicFormData" label-position="top" labelWidth="auto">
|
||||
<snowy-dyna-field
|
||||
v-for="(item, index) in dynamicFieldConfigList"
|
||||
:key="index"
|
||||
|
@@ -411,7 +411,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
apiName = annotationValue;
|
||||
}
|
||||
}
|
||||
permissionResult.add(patternsCondition.getPatterns().iterator().next() + StrUtil.BRACKET_START + apiName + StrUtil.BRACKET_END);
|
||||
String nm = StrUtil.BRACKET_START + apiName + StrUtil.BRACKET_END;
|
||||
patternsCondition.getPatterns().forEach(pt -> permissionResult.add(pt + nm));
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
@@ -203,8 +203,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
public Page<SysUser> page(SysUserPageParam sysUserPageParam) {
|
||||
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(sysUserPageParam.getSearchKey())) {
|
||||
queryWrapper.lambda().like(SysUser::getAccount, sysUserPageParam.getSearchKey()).or()
|
||||
.like(SysUser::getName, sysUserPageParam.getSearchKey());
|
||||
queryWrapper.lambda().and(q -> q.like(SysUser::getAccount, sysUserPageParam.getSearchKey()).or()
|
||||
.like(SysUser::getName, sysUserPageParam.getSearchKey()));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(sysUserPageParam.getOrgId())) {
|
||||
queryWrapper.lambda().eq(SysUser::getOrgId, sysUserPageParam.getOrgId());
|
||||
@@ -1163,9 +1163,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
queryWrapper.lambda().in(SysUser::getId, StrUtil.split(sysUserExportParam.getUserIds(), StrUtil.COMMA));
|
||||
} else {
|
||||
if (ObjectUtil.isNotEmpty(sysUserExportParam.getSearchKey())) {
|
||||
queryWrapper.lambda().like(SysUser::getAccount, sysUserExportParam.getSearchKey())
|
||||
queryWrapper.lambda().and(q -> q.like(SysUser::getAccount, sysUserExportParam.getSearchKey())
|
||||
.or().like(SysUser::getName, sysUserExportParam.getSearchKey())
|
||||
.or().like(SysUser::getPhone, sysUserExportParam.getSearchKey());
|
||||
.or().like(SysUser::getPhone, sysUserExportParam.getSearchKey()));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(sysUserExportParam.getUserStatus())) {
|
||||
queryWrapper.lambda().eq(SysUser::getUserStatus, sysUserExportParam.getUserStatus());
|
||||
|
@@ -25,7 +25,7 @@ knife4j:
|
||||
enableFooterCustom: true
|
||||
enableOpenApi: false
|
||||
enableSwaggerModels: false
|
||||
footerCustomContent: Apache License 2.0 | Copyright 2022-[SNOWY](https://www.xiaonuo.vip)
|
||||
footerCustomContent: Apache License 2.0
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
jdbc-type-for-null: 'null'
|
||||
@@ -38,7 +38,7 @@ mybatis-plus:
|
||||
logic-delete-value: DELETED
|
||||
logic-not-delete-value: NOT_DELETE
|
||||
enable-sql-runner: true
|
||||
mapper-locations: classpath*:vip/xiaonuo/**/mapping/*.xml,com/bstek/**/mapping/*.xml
|
||||
mapper-locations: classpath*:mjkf/xinke/**/mapping/*.xml,com/bstek/**/mapping/*.xml
|
||||
type-handlers-package: mjkf.xinke.common.handler
|
||||
sa-token:
|
||||
activity-timeout: -1
|
||||
@@ -63,12 +63,12 @@ sa-token:
|
||||
token-name: token
|
||||
token-style: random-32
|
||||
server:
|
||||
port: 82
|
||||
port: 9882
|
||||
mjkf-xinke:
|
||||
config:
|
||||
common:
|
||||
backend-url: http://localhost:82
|
||||
front-url: http://localhost:81
|
||||
backend-url: http://localhost:9882
|
||||
front-url: http://localhost:9881
|
||||
ten:
|
||||
default-ten-id: -1
|
||||
enabled: true
|
||||
@@ -86,7 +86,7 @@ spring:
|
||||
master:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
password: lyh123456!
|
||||
url: jdbc:mysql://localhost:3306/snowy-cloud?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&useInformationSchema=true
|
||||
url: jdbc:mysql://localhost:3306/mjkf-xinke-cloud?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&useInformationSchema=true
|
||||
username: root
|
||||
druid:
|
||||
break-after-acquire-failure: false
|
||||
|
Reference in New Issue
Block a user