WorkUserMapper.xml 3.91 KB
<?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>
        <if test="password != null">password = #{password},</if>
        <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="password != null">and password = #{password}</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>

    <select id="getUserById" resultMap="BaseResultMap" parameterType="integer" >
        select <include refid="cols_all"/>
        from <include refid="table"/>
        where id = #{userId}
    </select>

    <update id="updateUserInfo" parameterType="cn.wisenergy.model.app.WorkUser">
        update <include refid="table"/>
        set <include refid="updateCondition"/>
        where id = #{id}
    </update>

</mapper>