|
|
@ -18,6 +18,7 @@ import ${basePackage}.frame.utils.Message;
|
|
|
|
import ${basePackage}.frame.utils.ValidationUtil;
|
|
|
|
import ${basePackage}.frame.utils.ValidationUtil;
|
|
|
|
import ${basePackage}.module.system.ent.Tokens;
|
|
|
|
import ${basePackage}.module.system.ent.Tokens;
|
|
|
|
import ${basePackage}.module.system.mpr.TokensMapper;
|
|
|
|
import ${basePackage}.module.system.mpr.TokensMapper;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.ResFindRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensBuildRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensBuildRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensCreateRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensCreateRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensDeleteRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensDeleteRequest;
|
|
|
@ -25,6 +26,7 @@ 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.TokensLogoutRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensUpdateRequest;
|
|
|
|
import ${basePackage}.module.system.req.TokensUpdateRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.ResFindResponse;
|
|
|
|
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;
|
|
|
@ -42,12 +44,16 @@ import ${basePackage}.module.system.rsp.TokensUpdateResponse;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class TokensManagerImpl implements ${basePackage}.module.system.mgr.TokensManager {
|
|
|
|
public class TokensManagerImpl implements xyz.wbsite.module.system.mgr.TokensManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${r'${web.url.auth.admin}'}")
|
|
|
|
@Value("${web.url.auth.admin}")
|
|
|
|
private String admin;
|
|
|
|
private String admin;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private TokensMapper tokensMapper;
|
|
|
|
private TokensMapper tokensMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private UserRoleManager userRoleManager;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ResManager resManager;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 插入
|
|
|
|
* 插入
|
|
|
@ -221,15 +227,38 @@ public class TokensManagerImpl implements ${basePackage}.module.system.mgr.Token
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Tokens tokens = tokensFindResponse.getResult().get(0);
|
|
|
|
Tokens tokens = tokensFindResponse.getResult().get(0);
|
|
|
|
Token newToken = new Token();
|
|
|
|
Token newToken = new Token();
|
|
|
|
if (tokens.getUserName().equals(admin)) {
|
|
|
|
if (tokens.getUserName().equals(admin)) {//超级管理员
|
|
|
|
newToken.setId(0);
|
|
|
|
newToken.setId(0);
|
|
|
|
|
|
|
|
newToken.setToken(tokensFindResponse.getResult().get(0).getToken());
|
|
|
|
newToken.setUserId(0);
|
|
|
|
newToken.setUserId(0);
|
|
|
|
newToken.setUserName(admin);
|
|
|
|
newToken.setUserName(admin);
|
|
|
|
newToken.putResource(".*");
|
|
|
|
newToken.putRes(".*");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
// 获取用户的资源
|
|
|
|
|
|
|
|
ResFindRequest resFindRequest = new ResFindRequest();
|
|
|
|
|
|
|
|
resFindRequest.setPageSize(0);
|
|
|
|
|
|
|
|
ResFindResponse resFindResponse = resManager.find(resFindRequest, token);
|
|
|
|
|
|
|
|
if (resFindResponse.hasError()) {
|
|
|
|
|
|
|
|
response.addErrors(resFindResponse.getErrors());
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
newToken.putRes(resFindResponse.getResult());
|
|
|
|
|
|
|
|
} else { // 管理员或用户
|
|
|
|
newToken.setId(tokens.getId());
|
|
|
|
newToken.setId(tokens.getId());
|
|
|
|
|
|
|
|
newToken.setToken(tokensFindResponse.getResult().get(0).getToken());
|
|
|
|
newToken.setUserId(tokens.getUserId());
|
|
|
|
newToken.setUserId(tokens.getUserId());
|
|
|
|
newToken.setUserName(tokens.getUserName());
|
|
|
|
newToken.setUserName(tokens.getUserName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取用户的资源
|
|
|
|
|
|
|
|
ResFindRequest resFindRequest = new ResFindRequest();
|
|
|
|
|
|
|
|
resFindRequest.setPageSize(0);
|
|
|
|
|
|
|
|
resFindRequest.setUserId(token.getUserId());
|
|
|
|
|
|
|
|
ResFindResponse resFindResponse = resManager.find(resFindRequest, token);
|
|
|
|
|
|
|
|
if (resFindResponse.hasError()) {
|
|
|
|
|
|
|
|
response.addErrors(resFindResponse.getErrors());
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
newToken.putRes(resFindResponse.getResult());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.setToken(newToken);
|
|
|
|
response.setToken(newToken);
|
|
|
|