144 lines
4.8 KiB
XML
144 lines
4.8 KiB
XML
<?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.chaozhanggui.system.cashierservice.dao.TbActivateMapper">
|
|
|
|
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbActivate" id="TbActivateMap">
|
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
|
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
|
<result property="amount" column="amount" jdbcType="INTEGER"/>
|
|
<result property="giftAmount" column="gift_amount" jdbcType="INTEGER"/>
|
|
<result property="isUseCoupon" column="is_use_coupon" jdbcType="INTEGER"/>
|
|
<result property="couponId" column="coupon_id" jdbcType="INTEGER"/>
|
|
<result property="num" column="num" jdbcType="INTEGER"/>
|
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
</resultMap>
|
|
|
|
<sql id="Base_Column_List">
|
|
id
|
|
, shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time </sql>
|
|
|
|
<!--查询单个-->
|
|
<select id="selectByShopId" resultMap="TbActivateMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
|
|
from tb_activate
|
|
where shop_id = #{shopId}
|
|
</select>
|
|
|
|
<select id="queryById" resultMap="TbActivateMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
|
|
from tb_activate
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<select id="selectByAmount" resultMap="TbActivateMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
|
|
from tb_activate
|
|
where shop_id = #{shopId}
|
|
and amount <= #{amount}
|
|
order by amount desc
|
|
limit 1
|
|
</select>
|
|
|
|
|
|
<!--查询指定行数据-->
|
|
<select id="queryAll" resultMap="TbActivateMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
|
|
from tb_activate
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="shopId != null">
|
|
and shop_id = #{shopId}
|
|
</if>
|
|
<if test="amount != null">
|
|
and amount = #{amount}
|
|
</if>
|
|
<if test="giftAmount != null">
|
|
and gift_amount = #{giftAmount}
|
|
</if>
|
|
<if test="isUseCoupon != null">
|
|
and is_use_coupon = #{isUseCoupon}
|
|
</if>
|
|
<if test="couponId != null">
|
|
and coupon_id = #{couponId}
|
|
</if>
|
|
<if test="num != null">
|
|
and num = #{num}
|
|
</if>
|
|
<if test="createTime != null">
|
|
and create_time = #{createTime}
|
|
</if>
|
|
<if test="updateTime != null">
|
|
and update_time = #{updateTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<!--新增所有列-->
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
insert into tb_activate(shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time)
|
|
values (#{shopId}, #{amount}, #{giftAmount}, #{isUseCoupon}, #{couponId}, #{num}, #{createTime}, #{updateTime})
|
|
</insert>
|
|
|
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
|
insert into tb_activate(shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time)
|
|
values
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
(#{entity.shopId}, #{entity.amount}, #{entity.giftAmount}, #{entity.isUseCoupon}, #{entity.couponId},
|
|
#{entity.num}, #{entity.createTime}, #{entity.updateTime})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!--通过主键修改数据-->
|
|
<update id="update">
|
|
update tb_activate
|
|
<set>
|
|
<if test="shopId != null">
|
|
shop_id = #{shopId},
|
|
</if>
|
|
<if test="amount != null">
|
|
amount = #{amount},
|
|
</if>
|
|
<if test="giftAmount != null">
|
|
gift_amount = #{giftAmount},
|
|
</if>
|
|
<if test="isUseCoupon != null">
|
|
is_use_coupon = #{isUseCoupon},
|
|
</if>
|
|
<if test="couponId != null">
|
|
coupon_id = #{couponId},
|
|
</if>
|
|
<if test="num != null">
|
|
num = #{num},
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time = #{createTime},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time = #{updateTime},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!--通过主键删除-->
|
|
<delete id="deleteById">
|
|
delete
|
|
from tb_activate
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
</mapper>
|
|
|