新增套餐、套餐分页查询、根据分类id查询菜品
This commit is contained in:
@@ -2,6 +2,7 @@ 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 org.springframework.stereotype.Service;
|
||||
@@ -42,4 +43,11 @@ public interface DishService {
|
||||
* @param dishDTO
|
||||
*/
|
||||
void updateWithFlavor(DishDTO dishDTO);
|
||||
|
||||
/**
|
||||
* 根据分类id查询菜品
|
||||
* @param categoryId
|
||||
* @return
|
||||
*/
|
||||
List<Dish> selectByCategoryId(String categoryId);
|
||||
}
|
||||
|
||||
22
sky-server/src/main/java/com/sky/service/SetmealService.java
Normal file
22
sky-server/src/main/java/com/sky/service/SetmealService.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.sky.service;
|
||||
|
||||
import com.sky.dto.SetmealDTO;
|
||||
import com.sky.dto.SetmealPageQueryDTO;
|
||||
import com.sky.result.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface SetmealService {
|
||||
/**
|
||||
* 套餐分页查询
|
||||
* @param setmealPageQueryDTO
|
||||
* @return
|
||||
*/
|
||||
PageResult pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);
|
||||
|
||||
/**
|
||||
* 新增套餐
|
||||
* @param setmealDTO
|
||||
*/
|
||||
void insert(SetmealDTO setmealDTO);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sky.constant.MessageConstant;
|
||||
import com.sky.constant.StatusConstant;
|
||||
import com.sky.context.BaseContext;
|
||||
import com.sky.dto.CategoryDTO;
|
||||
import com.sky.dto.CategoryPageQueryDTO;
|
||||
import com.sky.entity.Category;
|
||||
@@ -18,8 +17,6 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -129,7 +126,6 @@ public class CategoryServiceImpl implements CategoryService {
|
||||
*/
|
||||
@Override
|
||||
public List<Category> list(Integer type) {
|
||||
List<Category> list = categoryMapper.selectByType(type);
|
||||
return list;
|
||||
return categoryMapper.selectByType(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -153,4 +152,14 @@ public class DishServiceImpl implements DishService {
|
||||
dishFlavorMapper.insertBatch(flavors);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类id查询菜品
|
||||
* @param categoryId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Dish> selectByCategoryId(String categoryId) {
|
||||
return dishMapper.selectByCategoryId(categoryId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.sky.constant.MessageConstant;
|
||||
import com.sky.constant.PasswordConstant;
|
||||
import com.sky.constant.StatusConstant;
|
||||
import com.sky.context.BaseContext;
|
||||
import com.sky.dto.EmployeeDTO;
|
||||
import com.sky.dto.EmployeeLoginDTO;
|
||||
import com.sky.dto.EmployeePageQueryDTO;
|
||||
@@ -21,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.sky.service.impl;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sky.dto.SetmealDTO;
|
||||
import com.sky.dto.SetmealPageQueryDTO;
|
||||
import com.sky.entity.Setmeal;
|
||||
import com.sky.entity.SetmealDish;
|
||||
import com.sky.mapper.SetmealDishMapper;
|
||||
import com.sky.mapper.SetmealMapper;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.service.SetmealService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SetmealServiceImpl implements SetmealService {
|
||||
|
||||
@Autowired
|
||||
private SetmealMapper setmealMapper;
|
||||
@Autowired
|
||||
private SetmealDishMapper setmealDishMapper;
|
||||
|
||||
/**
|
||||
* 套餐分页查询
|
||||
* @param setmealPageQueryDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageResult pageQuery(SetmealPageQueryDTO setmealPageQueryDTO) {
|
||||
//设置分页
|
||||
PageHelper.startPage(setmealPageQueryDTO.getPage(), setmealPageQueryDTO.getPageSize());
|
||||
Page<Setmeal> page = setmealMapper.pageQuery(setmealPageQueryDTO);
|
||||
return new PageResult(page.getTotal(),page.getResult());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增套餐
|
||||
* @param setmealDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void insert(SetmealDTO setmealDTO) {
|
||||
//插入套餐信息
|
||||
Setmeal setmeal = new Setmeal();
|
||||
BeanUtils.copyProperties(setmealDTO,setmeal);
|
||||
setmealMapper.insert(setmeal);
|
||||
|
||||
//插入套餐包含菜品的信息
|
||||
List<SetmealDish> setmealDishes = setmealDTO.getSetmealDishes();
|
||||
setmealDishMapper.insertBatch(setmealDishes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user