<?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="cn.ezhizao.project.business.daywork.mapper.BizDayworkItemMapper">

    <resultMap type="cn.ezhizao.project.business.daywork.domain.BizDayworkItem" id="BizDayworkItemResult">
        <id column="id" property="id"/>
    </resultMap>

    <select id="getList" parameterType="BizDayworkItem" resultMap="BizDayworkItemResult">
        SELECT * FROM biz_daywork_item
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="type != null">AND status &lt; 4</if>
            <if test="dayworkId != null and dayworkId != ''">AND daywork_id = #{dayworkId}</if>
            <if test="processId != null and processId != ''">AND process_id = #{processId}</if>
            <if test="equipmentDetailCode"> AND equipment_detail_code = #{equipmentDetailCode} </if>
            <if test="technologicalProcessDetailId != null and technologicalProcessDetailId != ''">AND technological_process_detail_id = #{technologicalProcessDetailId}</if>
            <if test="status != null and status != ''">AND status = #{status}</if>
            <if test="userStatus != null and userStatus != ''">AND `status` &lt; 5</if>
            <if test="userId !=null and userId != ''">AND user_id = #{userId}</if>
            <if test="tenantId != null  and tenantId != 0">AND tenant_id = #{tenantId}</if>
            <if test="updaterId != null  and updaterId != 0">AND updater_id = #{updaterId}</if>
            <if test="id != null"> AND id = #{id}</if>
            <if test="ids != null and ids.size > 0">
                AND id in
                <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
                    #{item,jdbcType=BIGINT}
                </foreach>
            </if>
        </trim>
        ORDER BY create_time DESC
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_daywork_item
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
            <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
