<?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.jumeirah.common.mapper.BusinessPlainMapper">

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, mc_id, business_type, img_url, introduction, name, phone, wechat, status, create_time, update_time,image_list_height,image_list_width
    </sql>

    <sql id="Base_Column_ListForApp">
        bp.business_type, bp.img_url, bp.introduction, bp.name, bp.phone, bp.wechat,m.`name` AS mcName
    </sql>

    <select id="getBusinessPlainById" resultType="com.jumeirah.common.vo.BusinessPlainQueryVo">
        select
        <include refid="Base_Column_List"/>
        from business_plain where id = #{id}
    </select>

    <select id="getBusinessPlainPageList" parameterType="com.jumeirah.common.param.BusinessPlainPageParam"
            resultType="com.jumeirah.common.vo.BusinessPlainQueryVo">
        select
        <include refid="Base_Column_List"/>
        from business_plain as bp
    </select>

    <select id="getBusinessPlainPageListForApp" parameterType="com.jumeirah.common.param.BusinessPlainPageParam"
            resultType="com.jumeirah.common.vo.BusinessPlainQueryForAppVo">
        select
        <include refid="Base_Column_ListForApp"/>,bp.image_list_height,bp.image_list_width,m.`head` AS mcHead
        from business_plain bp
        INNER JOIN merchant m ON bp.mc_id=m.id
        where bp.business_type=#{param.type}
        AND m.state=1 and m.audit_register_status=1
    </select>

</mapper>
