ソースを参照

fix:优化下发

xuezizhuo 1 年間 前
コミット
4dd8931369

+ 34 - 75
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/Sending.java

@@ -97,6 +97,30 @@ public class Sending<T> {
         return response;
     }
 
+    /**
+     * 共通get请求,params传参形式
+     * @param url 地址
+     * @param param
+     * @return
+     */
+    public ResponseEntity<AjaxResult> sendCommonGetParams(String url,T param){
+
+        // 得到当前用户的token  下发流程请求需要携带
+        String token = SecurityUtils.getLoginUser().getToken();
+        // 设置请求头
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Authorization", "XIAFA" + token);
+        HttpEntity request = new HttpEntity(headers);
+        ResponseEntity<AjaxResult> response = restTemplate.exchange(
+                url,
+                HttpMethod.GET,
+                request,
+                AjaxResult.class,
+                param
+        );
+        return response;
+    }
+
     /**
      * 执行流程排产 -> 共通修改
      */
@@ -128,61 +152,22 @@ public class Sending<T> {
     /**
      * 根据scriptKey获取节点脚本详情接口
      */
-    public ResponseEntity sendGetNodeScript(String scriptKey) {
-        // 得到当前用户的token  下发流程请求需要携带
-        String token = SecurityUtils.getLoginUser().getToken();
-        // 设置请求头
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("Authorization", "XIAFA" + token);
-        HttpEntity request = new HttpEntity(headers);
-        ResponseEntity<AjaxResult> response = restTemplate.exchange(
-                bpmProperties.getNodeScriptIp,
-                HttpMethod.GET,
-                request,
-                AjaxResult.class,
-                scriptKey
-        );
-        return response;
+    public ResponseEntity sendGetNodeScript(T param) {
+        return this.sendCommonGetParams(bpmProperties.getNodeScriptIp,param);
     }
 
     /**
      * 查看角色下是否存在真实用户接口
      */
-    public ResponseEntity sendQueryUserExistsByRoleKey(String roleKeys) {
-        // 得到当前用户的token  下发流程请求需要携带
-        String token = SecurityUtils.getLoginUser().getToken();
-        // 设置请求头
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("Authorization", "XIAFA" + token);
-        HttpEntity request = new HttpEntity(headers);
-        ResponseEntity<AjaxResult> response = restTemplate.exchange(
-                bpmProperties.queryUserExistsByRoleKeyIp,
-                HttpMethod.GET,
-                request,
-                AjaxResult.class,
-                roleKeys
-        );
-        return response;
+    public ResponseEntity sendQueryUserExistsByRoleKey(T param) {
+        return this.sendCommonGetParams(bpmProperties.queryUserExistsByRoleKeyIp,param);
     }
 
     /**
      * 查看一组用户下是否存在真实用户接口
      */
-    public ResponseEntity sendQueryUserExistsByUserIds(String userIds) {
-        // 得到当前用户的token  下发流程请求需要携带
-        String token = SecurityUtils.getLoginUser().getToken();
-        // 设置请求头
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("Authorization", "XIAFA" + token);
-        HttpEntity request = new HttpEntity(headers);
-        ResponseEntity<AjaxResult> response = restTemplate.exchange(
-                bpmProperties.queryUserExistsByUserIdsIp,
-                HttpMethod.GET,
-                request,
-                AjaxResult.class,
-                userIds
-        );
-        return response;
+    public ResponseEntity sendQueryUserExistsByUserIds(T param) {
+        return this.sendCommonGetParams(bpmProperties.queryUserExistsByUserIdsIp,param);
     }
 
     /**
@@ -195,40 +180,14 @@ public class Sending<T> {
     /**
      * 根据fid获取表单详情接口
      */
-    public ResponseEntity sendGetFormInfo(Long fId) {
-        // 得到当前用户的token  下发流程请求需要携带
-        String token = SecurityUtils.getLoginUser().getToken();
-        // 设置请求头
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("Authorization", "XIAFA" + token);
-        HttpEntity request = new HttpEntity(headers);
-        ResponseEntity<AjaxResult> response = restTemplate.exchange(
-                bpmProperties.formGetFormInfoIp,
-                HttpMethod.GET,
-                request,
-                AjaxResult.class,
-                fId
-        );
-        return response;
+    public ResponseEntity sendGetFormInfo(T param) {
+        return this.sendCommonGetParams(bpmProperties.formGetFormInfoIp,param);
     }
 
     /**
      * 根据fid获取表格组详情接口
      */
-    public ResponseEntity sendGetGroupInfo(String groupKey) {
-        // 得到当前用户的token  下发流程请求需要携带
-        String token = SecurityUtils.getLoginUser().getToken();
-        // 设置请求头
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("Authorization", "XIAFA" + token);
-        HttpEntity request = new HttpEntity(headers);
-        ResponseEntity<AjaxResult> response = restTemplate.exchange(
-                bpmProperties.getFormGetGroupInfoIp(),
-                HttpMethod.GET,
-                request,
-                AjaxResult.class,
-                groupKey
-        );
-        return response;
+    public ResponseEntity sendGetGroupInfo(T param) {
+        return this.sendCommonGetParams(bpmProperties.getFormGetGroupInfoIp(),param);
     }
 }