<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.lyms.platform.permission.intf.IUsersDao">
<resultMap id="UsersResultMap" type="com.lyms.platform.permission.model.Users">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="parent_id" property="parentId" jdbcType="INTEGER" />
<result column="dept_id" property="deptId" jdbcType="INTEGER" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="account" property="account" jdbcType="VARCHAR" />
<result column="pwd" property="pwd" jdbcType="VARCHAR" />
<result column="phone" property="phone" jdbcType="VARCHAR" />
<result column="publish_id" property="publishId" jdbcType="INTEGER" />
<result column="publish_name" property="publishName" jdbcType="VARCHAR" />
<result column="yn" property="yn" jdbcType="INTEGER" />
<result column="modified" property="modified" jdbcType="TIMESTAMP" />
<result column="created" property="created" jdbcType="TIMESTAMP" />
<result column="last_login_time" property="lastLoginTime"
jdbcType="TIMESTAMP" />
</resultMap>
<insert id="addUsers" parameterType="com.lyms.platform.permission.model.Users">
<selectKey resultType="java.lang.Integer" keyProperty="id"
order="AFTER">
SELECT LAST_INSERT_ID()
</selectKey>
insert into users
(type,parent_id,dept_id,username,account,pwd,phone,publish_id,publish_name,yn,modified,created,last_login_time)
values
(#{type},#{parentId},#{deptId},#{username},#{account},#{pwd},#{phone},#{publishId},#{publishName},#{yn},#{modified},#{created},#{lastLoginTime})
</insert>
<update id="updateUsers" parameterType="com.lyms.platform.permission.model.Users">
update users
<set>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="username != null and username != ''">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="account != null and account != ''">
account = #{account,jdbcType=VARCHAR},
</if>
<if test="pwd != null and pwd != ''">
pwd = #{pwd,jdbcType=VARCHAR},
</if>
<if test="phone != null and phone != ''">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="publishId != null">
publish_id = #{publishId,jdbcType=INTEGER},
</if>
<if test="publishName != null and publishName != ''">
publish_name = #{publishName,jdbcType=VARCHAR},
</if>
<if test="yn != null">
yn = #{yn,jdbcType=INTEGER},
</if>
<if test="modified != null">
modified = #{modified,jdbcType=TIMESTAMP},
</if>
<if test="created != null">
created = #{created,jdbcType=TIMESTAMP},
</if>
<if test="lastLoginTime != null">
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteUsers" parameterType="java.lang.String">
delete from users where
id = #{id,jdbcType=INTEGER}
</delete>
<select id="getUsers" resultMap="UsersResultMap" parameterType="java.lang.String">
select
id,type,parent_id,dept_id,username,account,pwd,phone,publish_id,publish_name,yn,modified,created,last_login_time
from users where id = #{id,jdbcType=INTEGER}
</select>
<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit,
jdbcType=INTEGER}
</if>
</if>
</sql>
<sql id="UsersCondition">
<where>
1 = 1
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="type != null">
and type = #{type,jdbcType=INTEGER}
</if>
<if test="parentId != null">
and parent_id = #{parentId,jdbcType=INTEGER}
</if>
<if test="deptId != null">
and dept_id = #{deptId,jdbcType=INTEGER}
</if>
<if test="username != null and username != ''">
and username like CONCAT(#{username}, '%')
</if>
<if test="account != null and account != ''">
and account = #{account,jdbcType=VARCHAR}
</if>
<if test="pwd != null and pwd != ''">
and pwd = #{pwd,jdbcType=VARCHAR}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone,jdbcType=VARCHAR}
</if>
<if test="publishId != null">
and publish_id = #{publishId,jdbcType=INTEGER}
</if>
<if test="publishName != null and publishName != ''">
and publish_name = #{publishName,jdbcType=VARCHAR}
</if>
<if test="yn != null">
and yn = #{yn,jdbcType=INTEGER}
</if>
<if test="modified != null">
and modified = #{modified,jdbcType=TIMESTAMP}
</if>
<if test="created != null">
and created = #{created,jdbcType=TIMESTAMP}
</if>
</where>
</sql>
<select id="queryUsers" resultMap="UsersResultMap"
parameterType="com.lyms.platform.permission.model.UsersQuery">
select
id,type,parent_id,dept_id,username,account,pwd,phone,publish_id,publish_name,yn,modified,created,last_login_time
from users
<include refid="UsersCondition" />
<include refid="orderAndLimit" />
</select>
<select id="queryUsersCount" resultType="int"
parameterType="com.lyms.platform.permission.model.UsersQuery">
select count(1) from users
<include refid="UsersCondition" />
</select>
</mapper>