Просмотр исходного кода

支持get请求映射params参数

RuoYi лет назад: 5
Родитель
Сommit
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 5
 import java.util.HashMap;
6 6
 import java.util.Map;
7 7
 import com.fasterxml.jackson.annotation.JsonFormat;
8
-import com.fasterxml.jackson.annotation.JsonIgnore;
9 8
 
10 9
 /**
11 10
  * Entity基类
@@ -36,14 +35,6 @@ public class BaseEntity implements Serializable
36 35
     /** 备注 */
37 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 39
     private Map<String, Object> params;
49 40
 
@@ -107,26 +98,6 @@ public class BaseEntity implements Serializable
107 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 101
     public Map<String, Object> getParams()
131 102
     {
132 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 64
 			<if test="tableComment != null and tableComment != ''">
65 65
 				AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
66 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 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 72
 			</if>
73 73
 		</where>
74 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 35
 			<if test="invokeTarget != null and invokeTarget != ''">
36 36
 				AND invoke_target like concat('%', #{invokeTarget}, '%')
37 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 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 43
 			</if>
44 44
 		</where>
45 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 50
 			<if test="configKey != null and configKey != ''">
51 51
 				AND config_key like concat('%', #{configKey}, '%')
52 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 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 58
 			</if>
59 59
 		</where>
60 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 32
 			<if test="dictType != null and dictType != ''">
33 33
 				AND dict_type like concat('%', #{dictType}, '%')
34 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 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 40
 			</if>
41 41
 	    </where>
42 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 30
 			<if test="userName != null and userName != ''">
31 31
 				AND user_name like concat('%', #{userName}, '%')
32 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 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 38
 			</if>
39 39
 		</where>
40 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 53
 			<if test="operName != null and operName != ''">
54 54
 				AND oper_name like concat('%', #{operName}, '%')
55 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 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 61
 			</if>
62 62
 		</where>
63 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 42
 		<if test="roleKey != null and roleKey != ''">
43 43
 			AND r.role_key like concat('%', #{roleKey}, '%')
44 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 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 50
 		</if>
51 51
 		<!-- 数据范围过滤 -->
52 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 68
 		<if test="phonenumber != null and phonenumber != ''">
69 69
 			AND u.phonenumber like concat('%', #{phonenumber}, '%')
70 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 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 76
 		</if>
77 77
 		<if test="deptId != null and deptId != 0">
78 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 19
   // 是否需要设置 token
20 20
   const isToken = (config.headers || {}).isToken === false
21 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 46
   return config
25 47
 }, error => {
@@ -34,17 +56,14 @@ service.interceptors.response.use(res => {
34 56
     // 获取错误信息
35 57
     const msg = errorCode[code] || res.data.msg || errorCode['default']
36 58
     if (code === 401) {
37
-      MessageBox.confirm(
38
-        '登录状态已过期,您可以继续留在该页面,或者重新登录',
39
-        '系统提示',
40
-        {
59
+      MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
41 60
           confirmButtonText: '重新登录',
42 61
           cancelButtonText: '取消',
43 62
           type: 'warning'
44 63
         }
45 64
       ).then(() => {
46 65
         store.dispatch('LogOut').then(() => {
47
-          location.reload() // 为了重新实例化vue-router对象 避免bug
66
+          location.href = '/index';
48 67
         })
49 68
       })
50 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 58
 	var search = params;
59
-	search.beginTime = "";
60
-	search.endTime = "";
59
+	search.params = {};
61 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 69
 	return search;
66 70
 }