|
|
|
@ -18,6 +18,7 @@ import ${basePackage}.frame.utils.Message;
|
|
|
|
|
import ${basePackage}.frame.utils.ValidationUtil;
|
|
|
|
|
import ${basePackage}.module.system.ent.Tokens;
|
|
|
|
|
import ${basePackage}.module.system.mpr.TokensMapper;
|
|
|
|
|
import ${basePackage}.module.system.req.ResFindRequest;
|
|
|
|
|
import ${basePackage}.module.system.req.TokensBuildRequest;
|
|
|
|
|
import ${basePackage}.module.system.req.TokensCreateRequest;
|
|
|
|
|
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.TokensLogoutRequest;
|
|
|
|
|
import ${basePackage}.module.system.req.TokensUpdateRequest;
|
|
|
|
|
import ${basePackage}.module.system.rsp.ResFindResponse;
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensBuildResponse;
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensCreateResponse;
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensDeleteResponse;
|
|
|
|
@ -42,12 +44,16 @@ import ${basePackage}.module.system.rsp.TokensUpdateResponse;
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
@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;
|
|
|
|
|
@Autowired
|
|
|
|
|
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 {
|
|
|
|
|
Tokens tokens = tokensFindResponse.getResult().get(0);
|
|
|
|
|
Token newToken = new Token();
|
|
|
|
|
if (tokens.getUserName().equals(admin)) {
|
|
|
|
|
if (tokens.getUserName().equals(admin)) {//超级管理员
|
|
|
|
|
newToken.setId(0);
|
|
|
|
|
newToken.setToken(tokensFindResponse.getResult().get(0).getToken());
|
|
|
|
|
newToken.setUserId(0);
|
|
|
|
|
newToken.setUserName(admin);
|
|
|
|
|
newToken.putResource(".*");
|
|
|
|
|
} else {
|
|
|
|
|
newToken.putRes(".*");
|
|
|
|
|
|
|
|
|
|
// 获取用户的资源
|
|
|
|
|
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.setToken(tokensFindResponse.getResult().get(0).getToken());
|
|
|
|
|
newToken.setUserId(tokens.getUserId());
|
|
|
|
|
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);
|
|
|
|
|