<?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.fzm.mall.server.admin.goods_center.mapper.ExternalTokenMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.goods_center.model.ExternalToken">
        <id column="id" property="id" />
        <result column="commodity_pass_id" property="commodityPassId" />
        <result column="label_name" property="labelName" />
        <result column="token_id" property="tokenId" />
        <result column="goods_type" property="goodsType" />
        <result column="name" property="name" />
        <result column="publish_time" property="publishTime" />
        <result column="publisher" property="publisher" />
        <result column="goods_id" property="goodsId" />
        <result column="goods_name" property="goodsName" />
        <result column="available_number" property="availableNumber" />
        <result column="bind_number" property="bindNumber" />
        <result column="merchant_id" property="merchantId" />
        <result column="status" property="status" />
        <result column="type" property="type" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="hash" property="hash" />
    </resultMap>

    <select id="page" resultType="com.fzm.mall.server.admin.goods_center.entity.dto.ExternalTokenDTO">
        select *
        from external_token
        <where>
            merchant_id = #{merchantId}
            <if test="labelName != null and labelName != ''">
                and label_name like CONCAT('%', #{labelName},'%')
            </if>
            <if test="goodsId != null and goodsId != ''">
                and goods_id like CONCAT('%', #{goodsId},'%')
            </if>
            <if test="goodsName != null and goodsName != ''">
                and goods_name like CONCAT('%', #{goodsName},'%')
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
        </where>
        order by create_time desc
    </select>
</mapper>
