<?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.miaxis.fulu.mapper.FuluCommodityInfoMapper">

    <resultMap type="FuluCommodityInfo" id="FuluCommodityInfoResult">
        <result property="id"    column="id"    />
        <result property="iconId"    column="icon_id"    />
        <result property="name"    column="name"    />
        <result property="introduction"    column="introduction"    />
        <result property="remark"    column="remark"    />
        <result property="productIds"    column="product_ids"    />
        <result property="fuluGoodsType"    column="fulu_goods_type"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFuluCommodityInfoVo">
        select * from fulu_commodity_info
    </sql>

    <select id="selectFuluCommodityInfoList" resultType="com.miaxis.fulu.vo.FuluCommodityInfoVo">
        select
        ci.id,
        ci.`name`,
        ci.introduction,
        ci.`remark`,
        f.file_url AS iconUrl,
        ci.product_ids,
        ci.fulu_goods_type,
        dd.dict_label as fuluGoodsTypeName,
        ci.create_time,
        ci.update_time,
        ci.`status`
        from fulu_commodity_info ci
        LEFT JOIN file_info f on f.file_id = ci.icon_id
        LEFT JOIN sys_dict_data dd ON dd.dict_type = 'fulu_goods_type' and dd.dict_value = ci.fulu_goods_type
        <where>
            <if test="name != null  and name != ''"> and ci.name like concat('%', #{name}, '%')</if>
            <if test="productIds != null  and productIds != ''"> and ci.product_ids like concat('%', #{productIds}, '%')</if>
            <if test="fuluGoodsType != null "> and ci.fulu_goods_type = #{fuluGoodsType}</if>
            <if test="status != null  and status != ''"> and ci.status = #{status}</if>
        </where>
    </select>


    <select id="getFuLuById" resultType="com.miaxis.fulu.vo.FuluCommodityInfoVo">
        select
        ci.id,
        ci.`name`,
        ci.introduction,
        ci.`remark`,
        f.file_url AS iconUrl,
        ci.product_ids,
        ci.fulu_goods_type,
        ci.`status`
        from fulu_commodity_info ci
        LEFT JOIN file_info f on f.file_id = ci.icon_id
        LEFT JOIN sys_dict_data dd ON dd.dict_type = 'fulu_goods_type' and dd.dict_value = ci.fulu_goods_type
        where ci.id = #{id}
    </select>

    <select id="getFuluDataList" resultType="com.miaxis.fulu.vo.FuluCommodityInfoVo">
        select
        ci.id,
        ci.`name`,
        ci.introduction,
        ci.`remark`,
        f.file_url AS iconUrl,
        ci.product_ids,
        ci.fulu_goods_type,
        ci.`status`
        from fulu_commodity_info ci
        LEFT JOIN file_info f on f.file_id = ci.icon_id
        where ci.status = '0'
    </select>

</mapper>