<?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.fs.course.mapper.FsUserTalentMapper">

    <resultMap type="FsUserTalent" id="FsUserTalentResult">
        <result property="talentId"    column="talent_id"    />
        <result property="userId"    column="user_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="nickName"    column="nick_name"    />
        <result property="avatar"    column="avatar"    />
        <result property="phone"    column="phone"    />
        <result property="title"    column="title"    />
        <result property="sex"    column="sex"    />
        <result property="tags"    column="tags"    />
        <result property="address"    column="address"    />
        <result property="level"    column="level"    />
        <result property="fans"    column="fans"    />
        <result property="likes"    column="likes"    />
        <result property="isDel"    column="is_del"    />
        <result property="tiktokLink"    column="tiktok_link"    />
        <result property="kwaiLink"    column="kwai_link"    />
        <result property="isAudit"    column="is_audit"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="certificateCode"    column="certificate_code"    />
        <result property="certificateImages"    column="certificate_images"    />
        <result property="balance"    column="balance"    />
        <result property="totalMoney"    column="total_money"    />
        <result property="freezeMoney"    column="freeze_money"    />
        <result property="extractMoney"    column="extract_money"    />
    </resultMap>

    <sql id="selectFsUserTalentVo">
        select talent_id, user_id, create_time, update_time, nick_name, avatar, phone, title, sex, tags, address, level, fans, likes, is_del, tiktok_link, kwai_link, is_audit, audit_time, certificate_code, certificate_images, balance, total_money, freeze_money, extract_money from fs_user_talent
    </sql>

    <select id="selectFsUserTalentList" parameterType="FsUserTalent" resultMap="FsUserTalentResult">
        <include refid="selectFsUserTalentVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="talentId != null "> and talent_id = #{talentId}</if>
            <if test="nickName != null  and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
            <if test="avatar != null  and avatar != ''"> and avatar = #{avatar}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="sex != null "> and sex = #{sex}</if>
            <if test="tags != null  and tags != ''"> and tags = #{tags}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="level != null "> and level = #{level}</if>
            <if test="fans != null "> and fans = #{fans}</if>
            <if test="likes != null "> and likes = #{likes}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="tiktokLink != null  and tiktokLink != ''"> and tiktok_link = #{tiktokLink}</if>
            <if test="kwaiLink != null  and kwaiLink != ''"> and kwai_link = #{kwaiLink}</if>
            <if test="isAudit != null "> and is_audit = #{isAudit}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
            <if test="certificateCode != null  and certificateCode != ''"> and certificate_code = #{certificateCode}</if>
            <if test="certificateImages != null  and certificateImages != ''"> and certificate_images = #{certificateImages}</if>
            <if test="balance != null "> and balance = #{balance}</if>
            <if test="totalMoney != null "> and total_money = #{totalMoney}</if>
            <if test="freezeMoney != null "> and freeze_money = #{freezeMoney}</if>
            <if test="extractMoney != null "> and extract_money = #{extractMoney}</if>
        </where>
    </select>

    <select id="selectFsUserTalentByTalentId" parameterType="Long" resultMap="FsUserTalentResult">
        <include refid="selectFsUserTalentVo"/>
        where talent_id = #{talentId}
    </select>

    <insert id="insertFsUserTalent" parameterType="FsUserTalent" useGeneratedKeys="true" keyProperty="talentId">
        insert into fs_user_talent
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="nickName != null">nick_name,</if>
            <if test="avatar != null">avatar,</if>
            <if test="phone != null">phone,</if>
            <if test="title != null">title,</if>
            <if test="sex != null">sex,</if>
            <if test="tags != null">tags,</if>
            <if test="address != null">address,</if>
            <if test="level != null">level,</if>
            <if test="fans != null">fans,</if>
            <if test="likes != null">likes,</if>
            <if test="isDel != null">is_del,</if>
            <if test="tiktokLink != null">tiktok_link,</if>
            <if test="kwaiLink != null">kwai_link,</if>
            <if test="isAudit != null">is_audit,</if>
            <if test="auditTime != null">audit_time,</if>
            <if test="certificateCode != null">certificate_code,</if>
            <if test="certificateImages != null">certificate_images,</if>
            <if test="balance != null">balance,</if>
            <if test="totalMoney != null">total_money,</if>
            <if test="freezeMoney != null">freeze_money,</if>
            <if test="extractMoney != null">extract_money,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="nickName != null">#{nickName},</if>
            <if test="avatar != null">#{avatar},</if>
            <if test="phone != null">#{phone},</if>
            <if test="title != null">#{title},</if>
            <if test="sex != null">#{sex},</if>
            <if test="tags != null">#{tags},</if>
            <if test="address != null">#{address},</if>
            <if test="level != null">#{level},</if>
            <if test="fans != null">#{fans},</if>
            <if test="likes != null">#{likes},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="tiktokLink != null">#{tiktokLink},</if>
            <if test="kwaiLink != null">#{kwaiLink},</if>
            <if test="isAudit != null">#{isAudit},</if>
            <if test="auditTime != null">#{auditTime},</if>
            <if test="certificateCode != null">#{certificateCode},</if>
            <if test="certificateImages != null">#{certificateImages},</if>
            <if test="balance != null">#{balance},</if>
            <if test="totalMoney != null">#{totalMoney},</if>
            <if test="freezeMoney != null">#{freezeMoney},</if>
            <if test="extractMoney != null">#{extractMoney},</if>
        </trim>
    </insert>

    <update id="updateFsUserTalent" parameterType="FsUserTalent">
        update fs_user_talent
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="nickName != null">nick_name = #{nickName},</if>
            <if test="avatar != null">avatar = #{avatar},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="title != null">title = #{title},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="tags != null">tags = #{tags},</if>
            <if test="address != null">address = #{address},</if>
            <if test="level != null">level = #{level},</if>
            <if test="fans != null">fans = #{fans},</if>
            <if test="likes != null">likes = #{likes},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="tiktokLink != null">tiktok_link = #{tiktokLink},</if>
            <if test="kwaiLink != null">kwai_link = #{kwaiLink},</if>
            <if test="isAudit != null">is_audit = #{isAudit},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="certificateCode != null">certificate_code = #{certificateCode},</if>
            <if test="certificateImages != null">certificate_images = #{certificateImages},</if>
            <if test="balance != null">balance = #{balance},</if>
            <if test="totalMoney != null">total_money = #{totalMoney},</if>
            <if test="freezeMoney != null">freeze_money = #{freezeMoney},</if>
            <if test="extractMoney != null">extract_money = #{extractMoney},</if>
        </trim>
        where talent_id = #{talentId}
    </update>

    <delete id="deleteFsUserTalentByTalentId" parameterType="Long">
        delete from fs_user_talent where talent_id = #{talentId}
    </delete>

    <delete id="deleteFsUserTalentByTalentIds" parameterType="String">
        delete from fs_user_talent where talent_id in
        <foreach item="talentId" collection="array" open="(" separator="," close=")">
            #{talentId}
        </foreach>
    </delete>
</mapper>
