| | |
| | | import com.gkhy.exam.common.exception.ApiException; |
| | | import com.gkhy.exam.common.utils.SecurityUtils; |
| | | import com.gkhy.exam.system.domain.SysCategory; |
| | | import com.gkhy.exam.system.mapper.ExCourseMapper; |
| | | import com.gkhy.exam.system.mapper.ExQuestionBankMapper; |
| | | import com.gkhy.exam.system.mapper.SysCategoryMapper; |
| | | import com.gkhy.exam.system.service.SysCategoryService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Comparator; |
| | |
| | | */ |
| | | @Service |
| | | public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCategory> implements SysCategoryService { |
| | | @Autowired |
| | | private ExCourseMapper courseMapper; |
| | | @Autowired |
| | | private ExQuestionBankMapper questionBankMapper; |
| | | |
| | | @Override |
| | | public List<SysCategory> selectCategoryList(SysCategory category) { |
| | |
| | | public int deleteCategoryById(Long categoryId) { |
| | | //校验课程分类是否存在课程或者题目 |
| | | checkUserAllowed(); |
| | | int courseCount=baseMapper.selectCountOfCoure(categoryId); |
| | | int courseCount=courseMapper.selectCountByCategoryId(categoryId); |
| | | if(courseCount>0){ |
| | | throw new ApiException("已绑定课程,无法删除"); |
| | | } |
| | | int bankCount=baseMapper.selectCountOfBank(categoryId); |
| | | int bankCount=questionBankMapper.selectCountByCategoryId(categoryId); |
| | | if(bankCount>0){ |
| | | throw new ApiException("已绑定题库,无法删除"); |
| | | } |
| | | int row=baseMapper.deleteById(categoryId); |
| | | int row=baseMapper.deleteByCategoryId(categoryId); |
| | | if(row<1){ |
| | | throw new ApiException("删除课程分类失败"); |
| | | } |