sky-take-out/sky-server/src/main/resources/mapper/SetmealMapper.xml

44 lines
1.7 KiB
XML
Raw Normal View History

<?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.sky.mapper.SetmealMapper">
2024-01-08 22:53:45 +08:00
<!-- 向套餐表插入数据 -->
<insert id="insert" parameterType="Setmeal" useGeneratedKeys="true" keyProperty="id">
insert into setmeal
(category_id, name, price, status, description, image, create_time, update_time, create_user, update_user)
values (#{categoryId}, #{name}, #{price}, #{status}, #{description}, #{image}, #{createTime}, #{updateTime},
#{createUser}, #{updateUser})
</insert>
<!-- 根据分类id查询套餐的数量 -->
<select id="countByCategoryId" resultType="java.lang.Integer">
select count(id)
from setmeal
where category_id = #{categoryId}
</select>
2024-01-08 16:56:43 +08:00
<!-- 动态条件查询套餐 -->
<select id="list" parameterType="Setmeal" resultType="Setmeal">
select * from setmeal
<where>
<if test="name != null">
and name like concat('%',#{name},'%')
</if>
<if test="categoryId != null">
and category_id = #{categoryId}
</if>
<if test="status != null">
and status = #{status}
</if>
</where>
</select>
<!-- 根据套餐id查询菜品选项 -->
<select id="getDishItemBySetmealId" resultType="com.sky.vo.DishItemVO">
select sd.name, sd.copies, d.image, d.description
from setmeal_dish sd
left join dish d on sd.dish_id = d.id
where sd.setmeal_id = #{setmealId}
</select>
</mapper>