菜品起售停售
This commit is contained in:
parent
573c1d8e3c
commit
3eb910ad07
|
@ -52,6 +52,7 @@ public class DishController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品批量删除
|
* 菜品批量删除
|
||||||
|
*
|
||||||
* @param ids List<Long>
|
* @param ids List<Long>
|
||||||
* @return Result<String>
|
* @return Result<String>
|
||||||
*/
|
*/
|
||||||
|
@ -65,6 +66,7 @@ public class DishController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据id查询菜品
|
* 根据id查询菜品
|
||||||
|
*
|
||||||
* @param id Long
|
* @param id Long
|
||||||
* @return Result<DishVO>
|
* @return Result<DishVO>
|
||||||
*/
|
*/
|
||||||
|
@ -78,6 +80,7 @@ public class DishController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改菜品
|
* 修改菜品
|
||||||
|
*
|
||||||
* @param dishDTO DishDTO
|
* @param dishDTO DishDTO
|
||||||
* @return Result<String>
|
* @return Result<String>
|
||||||
*/
|
*/
|
||||||
|
@ -88,4 +91,18 @@ public class DishController {
|
||||||
dishService.updateWithFlavor(dishDTO);
|
dishService.updateWithFlavor(dishDTO);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品起售停售
|
||||||
|
*
|
||||||
|
* @param status 状态
|
||||||
|
* @return Result<String>
|
||||||
|
*/
|
||||||
|
@ApiOperation("菜品起售停售")
|
||||||
|
@PostMapping("/status/{status}")
|
||||||
|
public Result<String> startOrStop(@PathVariable Integer status, Long id) {
|
||||||
|
// 1为起售,0为停售
|
||||||
|
dishService.startOrStop(status, id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.sky.entity.Dish;
|
||||||
import com.sky.enumeration.OperationType;
|
import com.sky.enumeration.OperationType;
|
||||||
import com.sky.vo.DishVO;
|
import com.sky.vo.DishVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -32,6 +31,7 @@ public interface DishMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品分页查询
|
* 菜品分页查询
|
||||||
|
*
|
||||||
* @param dishPageQueryDTO DishPageQueryDTO
|
* @param dishPageQueryDTO DishPageQueryDTO
|
||||||
* @return Page<DishVO>
|
* @return Page<DishVO>
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +39,7 @@ public interface DishMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断当前菜品是否能被删除---是否存在起售菜品
|
* 判断当前菜品是否能被删除---是否存在起售菜品
|
||||||
|
*
|
||||||
* @param id Long
|
* @param id Long
|
||||||
* @return Dish
|
* @return Dish
|
||||||
*/
|
*/
|
||||||
|
@ -46,18 +47,21 @@ public interface DishMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜品表中的菜品数据
|
* 删除菜品表中的菜品数据
|
||||||
|
*
|
||||||
* @param id Long
|
* @param id Long
|
||||||
*/
|
*/
|
||||||
void deleteById(Long id);
|
void deleteById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜品表中的菜品数据
|
* 删除菜品表中的菜品数据
|
||||||
|
*
|
||||||
* @param ids List<Long>
|
* @param ids List<Long>
|
||||||
*/
|
*/
|
||||||
void deleteByIds(List<Long> ids);
|
void deleteByIds(List<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除原有口味数据
|
* 删除原有口味数据
|
||||||
|
*
|
||||||
* @param dish Dish
|
* @param dish Dish
|
||||||
*/
|
*/
|
||||||
@AutoFill(value = OperationType.UPDATE)
|
@AutoFill(value = OperationType.UPDATE)
|
||||||
|
@ -65,6 +69,7 @@ public interface DishMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 条件查询菜品和口味
|
* 条件查询菜品和口味
|
||||||
|
*
|
||||||
* @param dish Dish
|
* @param dish Dish
|
||||||
* @return List<Dish>
|
* @return List<Dish>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package com.sky.mapper;
|
package com.sky.mapper;
|
||||||
|
|
||||||
|
import com.sky.annotation.AutoFill;
|
||||||
import com.sky.entity.Setmeal;
|
import com.sky.entity.Setmeal;
|
||||||
|
import com.sky.enumeration.OperationType;
|
||||||
import com.sky.vo.DishItemVO;
|
import com.sky.vo.DishItemVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -25,4 +26,11 @@ public interface SetMealDishMapper {
|
||||||
*/
|
*/
|
||||||
List<DishItemVO> getDishItemBySetmealId(Long setmealId);
|
List<DishItemVO> getDishItemBySetmealId(Long setmealId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品起售停售
|
||||||
|
*
|
||||||
|
* @param setmeal Setmeal
|
||||||
|
*/
|
||||||
|
@AutoFill(OperationType.UPDATE)
|
||||||
|
void update(Setmeal setmeal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ public interface DishService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品分页查询
|
* 菜品分页查询
|
||||||
|
*
|
||||||
* @param dishPageQueryDTO DishPageQueryDTO
|
* @param dishPageQueryDTO DishPageQueryDTO
|
||||||
* @return PageResult
|
* @return PageResult
|
||||||
*/
|
*/
|
||||||
|
@ -25,12 +26,14 @@ public interface DishService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品批量删除
|
* 菜品批量删除
|
||||||
|
*
|
||||||
* @param ids List<Long>
|
* @param ids List<Long>
|
||||||
*/
|
*/
|
||||||
void deleteBatch(List<Long> ids);
|
void deleteBatch(List<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据id查询菜品
|
* 根据id查询菜品
|
||||||
|
*
|
||||||
* @param id Long
|
* @param id Long
|
||||||
* @return DishVO
|
* @return DishVO
|
||||||
*/
|
*/
|
||||||
|
@ -38,14 +41,24 @@ public interface DishService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改菜品
|
* 修改菜品
|
||||||
|
*
|
||||||
* @param dishDTO DishDTO
|
* @param dishDTO DishDTO
|
||||||
*/
|
*/
|
||||||
void updateWithFlavor(DishDTO dishDTO);
|
void updateWithFlavor(DishDTO dishDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 条件查询菜品和口味
|
* 条件查询菜品和口味
|
||||||
|
*
|
||||||
* @param dish Dish
|
* @param dish Dish
|
||||||
* @return List<DishVO>
|
* @return List<DishVO>
|
||||||
*/
|
*/
|
||||||
List<DishVO> listWithFlavor(Dish dish);
|
List<DishVO> listWithFlavor(Dish dish);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品起售停售
|
||||||
|
*
|
||||||
|
* @param status 菜品状态
|
||||||
|
* @param id 菜品id
|
||||||
|
*/
|
||||||
|
void startOrStop(Integer status, Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.sky.dto.DishDTO;
|
||||||
import com.sky.dto.DishPageQueryDTO;
|
import com.sky.dto.DishPageQueryDTO;
|
||||||
import com.sky.entity.Dish;
|
import com.sky.entity.Dish;
|
||||||
import com.sky.entity.DishFlavor;
|
import com.sky.entity.DishFlavor;
|
||||||
|
import com.sky.entity.Setmeal;
|
||||||
import com.sky.exception.DeletionNotAllowedException;
|
import com.sky.exception.DeletionNotAllowedException;
|
||||||
import com.sky.mapper.DishFlavorMapper;
|
import com.sky.mapper.DishFlavorMapper;
|
||||||
import com.sky.mapper.DishMapper;
|
import com.sky.mapper.DishMapper;
|
||||||
|
@ -146,6 +147,7 @@ public class DishServiceImpl implements DishService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 条件查询菜品和口味
|
* 条件查询菜品和口味
|
||||||
|
*
|
||||||
* @param dish Dish
|
* @param dish Dish
|
||||||
* @return List<DishVO>
|
* @return List<DishVO>
|
||||||
*/
|
*/
|
||||||
|
@ -167,4 +169,31 @@ public class DishServiceImpl implements DishService {
|
||||||
|
|
||||||
return dishVOList;
|
return dishVOList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品起售停售
|
||||||
|
*
|
||||||
|
* @param status 菜品状态
|
||||||
|
* @param id 菜品id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void startOrStop(Integer status, Long id) {
|
||||||
|
// 菜品起售停售
|
||||||
|
Dish dish = Dish.builder().id(id).status(status).build();
|
||||||
|
dishMapper.update(dish);
|
||||||
|
// 如果当前菜品是停售,还需要将其套餐也停售
|
||||||
|
if (status.equals(StatusConstant.DISABLE)) {
|
||||||
|
ArrayList<Long> dishIds = new ArrayList<>();
|
||||||
|
dishIds.add(id);
|
||||||
|
List<Long> setMealDishIds = setMealDishMapper.getSetMealDishIds(dishIds);
|
||||||
|
if (setMealDishIds != null && !setMealDishIds.isEmpty()) {
|
||||||
|
for (Long setMealDishId : setMealDishIds) {
|
||||||
|
Setmeal setmeal = Setmeal.builder().id(setMealDishId)
|
||||||
|
.status(StatusConstant.DISABLE)
|
||||||
|
.build();
|
||||||
|
setMealDishMapper.update(setmeal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,38 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.sky.mapper.SetMealDishMapper">
|
<mapper namespace="com.sky.mapper.SetMealDishMapper">
|
||||||
|
|
||||||
|
<!-- 菜品起售停售 -->
|
||||||
|
<update id="update" parameterType="Setmeal">
|
||||||
|
update setmeal
|
||||||
|
<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="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>
|
||||||
|
|
||||||
<!-- 查询对应套餐id -->
|
<!-- 查询对应套餐id -->
|
||||||
<select id="getSetMealDishIds" resultType="java.lang.Long">
|
<select id="getSetMealDishIds" resultType="java.lang.Long">
|
||||||
select *
|
select *
|
||||||
|
|
Loading…
Reference in New Issue