优化部分查询SQL

dep_wangsr
wangchl 6 years ago committed by Limy
parent bac548db08
commit 9b0727b27f

@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="selectLogininforList" parameterType="Logininfor" resultMap="LogininforResult">
select * from sys_logininfor
select info_id,login_name,ipaddr,login_location,browser,os,status,msg,login_time from sys_logininfor
<where>
<if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%')

@ -26,9 +26,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" />
</resultMap>
<select id="selectOnlineById" parameterType="String" resultMap="UserOnlineResult">
select *
<sql id="selectOnlineVo">
select sessionId,login_name,dept_name,ipaddr,login_location,browser,os,status,status,start_timestsamp,last_access_time,expire_time
from sys_user_online
</sql>
<select id="selectOnlineById" parameterType="String" resultMap="UserOnlineResult">
<include refid="selectOnlineVo"/>
where sessionid = #{sessionid}
</select>
@ -42,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectUserOnlineList" parameterType="UserOnline" resultMap="UserOnlineResult">
select * from sys_user_online
<include refid="selectOnlineVo"/>
<where>
<if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%')
@ -54,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectOnlineByExpired" parameterType="String" resultMap="UserOnlineResult">
SELECT * FROM sys_user_online o
<include refid="selectOnlineVo"/> o
WHERE o.last_access_time <![CDATA[ <= ]]> #{lastAccessTime} ORDER BY o.last_access_time ASC
</select>

@ -21,13 +21,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="operTime" column="oper_time" />
</resultMap>
<sql id="selectOperLogVo">
select
oper_id, title, action, method, channel, oper_name, dept_name, oper_url, oper_ip,oper_location,oper_param,status,error_msg,oper_time
from
sys_oper_log
</sql>
<insert id="insertOperlog" parameterType="OperLog">
insert into sys_oper_log(title, action, method, channel, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, status, error_msg, oper_time)
values (#{title}, #{action}, #{method}, #{channel}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{status}, #{errorMsg}, sysdate())
</insert>
<select id="selectOperLogList" parameterType="OperLog" resultMap="OperLogResult">
select * from sys_oper_log
<include refid="selectOperLogVo"/>
<where>
<if test="title != null and title != ''">
AND title like concat('%', #{title}, '%')
@ -55,8 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectOperLogById" parameterType="Long" resultMap="OperLogResult">
select *
from sys_oper_log
<include refid="selectOperLogVo"/>
where oper_id = #{operId}
</select>

@ -41,11 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(*) from sys_user where dept_id = #{deptId} and del_flag = '0'
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
</select>
<select id="selectDeptCount" parameterType="Dept" resultType="int">
select count(*) from sys_dept
select count(1) from sys_dept
<where>
<if test="deptId != null and deptId != 0"> and dept_id = #{deptId} </if>
<if test="parentId != null and parentId != 0"> and parent_id = #{parentId} </if>

@ -55,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="countDictDataByType" resultType="Integer">
select count(*) from sys_dict_data where dict_type=#{dictType}
select count(1) from sys_dict_data where dict_type=#{dictType}
</select>
<delete id="deleteDictDataById" parameterType="Long">

@ -80,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectCountMenuByParentId" resultType="Integer">
select count(*) from sys_menu where parent_id=#{menuId}
select count(1) from sys_menu where parent_id=#{menuId}
</select>
<select id="checkMenuNameUnique" parameterType="String" resultMap="MenuResult">

@ -14,7 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectCountRoleMenuByMenuId" resultType="Integer">
select count(*) from sys_role_menu where menu_id=#{menuId}
select count(1) from sys_role_menu where menu_id=#{menuId}
</select>
<delete id="deleteRoleMenu" parameterType="Long">

@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkLoginNameUnique" parameterType="String" resultType="int">
select count(*) from sys_user where login_name=#{loginName}
select count(1) from sys_user where login_name=#{loginName}
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="UserResult">

@ -14,7 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="countUserPostById" resultType="Integer">
select count(*) from sys_user_post where post_id=#{postId}
select count(1) from sys_user_post where post_id=#{postId}
</select>
<delete id="deleteUserPost" parameterType="Long">

@ -14,7 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="countUserRoleByRoleId" resultType="Integer">
select count(*) from sys_user_role where role_id=#{roleId}
select count(1) from sys_user_role where role_id=#{roleId}
</select>
<delete id="deleteUserRole" parameterType="Long">

Loading…
Cancel
Save