117 lines
3.9 KiB
XML
117 lines
3.9 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.TbCouponProductMapper">
|
|
|
|
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbCouponProduct" id="TbCouponProductMap">
|
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
|
<result property="couponId" column="coupon_id" jdbcType="INTEGER"/>
|
|
<result property="productId" column="product_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
|
|
, coupon_id, product_id, num, create_time, update_time </sql>
|
|
|
|
<!--查询单个-->
|
|
<select id="queryById" resultMap="TbCouponProductMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
|
|
from tb_coupon_product
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<!--查询指定行数据-->
|
|
<select id="queryAll" resultMap="TbCouponProductMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
|
|
from tb_coupon_product
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="couponId != null">
|
|
and coupon_id = #{couponId}
|
|
</if>
|
|
<if test="productId != null">
|
|
and product_id = #{productId}
|
|
</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>
|
|
|
|
<select id="queryAllByCouponId" resultMap="TbCouponProductMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
from tb_coupon_product
|
|
where
|
|
coupon_id = #{couponId}
|
|
</select>
|
|
|
|
<select id="queryProsByActivateId" resultType="java.lang.String">
|
|
select CONCAT(tb_product.name, '*', SUM(tb_coupon_product.num)*#{num})
|
|
from tb_coupon_product
|
|
LEFT JOIN tb_product ON tb_coupon_product.product_id = tb_product.id
|
|
where coupon_id = #{couponId}
|
|
group by tb_coupon_product.product_id
|
|
</select>
|
|
|
|
<!--新增所有列-->
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
insert into tb_coupon_product(coupon_id, product_id, num, create_time, update_time)
|
|
values (#{couponId}, #{productId}, #{num}, #{createTime}, #{updateTime})
|
|
</insert>
|
|
|
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
|
insert into tb_coupon_product(coupon_id, product_id, num, create_time, update_time)
|
|
values
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
(#{entity.couponId}, #{entity.productId}, #{entity.num}, #{entity.createTime}, #{entity.updateTime})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!--通过主键修改数据-->
|
|
<update id="update">
|
|
update tb_coupon_product
|
|
<set>
|
|
<if test="couponId != null">
|
|
coupon_id = #{couponId},
|
|
</if>
|
|
<if test="productId != null">
|
|
product_id = #{productId},
|
|
</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_coupon_product
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
</mapper>
|
|
|