Sfoglia il codice sorgente

微应用添加签名

lidongyang 5 anni fa
parent
commit
9865e6382d

+ 9 - 0
src/main/java/com/lightinit/hsdataportal/common/GateWayUtils.java

@@ -1,5 +1,6 @@
 package com.lightinit.hsdataportal.common;
 
+import com.lightinit.hsdataportal.entity.PublishInfoWithBLOBs;
 import com.lightinit.hsdataportal.entity.ResourceApiInterfaceWithBLOBs;
 
 import java.util.HashMap;
@@ -33,4 +34,12 @@ public class GateWayUtils {
             }
         }
     }
+
+    public static void gatewayAuthAddMic(String appId, String username, String remark) throws Exception {
+        Map<String, String> params = new HashMap<>();
+        params.put("appId", appId);
+        params.put("userId", username);
+        params.put("remark", remark);
+        HttpUtil.httpPost(SysContants.GatewayPath.GATEWAYURL_SIGINSAVE, null, params);
+    }
 }

+ 7 - 7
src/main/java/com/lightinit/hsdataportal/controller/open/MicroappOpenController.java

@@ -94,17 +94,17 @@ public class MicroappOpenController extends BaseController {
     @RequestMapping(value = "apply.action")
     @ResponseBody
     @RequiresAuthentication
-    public ResultState doApply(HttpSession session,MicroappApplyModel inputModel) {
+    public ResultState doApply(HttpSession session,MicroappApplyModel inputModel) throws Exception {
         LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
         inputModel.setApplier(loginUser.getId());//在申请人
         inputModel.setPlatformType(DicPlatformType.OPEN);
         //判断是否已经申请过
-        Long resourceAuthId= myDataService.getResourceAuthId(inputModel.getPublishSettingId(),loginUser.getId(), DicPlatformType.OPEN);
-        if(resourceAuthId !=null){
-            ResultState resultState = new ResultState();
-            resultState.setMsg("已经申请过了,请前往用户中心下载");
-            return resultState;
-        }
+//        Long resourceAuthId= myDataService.getResourceAuthId(inputModel.getPublishSettingId(),loginUser.getId(), DicPlatformType.OPEN);
+//        if(resourceAuthId !=null){
+//            ResultState resultState = new ResultState();
+//            resultState.setMsg("已经申请过了,请前往用户中心下载");
+//            return resultState;
+//        }
         return microappService.doApply(inputModel);
     }
 

+ 1 - 1
src/main/java/com/lightinit/hsdataportal/controller/share/MicroappShareController.java

@@ -73,7 +73,7 @@ public class MicroappShareController {
     @RequestMapping(value = "apply.action")
     @ResponseBody
     @RequiresAuthentication
-    public ResultState doApply(HttpSession session,MicroappApplyModel inputModel,String chargeMethod,String openCondition ) {
+    public ResultState doApply(HttpSession session,MicroappApplyModel inputModel,String chargeMethod,String openCondition ) throws Exception {
         LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
         inputModel.setApplier(loginUser.getId());//在申请人
         inputModel.setPlatformType(DicPlatformType.SHARE);

+ 43 - 0
src/main/java/com/lightinit/hsdataportal/entity/ResourceApiInterfaceWithBLOBs.java

@@ -0,0 +1,43 @@
+package com.lightinit.hsdataportal.entity;
+
+public class ResourceApiInterfaceWithBLOBs extends ResourceApiInterface {
+    private String url;
+
+    private String requestDemo;
+
+    private String responseDemo;
+
+    private String remark;
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url == null ? null : url.trim();
+    }
+
+    public String getRequestDemo() {
+        return requestDemo;
+    }
+
+    public void setRequestDemo(String requestDemo) {
+        this.requestDemo = requestDemo == null ? null : requestDemo.trim();
+    }
+
+    public String getResponseDemo() {
+        return responseDemo;
+    }
+
+    public void setResponseDemo(String responseDemo) {
+        this.responseDemo = responseDemo == null ? null : responseDemo.trim();
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark == null ? null : remark.trim();
+    }
+}

+ 12 - 1
src/main/java/com/lightinit/hsdataportal/impl/MicroappServiceImpl.java

@@ -1,5 +1,6 @@
 package com.lightinit.hsdataportal.impl;
 
+import com.lightinit.hsdataportal.common.GateWayUtils;
 import com.lightinit.hsdataportal.common.OrderNumberUtils;
 import com.lightinit.hsdataportal.dictionary.*;
 import com.lightinit.hsdataportal.entity.*;
@@ -33,6 +34,12 @@ public class MicroappServiceImpl implements IMicroappService {
     private OrderGoodsMapper orderGoodsMapper;
     @Autowired
     private ResourceViewTimesMapper resourceViewTimesMapper;
+    @Autowired
+    private UserMapper userMapper ;
+    @Autowired
+    private PublishInfoMapper publishInfoMapper ;
+    @Autowired
+    private ResourceMapper resourceMapper ;
     /**
      * 开放列表
      * @param inputModel
@@ -94,7 +101,7 @@ public class MicroappServiceImpl implements IMicroappService {
 
     @Override
     @Transactional
-    public ResultState doApply(MicroappApplyModel inputModel) {
+    public ResultState doApply(MicroappApplyModel inputModel) throws Exception {
         DynamicDataContextHolder.setCustomerType(DynamicDataContextHolder.DEFAULT);
         ResultState<Long> resultState = new ResultState<Long>();
         ResourceAuth resourceAuth = new ResourceAuth();
@@ -103,6 +110,8 @@ public class MicroappServiceImpl implements IMicroappService {
         inputModel.setCreatedAt(date);
         inputModel.setApplyTime(date);
         PublishSetting publishSetting = publishSettingMapper.selectByPrimaryKey(inputModel.getPublishSettingId());
+        PublishInfoWithBLOBs publishInfoWithBLOBs = publishInfoMapper.selectByPrimaryKey(publishSetting.getPublishInfoId());
+        Resource resource = resourceMapper.selectByPrimaryKey(publishInfoWithBLOBs.getResourceId());
         if(inputModel.getPlatformType().equals(DicPlatformType.OPEN)){//开放平台
             if(inputModel.getOpenType().equals(DicResourceOpenType.UNCONDITIONAL)) {//无条件开放
                 inputModel.setAuditResult(DicResourceAuthAuditResult.AUTHORIZATION_SUCCESS);//授权成功
@@ -229,6 +238,8 @@ public class MicroappServiceImpl implements IMicroappService {
             resultState.setStateCode(ResultStateCode.INVALID_DATA);
             resultState.setMsg("数据插入失败");
         }
+        User user = userMapper.selectByPrimaryKey(inputModel.getApplier());
+        GateWayUtils.gatewayAuthAddMic(resource.getOutId2(),user.getUsername(),user.getUsername()+"添加授权") ;
 //        resultState.setData(inputModel.getId());
         return resultState;
     }

+ 1 - 1
src/main/java/com/lightinit/hsdataportal/service/IMicroappService.java

@@ -18,7 +18,7 @@ public interface IMicroappService {
 
     MicroappViewModel queryMicroapp(long id);
 
-    ResultState doApply(MicroappApplyModel inputModel);
+    ResultState doApply(MicroappApplyModel inputModel) throws Exception;
 
     ResourceMicroappWithBLOBs demo(long id);