<?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.bonus.sgzb.material.mapper.LeaseSceneRegistMapper">
    
    <resultMap type="com.bonus.sgzb.material.domain.LeaseSceneRegist" id="LeaseSceneRegistResult">
        <result property="id"    column="id"    />
        <result property="agreementId"    column="agreement_id"    />
        <result property="teamId"    column="team_id"    />
        <result property="typeId"    column="type_id"    />
        <result property="maId"    column="ma_id"    />
        <result property="num"    column="num"    />
        <result property="createTime"    column="create_time"    />
        <result property="type"    column="type"    />
        <result property="registrant"    column="registrant"    />
        <result property="telephone"    column="telephone"    />
        <result property="companyId"    column="company_id"    />
    </resultMap>

    <sql id="selectLeaseSceneRegistVo">
        select a.id,a.company_id,a.type_id,a.ma_id,a.num,b.create_by,b.update_by,a.create_time
    from lease_scene_regist a
    LEFT JOIN lease_team_info b on a.id=b.id
    </sql>

    <select id="selectLeaseSceneRegistList" parameterType="com.bonus.sgzb.material.domain.LeaseSceneRegist" resultMap="LeaseSceneRegistResult">
        select a.id,a.company_id,a.type_id,a.ma_id,a.num,b.create_by,b.update_by,a.create_time
        from lease_scene_regist a
        LEFT JOIN lease_team_info b on a.id=b.id
        <where>  type='1'
            <if test="companyId != null "> and a.company_id = #{companyId}</if>
            <if test="typeId != null "> and a.type_id= #{typeId}</if>
            <if test="maId != null "> and a.ma_id = #{maId}</if>
            <if test="num != null "> and a.num = #{num}</if>
            <if test="createTime != null and updateBy != '' "> and a.create_time = #{createTime}</if>
        </where>
    </select>
    <select id="selectLeaseSceneRegistLists" parameterType="com.bonus.sgzb.material.domain.LeaseSceneRegist" resultMap="LeaseSceneRegistResult">
        select a.id,a.company_id,a.type_id,a.ma_id,a.num,b.create_by,b.update_by,a.create_time
        from lease_scene_regist a
        LEFT JOIN lease_team_info b on a.id=b.id
        <where>  type='2'
            <if test="companyId != null "> and a.company_id = #{companyId}</if>
            <if test="typeId != null "> and a.type_id= #{typeId}</if>
            <if test="maId != null "> and a.ma_id = #{maId}</if>
            <if test="num != null "> and a.num = #{num}</if>
            <if test="createTime != null and updateBy != '' "> and a.create_time = #{createTime}</if>
        </where>
    </select>
    <select id="selectLeaseSceneRegistById" parameterType="Long" resultMap="LeaseSceneRegistResult">
        <include refid="selectLeaseSceneRegistVo"/>
        where id = #{id}
    </select>
</mapper>