厨房后场人员登录
This commit is contained in:
parent
1403165f3e
commit
228ad9c479
|
|
@ -52,6 +52,9 @@ public interface RemoteUserService {
|
|||
@GetMapping("/user/infoPhoto/{phone}")
|
||||
public R<LoginUser> getUserInfoByPhone(@PathVariable("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
@GetMapping("/user/kitchenStaff/{phone}")
|
||||
public R<LoginUser> getKitchenStaffInfoByPhone(@PathVariable("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
return R.fail("获取用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<LoginUser> getKitchenStaffInfoByPhone(String phone, String source) {
|
||||
return R.fail("获取用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ public enum LoginType {
|
|||
/**
|
||||
* 邮箱验证码
|
||||
*/
|
||||
EMAIL_OTP;
|
||||
EMAIL_OTP,
|
||||
/**
|
||||
* 邮箱验证码
|
||||
*/
|
||||
KITCHEN_PHONE_PASSWORD;
|
||||
|
||||
@JsonCreator
|
||||
public static LoginType fromString(String key) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ public class LoginStrategyFactory {
|
|||
strategyMap.put(LoginType.EMAIL_PASSWORD, strategy);
|
||||
} else if (strategy instanceof EmailOtpLoginStrategy) {
|
||||
strategyMap.put(LoginType.EMAIL_OTP, strategy);
|
||||
} else if (strategy instanceof KitchenPhonePasswordLoginStrategy) {
|
||||
strategyMap.put(LoginType.KITCHEN_PHONE_PASSWORD, strategy);
|
||||
}
|
||||
// 继续添加其他策略
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
package com.bonus.auth.service;
|
||||
|
||||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.RemoteUserService;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author bonus
|
||||
*/
|
||||
@Service
|
||||
public class KitchenPhonePasswordLoginStrategy implements LoginStrategy {
|
||||
|
||||
@Resource
|
||||
private SystemConfig systemConfig;
|
||||
|
||||
@Resource
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Resource
|
||||
private PasswordValidatorService passwordValidatorService;
|
||||
|
||||
@Resource
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
@Override
|
||||
public LoginUser login(String phone, String password) {
|
||||
if (!systemConfig.getLoginConfig().isPhonePassword()) {
|
||||
throw new ServiceException("用户不存在/密码错误");
|
||||
}
|
||||
//通过手机号获取用户信息
|
||||
R<LoginUser> userResult = remoteUserService.getKitchenStaffInfoByPhone(phone, SecurityConstants.INNER);
|
||||
//验证用户是否存在
|
||||
passwordValidatorService.validateUserResult(phone, userResult);
|
||||
//获取用户信息
|
||||
LoginUser userInfo = userResult.getData();
|
||||
SysUser user = userInfo.getSysUser();
|
||||
//校验用户审批状态
|
||||
//passwordValidatorService.validateApprovalStatus(user.getUserName(), user);
|
||||
// 处理IP校验
|
||||
//passwordValidatorService.validateIpBlacklist(user.getUserName());
|
||||
// 验证密码
|
||||
passwordService.validate(user, password, System.currentTimeMillis());
|
||||
//校验用户启用状态
|
||||
//passwordValidatorService.validateUserStatus(user.getUserName(), user);
|
||||
|
||||
//passwordValidatorService.processLoginBlackList(user);
|
||||
//返回信息
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -187,6 +187,18 @@ public class SysUserController extends BaseController {
|
|||
return R.ok(sysUserVo);
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@GetMapping("/kitchenStaff/{photoNumber}")
|
||||
public R<LoginUser> getKitchenStaffInfoByPhone(@PathVariable("photoNumber") String photoNumber) {
|
||||
SysUser sysUser = userService.selectKitchenStaffByPhotoNumber(photoNumber);
|
||||
if (StringUtils.isNull(sysUser)) {
|
||||
return R.fail("用户名或密码错误");
|
||||
}
|
||||
LoginUser sysUserVo = new LoginUser();
|
||||
sysUserVo.setSysUser(sysUser);
|
||||
return R.ok(sysUserVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public interface SysUserMapper {
|
|||
*/
|
||||
public SysUser selectUserByPhoneNumber(@Param("phoneNumber") String phoneNumber);
|
||||
|
||||
public SysUser selectKitchenStaffByPhoneNumber(@Param("phoneNumber") String phoneNumber);
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public interface ISysUserService {
|
|||
*/
|
||||
public SysUser selectUserByPhotoNumber(String photoNumber);
|
||||
|
||||
public SysUser selectKitchenStaffByPhotoNumber(String photoNumber);
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
|
|
|
|||
|
|
@ -189,6 +189,11 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
return userMapper.selectUserByPhoneNumber(Sm4Utils.encrypt(photoNumber));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser selectKitchenStaffByPhotoNumber(String photoNumber) {
|
||||
return userMapper.selectKitchenStaffByPhoneNumber(photoNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
|
|
|
|||
|
|
@ -248,6 +248,17 @@
|
|||
<include refid="selectUserVo"/>
|
||||
where u.del_flag = '0'AND u.phonenumber = #{phoneNumber} AND sd.del_flag = '0' AND sd.status = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectKitchenStaffByPhoneNumber" resultMap="SysUserResult">
|
||||
select staff_id as user_id,
|
||||
mobile as phonenumber,
|
||||
mobile as user_name,
|
||||
staff_name as nick_name,
|
||||
sex, password
|
||||
from kitchen_staff_info
|
||||
where mobile = #{phoneNumber}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByEmail" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.del_flag = '0'AND u.email = #{email}
|
||||
|
|
|
|||
Loading…
Reference in New Issue