密码登录优化
This commit is contained in:
parent
877307a77e
commit
0964356f2f
|
@ -3,6 +3,7 @@ package org.dromara.web.service.impl;
|
|||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
@ -109,6 +110,20 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
|||
}
|
||||
|
||||
private SysUserVo loadUserByUsername(String tenantId, String username) {
|
||||
boolean isMobile = Validator.isMobile(username);
|
||||
if (isMobile) {
|
||||
return TenantHelper.ignore(() -> {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, username));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
return user;
|
||||
});
|
||||
}
|
||||
return TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, username));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
|
|
|
@ -48,7 +48,7 @@ public class WxEvaluationController extends BaseController {
|
|||
*/
|
||||
@GetMapping("/answer/{id}")
|
||||
public R<List<QuestionAnswerVo>> queryAnswer(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID,() -> evaluationService.queryQuestionAnswerListByScaleId(id)));
|
||||
return R.ok(TenantHelper.ignore(() -> evaluationService.queryQuestionAnswerListByScaleId(id)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class WxEvaluationController extends BaseController {
|
|||
@RepeatSubmit()
|
||||
@PostMapping("/record/create/{scaleId}")
|
||||
public R<Void> newRecord(@NotNull(message = "主键不能为空") @PathVariable Long scaleId) {
|
||||
return toAjax(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID,() -> evaluationService.newRecord(scaleId)));
|
||||
return toAjax(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID, () -> evaluationService.newRecord(scaleId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ public class WxEvaluationController extends BaseController {
|
|||
@RepeatSubmit()
|
||||
@PostMapping("/record/{id}")
|
||||
public R<Void> checkRecord(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
||||
return toAjax(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID,() -> evaluationService.checkRecord(id)));
|
||||
return toAjax(TenantHelper.ignore(() -> evaluationService.checkRecord(id)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,6 +79,6 @@ public class WxEvaluationController extends BaseController {
|
|||
@RepeatSubmit()
|
||||
@PostMapping("/record/answer")
|
||||
public R<Map<String, Object>> add(@Validated(AddGroup.class) @RequestBody SubmitAnswerBo bo) {
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID,() -> evaluationService.submitAnswer(bo)));
|
||||
return R.ok(TenantHelper.ignore(() -> evaluationService.submitAnswer(bo)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class WxScaleController extends BaseController {
|
|||
@GetMapping("/pageList")
|
||||
public TableDataInfo<SysScaleVo> pageList(SysScaleBo bo, PageQuery pageQuery) {
|
||||
bo.setOrderBy("num");
|
||||
return TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID,() -> sysScaleService.queryPageList(bo, pageQuery));
|
||||
return TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID, () -> sysScaleService.queryPageList(bo, pageQuery));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ public class WxScaleController extends BaseController {
|
|||
@GetMapping("/typeList")
|
||||
public R<List<SysScaleVo>> pageListTest(SysScaleBo bo) {
|
||||
bo.setOrderBy("num");
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID,() -> sysScaleService.queryPageListType(bo)));
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID, () -> sysScaleService.queryPageListType(bo)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ public class WxScaleController extends BaseController {
|
|||
if (StringUtils.isEmpty(scaleType)) {
|
||||
throw new ServiceException("类型不能为空");
|
||||
}
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID,() ->sysScaleService.queryWxMapList(scaleType)));
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID, () -> sysScaleService.queryWxMapList(scaleType)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,6 +73,6 @@ public class WxScaleController extends BaseController {
|
|||
*/
|
||||
@GetMapping("/{scaleId}")
|
||||
public R<SysScaleVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long scaleId) {
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID,() ->sysScaleService.queryById4Wx(scaleId)));
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID, () -> sysScaleService.queryById4Wx(scaleId)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,11 @@ public class SysUser extends TenantEntity {
|
|||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 干预状态
|
||||
*/
|
||||
private Integer interveneStatus;
|
||||
|
||||
|
||||
public SysUser(Long userId) {
|
||||
this.userId = userId;
|
||||
|
|
|
@ -116,6 +116,11 @@ public class SysUserVo implements Serializable {
|
|||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 干预状态
|
||||
*/
|
||||
private Integer interveneStatus;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -280,8 +279,6 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
|||
List<SysScaleAnswer> allAnswerList = new ArrayList<>();
|
||||
List<SysScaleFactor> allFactorList = new ArrayList<>();
|
||||
List<SysScaleFactorRange> allRangeList = new ArrayList<>();
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
for (SysScale sysScale : allScaleList) {
|
||||
Long oldScaleId = sysScale.getScaleId();
|
||||
Long newScaleId = identifierGenerator.nextId(SysScale.class).longValue();
|
||||
|
@ -305,7 +302,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
|||
List<SysScaleAnswer> answerList = answerMapper.selectList(new LambdaQueryWrapper<SysScaleAnswer>()
|
||||
.eq(SysScaleAnswer::getTenantId, TenantConstants.DEFAULT_TENANT_ID)
|
||||
.eq(SysScaleAnswer::getScaleId, oldScaleId)
|
||||
.eq(SysScaleAnswer::getAnswerId, oldQuestionId));
|
||||
.eq(SysScaleAnswer::getQuestionId, oldQuestionId));
|
||||
for (SysScaleAnswer answer : answerList) {
|
||||
Long newAnswerId = identifierGenerator.nextId(SysScaleAnswer.class).longValue();
|
||||
answer.setAnswerId(newAnswerId);
|
||||
|
@ -348,16 +345,11 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
|||
}
|
||||
allFactorList.addAll(factorList);
|
||||
}
|
||||
stopWatch.stop();
|
||||
log.info("处理所有量表用时{} 秒", stopWatch.getTotalTimeSeconds());
|
||||
stopWatch.start();
|
||||
scaleMapper.insertBatch(allScaleList, 500);
|
||||
questionMapper.insertBatch(allQuestionList, 500);
|
||||
answerMapper.insertBatch(allAnswerList, 500);
|
||||
factorMapper.insertBatch(allFactorList, 500);
|
||||
rangeMapper.insertBatch(allRangeList, 500);
|
||||
stopWatch.stop();
|
||||
log.info("入库所有量表用时{} 秒", stopWatch.getTotalTimeSeconds());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue