<?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.pay.mapper.PayBaohuoWorktimeMapper">

    <resultMap type="com.ruoyi.pay.domain.PayBaohuoWorktime" id="PayBaohuoWorktimeResult">
        <result property="id" column="id"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="woId" column="wo_id"/>
        <result property="empId" column="emp_id"/>
        <result property="bheId" column="bhe_id"/>
        <result property="stime" column="stime"/>
        <result property="etime" column="etime"/>
        <result property="validHours" column="valid_hours"/>
        <result property="date" column="date"/>
        <result property="intime" column="intime"/>
    </resultMap>

    <sql id="selectBaohuoWorktime">
        select id, wo_id, emp_id, bhe_id, stime, etime, valid_hours, date, intime from pay_baohuo_worktime
    </sql>

    <select id="selectBaohuoWorktimeList" parameterType="PayBaohuoWorktime" resultMap="PayBaohuoWorktimeResult">
        <include refid="selectBaohuoWorktime"/>
        <where>
            <if test="woId != null "> and wo_id = #{woId}</if>
            <if test="empId != null "> and emp_id = #{empId}</if>
            <if test="bheId != null "> and bhe_id = #{bheId}</if>
            <if test="tenantId != null "> and tenant_id = #{tenantId}</if>
            <if test="stime != null "> and stime = #{stime}</if>
            <if test="etime != null "> and etime = #{etime}</if>
            <if test="validHours != null "> and valid_hours = #{validHours}</if>
            <if test="date != null ">
                <![CDATA[AND (DATE_FORMAT(`date`, '%Y-%m') = DATE_FORMAT( #{date}, '%Y-%m'))]]>
            </if>
            <if test="intime != null ">
                <![CDATA[AND (DATE_FORMAT(`intime`, '%Y-%m') = DATE_FORMAT( #{intime}, '%Y-%m'))]]>
            </if>
        </where>
    </select>

</mapper>
