SmartProductMapper.xml 3.17 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="com.glsx.smart.dao.mapper.SmartProductMapper">
    <resultMap id="BaseResultMap" type="com.glsx.smart.dao.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>
    <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="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>
</mapper>