<?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.IntegralExchangeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.goods_center.model.IntegralExchange">
        <id column="id" property="id"/>
        <result column="goods_id" property="goodsId"/>
        <result column="name" property="name"/>
        <result column="description" property="description"/>
        <result column="thumb" property="thumb"/>
        <result column="stock" property="stock"/>
        <result column="exchange" property="exchange"/>
        <result column="p_num" property="pNum"/>
        <result column="status" property="status"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <select id="page" resultType="com.fzm.mall.server.admin.goods_center.entity.vo.IntegralExchangeVO">
        SELECT
        goods_id,name,thumb,description,p_num,stock,status,exchange,create_time
        FROM
        goods_integral_exchange
        <where>
            status != 0
            <if test="goodsId!=null and goodsId!=''">
                AND
                goods_id = #{goodsId}
            </if>
            <if test="goodsName!=null and goodsName!=''">
                <bind name="goodsName" value="'%' + goodsName + '%'"/>
                AND
                name LIKE #{goodsName}
            </if>
            <if test="addTimeHead!=null">
                AND
                create_time &gt;= #{addTimeHead}
            </if>
            <if test="addTimeTail!=null">
                AND
                create_time &lt;= #{addTimeTail}
            </if>
        </where>
        ORDER BY
        create_time
        DESC
    </select>

</mapper>
