Files
wb-java-nc-shop/target/classes/mapper/ProductToppingMapper.xml

38 lines
1.4 KiB
XML
Raw Permalink Normal View History

2026-01-11 18:14:42 +08:00
<?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.nlshop.mapper.ProductToppingMapper">
<resultMap id="BaseResultMap" type="com.nlshop.entity.ProductTopping">
<id column="id" property="id"/>
<result column="product_id" property="productId"/>
<result column="topping_name" property="toppingName"/>
<result column="price" property="price"/>
</resultMap>
<insert id="insert" parameterType="com.nlshop.entity.ProductTopping" useGeneratedKeys="true" keyProperty="id">
INSERT INTO product_topping (product_id, topping_name, price)
VALUES (#{productId}, #{toppingName}, #{price})
</insert>
<select id="selectByProductId" resultMap="BaseResultMap">
SELECT * FROM product_topping WHERE product_id = #{productId}
</select>
<select id="selectById" resultMap="BaseResultMap">
SELECT * FROM product_topping WHERE id = #{id}
</select>
<update id="update" parameterType="com.nlshop.entity.ProductTopping">
UPDATE product_topping
SET topping_name = #{toppingName}, price = #{price}
WHERE id = #{id}
</update>
<delete id="delete">
DELETE FROM product_topping WHERE id = #{id}
</delete>
<delete id="deleteByProductId">
DELETE FROM product_topping WHERE product_id = #{productId}
</delete>
</mapper>