|
|
@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo;
|
|
|
|
import com.github.pagehelper.util.StringUtil;
|
|
|
|
import com.github.pagehelper.util.StringUtil;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@ -22,12 +23,14 @@ import ${basePackage}.module.system.req.TokensCreateRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensDeleteRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensDeleteRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensFindRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensFindRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensGetRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensGetRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.TokensLogoutRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensUpdateRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensUpdateRequest;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensBuildResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensBuildResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensCreateResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensCreateResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensDeleteResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensDeleteResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensFindResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensFindResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensGetResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensGetResponse;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensLogoutResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensUpdateResponse;
|
|
|
|
import ${basePackage}.module.system.rsp.TokensUpdateResponse;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -39,7 +42,7 @@ import ${basePackage}.module.system.rsp.TokensUpdateResponse;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class TokensManagerImpl implements TokensManager {
|
|
|
|
public class TokensManagerImpl implements ${basePackage}.module.system.mgr.TokensManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${r'${web.url.auth.admin}'}")
|
|
|
|
@Value("${r'${web.url.auth.admin}'}")
|
|
|
|
private String admin;
|
|
|
|
private String admin;
|
|
|
@ -82,6 +85,7 @@ public class TokensManagerImpl implements TokensManager {
|
|
|
|
* @param token 令牌
|
|
|
|
* @param token 令牌
|
|
|
|
* @return 响应
|
|
|
|
* @return 响应
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@CacheEvict(value = CacheConfig.TOKEN_CACHE, key = "#request.token", condition = "!#result.hasError()")
|
|
|
|
public TokensDeleteResponse delete(TokensDeleteRequest request, Token token) {
|
|
|
|
public TokensDeleteResponse delete(TokensDeleteRequest request, Token token) {
|
|
|
|
TokensDeleteResponse response = new TokensDeleteResponse();
|
|
|
|
TokensDeleteResponse response = new TokensDeleteResponse();
|
|
|
|
|
|
|
|
|
|
|
@ -107,6 +111,7 @@ public class TokensManagerImpl implements TokensManager {
|
|
|
|
* @param token 令牌
|
|
|
|
* @param token 令牌
|
|
|
|
* @return 响应
|
|
|
|
* @return 响应
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@CacheEvict(value = CacheConfig.TOKEN_CACHE, key = "#request.token", condition = "!#result.hasError()")
|
|
|
|
public TokensUpdateResponse update(TokensUpdateRequest request, Token token) {
|
|
|
|
public TokensUpdateResponse update(TokensUpdateRequest request, Token token) {
|
|
|
|
TokensUpdateResponse response = new TokensUpdateResponse();
|
|
|
|
TokensUpdateResponse response = new TokensUpdateResponse();
|
|
|
|
|
|
|
|
|
|
|
@ -188,7 +193,7 @@ public class TokensManagerImpl implements TokensManager {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Cacheable(value = CacheConfig.TOKEN_CACHE, key = "#request.token")
|
|
|
|
@Cacheable(value = CacheConfig.TOKEN_CACHE, key = "#request.token", unless = "#result.hasError()")
|
|
|
|
public TokensBuildResponse build(TokensBuildRequest request, Token token) {
|
|
|
|
public TokensBuildResponse build(TokensBuildRequest request, Token token) {
|
|
|
|
TokensBuildResponse response = new TokensBuildResponse();
|
|
|
|
TokensBuildResponse response = new TokensBuildResponse();
|
|
|
|
|
|
|
|
|
|
|
@ -230,4 +235,35 @@ public class TokensManagerImpl implements TokensManager {
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@CacheEvict(value = CacheConfig.TOKEN_CACHE, key = "#request.token", condition = "!#result.hasError()")
|
|
|
|
|
|
|
|
public TokensLogoutResponse logout(TokensLogoutRequest request, Token token) {
|
|
|
|
|
|
|
|
TokensLogoutResponse response = new TokensLogoutResponse();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ValidationUtil.validate(request, response);
|
|
|
|
|
|
|
|
if (response.hasError()) {
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TokensFindRequest tokensFindRequest = MapperUtil.map(request, TokensFindRequest.class);
|
|
|
|
|
|
|
|
tokensFindRequest.setValid(true);
|
|
|
|
|
|
|
|
TokensFindResponse tokensFindResponse = this.find(tokensFindRequest, token);
|
|
|
|
|
|
|
|
if (tokensFindResponse.hasError()) {
|
|
|
|
|
|
|
|
response.addErrors(tokensFindResponse.getErrors());
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Tokens tokens : tokensFindResponse.getResult()) {
|
|
|
|
|
|
|
|
TokensUpdateRequest tokensUpdateRequest = MapperUtil.map(tokens, TokensUpdateRequest.class);
|
|
|
|
|
|
|
|
tokensUpdateRequest.setValid(false);
|
|
|
|
|
|
|
|
long result = tokensMapper.update(tokensUpdateRequest, token);
|
|
|
|
|
|
|
|
if (1L != result) {
|
|
|
|
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE);
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|