<?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="org.springblade.modules.custom.mapper.BottleLabelMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="bottleLabelResultMap" type="org.springblade.modules.custom.entity.BottleLabel">
        <result column="id" property="id"/>
        <result column="is_delete" property="isDelete"/>
        <result column="create_user_id" property="createUserId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user_id" property="updateUserId"/>
        <result column="update_time" property="updateTime"/>
        <result column="name" property="name"/>
        <result column="image" property="image"/>
        <result column="price" property="price"/>
        <result column="unit" property="unit"/>
        <result column="sort" property="sort"/>
        <result column="status" property="status"/>
    </resultMap>


    <select id="selectBottleLabelPage" resultMap="bottleLabelResultMap">
        select * from biz_bottle_label where is_deleted = 0
    </select>
    <select id="selectByBottleBodyId" resultType="org.springblade.modules.custom.vo.BottleLabelVO">
        SELECT
            bc.*
        FROM
            biz_bottle_body_label bl
            JOIN biz_bottle_label_union cl ON bl.label_id = cl.label_id
            JOIN biz_bottle_label bc ON cl.bottle_label_id = bc.id
        WHERE
            bl.bottle_body_id = #{bottleBodyId}
            AND bl.is_delete = 0 and bc.is_delete = 0 and cl.is_delete = 0
        GROUP BY
            bc.id
    </select>

</mapper>
