<?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.playlet.system.mapper.PlayletUserExpandAccountMapper">

    <resultMap type="PlayletUserExpandAccount" id="PlayletUserExpandAccountResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="account"    column="account"    />
        <result property="type"    column="type"    />
        <result property="status"    column="status"    />
        <result property="openId"    column="open_id"    />
        <result property="unionId"    column="union_id"    />
        <result property="avatar"    column="avatar"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectPlayletUserExpandAccountVo">
        select id, name, account, type, status,open_id, union_id, avatar, create_by, create_time, update_by, update_time, remark from playlet_user_expand_account
    </sql>

    <select id="selectPlayletUserExpandAccountList" parameterType="PlayletUserExpandAccount" resultMap="PlayletUserExpandAccountResult">
        <include refid="selectPlayletUserExpandAccountVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="account != null  and account != ''"> and account = #{account}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
        </where>
    </select>

    <select id="selectPlayletUserExpandAccountById" parameterType="Long" resultMap="PlayletUserExpandAccountResult">
        <include refid="selectPlayletUserExpandAccountVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlayletUserExpandAccount" parameterType="PlayletUserExpandAccount" useGeneratedKeys="true" keyProperty="id">
        insert into playlet_user_expand_account
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="account != null">account,</if>
            <if test="type != null">type,</if>
            <if test="status != null">status,</if>
            <if test="avatar != null">avatar,</if>
            <if test="openId != null">open_id,</if>
            <if test="unionId != null">union_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="account != null">#{account},</if>
            <if test="type != null">#{type},</if>
            <if test="status != null">#{status},</if>
            <if test="avatar != null">#{avatar},</if>
            <if test="openId != null">#{openId},</if>
            <if test="unionId != null">#{unionId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updatePlayletUserExpandAccount" parameterType="PlayletUserExpandAccount">
        update playlet_user_expand_account
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="account != null">account = #{account},</if>
            <if test="type != null">type = #{type},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlayletUserExpandAccountById" parameterType="Long">
        delete from playlet_user_expand_account where id = #{id}
    </delete>

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

</mapper>