update 优化去除sql差异化 时间范围统一使用 between 处理

2.X
疯狂的狮子li 3 years ago
parent 58981b5b3d
commit a941caf3bd

@ -66,11 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
@ -104,11 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
@ -124,11 +115,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>

@ -54,11 +54,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>

@ -100,11 +100,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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},
@ -128,11 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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}, ancestors) ))

Loading…
Cancel
Save