parent
2a7d2572ad
commit
c9c036c244
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/sky-take-out.iml" filepath="$PROJECT_DIR$/sky-take-out.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.sky.mapper;
|
||||||
|
|
||||||
|
import com.sky.entity.DishFlavor;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DishFlavorMapper {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 批量插入口味数据
|
||||||
|
* */
|
||||||
|
void insertBatch(List<DishFlavor> flavors);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 根据菜品id删除对应口味
|
||||||
|
* */
|
||||||
|
@Delete("delete from dish_flavor where dish_id = #{dishId}")
|
||||||
|
void deleteByDishId(Long dishId);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 根据菜品id集合批量删除关联的口味数据
|
||||||
|
* */
|
||||||
|
void deleteByDishIds(List<Long> dishIds);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 根据菜品id返回口味数据
|
||||||
|
* */
|
||||||
|
@Select("select * from dish_flavor where dish_id = #{dishId}")
|
||||||
|
List<DishFlavor> getByDishId(Long dishId);
|
||||||
|
}
|
@ -1,7 +1,76 @@
|
|||||||
package com.sky.mapper;
|
package com.sky.mapper;
|
||||||
|
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.sky.annotation.AutoFill;
|
||||||
|
import com.sky.dto.SetmealPageQueryDTO;
|
||||||
import com.sky.entity.Setmeal;
|
import com.sky.entity.Setmeal;
|
||||||
|
import com.sky.enumeration.OperationType;
|
||||||
|
import com.sky.vo.DishItemVO;
|
||||||
|
import com.sky.vo.SetmealVO;
|
||||||
|
import org.apache.ibatis.annotations.Insert;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
public interface SetmealMapper {
|
public interface SetmealMapper {
|
||||||
Setmeal getById(Long setmealId);
|
|
||||||
|
/**
|
||||||
|
* 根据分类id查询套餐的数量
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Select("select count(id) from setmeal where category_id = #{categoryId}")
|
||||||
|
Integer countByCategoryId(Long id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 新增套餐
|
||||||
|
* */
|
||||||
|
@AutoFill(OperationType.INSERT)
|
||||||
|
void insert(Setmeal setmeal);
|
||||||
|
|
||||||
|
Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 根据套餐id获取套餐数据
|
||||||
|
* */
|
||||||
|
@Select("select * from setmeal where id = #{id}")
|
||||||
|
Setmeal getById(Long Id);
|
||||||
|
|
||||||
|
void deleteBatch(List<Long> ids);
|
||||||
|
|
||||||
|
|
||||||
|
@AutoFill(OperationType.UPDATE)
|
||||||
|
void updateWithDish(Setmeal setmeal);
|
||||||
|
|
||||||
|
@Update("update setmeal set status = #{status} where id = #{id}")
|
||||||
|
void startOrStop(Setmeal setmeal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态条件查询套餐
|
||||||
|
* @param setmeal
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Setmeal> list(Setmeal setmeal);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据套餐id查询菜品选项
|
||||||
|
* @param setmealId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Select("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}")
|
||||||
|
List<DishItemVO> getDishItemBySetmealId(Long setmealId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件统计套餐数量
|
||||||
|
* @param map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer countByMap(Map map);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.sky.service;
|
||||||
|
|
||||||
|
import com.sky.dto.DishDTO;
|
||||||
|
import com.sky.dto.DishPageQueryDTO;
|
||||||
|
import com.sky.entity.Dish;
|
||||||
|
import com.sky.result.PageResult;
|
||||||
|
import com.sky.vo.DishVO;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DishService {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 新增菜品和对应的口味
|
||||||
|
* */
|
||||||
|
void saveWithFlavor(DishDTO dishDTO);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 菜品分页查询
|
||||||
|
* */
|
||||||
|
PageResult pageQuery(DishPageQueryDTO dishPageQueryDTO);
|
||||||
|
|
||||||
|
void deleteBatch(List<Long> ids);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 根据菜品id返回菜品和口味数据
|
||||||
|
* */
|
||||||
|
DishVO getById(Long id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 根据id修改菜品基本信息和对应口味信息
|
||||||
|
* */
|
||||||
|
void updateWithFlavor(DishDTO dishDTO);
|
||||||
|
|
||||||
|
List<Dish> getByCategoryId(Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件查询菜品和口味
|
||||||
|
* @param dish
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DishVO> listWithFlavor(Dish dish);
|
||||||
|
|
||||||
|
|
||||||
|
void startOrStop(Integer status, Integer id);
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?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.DishFlavorMapper">
|
||||||
|
|
||||||
|
<insert id="insertBatch">
|
||||||
|
insert into dish_flavor (dish_id, name, value) values
|
||||||
|
<foreach collection="list" item="flavor" separator=",">
|
||||||
|
(#{flavor.dishId},#{flavor.name},#{flavor.value})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteByDishIds">
|
||||||
|
delete from dish_flavor where dish_id in
|
||||||
|
<foreach collection="dishIds" open="(" close=")" separator="," item="dishId">
|
||||||
|
#{dishId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
@ -0,0 +1,93 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<insert id="insert" 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>
|
||||||
|
|
||||||
|
<delete id="deleteByIds">
|
||||||
|
delete from dish where id in
|
||||||
|
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
</delete>
|
||||||
|
<select id="pageQuery" resultType="com.sky.vo.DishVO" parameterType="com.sky.dto.DishPageQueryDTO">
|
||||||
|
select d.*,cg.name categoryName from dish d,category cg
|
||||||
|
<where>
|
||||||
|
d.category_id = cg.id
|
||||||
|
<if test="name !=null">
|
||||||
|
and d.name like concat('%',#{name},'%')
|
||||||
|
</if>
|
||||||
|
<if test="categoryId !=null">
|
||||||
|
and d.category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
and d.status = #{status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by d.create_time desc
|
||||||
|
</select>
|
||||||
|
<select id="getByCategoryId" resultType="com.sky.entity.Dish">
|
||||||
|
select * from dish
|
||||||
|
<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>
|
||||||
|
order by create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="update" parameterType="com.sky.entity.Dish">
|
||||||
|
update dish
|
||||||
|
<set>
|
||||||
|
<if test="name != null">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null">
|
||||||
|
category_id = #{categoryId},
|
||||||
|
</if>
|
||||||
|
<if test="price != null">
|
||||||
|
price = #{price},
|
||||||
|
</if>
|
||||||
|
<if test="image != null">
|
||||||
|
image = #{image},
|
||||||
|
</if>
|
||||||
|
<if test="description != null">
|
||||||
|
description = #{description},
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
status = #{status},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time = #{updateTime},
|
||||||
|
</if>
|
||||||
|
<if test="updateUser != null">
|
||||||
|
update_user = #{updateUser},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="countByMap" resultType="java.lang.Integer">
|
||||||
|
select count(id) from dish
|
||||||
|
<where>
|
||||||
|
<if test="status != null">
|
||||||
|
and status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null">
|
||||||
|
and category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -0,0 +1,29 @@
|
|||||||
|
<?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.SetmealDishMapper">
|
||||||
|
|
||||||
|
<insert id="insertBatch">
|
||||||
|
insert into setmeal_dish(setmeal_id, dish_id, name, price, copies)
|
||||||
|
values
|
||||||
|
<foreach collection="list" item="setmealDish" separator=",">
|
||||||
|
(#{setmealDish.setmealId},#{setmealDish.dishId},#{setmealDish.name},#{setmealDish.price},#{setmealDish.copies})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteBySetmealIds">
|
||||||
|
delete from setmeal_dish
|
||||||
|
where setmeal_id in
|
||||||
|
<foreach collection="setmealIds" item="setmealId" open="(" close=")" separator=",">
|
||||||
|
#{setmealId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="getSetmealIdsByDishIds" resultType="java.lang.Long">
|
||||||
|
select setmeal_id from setmeal_dish
|
||||||
|
where dish_id in
|
||||||
|
<foreach collection="dishIds" item="dishId" separator="," open="(" close=")">
|
||||||
|
#{dishId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -0,0 +1,77 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="insert">
|
||||||
|
insert into setmeal(category_id, name, price, description, image, create_time, update_time, create_user, update_user,status)
|
||||||
|
values(#{categoryId},#{name},#{price},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})
|
||||||
|
</insert>
|
||||||
|
<delete id="deleteBatch">
|
||||||
|
delete from setmeal
|
||||||
|
where id in
|
||||||
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
<select id="pageQuery" resultType="com.sky.vo.SetmealVO">
|
||||||
|
select s.*,c.name categoryName from setmeal s,category c
|
||||||
|
<where>
|
||||||
|
s.category_id = c.id
|
||||||
|
<if test="name !=null">
|
||||||
|
and s.name like concat('%',#{name},'%')
|
||||||
|
</if>
|
||||||
|
<if test="categoryId !=null">
|
||||||
|
and s.category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
and s.status = #{status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by s.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="updateWithDish">
|
||||||
|
update setmeal
|
||||||
|
<set>
|
||||||
|
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||||
|
<if test="name != null">name = #{name},</if>
|
||||||
|
<if test="price != null">price = #{price},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="description != null">description = #{description},</if>
|
||||||
|
<if test="image != null">image = #{image},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="updateUser != null">update_user = #{updateUser}</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="list" parameterType="Setmeal" resultType="com.sky.entity.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>
|
||||||
|
|
||||||
|
<select id="countByMap" resultType="java.lang.Integer">
|
||||||
|
select count(id) from setmeal
|
||||||
|
<where>
|
||||||
|
<if test="status != null">
|
||||||
|
and status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null">
|
||||||
|
and category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in new issue