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