Browse Source

fix:修改流通管理系统-授权管理报错

414057798 5 years ago
parent
commit
4832317dfa

+ 22 - 8
src/main/java/com/lightinit/hsdataplatform/impl/admin/AuthorizationServiceImpl.java

@@ -17,6 +17,8 @@ import com.lightinit.hsdataplatform.model.admin.AuthorizationViewModel;
 import com.lightinit.hsdataplatform.service.admin.IAccountManageService;
 import com.lightinit.hsdataplatform.service.admin.IAuthorizationService;
 import com.lightinit.hsdataplatform.spring.DynamicDataContextHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -31,6 +33,7 @@ import java.util.*;
 @Service
 public class AuthorizationServiceImpl implements IAuthorizationService {
 
+    static Logger log = LoggerFactory.getLogger(AuthorizationServiceImpl.class);
     @Autowired
     private ResourceAuthMapper resourceAuthMapper ;
 
@@ -129,16 +132,27 @@ public class AuthorizationServiceImpl implements IAuthorizationService {
                 if (order.getOrderState().equals(DicOrderState.PAID)&&orderGoods.getResourceType().equals(DicResourceType.API)){
                     String userName = null ;
                     if (order.getPlatformType().equals(DicPlatformType.OPEN)){
-                        userName = userMapper.selectByPrimaryKey(order.getUserId()).getUsername() ;
+                        User user = userMapper.selectByPrimaryKey(order.getUserId());
+                        if (user!=null) {
+                            userName = user.getUsername() ;
+                        }
                     }else {
-                        userName = adminMapper.selectByPrimaryKey(order.getUserId()).getUsername() ;
+                        Admin admin = adminMapper.selectByPrimaryKey(order.getUserId());
+                        if (admin!=null) {
+                            userName =admin.getUsername() ;
+                        }
+                    }
+                    try {
+                        PublishInfoWithBLOBs publishInfoWithBLOBs = publishInfoMapper.selectByPrimaryKey(publishSetting.getPublishInfoId());
+                        // 新增网关授权
+                        GateWayUtils.gatewayAuthAdd(publishInfoWithBLOBs.getOutId1(),DicNewGateway.APPLICATIONID,userName,userName+"添加授权") ;
+                        //新增网关计费
+                        GateWayUtils.gatewayChargeAdd(publishInfoWithBLOBs.getOutId1(),DicNewGateway.APPLICATIONID,userName,
+                                DicPublishSettingChargeMethod.FREE,publishSetting.getUseTimesLimit().toString(),userName+"添加计费") ;
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        log.error("同步网关失败!所在类是:AuthorizationServiceImpl,行数是:147");
                     }
-                    PublishInfoWithBLOBs publishInfoWithBLOBs = publishInfoMapper.selectByPrimaryKey(publishSetting.getPublishInfoId());
-                    // 新增网关授权
-                    GateWayUtils.gatewayAuthAdd(publishInfoWithBLOBs.getOutId1(),DicNewGateway.APPLICATIONID,userName,userName+"添加授权") ;
-                    //新增网关计费
-                    GateWayUtils.gatewayChargeAdd(publishInfoWithBLOBs.getOutId1(),DicNewGateway.APPLICATIONID,userName,
-                            DicPublishSettingChargeMethod.FREE,publishSetting.getUseTimesLimit().toString(),userName+"添加计费") ;
                 }
             }
         }