From b2d3abd9d6412097febfe2027300d84f3888d144 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 03 三月 2022 11:18:10 +0800
Subject: [PATCH] update 优化去除sql差异化 时间范围统一使用 between 处理

---
 ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml        |   12 ------
 ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml        |   14 ++-----
 ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml |   28 ++++----------
 ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml        |   14 ++-----
 4 files changed, 16 insertions(+), 52 deletions(-)

diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
index 8f0c269..a7f2ce8 100644
--- a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
+++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
@@ -66,11 +66,8 @@
             <if test="genTable.tableComment != null and genTable.tableComment != ''">
                 AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
             </if>
-            <if test="genTable.params.beginTime != null and genTable.params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
-                AND date_format(create_time,'%y%m%d') &gt;= date_format(#{genTable.params.beginTime},'%y%m%d')
-            </if>
-            <if test="genTable.params.endTime != null and genTable.params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
-                AND date_format(create_time,'%y%m%d') &lt;= date_format(#{genTable.params.endTime},'%y%m%d')
+            <if test="genTable.params.beginTime != null and genTable.params.endTime != null">
+                AND create_time between #{genTable.params.beginTime} and #{genTable.params.endTime}
             </if>
         </where>
     </select>
@@ -86,11 +83,8 @@
         <if test="genTable.tableComment != null and genTable.tableComment != ''">
             AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
         </if>
-        <if test="genTable.params.beginTime != null and genTable.params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
-            AND date_format(create_time,'%y%m%d') &gt;= date_format(#{genTable.params.beginTime},'%y%m%d')
-        </if>
-        <if test="genTable.params.endTime != null and genTable.params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
-            AND date_format(create_time,'%y%m%d') &lt;= date_format(#{genTable.params.endTime},'%y%m%d')
+        <if test="genTable.params.beginTime != null and genTable.params.endTime != null">
+            AND create_time between #{genTable.params.beginTime} and #{genTable.params.endTime}
         </if>
         order by create_time desc
     </select>
@@ -105,11 +99,8 @@
             <if test="tableComment != null and tableComment != ''">
                 AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
             </if>
-            <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
-                AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-            </if>
-            <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
-                AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+            <if test="params.beginTime != null and params.endTime != null">
+                AND create_time between #{params.beginTime} and #{params.endTime}
             </if>
         </where>
     </select>
@@ -125,11 +116,8 @@
         <if test="tableComment != null and tableComment != ''">
             AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
         </if>
-        <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
-            AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-        </if>
-        <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
-            AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+        <if test="params.beginTime != null and params.endTime != null">
+            AND create_time between #{params.beginTime} and #{params.endTime}
         </if>
         order by create_time desc
     </select>
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml
index eebc0a7..3863f66 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml
@@ -17,18 +17,6 @@
         <result property="remark" column="remark"/>
     </resultMap>
 
-    <sql id="selectPostVo">
-        select post_id,
-               post_code,
-               post_name,
-               post_sort,
-               status,
-               create_by,
-               create_time,
-               remark
-        from sys_post
-    </sql>
-
     <select id="selectPostListByUserId" parameterType="Long" resultType="Long">
         select p.post_id
         from sys_post p
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
index 15f94f3..718dc3d 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
@@ -54,11 +54,8 @@
         <if test="role.roleKey != null and role.roleKey != ''">
             AND r.role_key like concat('%', #{role.roleKey}, '%')
         </if>
-        <if test="role.params.beginTime != null and role.params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
-            and date_format(r.create_time,'%y%m%d') &gt;= date_format(#{role.params.beginTime},'%y%m%d')
-        </if>
-        <if test="role.params.endTime != null and role.params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
-            and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{role.params.endTime},'%y%m%d')
+        <if test="role.params.beginTime != null and role.params.endTime != null">
+            AND r.create_time between #{role.params.beginTime} and #{role.params.endTime}
         </if>
         order by r.role_sort
     </select>
@@ -78,11 +75,8 @@
         <if test="roleKey != null and roleKey != ''">
             AND r.role_key like concat('%', #{roleKey}, '%')
         </if>
-        <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
-            and date_format(r.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-        </if>
-        <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
-            and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+        <if test="params.beginTime != null and params.endTime != null">
+            AND r.create_time between #{params.beginTime} and #{params.endTime}
         </if>
         order by r.role_sort
     </select>
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index 7f12db7..ef968ad 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -100,11 +100,8 @@
         <if test="user.phonenumber != null and user.phonenumber != ''">
             AND u.phonenumber like concat('%', #{user.phonenumber}, '%')
         </if>
-        <if test="user.params.beginTime != null and user.params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
-            AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{user.params.beginTime},'%y%m%d')
-        </if>
-        <if test="user.params.endTime != null and user.params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
-            AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{user.params.endTime},'%y%m%d')
+        <if test="user.params.beginTime != null and user.params.endTime != null">
+            AND u.create_time between #{user.params.beginTime} and #{user.params.endTime}
         </if>
         <if test="user.deptId != null and user.deptId != 0">
             AND (u.dept_id = #{user.deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{user.deptId},
@@ -130,11 +127,8 @@
         <if test="phonenumber != null and phonenumber != ''">
             AND u.phonenumber like concat('%', #{phonenumber}, '%')
         </if>
-        <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
-            AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-        </if>
-        <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
-            AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+        <if test="params.beginTime != null and params.endTime != null">
+            AND u.create_time between #{params.beginTime} and #{params.endTime}
         </if>
         <if test="deptId != null and deptId != 0">
             AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},

--
Gitblit v1.9.3