|
@@ -10,10 +10,7 @@ import com.lightinit.hsdataplatform.entity.*;
|
|
|
import com.lightinit.hsdataplatform.mapper.*;
|
|
|
import com.lightinit.hsdataplatform.model.ResultState;
|
|
|
import com.lightinit.hsdataplatform.model.ResultStateCode;
|
|
|
-import com.lightinit.hsdataplatform.model.admin.AuthorizationHeableModel;
|
|
|
-import com.lightinit.hsdataplatform.model.admin.AuthorizationListModel;
|
|
|
-import com.lightinit.hsdataplatform.model.admin.AuthorizationSearchModel;
|
|
|
-import com.lightinit.hsdataplatform.model.admin.AuthorizationViewModel;
|
|
|
+import com.lightinit.hsdataplatform.model.admin.*;
|
|
|
import com.lightinit.hsdataplatform.service.admin.IAccountManageService;
|
|
|
import com.lightinit.hsdataplatform.service.admin.IAuthorizationService;
|
|
|
import com.lightinit.hsdataplatform.spring.DynamicDataContextHolder;
|
|
@@ -61,6 +58,9 @@ public class AuthorizationServiceImpl implements IAuthorizationService {
|
|
|
@Autowired
|
|
|
private PublishInfoMapper publishInfoMapper ;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ResourceApiInterfaceMapper resourceApiInterfaceMapper ;
|
|
|
+
|
|
|
@Override
|
|
|
public List<AuthorizationListModel> queryList(AuthorizationSearchModel inputModel) {
|
|
|
DynamicDataContextHolder.setCustomerType(DynamicDataContextHolder.DEFAULT);
|
|
@@ -81,7 +81,7 @@ public class AuthorizationServiceImpl implements IAuthorizationService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public ResultState<Long> handle(AuthorizationHeableModel inputModel,Long followId) {
|
|
|
+ public ResultState<Long> handle(AuthorizationHeableModel inputModel, LoginUser loginUser) {
|
|
|
DynamicDataContextHolder.setCustomerType(DynamicDataContextHolder.DEFAULT);
|
|
|
ResultState<Long> resultState = new ResultState<Long>();
|
|
|
Date createdAt = new Date();
|
|
@@ -94,14 +94,15 @@ public class AuthorizationServiceImpl implements IAuthorizationService {
|
|
|
ResourceAuthExample.Criteria criteria = example.createCriteria() ;
|
|
|
criteria.andIdEqualTo(inputModel.getId()) ;
|
|
|
int result0 = resourceAuthMapper.updateByExampleSelective(resourceAuth,example) ;
|
|
|
+
|
|
|
int result1 = 0;int result2 = 0 ;
|
|
|
if (inputModel.getAuthorizationState().equals(DicAuthorizationState.AUTHORIZE_OK)){
|
|
|
PublishSetting publishSetting = publishSettingMapper.selectByPrimaryKey(inputModel.getPublishSettingId()) ;
|
|
|
-
|
|
|
+ PublishInfoWithBLOBs publishInfoWithBLOBs = publishInfoMapper.selectByPrimaryKey(publishSetting.getPublishInfoId());
|
|
|
//插入order表
|
|
|
Order order = new Order() ;
|
|
|
order.setPlatformType(inputModel.getPlatfromType());
|
|
|
- order.setUserId(followId) ;
|
|
|
+ order.setUserId(loginUser.getId()) ;
|
|
|
order.setOrderTime(createdAt) ;
|
|
|
order.setOrderNumber(OrderNumberUtils.generate());
|
|
|
if (inputModel.getPlatfromType().equals(DicOrderTypeState.OFFLINE)){
|
|
@@ -130,25 +131,25 @@ public class AuthorizationServiceImpl implements IAuthorizationService {
|
|
|
if (result1>0&&result2>0){
|
|
|
//=================新路由鉴权和计费==================
|
|
|
if (order.getOrderState().equals(DicOrderState.PAID)&&orderGoods.getResourceType().equals(DicResourceType.API)){
|
|
|
- String userName = null ;
|
|
|
- if (order.getPlatformType().equals(DicPlatformType.OPEN)){
|
|
|
- User user = userMapper.selectByPrimaryKey(order.getUserId());
|
|
|
- if (user!=null) {
|
|
|
- userName = user.getUsername() ;
|
|
|
- }
|
|
|
- }else {
|
|
|
- Admin admin = adminMapper.selectByPrimaryKey(order.getUserId());
|
|
|
- if (admin!=null) {
|
|
|
- userName =admin.getUsername() ;
|
|
|
- }
|
|
|
- }
|
|
|
+// String userName = null ;
|
|
|
+// if (order.getPlatformType().equals(DicPlatformType.OPEN)){
|
|
|
+// User user = userMapper.selectByPrimaryKey(loginUser.getId());
|
|
|
+// if (user!=null) {
|
|
|
+// userName = user.getUsername() ;
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// Admin admin = adminMapper.selectByPrimaryKey(loginUser.getId());
|
|
|
+// if (admin!=null) {
|
|
|
+// userName =admin.getUsername() ;
|
|
|
+// }
|
|
|
+// }
|
|
|
try {
|
|
|
- PublishInfoWithBLOBs publishInfoWithBLOBs = publishInfoMapper.selectByPrimaryKey(publishSetting.getPublishInfoId());
|
|
|
- // 新增网关授权
|
|
|
- GateWayUtils.gatewayAuthAdd(publishInfoWithBLOBs.getOutId1(),DicNewGateway.APPLICATIONID,userName,userName+"添加授权") ;
|
|
|
+ ResourceApiInterfaceExample example1 = new ResourceApiInterfaceExample() ;
|
|
|
+ ResourceApiInterfaceExample.Criteria criteria1 = example1.createCriteria() ;
|
|
|
+ criteria1.andApiIdEqualTo(publishInfoWithBLOBs.getResourceId()) ;
|
|
|
+ List<ResourceApiInterfaceWithBLOBs> resourceApiInterfaceWithBLOBs = resourceApiInterfaceMapper.selectByExampleWithBLOBs(example1);
|
|
|
//新增网关计费
|
|
|
- GateWayUtils.gatewayChargeAdd(publishInfoWithBLOBs.getOutId1(),DicNewGateway.APPLICATIONID,userName,
|
|
|
- DicPublishSettingChargeMethod.FREE,publishSetting.getUseTimesLimit().toString(),userName+"添加计费") ;
|
|
|
+ GateWayUtils.gatewayChargeAdd(resourceApiInterfaceWithBLOBs,loginUser.getUsername(),loginUser.getUsername()+"添加计费") ;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
log.error("同步网关失败!所在类是:AuthorizationServiceImpl,行数是:147");
|
|
@@ -161,90 +162,91 @@ public class AuthorizationServiceImpl implements IAuthorizationService {
|
|
|
if (!(result0>0||(result1>0&&result2>0))){
|
|
|
resultState.setStateCode(ResultStateCode.INVALID_DATA);
|
|
|
resultState.setMsg("授权失败");
|
|
|
- }else {
|
|
|
-
|
|
|
- //=====================================================
|
|
|
- //授权权限
|
|
|
- UserAuthSettingExample example1 = new UserAuthSettingExample() ;
|
|
|
- UserAuthSettingExample.Criteria criteria1 = example1.createCriteria() ;
|
|
|
- criteria1.andUserIdEqualTo((long) 60) ;
|
|
|
- List<UserAuthSetting> userAuthSettings = userAuthSettingMapper.selectByExample(example1);
|
|
|
- if (userAuthSettings.size()>0){
|
|
|
- UserAuthSetting userAuthSetting = userAuthSettings.get(0);
|
|
|
- String authKey = userAuthSetting.getAuthKey() ;
|
|
|
- Map<String,Object> params = new HashMap<>() ;
|
|
|
- params.put("Authorization","Bearer "+TokenUntils.getToken()) ;
|
|
|
- String str1 = null;
|
|
|
- try {
|
|
|
- str1 = HttpUtil.httpGet2(DicPaasApi.EDITUSER+authKey, "Bearer "+TokenUntils.getToken(),null );
|
|
|
- Map<String,Object> map1= HttpUtil.strToMap(str1) ;
|
|
|
- if ((boolean)map1.get("success")){
|
|
|
- LinkedTreeMap linkedTreeMap = (LinkedTreeMap) map1.get("data");
|
|
|
- //角色列表
|
|
|
- Double id = (Double) linkedTreeMap.get("id");
|
|
|
- int newId = id.intValue() ;
|
|
|
- String userName = (String) linkedTreeMap.get("username");
|
|
|
- ArrayList<Map<String,Object>> arrayList = (ArrayList<Map<String, Object>>) linkedTreeMap.get("roles");
|
|
|
- if (arrayList.size()>0){
|
|
|
- Map<String, Object> map3 = arrayList.get(0);
|
|
|
- //权限列表
|
|
|
- List<Map<String,Object>> list2 = (List<Map<String, Object>>) map3.get("authorities");
|
|
|
- Map<String,Object> map4 = new HashMap<>() ;
|
|
|
-// map4.put("id",inputModel.getOutId1()) ;
|
|
|
- map4.put("id",43) ;
|
|
|
- list2.add(map4) ;
|
|
|
- Map<String,Object> map5 = new HashMap<>() ;
|
|
|
- //更新角色
|
|
|
- Map<String, String> head = TokenUntils.getHead();
|
|
|
- head.put("Content-Type","application/json") ;
|
|
|
- map3.put("authorities",list2) ;
|
|
|
- Double id2 = (Double) map3.get("id");
|
|
|
- String str3 = HttpUtil.httpPut(DicPaasApi.UPDATAROLES+id2.intValue(), head ,map3) ;
|
|
|
- Map<String,Object> map10= HttpUtil.strToMap(str3) ;
|
|
|
- if ((boolean)map10.get("success")){
|
|
|
- arrayList.set(0,map3) ;
|
|
|
- linkedTreeMap.put("roles",arrayList) ;
|
|
|
- linkedTreeMap.remove("permissions") ;
|
|
|
- linkedTreeMap.remove("authorities") ;
|
|
|
- String str2 = HttpUtil.httpPut(DicPaasApi.UPDATEUSER+newId, head ,linkedTreeMap) ;
|
|
|
- }
|
|
|
- }else {
|
|
|
- //新建一个角色
|
|
|
- Map<String,Object> map8 = new HashMap<>() ;
|
|
|
- map8.put("name",userName) ;
|
|
|
- map8.put("value",userName) ;
|
|
|
- List<Map<String,Object>> list3 = new ArrayList<>() ;
|
|
|
- Map<String,Object> map9 = new HashMap<>() ;
|
|
|
- map9.put("id",inputModel.getOutId1()) ;
|
|
|
- list3.add(map9) ;
|
|
|
- map8.put("authorities",list3) ;
|
|
|
- Map<String, String> head = TokenUntils.getHead();
|
|
|
- head.put("Content-Type","application/json") ;
|
|
|
- String str2 = HttpUtil.httpPost(DicPaasApi.ADDROLES, head ,map8) ;
|
|
|
- Map<String,Object> map7= HttpUtil.strToMap(str2) ;
|
|
|
- if ((boolean)map7.get("success")){
|
|
|
- LinkedTreeMap linkedTreeMap1 = (LinkedTreeMap) map7.get("data");
|
|
|
- Double id3 = (Double) linkedTreeMap1.get("id");
|
|
|
- int newId3 = id3.intValue() ;
|
|
|
- List<Map<String,Object>> list4 = new ArrayList<>() ;
|
|
|
- Map<String,Object> map11 = new HashMap<>() ;
|
|
|
- map11.put("id",newId3) ;
|
|
|
- list4.add(map11) ;
|
|
|
- linkedTreeMap.put("roles",list4) ;
|
|
|
- linkedTreeMap.remove("permissions") ;
|
|
|
- linkedTreeMap.remove("authorities") ;
|
|
|
- String str3 = HttpUtil.httpPut(DicPaasApi.UPDATEUSER+newId, head ,linkedTreeMap) ;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ }
|
|
|
+// else {
|
|
|
+//
|
|
|
+// //=====================================================
|
|
|
+// //授权权限
|
|
|
+// UserAuthSettingExample example1 = new UserAuthSettingExample() ;
|
|
|
+// UserAuthSettingExample.Criteria criteria1 = example1.createCriteria() ;
|
|
|
+// criteria1.andUserIdEqualTo((long) 60) ;
|
|
|
+// List<UserAuthSetting> userAuthSettings = userAuthSettingMapper.selectByExample(example1);
|
|
|
+// if (userAuthSettings.size()>0){
|
|
|
+// UserAuthSetting userAuthSetting = userAuthSettings.get(0);
|
|
|
+// String authKey = userAuthSetting.getAuthKey() ;
|
|
|
+// Map<String,Object> params = new HashMap<>() ;
|
|
|
+// params.put("Authorization","Bearer "+TokenUntils.getToken()) ;
|
|
|
+// String str1 = null;
|
|
|
+// try {
|
|
|
+// str1 = HttpUtil.httpGet2(DicPaasApi.EDITUSER+authKey, "Bearer "+TokenUntils.getToken(),null );
|
|
|
+// Map<String,Object> map1= HttpUtil.strToMap(str1) ;
|
|
|
+// if ((boolean)map1.get("success")){
|
|
|
+// LinkedTreeMap linkedTreeMap = (LinkedTreeMap) map1.get("data");
|
|
|
+// //角色列表
|
|
|
+// Double id = (Double) linkedTreeMap.get("id");
|
|
|
+// int newId = id.intValue() ;
|
|
|
+// String userName = (String) linkedTreeMap.get("username");
|
|
|
+// ArrayList<Map<String,Object>> arrayList = (ArrayList<Map<String, Object>>) linkedTreeMap.get("roles");
|
|
|
+// if (arrayList.size()>0){
|
|
|
+// Map<String, Object> map3 = arrayList.get(0);
|
|
|
+// //权限列表
|
|
|
+// List<Map<String,Object>> list2 = (List<Map<String, Object>>) map3.get("authorities");
|
|
|
+// Map<String,Object> map4 = new HashMap<>() ;
|
|
|
+//// map4.put("id",inputModel.getOutId1()) ;
|
|
|
+// map4.put("id",43) ;
|
|
|
+// list2.add(map4) ;
|
|
|
+// Map<String,Object> map5 = new HashMap<>() ;
|
|
|
+// //更新角色
|
|
|
+// Map<String, String> head = TokenUntils.getHead();
|
|
|
+// head.put("Content-Type","application/json") ;
|
|
|
+// map3.put("authorities",list2) ;
|
|
|
+// Double id2 = (Double) map3.get("id");
|
|
|
+// String str3 = HttpUtil.httpPut(DicPaasApi.UPDATAROLES+id2.intValue(), head ,map3) ;
|
|
|
+// Map<String,Object> map10= HttpUtil.strToMap(str3) ;
|
|
|
+// if ((boolean)map10.get("success")){
|
|
|
+// arrayList.set(0,map3) ;
|
|
|
+// linkedTreeMap.put("roles",arrayList) ;
|
|
|
+// linkedTreeMap.remove("permissions") ;
|
|
|
+// linkedTreeMap.remove("authorities") ;
|
|
|
+// String str2 = HttpUtil.httpPut(DicPaasApi.UPDATEUSER+newId, head ,linkedTreeMap) ;
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// //新建一个角色
|
|
|
+// Map<String,Object> map8 = new HashMap<>() ;
|
|
|
+// map8.put("name",userName) ;
|
|
|
+// map8.put("value",userName) ;
|
|
|
+// List<Map<String,Object>> list3 = new ArrayList<>() ;
|
|
|
+// Map<String,Object> map9 = new HashMap<>() ;
|
|
|
+// map9.put("id",inputModel.getOutId1()) ;
|
|
|
+// list3.add(map9) ;
|
|
|
+// map8.put("authorities",list3) ;
|
|
|
+// Map<String, String> head = TokenUntils.getHead();
|
|
|
+// head.put("Content-Type","application/json") ;
|
|
|
+// String str2 = HttpUtil.httpPost(DicPaasApi.ADDROLES, head ,map8) ;
|
|
|
+// Map<String,Object> map7= HttpUtil.strToMap(str2) ;
|
|
|
+// if ((boolean)map7.get("success")){
|
|
|
+// LinkedTreeMap linkedTreeMap1 = (LinkedTreeMap) map7.get("data");
|
|
|
+// Double id3 = (Double) linkedTreeMap1.get("id");
|
|
|
+// int newId3 = id3.intValue() ;
|
|
|
+// List<Map<String,Object>> list4 = new ArrayList<>() ;
|
|
|
+// Map<String,Object> map11 = new HashMap<>() ;
|
|
|
+// map11.put("id",newId3) ;
|
|
|
+// list4.add(map11) ;
|
|
|
+// linkedTreeMap.put("roles",list4) ;
|
|
|
+// linkedTreeMap.remove("permissions") ;
|
|
|
+// linkedTreeMap.remove("authorities") ;
|
|
|
+// String str3 = HttpUtil.httpPut(DicPaasApi.UPDATEUSER+newId, head ,linkedTreeMap) ;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
|
|
|
- }
|
|
|
+// }
|
|
|
//=====================================================
|
|
|
- }
|
|
|
+// }
|
|
|
return resultState ;
|
|
|
}
|
|
|
|