Commit ef92ad4d8c0b500526471d7d4b8126b7fd05e466

Authored by RuoYi
1 parent d8b006c1

支持get请求映射params参数

ruoyi-common/src/main/java/com/ruoyi/common/core/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)
... ...
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
... ... @@ -64,11 +64,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
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>
... ... @@ -84,11 +84,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
84 84 <if test="tableComment != null and tableComment != ''">
85 85 AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
86 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 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 92 </if>
93 93 </select>
94 94  
... ...
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
... ... @@ -35,11 +35,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
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>
... ...
ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml
... ... @@ -50,11 +50,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
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>
... ...
ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml
... ... @@ -32,11 +32,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
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>
... ...
ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml
... ... @@ -33,11 +33,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
33 33 <if test="userName != null and userName != ''">
34 34 AND user_name like concat('%', #{userName}, '%')
35 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 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 41 </if>
42 42 </where>
43 43 order by info_id desc
... ...
ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml
... ... @@ -54,11 +54,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
54 54 <if test="operName != null and operName != ''">
55 55 AND oper_name like concat('%', #{operName}, '%')
56 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 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 62 </if>
63 63 </where>
64 64 order by oper_id desc
... ...
ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
... ... @@ -42,11 +42,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
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}
... ...
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
... ... @@ -68,11 +68,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
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) ))
... ...
ruoyi-ui/src/utils/request.js
... ... @@ -19,6 +19,28 @@ service.interceptors.request.use(config =&gt; {
19 19 if (getToken() && !isToken) {
20 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 44 return config
23 45 }, error => {
24 46 console.log(error)
... ...
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 }
... ...