<?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.hzs.sale.wares.mapper.BdWaresLabelMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.sale.wares.BdWaresLabel">
    <result column="CREATION_TIME" property="creationTime" />
    <result column="MODIFIED_TIME" property="modifiedTime" />
    <result column="DEL_FLAG" property="delFlag" />
    <result column="PK_COUNTRY" property="pkCountry" />
    <result column="PK_CREATOR" property="pkCreator" />
    <result column="PK_MODIFIED" property="pkModified" />
        <result column="PK_ID" property="pkId" />
        <result column="PK_WARES" property="pkWares" />
        <result column="LABEL_TYPE" property="labelType" />
        <result column="PK_LABLE" property="pkLable" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        CREATION_TIME,
        MODIFIED_TIME,
        DEL_FLAG,
        PK_COUNTRY,
        PK_CREATOR,
        PK_MODIFIED,
        PK_ID, PK_WARES, LABEL_TYPE, PK_LABLE
    </sql>

    <delete id="deleteByPkWares">
        delete from  BD_WARES_LABEL where PK_WARES = #{pkWares}
    </delete>

    <select id="selectByList" resultType="com.hzs.common.domain.system.ext.BdLabelExt">
        select bl.LABEL label,bl.LABEL_TYPE labelType,bl.PK_ID pkId,bl.LABEL_IMAGE  labelImage,wl.PK_WARES  pkWares from BD_WARES_LABEL wl
        left join  BD_LABEL bl on bl.PK_ID = wl.PK_LABLE
        where 1 = 1 and wl.DEL_FLAG=0
        <if test="pkWares != null">
            and wl.PK_WARES = #{pkWares}
        </if>
        <if test="labelType != null">
            and bl.LABEL_TYPE = #{labelType}
        </if>
        <if test="pkIdList != null and pkIdList.size > 0">
            and wl.PK_WARES in
            <foreach collection="pkIdList" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
    </select>

</mapper>
