|
|
@ -1,21 +1,32 @@
|
|
|
|
package ${basePackage}.module.system.mgr;
|
|
|
|
package ${basePackage}.module.system.mgr;
|
|
|
|
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.IDgenerator;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.Message;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.base.ErrorType;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.base.Token;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.MapperUtil;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.ValidationUtil;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.ent.Tokens;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.mpr.TokensMapper;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.*;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.*;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
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.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.base.ErrorType;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.base.Token;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.IDgenerator;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.MapperUtil;
|
|
|
|
|
|
|
|
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.TokensBuildRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.TokensCreateRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.TokensDeleteRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.TokensFindRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.TokensGetRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.TokensUpdateRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensBuildResponse;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensCreateResponse;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensDeleteResponse;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensFindResponse;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensGetResponse;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensUpdateResponse;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* TOKENS - 通行证
|
|
|
|
* TOKENS - 通行证
|
|
|
@ -164,4 +175,54 @@ public class TokensManagerImpl implements TokensManager {
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 构建Token
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param request 请求对象
|
|
|
|
|
|
|
|
* @param token 令牌
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public TokensBuildResponse build(TokensBuildRequest request, Token token) {
|
|
|
|
|
|
|
|
TokensBuildResponse response = new TokensBuildResponse();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tokensFindResponse.getResult().size() == 0) {
|
|
|
|
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, "令牌无效或不存在");
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
} else if (tokensFindResponse.getResult().size() > 1) {
|
|
|
|
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, "令牌异常");
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Tokens tokens = tokensFindResponse.getResult().get(0);
|
|
|
|
|
|
|
|
Token newToken = new Token();
|
|
|
|
|
|
|
|
if (tokens.getUserName().equals(admin)) {
|
|
|
|
|
|
|
|
newToken.setId(0);
|
|
|
|
|
|
|
|
newToken.setUserId(0);
|
|
|
|
|
|
|
|
newToken.setUserName(admin);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, "token");
|
|
|
|
|
|
|
|
newToken.setId(tokens.getId());
|
|
|
|
|
|
|
|
newToken.setUserId(tokens.getUserId());
|
|
|
|
|
|
|
|
newToken.setUserName(tokens.getUserName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response.setToken(newToken);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|