Selaa lähdekoodia

支持get请求映射params参数

RuoYi 5 vuotta sitten
vanhempi
commit
6beb5cadb2

+ 0 - 29
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java

@@ -5,7 +5,6 @@ import java.util.Date;
5
 import java.util.HashMap;
5
 import java.util.HashMap;
6
 import java.util.Map;
6
 import java.util.Map;
7
 import com.fasterxml.jackson.annotation.JsonFormat;
7
 import com.fasterxml.jackson.annotation.JsonFormat;
8
-import com.fasterxml.jackson.annotation.JsonIgnore;
9
 
8
 
10
 /**
9
 /**
11
  * Entity基类
10
  * Entity基类
@@ -36,14 +35,6 @@ public class BaseEntity implements Serializable
36
     /** 备注 */
35
     /** 备注 */
37
     private String remark;
36
     private String remark;
38
 
37
 
39
-    /** 开始时间 */
40
-    @JsonIgnore
41
-    private String beginTime;
42
-
43
-    /** 结束时间 */
44
-    @JsonIgnore
45
-    private String endTime;
46
-
47
     /** 请求参数 */
38
     /** 请求参数 */
48
     private Map<String, Object> params;
39
     private Map<String, Object> params;
49
 
40
 
@@ -107,26 +98,6 @@ public class BaseEntity implements Serializable
107
         this.remark = remark;
98
         this.remark = remark;
108
     }
99
     }
109
 
100
 
110
-    public String getBeginTime()
111
-    {
112
-        return beginTime;
113
-    }
114
-
115
-    public void setBeginTime(String beginTime)
116
-    {
117
-        this.beginTime = beginTime;
118
-    }
119
-
120
-    public String getEndTime()
121
-    {
122
-        return endTime;
123
-    }
124
-
125
-    public void setEndTime(String endTime)
126
-    {
127
-        this.endTime = endTime;
128
-    }
129
-
130
     public Map<String, Object> getParams()
101
     public Map<String, Object> getParams()
