Commit 02be8110 authored by kang.nie@inzymeits.com's avatar kang.nie@inzymeits.com
Browse files

初始化代码

parent e9f88257
Pipeline #3111 failed with stages
in 0 seconds
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>local-rnr-user</artifactId>
<groupId>com.cusc.nirvana</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>local-rnr-user-server</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<mapstruct.version>1.4.2.Final</mapstruct.version>
</properties>
<dependencies>
<dependency>
<groupId>com.cusc.nirvana</groupId>
<artifactId>cusc-rds</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<exclusions>
<exclusion>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.cusc.nirvana</groupId>
<artifactId>local-rnr-user-dto</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<!-- mapstruct-->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<!-- redis依赖 -->
<dependency>
<groupId>com.cusc.component</groupId>
<artifactId>cache-spring</artifactId>
<version>1.0.4-RELEASE</version>
</dependency>
<!-- 图形验证码依赖 -->
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId>
<version>1.6.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources/</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.yml</include>
<include>**/*.yaml</include>
<include>**/*.xml</include>
<include>**/*.factories</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
package com.cusc.nirvana.user;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
/**
* UserEiamApplication
*
* 1、使用generator生产骨架工程代码;
*
* 2、到nacos创建配置信息,默认集成nacos作为: 配置中心, 注册中心
* - nacos-url: http://172.24.120.141:8848/nacos/
* - nacos-user: cusc
* - nacos-password: cusc@nacos
* - 2.1、注意选择环境,环境不要选择错误
* - 2.2、Data-ID必须与项目名称相同,即:{spring.application.name}或者{spring.application.name}-yml
* - 2.3、Group使用默认
* - 2.4、配置文件类型必须选择"yaml(yml)"
*
* 3、本地测试启动是需要添加启动参数: VM options: -Denv=local -Dspring.profiles.active=local
* - 3.1、非本地调试环境由各环境启动脚本配置
*
* @author auto-generator
* @since 2021-10-20
*/
@Slf4j
@SpringBootApplication
@MapperScan({"com.cusc.nirvana.**.dao"})
@ComponentScan({"com.cusc", "com.cache.*"})
@EnableDiscoveryClient
public class LocalRnrUserApplication {
public static void main(String[] args) {
try {
ApplicationContext context = SpringApplication.run(LocalRnrUserApplication.class, args);
String serverPort = context.getEnvironment().getProperty("server.port");
log.info("启动成功! Swagger2: http://127.0.0.1:" + serverPort + "/swagger-ui.html");
} catch (Exception ex) {
log.error("", ex);
}
}
}
package com.cusc.nirvana.user.auth.authentication.controller;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.authentication.dto.AccessVerifyReq;
import com.cusc.nirvana.user.auth.authentication.service.AccessAuthService;
import com.cusc.nirvana.user.auth.authentication.service.TokenService;
import com.cusc.nirvana.user.auth.common.constants.ResponseCode;
import com.cusc.nirvana.user.auth.common.dto.AccessTokenHashDTO;
import com.cusc.nirvana.user.util.CuscStringUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Description: 访问鉴权
* <br />
* CreateDate 2021-11-08 11:48:33
*
* @author yuyi
**/
@Slf4j
@RestController
@RequestMapping("/auth")
public class AccessAuthController {
@Autowired
private AccessAuthService accessAuthService;
@Autowired
private TokenService tokenService;
@PostMapping("/getUserByToken")
@ApiOperation(value = "通过token获取用户信息", notes = "通过token获取用户信息")
public Response getUserByToken(@RequestBody AccessVerifyReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getToken())) {
return Response.createSuccess();
}
return Response.createSuccess(accessAuthService.getTokenInfo(bean));
}
@PostMapping("/accessVerify")
@ApiOperation(value = "请求鉴权", notes = "请求鉴权")
public Response accessVerify(@RequestBody AccessVerifyReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getToken()) || CuscStringUtils.isEmpty(
bean.getUrl())) {
return Response.createError(ResponseCode.AUTHENTICATION_FAIL.getMsg(),
ResponseCode.AUTHENTICATION_FAIL.getCode());
}
//1.检查token是否有效
Response<AccessTokenHashDTO> ckTokenResp = accessAuthService.checkToken(bean);
//当开启url鉴权时,此代码需要开放
if (!ckTokenResp.isSuccess()) {
return ckTokenResp;
}
//2.url鉴权
bean.setAppId(ckTokenResp.getData().getAppId());
bean.setTenantNo(ckTokenResp.getData().getTenantNo());
boolean checkUrl = accessAuthService.checkUrlAccess(bean, ckTokenResp.getData());
if (!checkUrl) {
return Response.createError(ResponseCode.UNAUTHORIZED.getMsg(),
ResponseCode.UNAUTHORIZED.getCode());
}
//token续期
tokenService.tokenRenewal(ckTokenResp, bean.getToken());
return ckTokenResp;
}
@PostMapping("/isWhiteList")
@ApiOperation(value = "判断是否是白名单", notes = "判断是否是白名单")
public Response isWhiteList(@RequestBody AccessVerifyReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getServerName()) || CuscStringUtils.isEmpty(
bean.getUrl())) {
return Response.createError(ResponseCode.WHITE_LIST_AUTHENTICATION_FAIL.getMsg(),
ResponseCode.WHITE_LIST_AUTHENTICATION_FAIL.getCode());
}
return Response.createSuccess(accessAuthService.isWhiteList(bean));
}
}
package com.cusc.nirvana.user.auth.authentication.service;
import com.cache.CacheFactory;
import com.cache.exception.CacheException;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.authentication.dto.AccessVerifyReq;
import com.cusc.nirvana.user.auth.common.constants.RedisConstant;
import com.cusc.nirvana.user.auth.common.constants.ResponseCode;
import com.cusc.nirvana.user.auth.common.dto.AccessTokenHashDTO;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Description: url白名单service
* <br />
* CreateDate 2021-12-01 19:13:36
*
* @author yuyi
**/
@Component
public class AccessAuthService {
private static final Logger LOGGER = LoggerFactory.getLogger(AccessAuthService.class);
@Autowired
private CacheFactory cacheFactory;
/**
* Description: 判断url是否是白名单
* <br />
* CreateDate 2021-12-01 19:14:45
*
* @author yuyi
**/
public boolean isWhiteList(AccessVerifyReq bean) {
try {
return cacheFactory.getSetService().containsValue(RedisConstant.URL_WHITE_LIST,
bean.getServerName() + bean.getUrl());
} catch (CacheException e) {
LOGGER.error("isWhiteList fail ", e);
return false;
}
}
/**
* Description: 检查token
* <br />
* CreateDate 2021-11-05 15:34:02
*
* @author yuyi
**/
public Response<AccessTokenHashDTO> checkToken(AccessVerifyReq bean) {
AccessTokenHashDTO accessTokenHashDTO = getTokenInfo(bean);
if (accessTokenHashDTO == null || CuscStringUtils.isEmpty(accessTokenHashDTO.getUserId())) {
LOGGER.info("checkToken token:{} 通过token获取信息失败", bean.getToken());
return Response.createError(ResponseCode.TOKEN_INVALID.getMsg(),
ResponseCode.TOKEN_INVALID.getCode());
}
return Response.createSuccess(accessTokenHashDTO);
}
/**
* Description: 获取token对应的信息
* <br />
* CreateDate 2021-11-05 15:34:02
*
* @author yuyi
**/
public AccessTokenHashDTO getTokenInfo(AccessVerifyReq bean) {
AccessTokenHashDTO accessTokenHashDTO = null;
try {
accessTokenHashDTO =
cacheFactory.getExpireHashService().getHash(RedisConstant.TOKEN_ACCESS_TOKEN_INFO + bean.getToken(),
AccessTokenHashDTO.class);
} catch (CacheException e) {
LOGGER.error("checkToken 检查token失败 :{}", e);
}
return accessTokenHashDTO;
}
/**
* Description: url鉴权
* <br />
* CreateDate 2021-11-05 15:34:02
*
* @return true 鉴权通过,false 鉴权失败
* @author yuyi
**/
public boolean checkUrlAccess(AccessVerifyReq bean, AccessTokenHashDTO token) {
String url = bean.getUrl();
String appId = bean.getAppId();
String userId = token.getUserId();
String tenantNo = token.getTenantNo();
try {
//匹配url是不是在用户对应的url中
boolean isPass = cacheFactory.getSetService()
.containsValue(RedisConstant.USER_URL_LIST + tenantNo + ":" + userId + "_" + appId, url);
if (isPass) {
//匹配上则返回通过,否则返回失败
return true;
}
} catch (CacheException e) {
LOGGER.error(
"checkUrlAccess fail url:" + url + " , userId:" + userId + " , appId:" + appId + " , tenantNo" + ":"
+ tenantNo + " ", e);
return false;
}
LOGGER.info("checkUrlAccess url:{} , userId:{} , appId:{} , tenantNo:{} , 未授权 ", url, userId, appId, tenantNo);
return false;
}
}
package com.cusc.nirvana.user.auth.authentication.service;
import com.cache.CacheFactory;
import com.cache.constants.CacheConstants;
import com.cache.exception.CacheException;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.common.constants.RedisConstant;
import com.cusc.nirvana.user.auth.common.dto.AccessTokenHashDTO;
import com.cusc.nirvana.user.auth.common.service.AppConfigService;
import com.cusc.nirvana.user.eiam.dto.ApplicationDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
/**
* Description: 令牌service实现类
* <br />
* CreateDate 2021-11-02 20:25:49
*
* @author yuyi
**/
@Service
@Slf4j
public class TokenService {
@Autowired
private CacheFactory cacheFactory;
@Autowired
private AppConfigService appConfigService;
/**
* Description: token续期
* <br />
* CreateDate 2021-12-03 20:10:46
*
* @author yuyi
**/
@Async("dataToRedisExecutor")
public void tokenRenewal(Response<AccessTokenHashDTO> ckTokenResp, String accessToken) {
if (ckTokenResp == null || !ckTokenResp.isSuccess() || ckTokenResp.getData() == null) {
return;
}
AccessTokenHashDTO tokenInfo = ckTokenResp.getData();
ApplicationDTO appBean = appConfigService.getAppConfigByCode(tokenInfo.getAppId());
try {
cacheFactory.getExpireHashService()
.expireKey(RedisConstant.TOKEN_REFRESH_TOKEN_INFO + accessToken, appBean.getRenewalTokenTime(),
CacheConstants.TimeType.EX);
//同时续期用户id对应的token信息
AccessTokenHashDTO accessTokenHashDTO = cacheFactory.getExpireHashService()
.getHash(RedisConstant.TOKEN_ACCESS_TOKEN_INFO + accessToken,
AccessTokenHashDTO.class);
if (accessTokenHashDTO != null) {
cacheFactory.getExpireListService()
.updateExpire(RedisConstant.TOKEN_USER_TOKEN_INFO + accessTokenHashDTO.getTenantNo() + ":" + accessTokenHashDTO.getUserId(),
appBean.getRenewalTokenTime());
}
} catch (CacheException e) {
log.error("tokenRenewal 访问reids失败 key:" + RedisConstant.TOKEN_ACCESS_TOKEN_INFO + accessToken + " 异常:{}",
e);
}
}
}
package com.cusc.nirvana.user.auth.common.constants;
import java.util.ArrayList;
import java.util.List;
/**
* Description: redis相关常量类
* <br />
* CreateDate 2021-11-03 20:36
*
* @author yuyi
**/
public class AppConfigConstant {
//是否限制单设备登录 不开启
public static final int IS_DEVICE_LOGIN_0 = 0;
//是否限制单设备登录 开启
public static final int IS_DEVICE_LOGIN_1 = 1;
//是否强制修改密码 不开启
public static final int IS_FORCE_CHANGE_PWD_0 = 0;
//是否强制修改密码 开启
public static final int IS_FORCE_CHANGE_PWD_1 = 1;
/**
* 应用list
*/
public static final List<String> APP_LIST = new ArrayList<String>() {{
//B端门户应用
add("3");
}};
}
package com.cusc.nirvana.user.auth.common.constants;
/**
* Description: redis相关常量类
* <br />
* CreateDate 2021-11-03 20:36
*
* @author yuyi
**/
public class RedisConstant {
//短信验证码key前缀
public static final String SMS_CAPTCHA_KEY = "CT:USER:AUTH:SMS:CAPTCHA:";
//短信验证码错误次数key前缀
public static final String SMS_CAPTCHA_ERROR_COUNT_KEY = "CT:USER:AUTH:SMS:CAPTCHA:ERROR_COUNT:";
//短信验证码错误次数key默认失效时间(秒)
public static final int SMS_CAPTCHA_ERROR_COUNT_EXPIRE = 3600;
//短信验证码发送间隔key前缀
public static final String SMS_CAPTCHA_SEND_INTERVAL_KEY = "CT:USER:AUTH:SMS:INTERVAL:CAPTCHA:";
//短信验证码发送天限制key前缀
public static final String SMS_CAPTCHA_SEND_TOTAL_KEY = "CT:USER:AUTH:SMS:DAY:CAPTCHA:";
//短信验证码key默认失效时间(秒)
public static final int SMS_CAPTCHA_EXPIRE = 1800;
//access_token对应的用户id、refresh_token、scope
public static final String TOKEN_ACCESS_TOKEN_INFO = "CT:USER:AUTH:TOKEN:ACCESS_TOKEN:";
//refresh_token对应的token和用户id
public static final String TOKEN_REFRESH_TOKEN_INFO = "CT:USER:AUTH:TOKEN:REFRESH_TOKEN:";
//用户id对应的access_token、refresh_token集合
public static final String TOKEN_USER_TOKEN_INFO = "CT:USER:AUTH:TOKEN:USER:";
//随机请求id redis key
public static final String RANDOM_REQUEST_ID = "CT:USER:AUTH:RANDOM:ID:";
//图形验证码 redis key
public static final String IMAGE_CAPTCHA_KEY = "CT:USER:AUTH:CAPTCHA:IMAGE:";
//账号密码错误次数 redis key
public static final String USERNAME_PASSWORD_FAIL_COUNT_KEY = "CT:USER:AUTH:USERNAME:PASSWORD_COUNT:";
//账号锁定 redis key
public static final String USERNAME_LOCK_KEY = "CT:USER:AUTH:USERNAME:LOCK:";
//-------------------鉴权相关------------------------
//url的白名单集合
public static final String URL_WHITE_LIST = "CT:USER:AUTH:URL:WHITE:LIST";
//角色对应的URL集合信息
public static final String ROLE_URL_LIST = "CT:USER:AUTH:URL:ROLE:";
//用户对应的角色id集合信息
public static final String USER_ROLE_ID_LIST = "CT:USER:AUTH:USER:ROLE:";
//应用与url的分隔符
public static final String APPID_URL_SEPARATOR = "-";
//token
public static final int TOKEN_RENEWAL_EXPIRES_IN = 1800;
//用户id对应的url集合 CT:USER:AUTH:URL:USER:租户编号:用户id_应用id
public static final String USER_URL_LIST = "CT:USER:AUTH:URL:USER:";
}
package com.cusc.nirvana.user.auth.common.constants;
/**
* Description: 响应码
* <br />
* CreateDate 2021-11-02 19:52:36
*
* @author yuyi
**/
public enum ResponseCode {
INVALID_DATA(1001, "数据校验不通过"),
SYS_BUSY(1002, "服务调用失败"),
SERVICE_NOT_FOUND(1003, "服务不存在"),
TP_SYS_BUSY(1004, "第三方服务调用失败"),
JSON_FORMAT_ERROR(1005, "参数格式错误"),
REQ_TOO_MANY_TIMES(1007, "请求过于频繁,请稍后再试!"),
NO_DATA_AUTH(1008, "请求过于频繁,请稍后再试!"),
REDIS_OPT_FAIL(1009, "redis操作失败,请稍后再试!"),
PARAMETER_NULL(1010, "请求参数不能为空!"),
UNAUTHORIZED(1050, "鉴权失败:未授权"),
AUTHENTICATION_FAIL(1051, "鉴权失败:无效的令牌或请求"),
//token获取失败,访问redis失败
TOKEN_AUTHENTICATION_FAIL(1052, "token鉴权失败"),
RESOURCE_NOT_REPORTED(1053, "请求的资源未登记"),
WHITE_LIST_AUTHENTICATION_FAIL(1055, "鉴权失败:无效的请求或应用未登记"),
TOKEN_INVALID(1101, "token已过期"),
//已在其他终端登录,强制下线
REPEAT_LOGIN_KICK_OUT(1102, "token已踢出"),
//用户冻结,强制下线
USER_FROZEN_KICK_OUT(1103, "token已踢出"),
//权限变动等原因,强制下线
AUTH_CHANGE_KICK_OUT(1104, "token已踢出"),
CLIENT_ID_INVALID(1110, "clientId无效"),
AES_SECRET_KEY_FAIL(1111, "AES生成秘钥失败"),
SMS_CREATE_CAPTCHA_FAIL(1112, "生成短信验证码失败"),
SMS_GET_CAPTCHA_FAIL(1113, "获取短信验证码失败"),
SMS_CAPTCHA_INVALID(1114, "短信验证码无效!"),
SMS_CAPTCHA_INTERVAL_FAIL(1115, "短信验证码获取太频繁,请稍后重试!"),
SMS_CAPTCHA_SEND_FAIL(1116, "短信发送失败,请稍后重试!"),
SMS_SEND_ERROR(1117, "短信发送失败,内部错误"),
SMS_TOTAL_LIMIT_OVERRUN(1118, "发送短信超过当天发送的最大限制"),
SMS_INTERVAL_LIMIT_OVERRUN(1119, "短信发送失败,发送间隔限制时间内重复发送"),
LOGIN_USER_NAME_PASSWORD_INVALID(1201,"账号或密码错误"),
LOGIN_PHONE_PASSWORD_NOT_NULL(1202,"手机号不能为空"),
LOGIN_NAME_INVALID(1203,"您输入的帐号不存在,请重新输入!"),
LOGIN_NAME_STOP(1204,"您输入的帐号已被停用,请与管理员联系!"),
LOGIN_NAME_NOT_NULL(1205,"请输入正确的账号!"),
TOEKN_CREATE_FAIL(1206,"token生成失败"),
LOGOUT_FAIL(1207,"退出失败,系统异常!"),
KICK_OUT_FAIL(1208,"踢出失败,系统异常!"),
SYSTEM_OPT_FAIL(1209,"系统异常,请与管理员联系!"),
CAPTCHA_IMAGGE_NOT_NULL(1210,"图形验证码不能为空"),
CAPTCHA_IMAGGE_CHECK_FAIL(1211,"图形验证码验证失败"),
SMS_SEND_CONFIG_NOT_NULL(1212,"短信发送配置不能为空"),
APP_CONFIG_NOT_NULL(1213,"应用配置信息不能为空"),
REQUEST_ID_SECRET_KEY_INVALID(1214,"请求id对应的密钥无效"),
APPLICATION_TENANT_REQUIRED(1215,"应用id和租户编号不能为空"),
USER_NAME_PWD_FAIL_LOCK(1216,"账号密码错误次数过多,账号已锁定,请稍后再试!"),
LOGIN_PHONE_INVALID(1217,"您输入的手机号不存在,请重新输入!"),
REGISTER_PHONE_FAIL(1218,"注册失败,请稍后重试!"),
;
private Integer code;
private String msg;
ResponseCode(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.cusc.nirvana.user.auth.common.service;
import com.cusc.nirvana.user.auth.common.constants.ResponseCode;
import com.cusc.nirvana.user.eiam.dto.ApplicationDTO;
import com.cusc.nirvana.user.eiam.service.IApplicationService;
import com.cusc.nirvana.user.exception.CuscUserException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Description: 异步执行service
* <br />
* CreateDate 2021-11-02 20:25:49
*
* @author yuyi
**/
@Service
@Slf4j
public class AppConfigService {
@Autowired
private IApplicationService applicationService;
/**
* Description: 通过应用编码获取应用配置信息
* <br />
* CreateDate 2022-01-27 15:25:17
*
* @author yuyi
**/
public ApplicationDTO getAppConfigByCode(String appCode) {
ApplicationDTO appResp = applicationService.getCacheByCode(appCode);
if(appResp != null){
return appResp;
}
throw new CuscUserException(ResponseCode.APP_CONFIG_NOT_NULL.getCode() + "",
ResponseCode.APP_CONFIG_NOT_NULL.getMsg());
}
}
package com.cusc.nirvana.user.auth.identification.login;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.common.constants.ResponseCode;
import com.cusc.nirvana.user.auth.identification.dto.CaptchaCreateReq;
import com.cusc.nirvana.user.auth.identification.dto.CaptchaCreateResp;
import com.cusc.nirvana.user.auth.identification.dto.CaptchaVerificationReq;
import com.cusc.nirvana.user.auth.identification.service.ICaptchaService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/captcha")
public class CaptchaController {
private static final Logger LOGGER = LoggerFactory.getLogger(CaptchaController.class);
@Autowired
private ICaptchaService captchaService;
@PostMapping("/simpleGraphic")
@ApiOperation(value = "简单图形验证码", notes = "简单图形验证码")
public Response<CaptchaCreateResp> simpleGraphic(@RequestBody CaptchaCreateReq captchaReq) {
if (captchaReq == null || captchaReq.getCaptchaType() == null || captchaReq.getCaptchaHeight() == 0
|| captchaReq.getCaptchaWidth() == 0 || captchaReq.getCaptchaLength() == 0 || CuscStringUtils.isEmpty(captchaReq.getApplicationId())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(), ResponseCode.PARAMETER_NULL.getCode());
}
return Response.createSuccess(captchaService.generateCaptcha(captchaReq));
}
@PostMapping("/verificationCaptcha")
@ApiOperation(value = "验证图形验证码", notes = "验证图形验证码")
public Response verificationCaptcha(@RequestBody CaptchaVerificationReq bean){
if (bean == null || CuscStringUtils.isEmpty(bean.getCaptchaValue()) || CuscStringUtils.isEmpty(bean.getRequestId())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(), ResponseCode.PARAMETER_NULL.getCode());
}
return Response.createSuccess(captchaService.verificationCaptcha(bean));
}
}
package com.cusc.nirvana.user.auth.identification.login;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.common.constants.ResponseCode;
import com.cusc.nirvana.user.auth.identification.dto.MobileLoginReq;
import com.cusc.nirvana.user.auth.identification.dto.Oauth2Token;
import com.cusc.nirvana.user.auth.identification.service.ILoginService;
import com.cusc.nirvana.user.auth.identification.util.CommonParamterCheck;
import com.cusc.nirvana.user.util.CuscStringUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/ciam/login")
public class CiamLoginController {
@Autowired
ILoginService loginService;
@PostMapping("/mobile")
@ApiOperation(value = "手机号登录", notes = "手机号登录")
public Response<Oauth2Token> mobileLogin(@RequestBody MobileLoginReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getPhone()) || CuscStringUtils.isEmpty(bean.getCaptcha())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
CommonParamterCheck.appIdAndTenantNoRequired(bean.getApplicationId(), bean.getTenantNo());
log.info("mobileLogin request url: /user-auth/ciam/login/mobileLogin , phone: {} , captcha: {}",
bean.getPhone(), bean.getCaptcha().substring(1));
return loginService.ciamMobileLogin(bean);
}
/**
* 小鹏用户登录
* @param bean
* @return
*/
@PostMapping("/mobileXP")
@ApiOperation(value = "手机号登录", notes = "手机号登录")
public Response<Oauth2Token> mobileLoginXP(@RequestBody MobileLoginReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getPhone()) ) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
CommonParamterCheck.appIdAndTenantNoRequired(bean.getApplicationId(), bean.getTenantNo());
log.info("mobileLoginXP request url: /user-auth/ciam/login/mobileLogin , phone: {} ",
bean.getPhone());
return loginService.ciamMobileLoginXP(bean);
}
@PostMapping("/userLoginAdd")
@ApiOperation(value = "手机号登录", notes = "手机号登录")
public Response<Oauth2Token> userLoginAdd(@RequestBody MobileLoginReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getPhone()) || CuscStringUtils.isEmpty(bean.getCaptcha())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
CommonParamterCheck.appIdAndTenantNoRequired(bean.getApplicationId(), bean.getTenantNo());
log.info("userLoginAdd request url: /user-auth/ciam/login/mobileLogin , phone: {} , captcha: {}",
bean.getPhone(), bean.getCaptcha().substring(1));
return loginService.userLoginAdd(bean);
}
}
package com.cusc.nirvana.user.auth.identification.login;
import com.alibaba.fastjson.JSON;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.common.constants.ResponseCode;
import com.cusc.nirvana.user.auth.identification.dto.MobileLoginReq;
import com.cusc.nirvana.user.auth.identification.dto.Oauth2Token;
import com.cusc.nirvana.user.auth.identification.dto.UserNameLoginReq;
import com.cusc.nirvana.user.auth.identification.service.ILoginService;
import com.cusc.nirvana.user.auth.identification.util.CommonParamterCheck;
import com.cusc.nirvana.user.util.CuscStringUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/login")
public class LoginController {
private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
@Autowired
ILoginService loginService;
@PostMapping("/sendSmsCaptcha")
@ApiOperation(value = "发送短信验证码", notes = "发送短信验证码")
public Response<Boolean> sendSmsCaptcha(@RequestBody MobileLoginReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getPhone()) || bean.getCaptchaExpire() == null) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
//图形验证码校验
if (bean.isCheckCaptchaImg() && CuscStringUtils.isEmpty(bean.getCaptchaImage()) && CuscStringUtils.isEmpty(
bean.getRequestId())) {
return Response.createError(ResponseCode.CAPTCHA_IMAGGE_NOT_NULL.getMsg(),
ResponseCode.CAPTCHA_IMAGGE_NOT_NULL.getCode());
}
//其他参数配置
CommonParamterCheck.appIdAndTenantNoRequired(bean.getApplicationId(), bean.getTenantNo());
log.info("sendSmsCaptcha request url: /user-auth/login/sendSmsCaptcha , param: {}",
JSON.toJSON(bean.getPhone()));
return loginService.sendSmsCaptcha(bean);
}
/**
* @author: jk
* @description: 登录注册发送验证码
* @date: 2022/6/14 9:56
* @version: 1.0
* @Param:
* @Return:
*/
@PostMapping("/sendSmsCaptchaNew")
@ApiOperation(value = "发送短信验证码", notes = "发送短信验证码")
public Response<Boolean> sendSmsCaptchaNew(@RequestBody MobileLoginReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getPhone()) || bean.getCaptchaExpire() == null) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
//图形验证码校验
if (bean.isCheckCaptchaImg() && CuscStringUtils.isEmpty(bean.getCaptchaImage()) && CuscStringUtils.isEmpty(
bean.getRequestId())) {
return Response.createError(ResponseCode.CAPTCHA_IMAGGE_NOT_NULL.getMsg(),
ResponseCode.CAPTCHA_IMAGGE_NOT_NULL.getCode());
}
//其他参数配置
CommonParamterCheck.appIdAndTenantNoRequired(bean.getApplicationId(), bean.getTenantNo());
log.info("sendSmsCaptcha request url: /user-auth/login/sendSmsCaptcha , param: {}",
JSON.toJSON(bean.getPhone()));
return loginService.sendSmsCaptchaNew(bean);
}
@PostMapping("/mobile")
@ApiOperation(value = "手机号登录", notes = "手机号登录")
public Response<Oauth2Token> mobileLogin(@RequestBody MobileLoginReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getPhone()) || CuscStringUtils.isEmpty(bean.getCaptcha())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
CommonParamterCheck.appIdAndTenantNoRequired(bean.getApplicationId(), bean.getTenantNo());
log.info("mobileLogin request url: /user-auth/login/mobile , phone: {} , captcha: {}",
bean.getPhone(), bean.getCaptcha().substring(1));
return loginService.mobileLogin(bean);
}
@PostMapping("/username")
@ApiOperation(value = "用户名登录", notes = "用户名登录")
public Response<Oauth2Token> userNameLogin(@RequestBody UserNameLoginReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getUserName()) || CuscStringUtils.isEmpty(
bean.getPassword())) {
return Response.createError(ResponseCode.LOGIN_USER_NAME_PASSWORD_INVALID.getMsg(),
ResponseCode.LOGIN_USER_NAME_PASSWORD_INVALID.getCode());
}
CommonParamterCheck.appIdAndTenantNoRequired(bean.getApplicationId(), bean.getTenantNo());
log.info("userNameLogin request url: /user-auth/login/username, param : {}", JSON.toJSONString(bean));
return loginService.userNameLogin(bean);
}
@PostMapping("/userLoginAdd")
@ApiOperation(value = "用户登录注册", notes = "用户登录注册")
public Response add(@RequestBody MobileLoginReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getPhone()) || CuscStringUtils.isEmpty(bean.getCaptcha())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
CommonParamterCheck.appIdAndTenantNoRequired(bean.getApplicationId(), bean.getTenantNo());
log.info("userLoginAdd request url: /user-auth/login/username, param : {}", JSON.toJSONString(bean));
return loginService.mobileLogin(bean);
}
}
package com.cusc.nirvana.user.auth.identification.login;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.common.constants.ResponseCode;
import com.cusc.nirvana.user.auth.common.dto.LogoutDTO;
import com.cusc.nirvana.user.auth.identification.service.ITokenService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
public class LogoutController {
private static final Logger LOGGER = LoggerFactory.getLogger(LogoutController.class);
@Autowired
ITokenService tokenService;
@PostMapping("/logout")
@ApiOperation(value = "退出", notes = "退出")
public Response logout(@RequestBody LogoutDTO logoutDTO) {
if (logoutDTO == null || CuscStringUtils.isEmpty(logoutDTO.getAccessToken()) || CuscStringUtils.isEmpty(logoutDTO.getApplicationId())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(), ResponseCode.PARAMETER_NULL.getCode());
}
return tokenService.logout(logoutDTO);
}
}
package com.cusc.nirvana.user.auth.identification.login;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.common.constants.ResponseCode;
import com.cusc.nirvana.user.auth.identification.dto.RandomIdReq;
import com.cusc.nirvana.user.auth.identification.dto.RandomIdResp;
import com.cusc.nirvana.user.auth.identification.service.IRandomIdService;
import com.cusc.nirvana.user.util.CuscRequestUtil;
import com.cusc.nirvana.user.util.CuscStringUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@Slf4j
@RestController
@RequestMapping("/random")
public class RandomIdController {
private static final Logger LOGGER = LoggerFactory.getLogger(RandomIdController.class);
//随机请求id的失效时间:秒 3小时
private static final int REQUEST_ID_EXPIRE_TIME = 10800;
@Autowired
private IRandomIdService randomIdService;
@PostMapping("/getRequestIdByCaptcha")
@ApiOperation(value = "获取随机请求id-图形验证码", notes = "获取随机请求id-图形验证码")
public Response<String> getRequestIdByCaptcha(@RequestBody RandomIdReq bean, HttpServletRequest request) {
if (bean == null || CuscStringUtils.isEmpty(bean.getApplicationId())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
Response ret = Response.createSuccess();
ret.setData(randomIdService.getRequestIdToRedis(bean.getApplicationId(), REQUEST_ID_EXPIRE_TIME,
CuscRequestUtil.getIpAddr(request)));
return ret;
}
@PostMapping("/getRequestIdByLogin")
@ApiOperation(value = "获取随机请求id-登录密码加密", notes = "获取随机请求id-登录密码加密")
public Response<RandomIdResp> getRequestIdByLogin(@RequestBody RandomIdReq bean) {
if (bean == null || CuscStringUtils.isEmpty(bean.getApplicationId())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
int expireTime = REQUEST_ID_EXPIRE_TIME;
if (bean.getExpireTime() != null && bean.getExpireTime() > 0) {
expireTime = bean.getExpireTime();
}
String secretKey = CuscStringUtils.generateUuid().substring(16);
String requestId = randomIdService.getRequestIdToRedis(bean.getApplicationId(), expireTime, secretKey);
RandomIdResp ret = new RandomIdResp();
ret.setSecretKey(secretKey);
ret.setRequestId(requestId);
return Response.createSuccess(ret);
}
@PostMapping("/getContentByRequestId")
@ApiOperation(value = "获取随机请求id对应的内容", notes = "获取随机请求id对应的内容")
public Response<String> getContentByRequestId(@RequestBody RandomIdReq bean) {
if (CuscStringUtils.isEmpty(bean.getRequestId()) || CuscStringUtils.isEmpty(bean.getApplicationId())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
Response ret = Response.createSuccess();
ret.setData(randomIdService.getByRequestId(bean.getRequestId(), bean.getApplicationId()));
return ret;
}
@PostMapping("/delByRequestId")
@ApiOperation(value = "删除随机请求id对应的内容", notes = "删除随机请求id对应的内容")
public Response<Boolean> delByRequestId(@RequestBody RandomIdReq bean) {
if (CuscStringUtils.isEmpty(bean.getRequestId()) || CuscStringUtils.isEmpty(bean.getApplicationId())) {
return Response.createError(ResponseCode.PARAMETER_NULL.getMsg(),
ResponseCode.PARAMETER_NULL.getCode());
}
Response ret = Response.createSuccess();
ret.setData(randomIdService.delRequestIdRedis(bean.getRequestId(), bean.getApplicationId()));
return ret;
}
}
package com.cusc.nirvana.user.auth.identification.service;
import com.cusc.nirvana.user.auth.identification.dto.CaptchaCreateReq;
import com.cusc.nirvana.user.auth.identification.dto.CaptchaCreateResp;
import com.cusc.nirvana.user.auth.identification.dto.CaptchaVerificationReq;
/**
* Description: 验证码业务
* <br />
* CreateDate 2021-11-02 20:25:19
*
* @author yuyi
**/
public interface ICaptchaService {
/**
* Description: 生成图形验证码
* <br />
* CreateDate 2022-01-24 10:32:21
* @param bean 图形验证码请求对象
* @author yuyi
**/
CaptchaCreateResp generateCaptcha(CaptchaCreateReq bean);
/**
* Description: 验证图形验证码
* <br />
* CreateDate 2022-01-24 10:32:21
* @param bean 图形验证码请求对象
* @author yuyi
**/
boolean verificationCaptcha(CaptchaVerificationReq bean);
/**
* Description: 检查短信验证码验证错误次数
* <br />
* CreateDate 2022-07-08 19:41:51
*
* @author yuyi
**/
void checkSmsCaptchaErrorCount(String phone, String tenantNo, String appId);
/**
* Description: 删除短信验证码验证错误次数
* <br />
* CreateDate 2022-07-08 19:41:51
*
* @author yuyi
**/
void delSmsCaptchaErrorCount(String phone, String tenantNo, String appId);
}
package com.cusc.nirvana.user.auth.identification.service;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.identification.dto.MobileLoginReq;
import com.cusc.nirvana.user.auth.identification.dto.Oauth2Token;
import com.cusc.nirvana.user.auth.identification.dto.UserNameLoginReq;
/**
* Description: 登录service
* <br />
* CreateDate 2021-11-02 20:25:19
*
* @author yuyi
**/
public interface ILoginService {
/**
* Description: C端用户手机号登录
* <br />
* CreateDate 2022-04-15 19:53:41
*
* @author huzl
**/
Response<Oauth2Token> ciamMobileLogin(MobileLoginReq bean);
/**
* Description: C端用户手机号登录小鹏
* <br />
* CreateDate 2022-04-15 19:53:41
*
* @author huzl
**/
Response<Oauth2Token> ciamMobileLoginXP(MobileLoginReq bean);
/**
* Description: 手机号登录
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response<Oauth2Token> mobileLogin(MobileLoginReq bean);
/**
* Description: 发送短信验证码
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response<Boolean> sendSmsCaptcha(MobileLoginReq bean);
/**
* @author: jk
* @description: 登录注册发送验证码
* @date: 2022/6/14 9:56
* @version: 1.0
* @Param:
* @Return:
*/
Response<Boolean> sendSmsCaptchaNew(MobileLoginReq bean);
/**
* Description: 检查短信验证码
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response<Boolean> checkSmsCaptcha(MobileLoginReq bean);
/**
* Description: 用户名登录
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response<Oauth2Token> userNameLogin(UserNameLoginReq bean);
/**
* @author: jk
* @description: 登录注册
* @date: 2022/6/8 14:17
* @version: 1.0
*/
Response<Oauth2Token> userLoginAdd(MobileLoginReq bean);
}
package com.cusc.nirvana.user.auth.identification.service;
/**
* Description: 随机id或随机数业务层
* <br />
* CreateDate 2021-11-02 20:25:19
*
* @author yuyi
**/
public interface IRandomIdService {
/**
* Description: 生成请求id并存放至redis
* <br />
* CreateDate 2022-01-24 10:32:21
*
* @param expireTime redis失效时间,单位:秒。必填
* @param content redis存放的内容
* @author yuyi
**/
String getRequestIdToRedis(String applicationId, int expireTime, String content);
/**
* Description: 判断请求id是否存在
* <br />
* CreateDate 2022-01-24 10:32:21
*
* @param requestId 请求id
* @author yuyi
**/
boolean existsRequestIdRedis(String requestId, String applicationId);
/**
* Description: 删除redis中的请求id
* <br />
* CreateDate 2022-01-24 10:32:21
*
* @param requestId 请求id
* @author yuyi
**/
boolean delRequestIdRedis(String requestId, String applicationId);
/**
* Description: 通过请求id获取请求的内容
* <br />
* CreateDate 2022-01-24 10:32:21
*
* @param requestId 请求id,必填
* @author yuyi
**/
String getByRequestId(String requestId, String applicationId);
}
package com.cusc.nirvana.user.auth.identification.service;
import com.cusc.nirvana.user.auth.common.dto.SmsResponseDTO;
import com.cusc.nirvana.user.auth.identification.dto.SmsSendConfig;
import com.cusc.nirvana.user.eiam.dto.ApplicationDTO;
import java.util.List;
/**
* Description: 短信service
* <br />
* CreateDate 2021-11-02 20:25:19
*
* @author yuyi
**/
public interface ISmsService {
/**
* Description: 发送短信-多个参数
* <br />
* CreateDate 2021-12-03 14:53:06
*
* @author yuyi
**/
SmsResponseDTO sendSms(String phone, List<String> paramterList, SmsSendConfig config);
/**
* Description: 发送短信-单个参数
* <br />
* CreateDate 2021-12-03 14:53:06
*
* @author yuyi
**/
SmsResponseDTO sendSms(String phone, String paramter, SmsSendConfig config);
/**
* Description: 检查短信配置是否为空
* <br />
* CreateDate 2022-01-27 14:43:41
*
* @author yuyi
**/
boolean checkSmsConfigNotNull(SmsSendConfig bean);
/**
* Description: 从应用配置转短信配置
* <br />
* CreateDate 2022-01-27 14:43:41
*
* @author yuyi
**/
void convertToSmsConfig(ApplicationDTO fromBean, SmsSendConfig toBean);
/**
* Description: 短信发送限制检查
* <br />
* CreateDate 2022-01-27 14:43:41
*
* @author yuyi
**/
void checkSmsSendLimit(String phone, SmsSendConfig bean);
}
package com.cusc.nirvana.user.auth.identification.service;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.common.dto.LogoutDTO;
import com.cusc.nirvana.user.auth.identification.dto.MobileLoginReq;
import com.cusc.nirvana.user.auth.identification.dto.Oauth2Token;
import com.cusc.nirvana.user.auth.identification.dto.UserNameLoginReq;
import com.cusc.nirvana.user.eiam.dto.UserDTO;
/**
* Description: 令牌service
* <br />
* CreateDate 2021-11-02 20:25:19
*
* @author yuyi
**/
public interface ITokenService {
/**
* Description: 创建Oauth2Token(手机号)
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response<Oauth2Token> createOauth2TokenByMobile(MobileLoginReq bean, UserDTO user);
/**
* Description: 创建Oauth2Token(手机号)小鹏
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response<Oauth2Token> createOauth2TokenByMobileXP(MobileLoginReq bean, UserDTO user);
/**
* Description: 创建Oauth2Token(登录名)
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response<Oauth2Token> createOauth2TokenByUserName(UserNameLoginReq bean, UserDTO user);
/**
* Description: 创建Oauth2Token
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response logout(LogoutDTO logoutDTO);
/**
* Description: 通过用户id踢出
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response kickOutByUserId(String userId, String tenantNo, String appId);
/**
* Description: access token续期
* <br />
* CreateDate 2021-11-04 19:53:41
*
* @author yuyi
**/
Response tokenRenewal(String accessToken, String appId);
}
package com.cusc.nirvana.user.auth.identification.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* Description: 应用配置服务类
* <br />
* CreateDate 2021-11-02 20:25:49
*
* @author yuyi
**/
@Service
@Slf4j
public class AsynExecService {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment