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

    <resultMap type="cn.ezhizao.project.business.entrust.domain.BizEntrust" id="BizEntrustResult">
        <id column="id" property="id"/>
    </resultMap>

    <resultMap id="SourceResultMap" type="java.util.HashMap">
        <result property="id" column="tenant_id"/>
        <result property="name" column="account_name"/>
    </resultMap>

    <select id="getList" parameterType="BizEntrust" resultMap="BizEntrustResult">
        SELECT * FROM biz_entrust
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="companyId != null "> AND company_id = #{companyId}</if>
            <if test="taskTypeId != null "> AND task_type_id = #{taskTypeId}</if>
            <if test="isStop != null "> AND is_stop = #{isStop}</if>
        </trim>
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_entrust
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
    <select id="entrustSource" resultType="java.util.HashMap" >
        select entrustOrder.from_tenant_id,tenant.account_name
        from biz_entrust_order entrustOrder
                 left join biz_tenant tenant on entrustOrder.from_tenant_id = tenant.id
        where entrustOrder.tenant_id = #{tenantId} or entrustOrder.from_tenant_id = #{tenantId}
    </select>
</mapper>
