分类管理
This commit is contained in:
@@ -2,12 +2,16 @@ 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.context.BaseContext;
|
||||
import com.sky.dto.CategoryDTO;
|
||||
import com.sky.dto.CategoryPageQueryDTO;
|
||||
import com.sky.entity.Category;
|
||||
import com.sky.exception.DeletionNotAllowedException;
|
||||
import com.sky.mapper.CategoryMapper;
|
||||
import com.sky.mapper.DishMapper;
|
||||
import com.sky.mapper.SetmealMapper;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.service.CategoryService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -23,7 +27,10 @@ public class CategoryServiceImpl implements CategoryService {
|
||||
|
||||
@Autowired
|
||||
private CategoryMapper categoryMapper;
|
||||
|
||||
@Autowired
|
||||
private DishMapper dishMapper;
|
||||
@Autowired
|
||||
private SetmealMapper setmealMapper;
|
||||
/**
|
||||
* 分类分页查询
|
||||
*
|
||||
@@ -70,7 +77,17 @@ public class CategoryServiceImpl implements CategoryService {
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(long id) {
|
||||
//查询是否关联套餐
|
||||
if (setmealMapper.countByCategoryId(id) > 0){
|
||||
throw new DeletionNotAllowedException(MessageConstant.CATEGORY_BE_RELATED_BY_SETMEAL);
|
||||
}
|
||||
//查询是否关联菜品
|
||||
if (dishMapper.countByCategoryId(id) > 0){
|
||||
throw new DeletionNotAllowedException(MessageConstant.CATEGORY_BE_RELATED_BY_DISH);
|
||||
}
|
||||
//删除分类数据
|
||||
categoryMapper.deleteById(id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user