Bladeren bron

feat: 完善下发工具类

韩帛霖 1 jaar geleden
bovenliggende
commit
8139d68d8b

+ 12 - 10
ruoyi-admin/src/main/resources/application.yml

@@ -87,13 +87,13 @@ spring:
   # redis 配置
   redis:
     # 地址
-    host: localhost
+    host: 192.168.110.15
     # 端口,默认为6379
     port: 6379
     # 数据库索引
     database: 0
     # 密码
-    password: 123456
+    password:
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -153,18 +153,20 @@ xss:
 parameter:
   ip:
     # 用户下对应的所有角色key
-    MAIN_ROLESKEY_IP: http://127.0.0.1:8080/system/user/roleKeyByUserId/
+    MAIN_ROLESKEY_IP: http://192.168.110.59:8080/system/user/roleKeyByUserId/
     # CRM项目根据scriptKey获取节点脚本详情地址
-    GET_NODESCRIPT_IP: http://localhost:8080/system/script/selectSysBpmNodeScriptByScriptKey/
+    GET_NODESCRIPT_IP: http://192.168.110.59:8080/system/script/selectSysBpmNodeScriptByScriptKey/
     # crm项目查看角色下是否存在真实用户
-    QUERY_USER_EXISTS_BY_ROLEKEY_IP: http://localhost:8080/system/role/selectUserByRoleKey/
+    QUERY_USER_EXISTS_BY_ROLEKEY_IP: http://192.168.110.59:8080/system/role/selectUserByRoleKey/
     # crm项目查看一组用户是否存在真实用户
-    QUERY_USER_EXISTS_BY_USERIDS_IP: http://localhost:8080/system/user/selectUserByUserIds/
+    QUERY_USER_EXISTS_BY_USERIDS_IP: http://192.168.110.59:8080/system/user/selectUserByUserIds/
     # form项目共通修改接口
-    FORM_COMMON_UPDATE_IP: http://localhost:8088/dragform/common/batchEdit
+    FORM_COMMON_UPDATE_IP: http://192.168.110.59:8088/dragform/common/batchEdit
     #from项目共通获取详情接口
-    FORM_COMMON_GETINFO_IP: http://localhost:8088/dragform/common/getInfo/
+    FORM_COMMON_GETINFO_IP: http://192.168.110.59:8088/dragform/common/getInfo/
     # form项目共通新增接口
-    FORM_COMMON_BATCHINSERT_IP: http://localhost:8088/dragform/common/batchInsert
+    FORM_COMMON_BATCHINSERT_IP: http://192.168.110.59:8088/dragform/common/batchInsert
     # CRM项目根据scriptKeys获取节点脚本详情地址
-    GET_NODESCRIPTS_IP: http://localhost:8080/system/script/selectSysBpmNodeScriptByScriptKeys
+    GET_NODESCRIPTS_IP: http://192.168.110.59:8080/system/script/selectSysBpmNodeScriptByScriptKeys
+    # 租户字典:根据字典类型得到当前字典下的所有的数据
+    GET_TENANT_DICT_IP: http://192.168.110.59:8088/system/dict/data/list

+ 16 - 6
ruoyi-common/src/main/java/com/ruoyi/common/config/bpm/BpmProperties.java

