<?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.DailyWorkMapper">
    
    <resultMap type="DailyWork" id="DailyWorkResult">
        <result property="dailyWorkId"    column="daily_work_id"    />
        <result property="workId"    column="work_id"    />
        <result property="rock"    column="rock"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="date"    column="date"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectDailyWorkVo">
        select daily_work_id, work_id, rock, create_time, update_time, date, del_flag from daily_work
    </sql>

    <select id="selectDailyWorkList" parameterType="DailyWork" resultMap="DailyWorkResult">
        <include refid="selectDailyWorkVo"/>
        <where>  
            <if test="workId != null "> and work_id = #{workId}</if>
            <if test="rock != null "> and rock = #{rock}</if>
            <if test="date != null "> and date = #{date}</if>
        </where>
    </select>
    
    <select id="selectDailyWorkByDailyWorkId" parameterType="Long" resultMap="DailyWorkResult">
        <include refid="selectDailyWorkVo"/>
        where daily_work_id = #{dailyWorkId}
    </select>
        
    <insert id="insertDailyWork" parameterType="DailyWork" useGeneratedKeys="true" keyProperty="dailyWorkId">
        insert into daily_work
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workId != null">work_id,</if>
            <if test="rock != null">rock,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="date != null">date,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workId != null">#{workId},</if>
            <if test="rock != null">#{rock},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="date != null">#{date},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateDailyWork" parameterType="DailyWork">
        update daily_work
        <trim prefix="SET" suffixOverrides=",">
            <if test="workId != null">work_id = #{workId},</if>
            <if test="rock != null">rock = #{rock},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="date != null">date = #{date},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where daily_work_id = #{dailyWorkId}
    </update>

    <delete id="deleteDailyWorkByDailyWorkId" parameterType="Long">
        delete from daily_work where daily_work_id = #{dailyWorkId}
    </delete>

    <delete id="deleteDailyWorkByDailyWorkIds" parameterType="String">
        delete from daily_work where daily_work_id in 
        <foreach item="dailyWorkId" collection="array" open="(" separator="," close=")">
            #{dailyWorkId}
        </foreach>
    </delete>
</mapper>