根据id查询套餐、菜品起售停售(TODO)
This commit is contained in:
@@ -5,6 +5,7 @@ import com.sky.dto.SetmealPageQueryDTO;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.result.Result;
|
||||
import com.sky.service.SetmealService;
|
||||
import com.sky.vo.SetmealVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -60,4 +61,17 @@ public class SetmealController {
|
||||
setmealService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询套餐
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation("根据id查询套餐")
|
||||
public Result<SetmealVO> getById(@PathVariable Long id){
|
||||
log.info("根据id查询套餐");
|
||||
SetmealVO setmealVO = setmealService.getByIdWithSetmealDishes(id);
|
||||
return Result.success(setmealVO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
import com.sky.entity.Dish;
|
||||
import com.sky.entity.SetmealDish;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,4 +19,7 @@ public interface SetmealDishMapper {
|
||||
void insertBatch(List<SetmealDish> setmealDishes);
|
||||
|
||||
void deleteBySetmealIds(List<Long> setmealIds);
|
||||
|
||||
@Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
|
||||
List<SetmealDish> selectBySetmealId(Long setmealId);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.sky.service;
|
||||
import com.sky.dto.SetmealDTO;
|
||||
import com.sky.dto.SetmealPageQueryDTO;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.vo.SetmealVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -27,4 +28,11 @@ public interface SetmealService {
|
||||
* @param ids
|
||||
*/
|
||||
void deleteBatch(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据id查询套餐(及关联菜品)
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
SetmealVO getByIdWithSetmealDishes(Long id);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.sky.constant.MessageConstant;
|
||||
import com.sky.constant.StatusConstant;
|
||||
import com.sky.dto.SetmealDTO;
|
||||
import com.sky.dto.SetmealPageQueryDTO;
|
||||
import com.sky.entity.Dish;
|
||||
import com.sky.entity.Setmeal;
|
||||
import com.sky.entity.SetmealDish;
|
||||
import com.sky.exception.DeletionNotAllowedException;
|
||||
@@ -13,6 +14,7 @@ import com.sky.mapper.SetmealDishMapper;
|
||||
import com.sky.mapper.SetmealMapper;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.service.SetmealService;
|
||||
import com.sky.vo.SetmealVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -81,4 +83,21 @@ public class SetmealServiceImpl implements SetmealService {
|
||||
//删除setmeal_dish数据
|
||||
setmealDishMapper.deleteBySetmealIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询套餐(及关联菜品)
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SetmealVO getByIdWithSetmealDishes(Long id) {
|
||||
SetmealVO setmealVO = new SetmealVO();
|
||||
//查询基本套餐信息
|
||||
Setmeal setmeal = setmealMapper.selectById(id);
|
||||
BeanUtils.copyProperties(setmeal,setmealVO);
|
||||
//查询对应菜品信息
|
||||
List<SetmealDish> setmealDishes = setmealDishMapper.selectBySetmealId(id);
|
||||
setmealVO.setSetmealDishes(setmealDishes);
|
||||
return setmealVO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user