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

    <resultMap type="cn.ezhizao.project.business.domain.BizResourceAllocation" id="BizResourceAllocationResult">
        <id column="id" property="id"/>
        <result column="equipment_id" property="equipmentId"/>
        <result column="process_id" property="processId"/>
    </resultMap>

    <select id="getList" parameterType="BizResourceAllocation" resultMap="BizResourceAllocationResult">
        SELECT l.*,p.process_code,p.process_alias,e.equipment_code,e.usage_dept_code,e.scrapping_date,e.equipment_status_code
        FROM biz_resource_allocation l  LEFT JOIN biz_process p ON l.process_id = p.id LEFT JOIN biz_equipment_detail e ON l.equipment_id = e.id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            l.deleted = 0
            <if test="deptUserId != null "> AND l.dept_user_id = #{deptUserId}</if>
        </trim>
    </select>

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