|
|
|
|
@ -2,10 +2,13 @@ package com.sky.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.sky.constant.MessageConstant;
|
|
|
|
|
import com.sky.constant.StatusConstant;
|
|
|
|
|
import com.sky.dto.SetmealDTO;
|
|
|
|
|
import com.sky.dto.SetmealPageQueryDTO;
|
|
|
|
|
import com.sky.entity.Setmeal;
|
|
|
|
|
import com.sky.entity.SetmealDish;
|
|
|
|
|
import com.sky.exception.DeletionNotAllowedException;
|
|
|
|
|
import com.sky.mapper.DishMapper;
|
|
|
|
|
import com.sky.mapper.SetmealDishMapper;
|
|
|
|
|
import com.sky.mapper.SetmealMapper;
|
|
|
|
|
@ -15,6 +18,7 @@ import com.sky.vo.SetmealVO;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
@ -65,4 +69,27 @@ public class SetmealServiceImpl implements SetmealService {
|
|
|
|
|
Page<SetmealVO> page = setmealMapper.pageQuery(setmealPageQueryDTO);
|
|
|
|
|
return new PageResult(page.getTotal(), page.getResult());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除套餐
|
|
|
|
|
* @param ids
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(List<Long> ids) {
|
|
|
|
|
ids.forEach(id -> {
|
|
|
|
|
Setmeal setmeal = setmealMapper.getById(id);
|
|
|
|
|
if (setmeal.getStatus() == StatusConstant.ENABLE){
|
|
|
|
|
//起售中的套餐不能删除
|
|
|
|
|
throw new DeletionNotAllowedException(MessageConstant.SETMEAL_ON_SALE);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
ids.forEach(id -> {
|
|
|
|
|
//删除套餐表中的数据
|
|
|
|
|
setmealMapper.deleteById(id);
|
|
|
|
|
//删除套餐菜品关系表中的数据
|
|
|
|
|
setmealDishMapper.deleteBySetmealId(id);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|