<?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.model.mapper.AppletTaskMapper">

    <resultMap type="AppletTask" id="AppletTaskResult">
        <result property="id" column="id"/>
        <result property="status" column="status"/>
        <result property="memberId" column="member_id"/>
        <result property="taskName" column="task_name"/>
        <result property="taskIcon" column="task_icon"/>
        <result property="taskMoney" column="task_money"/>
        <result property="image" column="image"/>
        <result property="title" column="title"/>
        <result property="theme" column="theme"/>
        <result property="taskEndTime" column="task_end_time"/>
        <result property="taskState" column="task_state"/>
        <result property="examineState" column="examine_state"/>
        <result property="examineText" column="examine_text"/>
        <result property="examineImage" column="examine_image"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="delFlag" column="del_flag"/>

    </resultMap>

    <sql id="selectAppletTaskVo">
        select id, status, member_id, task_name, task_icon, task_money, image, title, theme, task_end_time, task_state, examine_state, examine_text, examine_image, create_time, create_by, update_time, update_by, del_flag  from applet_task
    </sql>

    <select id="selectList" parameterType="AppletTask" resultMap="AppletTaskResult">
        <include refid="selectAppletTaskVo"/>
        <where>
            <if test="status != null "> and status = #{status}</if>
            <if test="memberId != null "> and member_id = #{memberId}</if>
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="taskIcon != null  and taskIcon != ''"> and task_icon = #{taskIcon}</if>
            <if test="taskMoney != null "> and task_money = #{taskMoney}</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="theme != null  and theme != ''"> and theme = #{theme}</if>
            <if test="taskEndTime != null "> and task_end_time = #{taskEndTime}</if>
            <if test="taskState != null "> and task_state = #{taskState}</if>
            <if test="examineState != null "> and examine_state = #{examineState}</if>
            <if test="examineText != null  and examineText != ''"> and examine_text = #{examineText}</if>
            <if test="examineImage != null  and examineImage != ''"> and examine_image = #{examineImage}</if>
        </where>
    </select>

    <select id="selectById" parameterType="Long" resultMap="AppletTaskResult">
        <include refid="selectAppletTaskVo"/>
        where id = #{id}
    </select>

    <insert id="insert" parameterType="AppletTask">
        insert into applet_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="status != null">status,</if>
            <if test="memberId != null">member_id,</if>
            <if test="taskName != null">task_name,</if>
            <if test="taskIcon != null">task_icon,</if>
            <if test="taskMoney != null">task_money,</if>
            <if test="image != null">image,</if>
            <if test="title != null">title,</if>
            <if test="theme != null">theme,</if>
            <if test="taskEndTime != null">task_end_time,</if>
            <if test="taskState != null">task_state,</if>
            <if test="examineState != null">examine_state,</if>
            <if test="examineText != null">examine_text,</if>
            <if test="examineImage != null">examine_image,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>

        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="status != null">#{status},</if>
            <if test="memberId != null">#{memberId},</if>
            <if test="taskName != null">#{taskName},</if>
            <if test="taskIcon != null">#{taskIcon},</if>
            <if test="taskMoney != null">#{taskMoney},</if>
            <if test="image != null">#{image},</if>
            <if test="title != null">#{title},</if>
            <if test="theme != null">#{theme},</if>
            <if test="taskEndTime != null">#{taskEndTime},</if>
            <if test="taskState != null">#{taskState},</if>
            <if test="examineState != null">#{examineState},</if>
            <if test="examineText != null">#{examineText},</if>
            <if test="examineImage != null">#{examineImage},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>

        </trim>
    </insert>

    <update id="update" parameterType="AppletTask">
        update applet_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">status = #{status},</if>
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="taskIcon != null">task_icon = #{taskIcon},</if>
            <if test="taskMoney != null">task_money = #{taskMoney},</if>
            <if test="image != null">image = #{image},</if>
            <if test="title != null">title = #{title},</if>
            <if test="theme != null">theme = #{theme},</if>
            <if test="taskEndTime != null">task_end_time = #{taskEndTime},</if>
            <if test="taskState != null">task_state = #{taskState},</if>
            <if test="examineState != null">examine_state = #{examineState},</if>
            <if test="examineText != null">examine_text = #{examineText},</if>
            <if test="examineImage != null">examine_image = #{examineImage},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>

        </trim>
        where id = #{id}
    </update>

    <delete id="deleteById" parameterType="Long">
        delete from applet_task where id = #{id}
    </delete>

    <delete id="deleteByIds" parameterType="String">
        delete from applet_task where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <insert id="insertOrUpdate" parameterType="AppletTask" useGeneratedKeys="true" keyProperty="id">
        insert into applet_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            status, member_id, task_name, task_icon, task_money, image, title, theme, task_end_time, task_state, examine_state, examine_text, examine_image, create_time, create_by, update_time, update_by, del_flag,

        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id, jdbcType=BIGINT},
            </if>
            #{status, jdbcType=INTEGER},#{memberId, jdbcType=BIGINT},#{taskName, jdbcType=VARCHAR},#{taskIcon, jdbcType=VARCHAR},#{taskMoney, jdbcType=DECIMAL},#{image, jdbcType=VARCHAR},#{title, jdbcType=VARCHAR},#{theme, jdbcType=VARCHAR},#{taskEndTime, jdbcType=DATE},#{taskState, jdbcType=INTEGER},#{examineState, jdbcType=INTEGER},#{examineText, jdbcType=VARCHAR},#{examineImage, jdbcType=VARCHAR},#{createTime, jdbcType=DATE},#{createBy, jdbcType=BIGINT},#{updateTime, jdbcType=DATE},#{updateBy, jdbcType=BIGINT},#{delFlag, jdbcType=BIGINT},

        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=BIGINT},
            </if>
            status = #{status, jdbcType=INTEGER},
            member_id = #{memberId, jdbcType=BIGINT},
            task_name = #{taskName, jdbcType=VARCHAR},
            task_icon = #{taskIcon, jdbcType=VARCHAR},
            task_money = #{taskMoney, jdbcType=DECIMAL},
            image = #{image, jdbcType=VARCHAR},
            title = #{title, jdbcType=VARCHAR},
            theme = #{theme, jdbcType=VARCHAR},
            task_end_time = #{taskEndTime, jdbcType=DATE},
            task_state = #{taskState, jdbcType=INTEGER},
            examine_state = #{examineState, jdbcType=INTEGER},
            examine_text = #{examineText, jdbcType=VARCHAR},
            examine_image = #{examineImage, jdbcType=VARCHAR},
            create_time = #{createTime, jdbcType=DATE},
            create_by = #{createBy, jdbcType=BIGINT},
            update_time = #{updateTime, jdbcType=DATE},
            update_by = #{updateBy, jdbcType=BIGINT},
            del_flag = #{delFlag, jdbcType=BIGINT},

        </trim>
    </insert>
</mapper>
