<?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.product.mapper.BladeProductMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="org.springblade.product.entity.BladeProduct">
        <result column="ID" property="id" />
        <result column="CATEGORYID" property="categoryid" />
        <result column="CATEGORYNAME" property="categoryname" />
        <result column="CPID2" property="cpid2" />
        <result column="CPID" property="cpid" />
        <result column="CPNAME" property="cpname" />
        <result column="SPID" property="spid" />
        <result column="SPNAME" property="spname" />
        <result column="CPORDER" property="cporder" />
        <result column="VACPRODUCTID" property="vacproductid" />
        <result column="SPCODE" property="spcode" />
        <result column="SPCODENAME" property="spcodename" />
        <result column="PRICE" property="price" />
        <result column="REGTIME" property="regtime" />
        <result column="STARTDATE" property="startdate" />
        <result column="ENDDATE" property="enddate" />
        <result column="FLOWTYPE" property="flowtype" />
        <result column="MAXFLOW" property="maxflow" />
        <result column="SHORTNAME" property="shortname" />
        <result column="ISIMPORTANT" property="isimportant" />
        <result column="CPTYPE" property="cptype" />
        <result column="ISORDER" property="isorder" />
        <result column="ISDIANBO" property="isdianbo" />
        <result column="ISPRM" property="isprm" />
        <result column="INMEAL" property="inmeal" />
        <result column="INCOMESTYLE" property="incomestyle" />
        <result column="IWIGHT" property="iwight" />
        <result column="KC_SPID" property="kcSpid" />
        <result column="PRODUCT_ID" property="productId" />
        <result column="SXXHY_SETID" property="sxxhySetid" />
        <result column="VIPS" property="vips" />
        <result column="CPTYPE2" property="cptype2" />
        <result column="CATEGORYNAME2" property="categoryname2" />
        <result column="FULL_CPTYPE" property="fullCptype" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID, CATEGORYID, CATEGORYNAME, CPID2, CPID, CPNAME, SPID, SPNAME, CPORDER, VACPRODUCTID, SPCODE, SPCODENAME, PRICE, REGTIME, STARTDATE, ENDDATE, FLOWTYPE, MAXFLOW, SHORTNAME, ISIMPORTANT, CPTYPE, ISORDER, ISDIANBO, ISPRM, INMEAL, INCOMESTYLE, IWIGHT, KC_SPID, PRODUCT_ID, SXXHY_SETID, VIPS, CPTYPE2, CATEGORYNAME2, FULL_CPTYPE
    </sql>

    <select id="getPageByQuery" resultMap="BaseResultMap">
        SELECT
        *
        FROM
        blade_product
        where 1=1
        <if test="query.productName != null and query.productName != ''">
            and SPNAME LIKE CONCAT('%',#{query.productName},'%')
        </if>
        <if test="query.spid != null and query.spid != ''">
            and SPID = #{query.spid}
        </if>
    </select>
</mapper>
