新增套餐、套餐分页查询、根据分类id查询菜品
This commit is contained in:
@@ -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