<?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.cf.imes.module.system.dal.mysql.machine.MachineBrandMapper">


    <resultMap id="MachineMap" type="com.cf.imes.module.system.controller.admin.machine.vo.MachineBrandModelRespVO">

        <result property="brandId" column="brandId"/>
        <result property="brand" column="brand"/>
        <result property="machineType" column="machineType"/>

        <collection property="machineSimpleRespVOS" ofType="com.cf.imes.module.system.controller.admin.machine.vo.MachineSimpleRespVO" resultMap="MachineSimpleMap"/>

    </resultMap>


    <resultMap id="MachineSimpleMap" type="com.cf.imes.module.system.controller.admin.machine.vo.MachineSimpleRespVO">

        <result property="id" column="id"/>
        <result property="name" column="name"/>

    </resultMap>


    <select id="selectMachineList"  resultMap="MachineMap">


        select smb.id as brandId,
               smb.brand,
               smt.id,
               smt.name

        from system_machine_brand smb
                 left join system_machine_template smt on smb.id = smt.brand_id

        where  smt.deleted = false and smt.is_enabled = true and smt.is_default = true and smb.machine_type = #{type}


    </select>


<!--    where  smt.deleted = false and smt.is_enabled = true and smt.is_default = true and smb.machine_type = #{type}-->


<!--</select>-->


    <select id="selectMachineNoDefault"  resultMap="MachineMap">


        select smb.id as brandId,
               smb.machine_type as machineType,
               smb.brand,
               smt.id,
               smt.name

        from system_machine_brand smb
                 left join system_machine_template smt on smb.id = smt.brand_id

        where  smt.deleted = false and smt.is_enabled = true and smt.is_default = false


    </select>
</mapper>