|
|
@@ -1,9 +1,11 @@
|
|
|
-package com.yingpaipay.web.service.impl;
|
|
|
+package com.yingpaipay.web.service.strategy;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
|
|
+import cn.hutool.core.lang.Dict;
|
|
|
import cn.hutool.crypto.digest.BCrypt;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.yingpaipay.web.constant.UserAppletStatusConst;
|
|
|
import com.yingpaipay.web.domain.bo.AppletLoginBo;
|
|
|
import com.yingpaipay.web.domain.vo.AppletLoginVo;
|
|
|
import com.yingpaipay.web.service.IAppletAuthService;
|
|
|
@@ -12,12 +14,13 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.domain.model.LoginUser;
|
|
|
import org.dromara.common.core.exception.BusinessException;
|
|
|
import org.dromara.common.core.utils.MessageUtils;
|
|
|
+import org.dromara.common.json.utils.JsonUtils;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.system.domain.SysUser;
|
|
|
import org.dromara.system.domain.vo.SysClientVo;
|
|
|
import org.dromara.system.domain.vo.SysUserVo;
|
|
|
import org.dromara.system.mapper.SysUserMapper;
|
|
|
-import org.dromara.system.service.*;
|
|
|
+import org.dromara.system.service.ISysClientService;
|
|
|
import org.dromara.web.service.SysLoginService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -25,7 +28,7 @@ import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @Author: Huanyi
|
|
|
- * @CreateTime: 2025-11-26
|
|
|
+ * @CreateTime: 2025-12-04
|
|
|
* @Description:
|
|
|
* @Version: 1.0
|
|
|
*/
|
|
|
@@ -33,7 +36,7 @@ import java.util.List;
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
@Slf4j
|
|
|
-public class AppletAuthServiceImpl implements IAppletAuthService {
|
|
|
+public class PasswordAppletAuthService implements IAppletAuthService {
|
|
|
|
|
|
private final SysUserMapper userMapper;
|
|
|
|
|
|
@@ -42,36 +45,33 @@ public class AppletAuthServiceImpl implements IAppletAuthService {
|
|
|
|
|
|
@Override
|
|
|
public AppletLoginVo login(AppletLoginBo bo) {
|
|
|
-
|
|
|
+ Dict map = JsonUtils.parseMap(bo.getContent());
|
|
|
List<SysUserVo> userList = userMapper.selectVoList(
|
|
|
Wrappers.lambdaQuery(SysUser.class)
|
|
|
- .eq(SysUser::getPhonenumber, bo.getPhoneNumber())
|
|
|
- .orderByDesc(SysUser::getUserId)
|
|
|
+ .eq(SysUser::getAppletStatus, UserAppletStatusConst.NORMAL)
|
|
|
+ .eq(SysUser::getPhonenumber, map.getStr("phoneNumber"))
|
|
|
);
|
|
|
if (userList.isEmpty()) {
|
|
|
- throw new BusinessException(MessageUtils.message("applet.auth.notexists"));
|
|
|
+ throw new BusinessException(MessageUtils.message("applet.auth.login.notexists"));
|
|
|
}
|
|
|
for (SysUserVo sysUser : userList) {
|
|
|
- if (BCrypt.checkpw(bo.getPassword(), sysUser.getPassword())) {
|
|
|
- SysClientVo client = clientService.queryByClientId(bo.getClientId());
|
|
|
+ if (BCrypt.checkpw(map.getStr("password"), sysUser.getPassword())) {
|
|
|
LoginUser loginUser = loginService.buildLoginUser(sysUser);
|
|
|
+ SysClientVo client = clientService.queryByClientId(bo.getClientId());
|
|
|
loginUser.setClientKey(client.getClientKey());
|
|
|
loginUser.setDeviceType(client.getDeviceType());
|
|
|
- SaLoginParameter model = new SaLoginParameter();
|
|
|
- model.setDeviceType(client.getDeviceType());
|
|
|
- // 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
|
|
- // 例如: 后台用户30分钟过期 app用户1天过期
|
|
|
- model.setTimeout(client.getTimeout());
|
|
|
- model.setActiveTimeout(client.getActiveTimeout());
|
|
|
- model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
|
|
- // 生成token
|
|
|
- LoginHelper.login(loginUser, model);
|
|
|
+ SaLoginParameter parameter = new SaLoginParameter();
|
|
|
+ parameter.setTimeout(client.getTimeout());
|
|
|
+ parameter.setDeviceType(client.getDeviceType());
|
|
|
+ parameter.setActiveTimeout(client.getActiveTimeout());
|
|
|
+ parameter.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
|
|
+ LoginHelper.login(loginUser, parameter);
|
|
|
+
|
|
|
AppletLoginVo vo = new AppletLoginVo();
|
|
|
vo.setToken(StpUtil.getTokenValue());
|
|
|
return vo;
|
|
|
}
|
|
|
}
|
|
|
- throw new BusinessException(MessageUtils.message("applet.auth.passworderror"));
|
|
|
+ throw new BusinessException(MessageUtils.message("applet.auth.login.passworderror"));
|
|
|
}
|
|
|
-
|
|
|
}
|