SmartProductMapper.xml 5.61 KB
<?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="cn.com.glsx.smart.modules.mapper.SmartProductMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.smart.modules.entity.SmartProduct">
        <!--@mbg.generated-->
        <!--@Table smart_product-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="product_name" jdbcType="VARCHAR" property="productName"/>
        <result column="icon" jdbcType="BIGINT" property="icon"/>
        <result column="type_id" jdbcType="BIGINT" property="typeId"/>
        <result column="shop_product_id" jdbcType="VARCHAR" property="shopProductId"/>
        <result column="platform_key" jdbcType="VARCHAR" property="platformKey"/>
        <result column="platform_product_id" jdbcType="VARCHAR" property="platformProductId"/>
        <result column="network_key" jdbcType="VARCHAR" property="networkKey"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
    </resultMap>
    <resultMap id="DetailResultMap" type="cn.com.glsx.smart.modules.entity.SmartProduct" extends="BaseResultMap">
        <collection property="iconUrl" column="icon" ofType="cn.com.glsx.smart.modules.entity.SmartProduct" fetchType="eager"
                    select="cn.com.glsx.smart.modules.mapper.SmartSysFileMapper.selectUrlById">
        </collection>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, product_name, icon, type_id, shop_product_id, platform_key, platform_product_id,
        network_key, `status`, remark, create_time, create_by, update_time, update_by
    </sql>

    <select id="getList" resultMap="BaseResultMap">
        select sp.id, sp.product_name, sp.icon, sp.type_id, sp.shop_product_id, sp.platform_key,
            sp.platform_product_id, sp.network_key, sp.status, sp.remark, sp.create_time,
            sp.create_by, sp.update_time, sp.update_by,
            ssf.url iconUrl,
            spt.type_name typeName
        from smart_product sp
        left join smart_sys_file ssf on ssf.id = sp.icon
        left join smart_product_type spt on spt.id = sp.type_id
        <where>
            <if test="productName != null and productName != ''">
                and sp.product_name like concat('%', #{productName,jdbcType=VARCHAR}, '%')
            </if>
        </where>
        order by sp.create_time desc
    </select>

    <select id="getByCondition" parameterType="cn.com.glsx.smart.modules.entity.SmartProduct" resultMap="DetailResultMap">
        select <include refid="Base_Column_List" /> from smart_product
        <where>
            <if test="platformProductId != null and platformProductId != ''" >
                and platform_product_id = #{platformProductId,jdbcType=VARCHAR}
            </if>
            <if test="typeId != null">
                and type_id = #{typeId,jdbcType=BIGINT}
            </if>
            <if test="status != null">
                and `status` = #{status,jdbcType=TINYINT}
            </if>
        </where>
    </select>

    <select id="getByPlatProductIdList" parameterType="java.util.List" resultMap="DetailResultMap">
        select <include refid="Base_Column_List" />
        from smart_product where `status` = 1 and platform_product_id in
        <foreach collection="list" open="(" close=")" separator="," index="index" item="item">
            #{item,jdbcType=VARCHAR}
        </foreach>
    </select>

    <select id="getById" resultMap="BaseResultMap">
        select sp.id, sp.product_name, sp.icon, sp.type_id, sp.shop_product_id, sp.platform_key,
            sp.platform_product_id, sp.network_key, sp.status, sp.remark, sp.create_time,
            sp.create_by, sp.update_time, sp.update_by,
            ssf.url iconUrl,
            spt.type_name typeName
        from smart_product sp
        left join smart_sys_file ssf on ssf.id = sp.icon
        left join smart_product_type spt on spt.id = sp.type_id
        where sp.id = #{id,jdbcType=BIGINT}
    </select>

    <select id="countByProductName" resultType="integer">
        select count(0)
        from smart_product
        where product_name = #{productName,jdbcType=VARCHAR}
    </select>

    <select id="getAllProductList" resultMap="BaseResultMap">
        select sp.id, sp.product_name, sp.icon, sp.type_id, sp.shop_product_id, sp.platform_key,
            sp.platform_product_id, sp.network_key, sp.status, sp.create_time,
            sp.create_by, sp.update_time, sp.update_by,
            concat(ssc.parent_key, ',', spt.category_key) remark,
            ssf.url iconUrl,
            spt.category_key as categoryKey,
            spt.type_name typeName,
            sp.network_key networkKey
        from smart_product sp
        left join smart_product_type spt on spt.id = sp.type_id
        left join smart_sys_file ssf on ssf.id = sp.icon
        left join smart_sys_code ssc on ssc.dict_key = spt.category_key
        where sp.status = 1
    </select>

    <select id="getSupportedCommands" resultType="java.lang.String">
        select distinct ss.order_code
        from smart_product p
        left join smart_scence_supstatus ss on ss.product_id = p.type_id
        where p.platform_product_id = #{platformProductId,jdbcType=VARCHAR}
    </select>
</mapper>