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

    <resultMap type="cn.ezhizao.project.business.onwork.domain.BizOnceworkDetail" id="BizOnceworkDetailResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizOnceworkDetail" resultMap="BizOnceworkDetailResult">
        SELECT *,user.nick_name as userName FROM biz_oncework_detail
        left join sys_user user on user.user_id = biz_oncework_detail.user_id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="recordDate != null "> AND record_date = #{recordDate}</if>
            <if test="workOrderId != null "> AND work_order_id = #{workOrderId}</if>
            <if test="recordDetail != null  and recordDetail != ''"> AND record_detail = #{recordDetail}</if>
            <if test="userName != null  and userName != ''"> AND user_name like concat('%', #{userName}, '%')</if>
        </trim>
        order by biz_oncework_detail.create_time desc
    </select>

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