<?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.ssm.manage.mapper.UseStoreMapper">

    <resultMap id="BaseResultMap" type="com.ssm.manage.entity.UseStore">
        <result property="id" column="id"/>
        <result property="couponId" column="coupon_id"/>
        <result property="couponNum" column="coupon_num"/>
        <result property="couponName" column="coupon_name"/>
        <result property="storeId" column="store_id"/>
        <result property="storeNum" column="store_num"/>
        <result property="storeName" column="store_name"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        , coupon_id, coupon_num, coupon_name, store_id, store_num, store_name
    </sql>
    <delete id="deleteuseStore">
        delete from use_store where coupon_num = #{platformCoupon.couponNum} and store_num=#{storeNum}
    </delete>

    <select id="queryAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from use_store
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="couponId != null">
                and coupon_id = #{couponId}
            </if>
            <if test="couponNum != null and couponNum != ''">
                and coupon_num = #{couponNum}
            </if>
            <if test="couponName != null and couponName != ''">
                and coupon_name = #{couponName}
            </if>
            <if test="storeId != null">
                and store_id = #{storeId}
            </if>
            <if test="storeNum != null and storeNum != ''">
                and store_num = #{storeNum}
            </if>
            <if test="storeName != null and storeName != ''">
                and store_name = #{storeName}
            </if>
        </where>
    </select>
    <select id="selectStore" resultMap="BaseResultMap">
        select id as store_id,store_num,store_name from base_store where store_num = #{storeNum}
    </select>


</mapper>