131
     {
102
     {
132
         if (params == null)
103
         if (params == null)

+ 4 - 4
ruoyi-modules/ruoyi-gen/src/main/resources/mapper/generator/GenTableMapper.xml

@@ -64,11 +64,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
64
 			<if test="tableComment != null and tableComment != ''">
64
 			<if test="tableComment != null and tableComment != ''">
65
 				AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
65
 				AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
66
 			</if>
66
 			</if>
67
-			<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
68
-				AND date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
67
+			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
68
+				AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
69
 			</if>
69
 			</if>
70
-			<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
71
-				AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
70
+			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
71
+				AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
72
 			</if>
72
 			</if>
73
 		</where>
73
 		</where>
74
 	</select>
74
 	</select>

+ 4 - 4
ruoyi-modules/ruoyi-job/src/main/resources/mapper/job/SysJobLogMapper.xml

@@ -35,11 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
35
 			<if test="invokeTarget != null and invokeTarget != ''">
35
 			<if test="invokeTarget != null and invokeTarget != ''">
36
 				AND invoke_target like concat('%', #{invokeTarget}, '%')
36
 				AND invoke_target like concat('%', #{invokeTarget}, '%')
37
 			</if>
37
 			</if>
38
-			<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
39
-				and date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
38
+			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
39
+				and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
40
 			</if>
40
 			</if>
41
-			<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
42
-				and date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
41
+			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
42
+				and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
43
 			</if>
43
 			</if>
44
 		</where>
44
 		</where>
45
 	</select>
45
 	</select>

+ 4 - 4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml

@@ -50,11 +50,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
50
 			<if test="configKey != null and configKey != ''">
50
 			<if test="configKey != null and configKey != ''">
51
 				AND config_key like concat('%', #{configKey}, '%')
51
 				AND config_key like concat('%', #{configKey}, '%')
52
 			</if>
52
 			</if>
53
-			<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
54
-				and date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
53
+			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
54
+				and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
55
 			</if>
55
 			</if>
56
-			<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
57
-				and date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
56
+			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
57
+				and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
58
 			</if>
58
 			</if>
59
 		</where>
59
 		</where>
60
     </select>
60
     </select>

+ 4 - 4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml

@@ -32,11 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
32
 			<if test="dictType != null and dictType != ''">
32
 			<if test="dictType != null and dictType != ''">
33
 				AND dict_type like concat('%', #{dictType}, '%')
33
 				AND dict_type like concat('%', #{dictType}, '%')
34
 			</if>
34
 			</if>
35
-			<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
36
-				and date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
35
+			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
36
+				and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
37
 			</if>
37
 			</if>
38
-			<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
39
-				and date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
38
+			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
39
+				and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
40
 			</if>
40
 			</if>
41
 	    </where>
41
 	    </where>
42
 	</select>
42
 	</select>

+ 4 - 4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml

@@ -30,11 +30,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
30
 			<if test="userName != null and userName != ''">
30
 			<if test="userName != null and userName != ''">
31
 				AND user_name like concat('%', #{userName}, '%')
31
 				AND user_name like concat('%', #{userName}, '%')
32
 			</if>
32
 			</if>
33
-			<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
34
-				and date_format(access_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
33
+			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
34
+				and date_format(access_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
35
 			</if>
35
 			</if>
36
-			<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
37
-				and date_format(access_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
36
+			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
37
+				and date_format(access_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
38
 			</if>
38
 			</if>
39
 		</where>
39
 		</where>
40
 		order by info_id desc
40
 		order by info_id desc

+ 4 - 4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml

@@ -53,11 +53,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
53
 			<if test="operName != null and operName != ''">
53
 			<if test="operName != null and operName != ''">
54
 				AND oper_name like concat('%', #{operName}, '%')
54
 				AND oper_name like concat('%', #{operName}, '%')
55
 			</if>
55
 			</if>
56
-			<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
57
-				and date_format(oper_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
56
+			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
57
+				and date_format(oper_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
58
 			</if>
58
 			</if>
59
-			<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
60
-				and date_format(oper_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
59
+			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
60
+				and date_format(oper_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
61
 			</if>
61
 			</if>
62
 		</where>
62
 		</where>
63
 		order by oper_id desc
63
 		order by oper_id desc

+ 4 - 4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -42,11 +42,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
42
 		<if test="roleKey != null and roleKey != ''">
42
 		<if test="roleKey != null and roleKey != ''">
43
 			AND r.role_key like concat('%', #{roleKey}, '%')
43
 			AND r.role_key like concat('%', #{roleKey}, '%')
44
 		</if>
44
 		</if>
45
-		<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
46
-			and date_format(r.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
45
+		<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
46
+			and date_format(r.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
47
 		</if>
47
 		</if>
48
-		<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
49
-			and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
48
+		<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
49
+			and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
50
 		</if>
50
 		</if>
51
 		<!-- 数据范围过滤 -->
51
 		<!-- 数据范围过滤 -->
52
 		${params.dataScope}
52
 		${params.dataScope}

+ 4 - 4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -68,11 +68,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
68
 		<if test="phonenumber != null and phonenumber != ''">
68
 		<if test="phonenumber != null and phonenumber != ''">
69
 			AND u.phonenumber like concat('%', #{phonenumber}, '%')
69
 			AND u.phonenumber like concat('%', #{phonenumber}, '%')
70
 		</if>
70
 		</if>
71
-		<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
72
-			AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
71
+		<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
72
+			AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
73
 		</if>
73
 		</if>
74
-		<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
75
-			AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
74
+		<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
75
+			AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
76
 		</if>
76
 		</if>
77
 		<if test="deptId != null and deptId != 0">
77
 		<if test="deptId != null and deptId != 0">
78
 			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
78
 			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))

+ 25 - 6
ruoyi-ui/src/utils/request.js

@@ -19,7 +19,29 @@ service.interceptors.request.use(config => {
19
   // 是否需要设置 token
19
   // 是否需要设置 token
20
   const isToken = (config.headers || {}).isToken === false
20
   const isToken = (config.headers || {}).isToken === false
21
   if (getToken() && !isToken) {
21
   if (getToken() && !isToken) {
22
-    config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际
22
+    config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
23
+  }
24
+  // get请求映射params参数
25
+  if (config.method === 'get' && config.params) {
26
+    let url = config.url + '?';
27
+    for (const propName of Object.keys(config.params)) {
28
+      const value = config.params[propName];
29
+      var part = encodeURIComponent(propName) + "=";
30
+      if (typeof(value) !== "undefined") {
31
+        if (typeof value === 'object') {
32
+          for (const key of Object.keys(value)) {
33
+            let params = propName + '[' + key + ']';
34
+            var subPart = encodeURIComponent(params) + "=";
35
+            url += subPart + encodeURIComponent(value[key]) + "&";
36
+          }
37
+        } else {
38
+          url += part + encodeURIComponent(value) + "&";
39
+        }
40
+      }
41
+    }
42
+    url = url.slice(0, -1);
43
+    config.params = {};
44
+    config.url = url;
23
   }
45
   }
24
   return config
46
   return config
25
 }, error => {
47
 }, error => {
@@ -34,17 +56,14 @@ service.interceptors.response.use(res => {
34
     // 获取错误信息
56
     // 获取错误信息
35
     const msg = errorCode[code] || res.data.msg || errorCode['default']
57
     const msg = errorCode[code] || res.data.msg || errorCode['default']
36
     if (code === 401) {
58
     if (code === 401) {
37
-      MessageBox.confirm(
38
-        '登录状态已过期,您可以继续留在该页面,或者重新登录',
39
-        '系统提示',
40
-        {
59
+      MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
41
           confirmButtonText: '重新登录',
60
           confirmButtonText: '重新登录',
42
           cancelButtonText: '取消',
61
           cancelButtonText: '取消',
43
           type: 'warning'
62
           type: 'warning'
44
         }
63
         }
45
       ).then(() => {
64
       ).then(() => {
46
         store.dispatch('LogOut').then(() => {
65
         store.dispatch('LogOut').then(() => {
47
-          location.reload() // 为了重新实例化vue-router对象 避免bug
66
+          location.href = '/index';
48
         })
67
         })
49
       })
68
       })
50
     } else if (code === 500) {
69
     } else if (code === 500) {

+ 9 - 5
ruoyi-ui/src/utils/ruoyi.js

@@ -54,13 +54,17 @@ export function resetForm(refName) {
54
 }
54
 }
55
 
55
 
56
 // 添加日期范围
56
 // 添加日期范围
57
-export function addDateRange(params, dateRange) {
57
+export function addDateRange(params, dateRange, propName) {
58
 	var search = params;
58
 	var search = params;
59
-	search.beginTime = "";
60
-	search.endTime = "";
59
+	search.params = {};
61
 	if (null != dateRange && '' != dateRange) {
60
 	if (null != dateRange && '' != dateRange) {
62
-		search.beginTime = dateRange[0];
63
-		search.endTime = dateRange[1];
61
+		if (typeof(propName) === "undefined") {
62
+			search.params["beginTime"] = dateRange[0];
63
+			search.params["endTime"] = dateRange[1];
64
+		} else {
65
+			search.params[propName + "BeginTime"] = dateRange[0];
66
+			search.params[propName + "EndTime"] = dateRange[1];
67
+		}
64
 	}
68
 	}
65
 	return search;
69
 	return search;
66
 }
70
 }