<?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.ruixuan.launch.mapper.KuaishouLaunchGroupTargetMapper">

    <resultMap type="com.ruixuan.launch.entity.KuaishouLaunchGroupTarget" id="KuaishouLaunchGroupTargetResult">
        <result property="id" column="id"/>
        <result property="accountId" column="account_id"/>
        <result property="unitId" column="unit_id"/>
        <result property="region" column="region"/>
        <result property="regionType" column="region_type"/>
        <result property="age" column="age"/>
        <result property="genderType" column="gender_type"/>
        <result property="population" column="population"/>
        <result property="excludePopulation" column="exclude_population"/>
        <result property="paidAudience" column="paid_audience"/>
        <result property="behaviorList" column="behavior_list"/>
        <result property="fansStarList" column="fans_star_list"/>
        <result property="purchaseIntention" column="purchase_intention"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectKuaishouLaunchGroupTargetVo">
        select id,
               account_id,
               unit_id,
               region,
               region_type,
               age,
               gender_type,
               population,
               exclude_population,
               paid_audience,
               behavior_list,
               fans_star_list,
               purchase_intention,
               create_time,
               update_time
        from kuaishou_launch_group_target
    </sql>

    <select id="selectKuaishouLaunchGroupTargetList" parameterType="com.ruixuan.launch.entity.KuaishouLaunchGroupTarget"
            resultMap="KuaishouLaunchGroupTargetResult">
        <include refid="selectKuaishouLaunchGroupTargetVo"/>
        <where>
            <if test="accountId != null ">and account_id = #{accountId}</if>
            <if test="unitId != null ">and unit_id = #{unitId}</if>
            <if test="region != null  and region != ''">and region = #{region}</if>
            <if test="regionType != null  and regionType != ''">and region_type = #{regionType}</if>
            <if test="age != null  and age != ''">and age = #{age}</if>
            <if test="genderType != null ">and gender_type = #{genderType}</if>
            <if test="population != null  and population != ''">and population = #{population}</if>
            <if test="excludePopulation != null  and excludePopulation != ''">and exclude_population =
                #{excludePopulation}
            </if>
            <if test="paidAudience != null  and paidAudience != ''">and paid_audience = #{paidAudience}</if>
            <if test="behaviorList != null  and behaviorList != ''">and behavior_list = #{behaviorList}</if>
            <if test="fansStarList != null  and fansStarList != ''">and fans_star_list = #{fansStarList}</if>
            <if test="purchaseIntention != null  and purchaseIntention != ''">and purchase_intention =
                #{purchaseIntention}
            </if>
        </where>
    </select>

    <select id="selectKuaishouLaunchGroupTargetById" parameterType="Long" resultMap="KuaishouLaunchGroupTargetResult">
        <include refid="selectKuaishouLaunchGroupTargetVo"/>
        where id = #{id}
    </select>

    <insert id="insertKuaishouLaunchGroupTarget" parameterType="com.ruixuan.launch.entity.KuaishouLaunchGroupTarget"
            useGeneratedKeys="true" keyProperty="id">
        insert into kuaishou_launch_group_target
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="accountId != null">account_id,</if>
            <if test="unitId != null">unit_id,</if>
            <if test="region != null">region,</if>
            <if test="regionType != null">region_type,</if>
            <if test="age != null">age,</if>
            <if test="genderType != null">gender_type,</if>
            <if test="population != null">population,</if>
            <if test="excludePopulation != null">exclude_population,</if>
            <if test="paidAudience != null">paid_audience,</if>
            <if test="behaviorList != null">behavior_list,</if>
            <if test="fansStarList != null">fans_star_list,</if>
            <if test="purchaseIntention != null">purchase_intention,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="accountId != null">#{accountId},</if>
            <if test="unitId != null">#{unitId},</if>
            <if test="region != null">#{region},</if>
            <if test="regionType != null">#{regionType},</if>
            <if test="age != null">#{age},</if>
            <if test="genderType != null">#{genderType},</if>
            <if test="population != null">#{population},</if>
            <if test="excludePopulation != null">#{excludePopulation},</if>
            <if test="paidAudience != null">#{paidAudience},</if>
            <if test="behaviorList != null">#{behaviorList},</if>
            <if test="fansStarList != null">#{fansStarList},</if>
            <if test="purchaseIntention != null">#{purchaseIntention},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateKuaishouLaunchGroupTarget" parameterType="com.ruixuan.launch.entity.KuaishouLaunchGroupTarget">
        update kuaishou_launch_group_target
        <trim prefix="SET" suffixOverrides=",">
            <if test="accountId != null">account_id = #{accountId},</if>
            <if test="unitId != null">unit_id = #{unitId},</if>
            <if test="region != null">region = #{region},</if>
            <if test="regionType != null">region_type = #{regionType},</if>
            <if test="age != null">age = #{age},</if>
            <if test="genderType != null">gender_type = #{genderType},</if>
            <if test="population != null">population = #{population},</if>
            <if test="excludePopulation != null">exclude_population = #{excludePopulation},</if>
            <if test="paidAudience != null">paid_audience = #{paidAudience},</if>
            <if test="behaviorList != null">behavior_list = #{behaviorList},</if>
            <if test="fansStarList != null">fans_star_list = #{fansStarList},</if>
            <if test="purchaseIntention != null">purchase_intention = #{purchaseIntention},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

</mapper>