You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.5 KiB
112 lines
3.5 KiB
<?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.DishMapper">
|
|
|
|
<select id="pageQuery" resultType="com.sky.entity.Dish">
|
|
select * from dish
|
|
<where>
|
|
<if test="status!=null">
|
|
and status=#{status},
|
|
</if>
|
|
<if test="categoryId!=null">
|
|
and category_id=#{categoryId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<insert id="save" useGeneratedKeys="true" keyProperty="id">
|
|
insert into dish(name, category_id, price, image, description, create_time, update_time, create_user,
|
|
update_user, status)
|
|
values (#{name}, #{categoryId}, #{price}, #{image}, #{description}, #{createTime}, #{updateTime}, #{createUser},
|
|
#{updateUser}, #{status})
|
|
</insert>
|
|
|
|
<insert id="insertBatchFlavors">
|
|
insert into dish_flavor(dish_id, name, value)
|
|
values
|
|
<foreach collection="flavors" item="flavor" separator=",">
|
|
(#{flavor.dishId},#{flavor.name},#{flavor.value})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<delete id="deleteBatch">
|
|
delete from dish where id in
|
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="getByIdBatch" resultType="com.sky.entity.Dish">
|
|
select * from dish where id in
|
|
<foreach collection="ids" item="id" close=")" open="(" separator=",">
|
|
#{id}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="countMealDish" resultType="java.lang.Integer">
|
|
select count(*) from setmeal_dish where id in
|
|
<foreach collection="ids" separator="," open="(" close=")" item="id">
|
|
#{id}
|
|
</foreach>
|
|
</select>
|
|
|
|
<update id="updateDish">
|
|
update dish
|
|
<set>
|
|
<if test="name!=null and name!=''">
|
|
name=#{name},
|
|
</if>
|
|
<if test="categoryId!=null">
|
|
category_id=#{categoryId},
|
|
</if>
|
|
<if test="description!=null and description!=''">
|
|
description=#{description},
|
|
</if>
|
|
<if test="image!=null and image!=''">
|
|
image=#{image},
|
|
</if>
|
|
<if test="price!=null">
|
|
price=#{price},
|
|
</if>
|
|
<if test="status!=null">
|
|
status=#{status}
|
|
</if>
|
|
</set>
|
|
where id=#{id}
|
|
</update>
|
|
|
|
<delete id="deleteBatchFlavors">
|
|
delete from dish_flavor where dish_id in
|
|
<foreach collection="flavors" item="flavor" close=")" open="(" separator=",">
|
|
#{flavor.dishId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="getFlavorById" resultType="com.sky.entity.DishFlavor">
|
|
select *
|
|
from dish_flavor
|
|
where dish_id = #{id}
|
|
</select>
|
|
<select id="countByMap" resultType="java.lang.Integer">
|
|
select count(id) from dish
|
|
<where>
|
|
<if test="status != null">
|
|
and status = #{status}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="getByCategoryId" resultType="com.sky.entity.Dish">
|
|
select * from dish
|
|
<where>
|
|
<if test="categoryId!=null">
|
|
category_id=#{categoryId}
|
|
</if>
|
|
<if test="status!=null">
|
|
and status=#{status}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
</mapper> |