@@ -19,25 +19,35 @@ public class BpmProperties {
     // 根据scriptKey获取节点脚本详情地址
     @Value("${parameter.ip.GET_NODESCRIPT_IP}")
     public String getNodeScriptIp;
-
+    // crm项目查看角色下是否存在真实用户
     @Value("${parameter.ip.QUERY_USER_EXISTS_BY_ROLEKEY_IP}")
     public String queryUserExistsByRoleKeyIp;
-
+    // crm项目查看一组用户是否存在真实用户
     @Value("${parameter.ip.QUERY_USER_EXISTS_BY_USERIDS_IP}")
     public String queryUserExistsByUserIdsIp;
-
+    // form项目共通修改接口
     @Value("${parameter.ip.FORM_COMMON_UPDATE_IP}")
     public String formCommonUpdateIp;
-
+    // FORM_COMMON_GETINFO_IP
     @Value("${parameter.ip.FORM_COMMON_GETINFO_IP}")
     public String formCommonGetInfoIp;
-
+    // form项目共通新增接口
     @Value("${parameter.ip.FORM_COMMON_BATCHINSERT_IP}")
     public String formCommonBatchInsertIp;
-
+    // CRM项目根据scriptKeys获取节点脚本详情地址
     @Value("${parameter.ip.GET_NODESCRIPTS_IP}")
     public String getNodeScriptsIp;
+    // 租户字典:根据字典类型得到当前字典下的所有的数据
+    @Value("${parameter.ip.GET_TENANT_DICT_IP}")
+    public String getTenantDictValIp;
+
+    public String getGetTenantDictValIp() {
+        return getTenantDictValIp;
+    }
 
+    public void setGetTenantDictValIp(String getTenantDictValIp) {
+        this.getTenantDictValIp = getTenantDictValIp;
+    }
 
     public String getMainRolesKeyIp() {
         return mainRolesKeyIp;

+ 89 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/Sending.java

@@ -0,0 +1,89 @@
+package com.ruoyi.common.utils.http;
+
+import com.ruoyi.common.config.bpm.BpmProperties;
+import com.ruoyi.common.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.*;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Map;
+
+
+@Component
+public class Sending<T> {
+
+    @Autowired
+    private BpmProperties bpmProperties;
+
+    // 创建RestTemplate实例
+    RestTemplate restTemplate = new RestTemplate();
+
+    /**
+     * get请求拼接参数使用
+     *
+     * @param url
+     * @param params
+     * @return
+     */
+    private String appendParamsToUrl(String url, Map<String, Object> params) {
+        if (params != null && !params.isEmpty()) {
+            StringBuilder urlBuilder = new StringBuilder(url);
+            urlBuilder.append("?");
+            for (Map.Entry<String, Object> entry : params.entrySet()) {
+                urlBuilder.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
+            }
+            url = urlBuilder.toString();
+        }
+        return url;
+    }
+
+
+    public ResponseEntity<String> sendCommon(String url, String httpMethod, T param) {
+        // 得到当前用户的token  下发流程请求需要携带
+        String token = SecurityUtils.getLoginUser().getToken();
+        // 设置请求头
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Authorization", "XIAFA" + token);
+        // 判断请求类型
+        if (HttpMethod.GET.name().equalsIgnoreCase(httpMethod)) {
+            // 如果是 GET 请求,将参数拼接到 URL 上
+            url = appendParamsToUrl(url, (Map<String, Object>) param);
+        }
+        // 将请求体和请求头添加到 HttpEntity
+        HttpEntity<Object> requestEntity = new HttpEntity<>(param, headers);
+        // 发送请求
+        ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.resolve(httpMethod), requestEntity, String.class);
+        // 返回响应
+        return response;
+    }
+
+    /**
+     * 执行流程排产
+     */
+    public ResponseEntity sendCommonUpdate(T param) {
+        return this.sendCommon(bpmProperties.formCommonUpdateIp, "PUT", param);
+    }
+
+    /**
+     * 根据脚本key得到所有异常脚本信息
+     */
+    public ResponseEntity sendGetScriptInfo(T param) {
+        return this.sendCommon(bpmProperties.getNodeScriptsIp, "POST", param);
+    }
+
+    /**
+     * 共通获取详情接口
+     */
+    public ResponseEntity sendCommonGetInfo(T param) {
+        return this.sendCommon(bpmProperties.formCommonGetInfoIp, "GET", param);
+    }
+
+    /**
+     * 通过字段类型得到当前租户字典的所有值
+     */
+    public ResponseEntity sendGetTenantDict(T param) {
+        return this.sendCommon(bpmProperties.getTenantDictValIp, "GET", param);
+    }
+
+}

+ 0 - 58
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/sending.java

@@ -1,58 +0,0 @@
-package com.ruoyi.common.utils.http;
-
-import com.ruoyi.common.config.bpm.BpmProperties;
-import com.ruoyi.common.utils.SecurityUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.*;
-import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.Map;
-
-
-@Component
-public class sending<T> {
-
-    @Autowired
-    private BpmProperties bpmProperties;
-
-    // 创建RestTemplate实例
-    RestTemplate restTemplate = new RestTemplate();
-
-    public ResponseEntity sendCommonPOST(String url, String httpMethod, T param) {
-        // 得到当前用户的token  下发流程请求需要携带
-        String token = SecurityUtils.getLoginUser().getToken();
-        // 设置请求头
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("Authorization", "XIAFA" + token);
-        // 将请求体和请求头添加到HttpEntity
-        HttpEntity<Map<String, Object>> requestEntity = (HttpEntity<Map<String, Object>>) new HttpEntity<>(param, headers);
-        // 发送请求
-        ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.resolve(httpMethod), requestEntity, String.class);
-        // 返回响应
-        return response;
-    }
-
-    /**
-     * 执行流程排产
-     */
-    public ResponseEntity sendCommonUpdate(T param) {
-        return this.sendCommonPOST(bpmProperties.formCommonUpdateIp, "PUT", param);
-    }
-
-    /**
-     * 根据脚本key得到所有异常脚本信息
-     */
-    public ResponseEntity sendGetScriptInfo(T param) {
-        return this.sendCommonPOST(bpmProperties.getNodeScriptsIp, "POST", param);
-    }
-
-    /**
-     * 共通获取详情接口
-     */
-    public ResponseEntity sendCommonGetInfo(T param) {
-        return this.sendCommonPOST(bpmProperties.formCommonGetInfoIp, "GET", param);
-    }
-
-
-}