|
@@ -6,13 +6,21 @@
|
|
|
package org.eco.vip.auth.service.auth;
|
|
|
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.eco.vip.auth.domain.auth.vo.AuthQuery;
|
|
|
import org.eco.vip.auth.domain.auth.vo.AuthVO;
|
|
|
-import org.eco.vip.auth.domain.user.User;
|
|
|
+import org.eco.vip.auth.domain.user.vo.UserVO;
|
|
|
import org.eco.vip.auth.service.user.IUserService;
|
|
|
+import org.eco.vip.orm.enums.UserStatus;
|
|
|
+import org.eco.vip.orm.exception.BusinessException;
|
|
|
+import org.eco.vip.orm.pojo.LoginUser;
|
|
|
+import org.eco.vip.orm.utils.ObjUtils;
|
|
|
+import org.eco.vip.orm.utils.StrUtils;
|
|
|
+import org.eco.vip.security.utils.LoginHelper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
@@ -30,11 +38,36 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
|
|
IUserService userService;
|
|
|
@Override
|
|
|
public AuthVO login(AuthQuery authQuery) {
|
|
|
- return null;
|
|
|
+ String tenantId = authQuery.getTenantId();
|
|
|
+ String account = authQuery.getAccount();
|
|
|
+ String password = authQuery.getPassword();
|
|
|
+ String code = authQuery.getCode();
|
|
|
+ String uuid = authQuery.getUuid();
|
|
|
+
|
|
|
+ UserVO userVO = getUserByAccount(tenantId, account);
|
|
|
+
|
|
|
+ LoginUser loginUser = new LoginUser();
|
|
|
+ SaLoginParameter loginParameter = new SaLoginParameter();
|
|
|
+ loginParameter.setDeviceType("pc");
|
|
|
+ loginParameter.setTimeout(10);
|
|
|
+ loginParameter.setActiveTimeout(30);
|
|
|
+ loginParameter.setExtra(LoginHelper.CLIENT_KEY, "");
|
|
|
+ LoginHelper.login(loginUser, loginParameter);
|
|
|
+ AuthVO authVO = new AuthVO();
|
|
|
+ authVO.setAccessToken(StpUtil.getTokenValue());
|
|
|
+ authVO.setExpiresTime(StpUtil.getTokenTimeout());
|
|
|
+ return authVO;
|
|
|
}
|
|
|
|
|
|
- private User getUserByUsername(String tenantId, String username) {
|
|
|
- userService.selectTenantUserByUserName(tenantId, username);
|
|
|
- return null;
|
|
|
+ private UserVO getUserByAccount(String tenantId, String account) {
|
|
|
+ UserVO userVO = userService.selectTenantUserByUserName(tenantId, account);
|
|
|
+ if (ObjUtils.isNull(userVO)) {
|
|
|
+ log.info("登录账号:{} 不存在.", account);
|
|
|
+ throw new BusinessException("登录账号:{} 不存在.", account);
|
|
|
+ } else if (StrUtils.equals(UserStatus.DISABLE.getCode(), userVO.getStatus())) {
|
|
|
+ log.info("登录账号:{} 已被停用.", account);
|
|
|
+ throw new BusinessException("登录账号:{} 已被停用.", account);
|
|
|
+ }
|
|
|
+ return userVO;
|
|
|
}
|
|
|
}
|