作者 RuoYi

支持get请求映射params参数

@@ -5,7 +5,6 @@ import java.util.Date; @@ -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,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,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)
@@ -64,11 +64,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -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>
@@ -84,11 +84,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -84,11 +84,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
84 <if test="tableComment != null and tableComment != ''"> 84 <if test="tableComment != null and tableComment != ''">
85 AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) 85 AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
86 </if> 86 </if>
87 - <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->  
88 - AND date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') 87 + <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  88 + AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
89 </if> 89 </if>
90 - <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->  
91 - AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') 90 + <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  91 + AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
92 </if> 92 </if>
93 </select> 93 </select>
94 94
@@ -35,11 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -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>
@@ -50,11 +50,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -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>
@@ -32,11 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -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>
@@ -33,11 +33,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -33,11 +33,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
33 <if test="userName != null and userName != ''"> 33 <if test="userName != null and userName != ''">
34 AND user_name like concat('%', #{userName}, '%') 34 AND user_name like concat('%', #{userName}, '%')
35 </if> 35 </if>
36 - <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->  
37 - and date_format(login_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') 36 + <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  37 + and date_format(login_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
38 </if> 38 </if>
39 - <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->  
40 - and date_format(login_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') 39 + <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  40 + and date_format(login_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
41 </if> 41 </if>
42 </where> 42 </where>
43 order by info_id desc 43 order by info_id desc
@@ -54,11 +54,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -54,11 +54,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
54 <if test="operName != null and operName != ''"> 54 <if test="operName != null and operName != ''">
55 AND oper_name like concat('%', #{operName}, '%') 55 AND oper_name like concat('%', #{operName}, '%')
56 </if> 56 </if>
57 - <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->  
58 - and date_format(oper_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') 57 + <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  58 + and date_format(oper_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
59 </if> 59 </if>
60 - <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->  
61 - and date_format(oper_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') 60 + <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  61 + and date_format(oper_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
62 </if> 62 </if>
63 </where> 63 </where>
64 order by oper_id desc 64 order by oper_id desc
@@ -42,11 +42,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -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}
@@ -68,11 +68,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -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) ))
@@ -19,6 +19,28 @@ service.interceptors.request.use(config => { @@ -19,6 +19,28 @@ service.interceptors.request.use(config => {
19 if (getToken() && !isToken) { 19 if (getToken() && !isToken) {
20 config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 20 config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
21 } 21 }
  22 + // get请求映射params参数
  23 + if (config.method === 'get' && config.params) {
  24 + let url = config.url + '?';
  25 + for (const propName of Object.keys(config.params)) {
  26 + const value = config.params[propName];
  27 + var part = encodeURIComponent(propName) + "=";
  28 + if (typeof(value) !== "undefined") {
  29 + if (typeof value === 'object') {
  30 + for (const key of Object.keys(value)) {
  31 + let params = propName + '[' + key + ']';
  32 + var subPart = encodeURIComponent(params) + "=";
  33 + url += subPart + encodeURIComponent(value[key]) + "&";
  34 + }
  35 + } else {
  36 + url += part + encodeURIComponent(value) + "&";
  37 + }
  38 + }
  39 + }
  40 + url = url.slice(0, -1);
  41 + config.params = {};
  42 + config.url = url;
  43 + }
22 return config 44 return config
23 }, error => { 45 }, error => {
24 console.log(error) 46 console.log(error)
@@ -54,13 +54,17 @@ export function resetForm(refName) { @@ -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 }