优化登录
This commit is contained in:
@@ -13,7 +13,6 @@ import top.wms.admin.common.context.UserContext;
|
|||||||
import top.wms.admin.common.context.UserContextHolder;
|
import top.wms.admin.common.context.UserContextHolder;
|
||||||
import top.wms.admin.common.context.UserExtraContext;
|
import top.wms.admin.common.context.UserExtraContext;
|
||||||
import top.wms.admin.common.enums.DisEnableStatusEnum;
|
import top.wms.admin.common.enums.DisEnableStatusEnum;
|
||||||
import top.wms.admin.system.model.entity.DeptDO;
|
|
||||||
import top.wms.admin.system.model.entity.UserDO;
|
import top.wms.admin.system.model.entity.UserDO;
|
||||||
import top.wms.admin.system.model.resp.ClientResp;
|
import top.wms.admin.system.model.resp.ClientResp;
|
||||||
import top.wms.admin.system.service.DeptService;
|
import top.wms.admin.system.service.DeptService;
|
||||||
@@ -106,7 +105,7 @@ public abstract class AbstractLoginHandler<T extends LoginReq> implements LoginH
|
|||||||
*/
|
*/
|
||||||
protected void checkUserStatus(UserDO user) {
|
protected void checkUserStatus(UserDO user) {
|
||||||
CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, user.getStatus(), "此账号已被禁用,如有疑问,请联系管理员");
|
CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, user.getStatus(), "此账号已被禁用,如有疑问,请联系管理员");
|
||||||
// DeptDO dept = deptService.getById(user.getDeptId());
|
// DeptDO dept = deptService.getById(user.getDeptId());
|
||||||
// CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, dept.getStatus(), "此账号所属部门已被禁用,如有疑问,请联系管理员");
|
// CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, dept.getStatus(), "此账号所属部门已被禁用,如有疑问,请联系管理员");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
package top.wms.admin.auth.handler;
|
package top.wms.admin.auth.handler;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
import org.springframework.stereotype.Component;
|
||||||
import top.continew.starter.core.validation.ValidationUtils;
|
import top.continew.starter.core.validation.ValidationUtils;
|
||||||
import top.wms.admin.auth.AbstractLoginHandler;
|
import top.wms.admin.auth.AbstractLoginHandler;
|
||||||
import top.wms.admin.auth.enums.AuthTypeEnum;
|
import top.wms.admin.auth.enums.AuthTypeEnum;
|
||||||
import top.wms.admin.auth.model.req.CardLoginReq;
|
import top.wms.admin.auth.model.req.CardLoginReq;
|
||||||
import top.wms.admin.auth.model.req.PhoneLoginReq;
|
|
||||||
import top.wms.admin.auth.model.resp.LoginResp;
|
import top.wms.admin.auth.model.resp.LoginResp;
|
||||||
import top.wms.admin.common.constant.CacheConstants;
|
|
||||||
import top.wms.admin.system.model.entity.UserDO;
|
import top.wms.admin.system.model.entity.UserDO;
|
||||||
import top.wms.admin.system.model.resp.ClientResp;
|
import top.wms.admin.system.model.resp.ClientResp;
|
||||||
|
|
||||||
public class CardLoginHandler extends AbstractLoginHandler<CardLoginReq> {
|
@Component
|
||||||
|
public class CardLoginHandler extends AbstractLoginHandler<CardLoginReq> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginResp login(CardLoginReq req, ClientResp client, HttpServletRequest request) {
|
public LoginResp login(CardLoginReq req, ClientResp client, HttpServletRequest request) {
|
||||||
// 验证手机号
|
// 验证手机号
|
||||||
UserDO user = userService.getByCard(req.getCardNumber());
|
UserDO user = userService.getByCard(req.getCardNumber());
|
||||||
ValidationUtils.throwIfNull(user, "此手机号未绑定本系统账号");
|
ValidationUtils.throwIfNull(user, "此卡号未绑定本系统账号");
|
||||||
// 检查用户状态
|
// 检查用户状态
|
||||||
super.checkUserStatus(user);
|
super.checkUserStatus(user);
|
||||||
// 执行认证
|
// 执行认证
|
||||||
@@ -27,17 +26,12 @@ public class CardLoginHandler extends AbstractLoginHandler<CardLoginReq> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preLogin(PhoneLoginReq req, ClientResp client, HttpServletRequest request) {
|
public void preLogin(CardLoginReq req, ClientResp client, HttpServletRequest request) {
|
||||||
String phone = req.getPhone();
|
super.preLogin(req, client, request);
|
||||||
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + phone;
|
|
||||||
String captcha = RedisUtils.get(captchaKey);
|
|
||||||
ValidationUtils.throwIfBlank(captcha, CAPTCHA_EXPIRED);
|
|
||||||
ValidationUtils.throwIfNotEqualIgnoreCase(req.getCaptcha(), captcha, CAPTCHA_ERROR);
|
|
||||||
RedisUtils.delete(captchaKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthTypeEnum getAuthType() {
|
public AuthTypeEnum getAuthType() {
|
||||||
return AuthTypeEnum.PHONE;
|
return AuthTypeEnum.CARD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,4 +94,13 @@ public interface UserMapper extends DataPermissionMapper<UserDO> {
|
|||||||
* @return 用户数量
|
* @return 用户数量
|
||||||
*/
|
*/
|
||||||
Long selectCountByPhone(@FieldEncrypt @Param("phone") String phone, @Param("id") Long id);
|
Long selectCountByPhone(@FieldEncrypt @Param("phone") String phone, @Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据卡片号查询
|
||||||
|
*
|
||||||
|
* @param card 卡片号
|
||||||
|
* @return 用户信息
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM sys_user WHERE card_no = #{card}")
|
||||||
|
UserDO selectByCard(@Param("card") String card);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDO getByCard(String card) {
|
public UserDO getByCard(String card) {
|
||||||
return baseMapper.selectOne(new QueryWrapper<UserDO>().eq("card_no", card));
|
return baseMapper.selectByCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package top.wms.admin.weighManage.model.resp;
|
package top.wms.admin.weighManage.model.resp;
|
||||||
|
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import top.wms.admin.weighManage.model.resp.MaterialResp;
|
|||||||
@RequestMapping("/weighManage/material")
|
@RequestMapping("/weighManage/material")
|
||||||
public class WeighController {
|
public class WeighController {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取材料详细信息
|
* 获取材料详细信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user