<?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.ruoyi.system.mapper.TaskDataMapper">

    <resultMap type="TaskData" id="TaskDataResult">
        <result property="id"    column="id"    />
        <result property="costDate"    column="cost_date"    />
        <result property="sourceApp"    column="source_app"    />
        <result property="totalCost"    column="total_cost"    />
        <result property="exposure"    column="exposure"    />
        <result property="click"    column="click"    />
        <result property="clickRate"    column="click_rate"    />
        <result property="download"    column="download"    />
        <result property="downloadRate"    column="download_rate"    />
        <result property="downloadAvgCost"    column="download_avg_cost"    />
        <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="selectTaskDataVo">
        select id, cost_date, source_app, total_cost, exposure, click, click_rate, download, download_rate, download_avg_cost, create_by, create_time, update_by, update_time, remark from task_data
    </sql>

    <select id="selectTaskDataList" parameterType="TaskData" resultMap="TaskDataResult">
        <include refid="selectTaskDataVo"/>
        <where>
            <if test="costDate != null  and costDate != ''"> and cost_date = #{costDate}</if>
            <if test="sourceApp != null  and sourceApp != ''"> and source_app = #{sourceApp}</if>
            <if test="totalCost != null  and totalCost != ''"> and total_cost = #{totalCost}</if>
            <if test="exposure != null "> and exposure = #{exposure}</if>
            <if test="click != null "> and click = #{click}</if>
            <if test="clickRate != null  and clickRate != ''"> and click_rate = #{clickRate}</if>
            <if test="download != null "> and download = #{download}</if>
            <if test="downloadRate != null  and downloadRate != ''"> and download_rate = #{downloadRate}</if>
            <if test="downloadAvgCost != null "> and download_avg_cost = #{downloadAvgCost}</if>
        </where>
    </select>

    <select id="selectTaskDataById" parameterType="Long" resultMap="TaskDataResult">
        <include refid="selectTaskDataVo"/>
        where id = #{id}
    </select>

    <insert id="insertTaskData" parameterType="TaskData" useGeneratedKeys="true" keyProperty="id">
        insert into task_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="costDate != null">cost_date,</if>
            <if test="sourceApp != null">source_app,</if>
            <if test="totalCost != null">total_cost,</if>
            <if test="exposure != null">exposure,</if>
            <if test="click != null">click,</if>
            <if test="clickRate != null">click_rate,</if>
            <if test="download != null">download,</if>
            <if test="downloadRate != null">download_rate,</if>
            <if test="downloadAvgCost != null">download_avg_cost,</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="costDate != null">#{costDate},</if>
            <if test="sourceApp != null">#{sourceApp},</if>
            <if test="totalCost != null">#{totalCost},</if>
            <if test="exposure != null">#{exposure},</if>
            <if test="click != null">#{click},</if>
            <if test="clickRate != null">#{clickRate},</if>
            <if test="download != null">#{download},</if>
            <if test="downloadRate != null">#{downloadRate},</if>
            <if test="downloadAvgCost != null">#{downloadAvgCost},</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="updateTaskData" parameterType="TaskData">
        update task_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="costDate != null">cost_date = #{costDate},</if>
            <if test="sourceApp != null">source_app = #{sourceApp},</if>
            <if test="totalCost != null">total_cost = #{totalCost},</if>
            <if test="exposure != null">exposure = #{exposure},</if>
            <if test="click != null">click = #{click},</if>
            <if test="clickRate != null">click_rate = #{clickRate},</if>
            <if test="download != null">download = #{download},</if>
            <if test="downloadRate != null">download_rate = #{downloadRate},</if>
            <if test="downloadAvgCost != null">download_avg_cost = #{downloadAvgCost},</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="deleteTaskDataById" parameterType="Long">
        delete from task_data where id = #{id}
    </delete>

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

</mapper>