diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamQuestionCategoryController.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamQuestionCategoryController.java index 49ecd1cfc..60fae6d07 100644 --- a/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamQuestionCategoryController.java +++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamQuestionCategoryController.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.Map; import com.ruoyi.exam.domain.ExamPaperCategory; +import com.ruoyi.exam.domain.ExamQuestion; +import com.ruoyi.exam.service.IExamQuestionService; import com.ruoyi.framework.web.util.ShiroUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -33,169 +35,159 @@ import com.ruoyi.common.utils.ExcelUtil; */ @Controller @RequestMapping("/exam/examQuestionCategory") -public class ExamQuestionCategoryController extends BaseController -{ - private String prefix = "exam/examQuestionCategory"; +public class ExamQuestionCategoryController extends BaseController { + private String prefix = "exam/examQuestionCategory"; - @Autowired - private IExamQuestionCategoryService examQuestionCategoryService; + @Autowired + private IExamQuestionCategoryService examQuestionCategoryService; - @RequiresPermissions("exam:examQuestionCategory:view") - @GetMapping() - public String examQuestionCategory() - { - return prefix + "/examQuestionCategory"; - } + @Autowired + private IExamQuestionService examQuestionService; + + @RequiresPermissions("exam:examQuestionCategory:view") + @GetMapping() + public String examQuestionCategory() { + return prefix + "/examQuestionCategory"; + } + /** + * 查询试题分类列表 + */ + @RequiresPermissions("exam:examQuestionCategory:list") + @GetMapping("/list") + @ResponseBody + public List list(ExamQuestionCategory examQuestionCategory) { - /** - * 查询试题分类列表 - */ - @RequiresPermissions("exam:examQuestionCategory:list") - @GetMapping("/list") - @ResponseBody - public List list(ExamQuestionCategory examQuestionCategory) - { - - List list = examQuestionCategoryService.selectExamQuestionCategoryList(examQuestionCategory); - return list; - } + List list = examQuestionCategoryService.selectExamQuestionCategoryList(examQuestionCategory); + return list; + } - /** - * 导出试题分类列表 - */ - @RequiresPermissions("exam:examQuestionCategory:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(ExamQuestionCategory examQuestionCategory) - { - List list = examQuestionCategoryService.selectExamQuestionCategoryList(examQuestionCategory); - ExcelUtil util = new ExcelUtil(ExamQuestionCategory.class); - return util.exportExcel(list, "examQuestionCategory"); - } + /** + * 导出试题分类列表 + */ + @RequiresPermissions("exam:examQuestionCategory:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ExamQuestionCategory examQuestionCategory) { + List list = examQuestionCategoryService.selectExamQuestionCategoryList(examQuestionCategory); + ExcelUtil util = new ExcelUtil(ExamQuestionCategory.class); + return util.exportExcel(list, "examQuestionCategory"); + } - /** - * 新增试题分类 - */ - @GetMapping("/add/{parentId}") - public String add(@PathVariable("parentId") String parentId, ModelMap mmap) - { - mmap.put("examQuestionCategory", examQuestionCategoryService.selectExamQuestionCategoryById(parentId)); - return prefix + "/add"; - } + /** + * 新增试题分类 + */ + @GetMapping("/add/{parentId}") + public String add(@PathVariable("parentId") String parentId, ModelMap mmap) { + mmap.put("examQuestionCategory", examQuestionCategoryService.selectExamQuestionCategoryById(parentId)); + return prefix + "/add"; + } - /** - * 新增保存试题分类 - */ - @RequiresPermissions("exam:examQuestionCategory:add") - @Log(title = "试题分类", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(ExamQuestionCategory examQuestionCategory) - { - examQuestionCategory.setCreateBy(ShiroUtils.getLoginName()); - examQuestionCategory.setCreateDate(new Date()); - return toAjax(examQuestionCategoryService.insertExamQuestionCategory(examQuestionCategory)); - } + /** + * 新增保存试题分类 + */ + @RequiresPermissions("exam:examQuestionCategory:add") + @Log(title = "试题分类", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(ExamQuestionCategory examQuestionCategory) { + ExamQuestion examQuestion = new ExamQuestion(); + examQuestion.setCategoryId(examQuestionCategory.getParentId().toString()); + if (examQuestionService.selectList(examQuestion).size() > 0) { + return error(1, "分类包含试题,不允许扩展分类"); + } + examQuestionCategory.setCreateBy(ShiroUtils.getLoginName()); + examQuestionCategory.setCreateDate(new Date()); + return toAjax(examQuestionCategoryService.insertExamQuestionCategory(examQuestionCategory)); + } - /** - * 修改试题分类 - */ - @GetMapping("/edit/{id}") - public String edit(@PathVariable("id") String id, ModelMap mmap) - { - ExamQuestionCategory examQuestionCategory = examQuestionCategoryService.selectExamQuestionCategoryById(id); - mmap.put("examQuestionCategory", examQuestionCategory); - return prefix + "/edit"; - } + /** + * 修改试题分类 + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") String id, ModelMap mmap) { + ExamQuestionCategory examQuestionCategory = examQuestionCategoryService.selectExamQuestionCategoryById(id); + mmap.put("examQuestionCategory", examQuestionCategory); + return prefix + "/edit"; + } - /** - * 修改保存试题分类 - */ - @RequiresPermissions("exam:examQuestionCategory:edit") - @Log(title = "试题分类", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(ExamQuestionCategory examQuestionCategory) - { - return toAjax(examQuestionCategoryService.updateExamQuestionCategory(examQuestionCategory)); - } + /** + * 修改保存试题分类 + */ + @RequiresPermissions("exam:examQuestionCategory:edit") + @Log(title = "试题分类", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(ExamQuestionCategory examQuestionCategory) { + return toAjax(examQuestionCategoryService.updateExamQuestionCategory(examQuestionCategory)); + } - /** - * 删除试题分类 - */ - @RequiresPermissions("exam:examQuestionCategory:remove") - @Log(title = "试题分类", businessType = BusinessType.DELETE) - @PostMapping( "/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(examQuestionCategoryService.deleteExamQuestionCategoryByIds(ids)); - } + /** + * 删除试题分类 + */ + @RequiresPermissions("exam:examQuestionCategory:remove") + @Log(title = "试题分类", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) { + return toAjax(examQuestionCategoryService.deleteExamQuestionCategoryByIds(ids)); + } - /** - * 选择部门树 - */ - @GetMapping("/selectExamQuestionCategoryTree/{examQuestionCategoryId}") - public String selectDeptTree(@PathVariable("examQuestionCategoryId") String examQuestionCategoryId, ModelMap mmap) - { - mmap.put("examQuestionCategory", examQuestionCategoryService.selectExamQuestionCategoryById(examQuestionCategoryId)); - return prefix + "/tree"; - } + /** + * 选择部门树 + */ + @GetMapping("/selectExamQuestionCategoryTree/{examQuestionCategoryId}") + public String selectDeptTree(@PathVariable("examQuestionCategoryId") String examQuestionCategoryId, ModelMap mmap) { + mmap.put("examQuestionCategory", examQuestionCategoryService.selectExamQuestionCategoryById(examQuestionCategoryId)); + return prefix + "/tree"; + } - /** - * 加载列表树 - */ - @GetMapping("/treeData") - @ResponseBody - public List> treeData() - { - List> tree = examQuestionCategoryService.selectDeptTree(); - return tree; - } + /** + * 加载列表树 + */ + @GetMapping("/treeData") + @ResponseBody + public List> treeData() { + List> tree = examQuestionCategoryService.selectDeptTree(); + return tree; + } - /** - * 选择部门树 - */ - @GetMapping("/treeDataForAdd") - @ResponseBody - public List> treeDataForAdd() - { - List> tree = examQuestionCategoryService.selectDeptTree(); - List> res = new ArrayList<>(); - for (Map stringObjectMap : tree) { - String pId = stringObjectMap.get("pId").toString(); - if(pId.equals("0")||pId.equals("1")){ - res.add(stringObjectMap); - } + /** + * 选择部门树 + */ + @GetMapping("/treeDataForAdd") + @ResponseBody + public List> treeDataForAdd() { + List> tree = examQuestionCategoryService.selectDeptTree(); + return tree; + } - } + /** + * 删除 + */ + @Log(title = "试题分类管理", businessType = BusinessType.DELETE) + @RequiresPermissions("system:examQuestionCategory:remove") + @PostMapping("/remove/{id}") + @ResponseBody + public AjaxResult remove(@PathVariable("id") Long id) { + ExamQuestionCategory exam = new ExamQuestionCategory(); + exam.setParentId(id); + if (examQuestionCategoryService.selectList(exam).size() > 0) { + return error(1, "存在下级分类,不允许删除"); + } + ExamQuestion examQuestion = new ExamQuestion(); + examQuestion.setCategoryId(id.toString()); - return res; - } + if (examQuestionService.selectList(examQuestion).size() > 0) { + return error(1, "分类包含试题,不允许删除"); + } - /** - * 删除 - */ - @Log(title = "试题分类管理", businessType = BusinessType.DELETE) - @RequiresPermissions("system:examQuestionCategory:remove") - @PostMapping("/remove/{id}") - @ResponseBody - public AjaxResult remove(@PathVariable("id") Long id) - { - ExamQuestionCategory exam = new ExamQuestionCategory(); - exam.setParentId(id); - if (examQuestionCategoryService.selectList(exam).size() > 0) - { - return error(1, "存在下级分类,不允许删除"); - } - - return toAjax(examQuestionCategoryService.deleteById(id)); - } + return toAjax(examQuestionCategoryService.deleteById(id)); + } } diff --git a/ruoyi-exam/src/main/resources/templates/exam/examQuestion/examQuestion.html b/ruoyi-exam/src/main/resources/templates/exam/examQuestion/examQuestion.html index 6ae276e86..9a28602ca 100644 --- a/ruoyi-exam/src/main/resources/templates/exam/examQuestion/examQuestion.html +++ b/ruoyi-exam/src/main/resources/templates/exam/examQuestion/examQuestion.html @@ -36,7 +36,7 @@
- +
  • @@ -97,7 +97,9 @@ $(function () { $('body').layout({west__size: 185}); + $("#categoryId").val(0); queryExamQuestionList(); +// $.table.search(); queryExamQuestionCategoryTree(); }); @@ -188,9 +190,9 @@ $.tree.init(options); function zOnClick(event, treeId, treeNode) { - if(treeNode.pId == 1 || treeNode.pId == 0 ||treeNode.pId == null) { - return; - } +// if(treeNode.pId == 1 || treeNode.pId == 0 ||treeNode.pId == null) { +// return; +// } $("#categoryId").val(treeNode.id); $.table.search(); } @@ -220,7 +222,7 @@ } function addChoiceQuestion(){ - if($("#categoryId").val() == null||$("#categoryId").val() == ''){ + if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){ alert("请选择题库!") return; } @@ -229,7 +231,7 @@ } function addMoreChoiceQuestion(){ - if($("#categoryId").val() == null||$("#categoryId").val() == ''){ + if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){ alert("请选择题库!") return; } @@ -238,7 +240,7 @@ } function addJudgeQuestion(){ - if($("#categoryId").val() == null||$("#categoryId").val() == ''){ + if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){ alert("请选择题库!") return; } diff --git a/ruoyi-exam/src/main/resources/templates/exam/examQuestionCategory/examQuestionCategory.html b/ruoyi-exam/src/main/resources/templates/exam/examQuestionCategory/examQuestionCategory.html index 2743abeeb..dce014ca2 100644 --- a/ruoyi-exam/src/main/resources/templates/exam/examQuestionCategory/examQuestionCategory.html +++ b/ruoyi-exam/src/main/resources/templates/exam/examQuestionCategory/examQuestionCategory.html @@ -73,11 +73,6 @@ field: 'name', title: '分类', align: "left" - }, - { - field: 'orderNum', - title: '排序', - align: "left" }, { field : 'createBy', @@ -87,16 +82,6 @@ { field : 'createDate', title : '创建时间', - align: "left" - }, - { - field : 'updateBy', - title : '更新者', - align: "left" - }, - { - field : 'updateDate', - title : '更新时间', align: "left" }, {