<?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.TaskNoticeMapper">

    <resultMap type="com.ruoyi.system.domain.TaskNotice" id="TaskNoticeMap">
        <result property="startId" column="start_id" jdbcType="INTEGER"/>
        <result property="taskid" column="taskid" jdbcType="VARCHAR"/>
        <result property="workmode" column="workmode" jdbcType="INTEGER"/>
        <result property="planid" column="planid" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="siteId" column="site_id" jdbcType="INTEGER"/>
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
        <result property="pn" column="pn" jdbcType="INTEGER"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="TaskNoticeMap">
        select
start_id, taskid, workmode, planid, create_time, site_id, id, remark, code, pn
        from task_notice
        where start_id = #{startId}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TaskNoticeMap">
        select
            start_id, taskid, workmode, planid, create_time, site_id, id, remark, code, pn
        from task_notice
        <where>
            <if test="siteId != null">
                and site_id= #{siteId}
            </if>
            <if test="taskid != null and taskid != ''">
                and taskid = #{taskid}
            </if>
        </where>
        order by create_time desc
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from task_notice
        <where>
            <if test="startId != null">
                and start_id = #{startId}
            </if>
            <if test="taskid != null and taskid != ''">
                and taskid = #{taskid}
            </if>
            <if test="workmode != null">
                and workmode = #{workmode}
            </if>
            <if test="planid != null">
                and planid = #{planid}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="siteId != null">
                and site_id = #{siteId}
            </if>
            <if test="id != null and id != ''">
                and id = #{id}
            </if>
            <if test="remark != null and remark != ''">
                and remark = #{remark}
            </if>
            <if test="code != null and code != ''">
                and code = #{code}
            </if>
            <if test="pn != null">
                and pn = #{pn}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="startId" useGeneratedKeys="true">
        insert into task_notice(taskid, workmode, planid, create_time, site_id, id, remark, code, pn)
        values (#{taskid}, #{workmode}, #{planid}, #{createTime}, #{siteId}, #{id}, #{remark}, #{code}, #{pn})
    </insert>

    <insert id="insertBatch" keyProperty="startId" useGeneratedKeys="true">
        insert into task_notice(taskid, workmode, planid, create_time, site_id, id, remark, code, pn)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.taskid}, #{entity.workmode}, #{entity.planid}, #{entity.createTime}, #{entity.siteId}, #{entity.id}, #{entity.remark}, #{entity.code}, #{entity.pn})
        </foreach>
    </insert>

    <insert id="insertOrUpdateBatch" keyProperty="startId" useGeneratedKeys="true">
        insert into task_notice(taskid, workmode, planid, create_time, site_id, id, remark, code, pn)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.taskid}, #{entity.workmode}, #{entity.planid}, #{entity.createTime}, #{entity.siteId}, #{entity.id}, #{entity.remark}, #{entity.code}, #{entity.pn})
        </foreach>
        on duplicate key update
        taskid = values(taskid),
        workmode = values(workmode),
        planid = values(planid),
        create_time = values(create_time),
        site_id = values(site_id),
        id = values(id),
        remark = values(remark),
        code = values(code),
        pn = values(pn)
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update task_notice
        <set>
            <if test="taskid != null and taskid != ''">
                taskid = #{taskid},
            </if>
            <if test="workmode != null">
                workmode = #{workmode},
            </if>
            <if test="planid != null">
                planid = #{planid},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="siteId != null">
                site_id = #{siteId},
            </if>
            <if test="id != null and id != ''">
                id = #{id},
            </if>
            <if test="remark != null and remark != ''">
                remark = #{remark},
            </if>
            <if test="code != null and code != ''">
                code = #{code},
            </if>
            <if test="pn != null">
                pn = #{pn},
            </if>
        </set>
        where start_id = #{startId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from task_notice where start_id = #{startId}
    </delete>

</mapper>

