WorkUserMapper.xml 3.85 KB
Newer Older
nie'hong's avatar
nie'hong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
<?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="cn.wisenergy.mapper.WorkUserMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkUser">
        <id column="id" property="id" />
        <result column="oa_user_id" property="oaUserId" />
        <result column="dept_id" property="deptId" />
        <result column="name" property="name" />
        <result column="login_name" property="loginName" />
        <result column="password" property="password" />
        <result column="phone" property="phone" />
        <result column="email" property="email" />
        <result column="role" property="role" />
        <result column="type" property="type" />
        <result column="status" property="status" />
        <result column="wx_id" property="wxId" />
        <result column="level" property="level" />
        <result column="create_time" property="createTime" />
        <result column="modify_time" property="modifyTime" />
    </resultMap>

    <sql id="table">
        work_user
    </sql>

    <sql id="cols_all">
        id,
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
        name, oa_user_id, login_name, phone, dept_id, email, role ,type,status,wx_id,level,create_time,modify_time
    </sql>

    <sql id="values">
        #{name},#{oaUserId},#{loginName},#{phone},#{deptId},#{email},#{role},#{type},#{status},#{wxId},#{level},now(),now()
    </sql>

    <sql id="updateCondition">
        <if test="name != null">name = #{name},</if>
        <if test="oaUserId != null">oa_user_id = #{oaUserId},</if>
        <if test="loginName != null">login_name = #{loginName},</if>
nie'hong's avatar
nie'hong committed
45
        <if test="password != null">password = #{password},</if>
nie'hong's avatar
nie'hong committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
        <if test="phone != null">phone =#{phone},</if>
        <if test="deptId != null">dept_id = #{deptId},</if>
        <if test="email != null">email = #{email},</if>
        <if test="role != null">role = #{role},</if>
        <if test="type != null">type =#{type},</if>
        <if test="status != null">status = #{status},</if>
        <if test="wxId != null">wx_id =#{wxId},</if>
        <if test="level != null">level = #{level},</if>
        modify_time =now()
    </sql>

    <sql id="criteria">
        <if test="id != null">and id = #{id}</if>
        <if test="oaUserId != null">and oa_user_id = #{oaUserId}</if>
        <if test="name != null">and name = #{name}</if>
        <if test="loginName != null">and login_name = #{loginName}</if>
        <if test="phone != null">and phone =#{phone}</if>
        <if test="deptId != null">and dept_id = #{deptId}</if>
        <if test="email != null">and email = #{email}</if>
        <if test="role != null">and role = #{role}</if>
        <if test="type != null">and type =#{type}</if>
        <if test="status != null">and status = #{status}</if>
        <if test="wxId != null">and wx_id =#{wxId},</if>
        <if test="level != null">and level = #{level}</if>
        <if test="createTime != null">and create_time &gt;= #{createTime}</if>
        <if test="modifyTime != null">and #{modifyTime} &gt;= modify_time</if>
    </sql>

    <select id="getUserInfo" resultMap="BaseResultMap" parameterType="map" >
        select <include refid="cols_all"/>
        from <include refid="table"/>
        <where>
            <include refid="criteria"/>
        </where>
    </select>

nie'hong's avatar
nie'hong committed
82
    <select id="getUserById" resultMap="BaseResultMap" parameterType="integer" >
nie'hong's avatar
nie'hong committed
83 84 85 86 87
        select <include refid="cols_all"/>
        from <include refid="table"/>
        where id = #{userId}
    </select>

nie'hong's avatar
nie'hong committed
88 89 90 91 92 93
    <update id="updateUserInfo" parameterType="cn.wisenergy.model.app.WorkUser">
        update <include refid="table"/>
        set <include refid="updateCondition"/>
        where id = #{id}
    </update>

nie'hong's avatar
nie'hong committed
94
</mapper>