WeUserMapper.xml 8.8 KB
Newer Older
1 2 3 4 5 6 7 8
<?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.linkwechat.wecom.mapper.WeUserMapper">
    
    <resultMap type="WeUser" id="WeUserResult">
        <result property="id"    column="id"    />
9 10
        <result property="avatarMediaid"    column="head_image_url"    />
        <result property="name"    column="user_name"    />
11 12 13 14 15 16
        <result property="alias"    column="alias"    />
        <result property="userId"    column="user_id"    />
        <result property="gender"    column="gender"    />
        <result property="mobile"    column="mobile"    />
        <result property="email"    column="email"    />
        <result property="wxAccount"    column="wx_account"    />
17
        <result property="department"    column="department"  typeHandler="com.linkwechat.framework.handler.StringArrayJoinTypeHandler" />
18
        <result property="position"    column="position"    />
19
        <result property="isLeaderInDept"    column="is_leader_in_dept"  typeHandler="com.linkwechat.framework.handler.StringArrayJoinTypeHandler"  />
20 21 22 23 24 25 26 27 28 29 30 31
        <result property="joinTime"    column="join_time"    />
        <result property="enable"    column="enable"    />
        <result property="idCard"    column="id_card"    />
        <result property="qqAccount"    column="qq_account"    />
        <result property="telephone"    column="telephone"    />
        <result property="address"    column="address"    />
        <result property="birthday"    column="birthday"    />
        <result property="remark"    column="remark"    />
        <result property="isActivate"    column="is_activate"    />
    </resultMap>

    <sql id="selectWeUserVo">
32
        select id, head_image_url as avatarMediaid, user_name as name, alias, user_id, gender, mobile, email, wx_account, department, position, is_leader_in_dept, join_time, enable, id_card, qq_account, telephone, address, birthday, remark, is_activate from we_user
33 34 35 36 37
    </sql>

    <select id="selectWeUserList" parameterType="WeUser" resultMap="WeUserResult">
        <include refid="selectWeUserVo"/>
        <where>  
38 39
            <if test="avatarMediaid != null  and avatarMediaid != ''"> and head_image_url = #{avatarMediaid}</if>
            <if test="name != null  and name != ''"> and user_name like concat('%', #{name}, '%')</if>
40 41 42 43 44 45
            <if test="alias != null  and alias != ''"> and alias = #{alias}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="gender != null "> and gender = #{gender}</if>
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="email != null  and email != ''"> and email = #{email}</if>
            <if test="wxAccount != null  and wxAccount != ''"> and wx_account = #{wxAccount}</if>
46
            <if test="department != null  and department != ''"> and FIND_IN_SET(#{department},department)</if>
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="isLeaderInDept != null "> and is_leader_in_dept = #{isLeaderInDept}</if>
            <if test="joinTime != null "> and join_time = #{joinTime}</if>
            <if test="enable != null "> and enable = #{enable}</if>
            <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
            <if test="qqAccount != null  and qqAccount != ''"> and qq_account = #{qqAccount}</if>
            <if test="telephone != null  and telephone != ''"> and telephone = #{telephone}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="birthday != null "> and birthday = #{birthday}</if>
            <if test="isActivate != null "> and is_activate = #{isActivate}</if>
        </where>
    </select>
    
    <select id="selectWeUserById" parameterType="Long" resultMap="WeUserResult">
        <include refid="selectWeUserVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWeUser" parameterType="WeUser">
        insert into we_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
69 70
            <if test="avatarMediaid != null">head_image_url,</if>
            <if test="name != null">user_name,</if>
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
            <if test="alias != null">alias,</if>
            <if test="userId != null">user_id,</if>
            <if test="gender != null">gender,</if>
            <if test="mobile != null and mobile != ''">mobile,</if>
            <if test="email != null">email,</if>
            <if test="wxAccount != null">wx_account,</if>
            <if test="department != null">department,</if>
            <if test="position != null">position,</if>
            <if test="isLeaderInDept != null">is_leader_in_dept,</if>
            <if test="joinTime != null">join_time,</if>
            <if test="enable != null">enable,</if>
            <if test="idCard != null">id_card,</if>
            <if test="qqAccount != null">qq_account,</if>
            <if test="telephone != null">telephone,</if>
            <if test="address != null">address,</if>
            <if test="birthday != null">birthday,</if>
            <if test="remark != null">remark,</if>
            <if test="isActivate != null">is_activate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
92 93
            <if test="avatarMediaid != null">#{avatarMediaid},</if>
            <if test="name != null">#{name},</if>
94 95 96 97 98 99
            <if test="alias != null">#{alias},</if>
            <if test="userId != null">#{userId},</if>
            <if test="gender != null">#{gender},</if>
            <if test="mobile != null and mobile != ''">#{mobile},</if>
            <if test="email != null">#{email},</if>
            <if test="wxAccount != null">#{wxAccount},</if>
100
            <if test="department != null" >#{department,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.StringArrayJoinTypeHandler},</if>
101
            <if test="position != null">#{position},</if>
102
            <if test="isLeaderInDept != null">#{isLeaderInDept,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.StringArrayJoinTypeHandler},</if>
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
            <if test="joinTime != null">#{joinTime},</if>
            <if test="enable != null">#{enable},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="qqAccount != null">#{qqAccount},</if>
            <if test="telephone != null">#{telephone},</if>
            <if test="address != null">#{address},</if>
            <if test="birthday != null">#{birthday},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isActivate != null">#{isActivate},</if>
         </trim>
    </insert>

    <update id="updateWeUser" parameterType="WeUser">
        update we_user
        <trim prefix="SET" suffixOverrides=",">
118 119
            <if test="avatarMediaid != null">head_image_url = #{avatarMediaid},</if>
            <if test="name != null">user_name = #{name},</if>
120 121 122 123 124 125
            <if test="alias != null">alias = #{alias},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
            <if test="email != null">email = #{email},</if>
            <if test="wxAccount != null">wx_account = #{wxAccount},</if>
H
HaoN 已提交
126
            <if test="department != null">department = #{department,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.StringArrayJoinTypeHandler},</if>
127
            <if test="position != null">position = #{position},</if>
H
HaoN 已提交
128
            <if test="isLeaderInDept != null">is_leader_in_dept = #{isLeaderInDept,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.StringArrayJoinTypeHandler},</if>
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
            <if test="joinTime != null">join_time = #{joinTime},</if>
            <if test="enable != null">enable = #{enable},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="qqAccount != null">qq_account = #{qqAccount},</if>
            <if test="telephone != null">telephone = #{telephone},</if>
            <if test="address != null">address = #{address},</if>
            <if test="birthday != null">birthday = #{birthday},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isActivate != null">is_activate = #{isActivate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWeUserById" parameterType="Long">
        delete from we_user where id = #{id}
    </delete>

    <delete id="deleteWeUserByIds" parameterType="String">
        delete from we_user where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
152 153


154 155
    
</mapper>