mirror of https://gitee.com/xiaonuobase/snowy
【更新】AuthApi增加一些登录接口方便其他模块调用
parent
f5278a8df8
commit
ad80b8508c
|
@ -39,7 +39,7 @@ public interface AuthApi {
|
|||
Long getThirdUserCount();
|
||||
|
||||
/**
|
||||
* B端登录
|
||||
* B端账号密码登录
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2024/7/18 17:35
|
||||
|
@ -47,10 +47,42 @@ public interface AuthApi {
|
|||
String doLoginForB(String account, String password, String validCode, String validCodeReqNo);
|
||||
|
||||
/**
|
||||
* BC端登录
|
||||
* C端账号密码登录
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2024/7/18 17:35
|
||||
*/
|
||||
String doLoginForC(String account, String password, String validCode, String validCodeReqNo);
|
||||
|
||||
/**
|
||||
* B端用户id登录
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2024/7/18 17:35
|
||||
*/
|
||||
String doLoginByIdForB(String userId);
|
||||
|
||||
/**
|
||||
* C端用户id登录
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2024/7/18 17:35
|
||||
*/
|
||||
String doLoginByIdForC(String userId);
|
||||
|
||||
/**
|
||||
* B端账号登录
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2024/7/18 17:35
|
||||
*/
|
||||
String doLoginByAccountForB(String account);
|
||||
|
||||
/**
|
||||
* C端账号登录
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2024/7/18 17:35
|
||||
*/
|
||||
String doLoginByAccountForC(String account);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
|
|||
import vip.xiaonuo.auth.api.AuthApi;
|
||||
import vip.xiaonuo.auth.core.enums.SaClientTypeEnum;
|
||||
import vip.xiaonuo.auth.core.util.StpClientUtil;
|
||||
import vip.xiaonuo.auth.modular.login.enums.AuthDeviceTypeEnum;
|
||||
import vip.xiaonuo.auth.modular.login.param.AuthAccountPasswordLoginParam;
|
||||
import vip.xiaonuo.auth.modular.login.service.AuthService;
|
||||
import vip.xiaonuo.auth.modular.third.service.AuthThirdService;
|
||||
|
@ -101,4 +102,24 @@ public class AuthApiProvider implements AuthApi {
|
|||
authAccountPasswordLoginParam.setValidCodeReqNo(validCodeReqNo);
|
||||
return authService.doLogin(authAccountPasswordLoginParam, SaClientTypeEnum.C.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doLoginByIdForB(String userId) {
|
||||
return authService.doLoginById(userId, AuthDeviceTypeEnum.PC.getValue(), SaClientTypeEnum.B.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doLoginByIdForC(String userId) {
|
||||
return authService.doLoginById(userId, AuthDeviceTypeEnum.PC.getValue(), SaClientTypeEnum.C.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doLoginByAccountForB(String account) {
|
||||
return authService.doLoginByAccount(account, AuthDeviceTypeEnum.PC.getValue(), SaClientTypeEnum.B.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doLoginByAccountForC(String account) {
|
||||
return authService.doLoginByAccount(account, AuthDeviceTypeEnum.PC.getValue(), SaClientTypeEnum.C.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,6 +97,14 @@ public interface AuthService {
|
|||
*/
|
||||
String doLoginById(String userId, String device, String type);
|
||||
|
||||
/**
|
||||
* 根据用户账号和客户端类型登录,用于第三方登录
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/7/9 14:44
|
||||
*/
|
||||
String doLoginByAccount(String account, String device, String type);
|
||||
|
||||
/**
|
||||
* C端注册
|
||||
*
|
||||
|
|
|
@ -915,6 +915,26 @@ public class AuthServiceImpl implements AuthService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doLoginByAccount(String account, String device, String type) {
|
||||
// 根据id获取用户信息,根据B端或C端判断
|
||||
if(SaClientTypeEnum.B.getValue().equals(type)) {
|
||||
SaBaseLoginUser saBaseLoginUser = loginUserApi.getUserByAccount(account);
|
||||
if (ObjectUtil.isEmpty(saBaseLoginUser)) {
|
||||
throw new CommonException(AuthExceptionEnum.ACCOUNT_ERROR.getValue());
|
||||
}
|
||||
// 执行B端登录
|
||||
return execLoginB(saBaseLoginUser, device);
|
||||
} else {
|
||||
SaBaseClientLoginUser saBaseClientLoginUser = clientLoginUserApi.getClientUserByAccount(account);
|
||||
if (ObjectUtil.isEmpty(saBaseClientLoginUser)) {
|
||||
throw new CommonException(AuthExceptionEnum.ACCOUNT_ERROR.getValue());
|
||||
}
|
||||
// 执行C端登录
|
||||
return execLoginC(saBaseClientLoginUser, device);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(AuthRegisterParam authRegisterParam, String type) {
|
||||
// 校验是否允许注册
|
||||
|
|
Loading…
Reference in New Issue