|
|
@@ -1,12 +1,12 @@
|
|
|
package com.lc.ibps.cloud.oauth.server.provider;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import com.lc.ibps.cloud.oauth.exception.*;
|
|
|
+import com.lc.ibps.org.party.persistence.entity.PartyEmployeePo;
|
|
|
+import com.lc.ibps.org.party.persistence.entity.PartyEntityPo;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.data.redis.connection.DataType;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
@@ -51,6 +51,8 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
/**
|
|
|
* auth2.0 访问令牌控制器
|
|
|
* <pre>
|
|
|
@@ -152,7 +154,12 @@ public class TokenProvider extends BaseProvider implements ITokenService {
|
|
|
String refreshToken = accessTokenVo.getRefresh_token();
|
|
|
String authorizeCode = accessTokenVo.getAuthorize_code();
|
|
|
String redirectUri = accessTokenVo.getRedirect_uri();
|
|
|
- String licJson = checkLicense();
|
|
|
+
|
|
|
+ String org = getOrgByAccount(username);
|
|
|
+ Map<String, Object> lcMap = commonDao.queryOne("select zheng_shu_bian_ma from t_ipcc WHERE org_ = '" + org + "' ");
|
|
|
+ String licText = lcMap.get("zheng_shu_bian_ma").toString();
|
|
|
+
|
|
|
+ String licJson = checkLicense(licText);
|
|
|
TokenEntity token = new TokenEntity();
|
|
|
logger.debug("grant type is {}", grantType);
|
|
|
if(GrantType.AUTHORIZATION_CODE.equalsIgnoreCase(grantType)){
|
|
|
@@ -1132,5 +1139,35 @@ public class TokenProvider extends BaseProvider implements ITokenService {
|
|
|
|
|
|
return tokenList;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public APIResult<Void> updateLicense(Map<String,Object> map) {
|
|
|
+ APIResult<Void> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ String username = map.get("username").toString();
|
|
|
+ String licText = map.get("license").toString();
|
|
|
+ String licJson = checkLicense(licText);
|
|
|
+ if (BeanUtils.isNotEmpty(licJson)){
|
|
|
+ String org = getOrgByAccount(username);
|
|
|
+ commonDao.execute("UPDATE t_ipcc set zheng_shu_bian_ma = '" + licText + "' where org_ = '" + org + "' ");
|
|
|
+ }
|
|
|
+ result.getVariables().put("licJson",licJson);
|
|
|
+ } catch(Exception e) {
|
|
|
+ if(StateEnum.SUCCESS.getCode() == result.getState()){
|
|
|
+ result.setState(StateEnum.ILLEGAL_REQUEST.getCode());
|
|
|
+ }
|
|
|
+ result.setCause(ExceptionUtil.analysisCause(e));
|
|
|
+ logger.error("access token failed:", e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getOrgByAccount(String username){
|
|
|
+ PartyUserPo userPo = partyUserRepository.getByAccount(username);
|
|
|
+ PartyEmployeePo employeePo = partyEmployeeRepository.get(userPo.getUserId());
|
|
|
+ String position = employeePo.getPositions().split(",")[0];
|
|
|
+ PartyEntityPo entityPo = partyEntityRepository.get(position);
|
|
|
+ String org = entityPo.getPath().split("\\.")[0];
|
|
|
+ return org;
|
|
|
+ }
|
|
|
}
|