试卷分类扩展层级不卡控
This commit is contained in:
parent
ce5c7314de
commit
f08bb2c98d
|
|
@ -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,30 +35,29 @@ import com.ruoyi.common.utils.ExcelUtil;
|
|||
*/
|
||||
@Controller
|
||||
@RequestMapping("/exam/examQuestionCategory")
|
||||
public class ExamQuestionCategoryController extends BaseController
|
||||
{
|
||||
public class ExamQuestionCategoryController extends BaseController {
|
||||
private String prefix = "exam/examQuestionCategory";
|
||||
|
||||
@Autowired
|
||||
private IExamQuestionCategoryService examQuestionCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IExamQuestionService examQuestionService;
|
||||
|
||||
@RequiresPermissions("exam:examQuestionCategory:view")
|
||||
@GetMapping()
|
||||
public String examQuestionCategory()
|
||||
{
|
||||
public String examQuestionCategory() {
|
||||
return prefix + "/examQuestionCategory";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询试题分类列表
|
||||
*/
|
||||
@RequiresPermissions("exam:examQuestionCategory:list")
|
||||
@GetMapping("/list")
|
||||
@ResponseBody
|
||||
public List<ExamQuestionCategory> list(ExamQuestionCategory examQuestionCategory)
|
||||
{
|
||||
public List<ExamQuestionCategory> list(ExamQuestionCategory examQuestionCategory) {
|
||||
|
||||
List<ExamQuestionCategory> list = examQuestionCategoryService.selectExamQuestionCategoryList(examQuestionCategory);
|
||||
return list;
|
||||
|
|
@ -69,8 +70,7 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
@RequiresPermissions("exam:examQuestionCategory:export")
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(ExamQuestionCategory examQuestionCategory)
|
||||
{
|
||||
public AjaxResult export(ExamQuestionCategory examQuestionCategory) {
|
||||
List<ExamQuestionCategory> list = examQuestionCategoryService.selectExamQuestionCategoryList(examQuestionCategory);
|
||||
ExcelUtil<ExamQuestionCategory> util = new ExcelUtil<ExamQuestionCategory>(ExamQuestionCategory.class);
|
||||
return util.exportExcel(list, "examQuestionCategory");
|
||||
|
|
@ -80,8 +80,7 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
* 新增试题分类
|
||||
*/
|
||||
@GetMapping("/add/{parentId}")
|
||||
public String add(@PathVariable("parentId") String parentId, ModelMap mmap)
|
||||
{
|
||||
public String add(@PathVariable("parentId") String parentId, ModelMap mmap) {
|
||||
mmap.put("examQuestionCategory", examQuestionCategoryService.selectExamQuestionCategoryById(parentId));
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
|
@ -93,8 +92,12 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
@Log(title = "试题分类", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(ExamQuestionCategory examQuestionCategory)
|
||||
{
|
||||
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));
|
||||
|
|
@ -104,8 +107,7 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
* 修改试题分类
|
||||
*/
|
||||
@GetMapping("/edit/{id}")
|
||||
public String edit(@PathVariable("id") String id, ModelMap mmap)
|
||||
{
|
||||
public String edit(@PathVariable("id") String id, ModelMap mmap) {
|
||||
ExamQuestionCategory examQuestionCategory = examQuestionCategoryService.selectExamQuestionCategoryById(id);
|
||||
mmap.put("examQuestionCategory", examQuestionCategory);
|
||||
return prefix + "/edit";
|
||||
|
|
@ -118,8 +120,7 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
@Log(title = "试题分类", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(ExamQuestionCategory examQuestionCategory)
|
||||
{
|
||||
public AjaxResult editSave(ExamQuestionCategory examQuestionCategory) {
|
||||
return toAjax(examQuestionCategoryService.updateExamQuestionCategory(examQuestionCategory));
|
||||
}
|
||||
|
||||
|
|
@ -128,10 +129,9 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("exam:examQuestionCategory:remove")
|
||||
@Log(title = "试题分类", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/remove")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
public AjaxResult remove(String ids) {
|
||||
return toAjax(examQuestionCategoryService.deleteExamQuestionCategoryByIds(ids));
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +140,7 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
* 选择部门树
|
||||
*/
|
||||
@GetMapping("/selectExamQuestionCategoryTree/{examQuestionCategoryId}")
|
||||
public String selectDeptTree(@PathVariable("examQuestionCategoryId") String examQuestionCategoryId, ModelMap mmap)
|
||||
{
|
||||
public String selectDeptTree(@PathVariable("examQuestionCategoryId") String examQuestionCategoryId, ModelMap mmap) {
|
||||
mmap.put("examQuestionCategory", examQuestionCategoryService.selectExamQuestionCategoryById(examQuestionCategoryId));
|
||||
return prefix + "/tree";
|
||||
}
|
||||
|
|
@ -152,8 +151,7 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
*/
|
||||
@GetMapping("/treeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeData()
|
||||
{
|
||||
public List<Map<String, Object>> treeData() {
|
||||
List<Map<String, Object>> tree = examQuestionCategoryService.selectDeptTree();
|
||||
return tree;
|
||||
}
|
||||
|
|
@ -164,19 +162,9 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
*/
|
||||
@GetMapping("/treeDataForAdd")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeDataForAdd()
|
||||
{
|
||||
public List<Map<String, Object>> treeDataForAdd() {
|
||||
List<Map<String, Object>> tree = examQuestionCategoryService.selectDeptTree();
|
||||
List<Map<String, Object>> res = new ArrayList<>();
|
||||
for (Map<String, Object> stringObjectMap : tree) {
|
||||
String pId = stringObjectMap.get("pId").toString();
|
||||
if(pId.equals("0")||pId.equals("1")){
|
||||
res.add(stringObjectMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
return tree;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -186,14 +174,18 @@ public class ExamQuestionCategoryController extends BaseController
|
|||
@RequiresPermissions("system:examQuestionCategory:remove")
|
||||
@PostMapping("/remove/{id}")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(@PathVariable("id") Long id)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable("id") Long id) {
|
||||
ExamQuestionCategory exam = new ExamQuestionCategory();
|
||||
exam.setParentId(id);
|
||||
if (examQuestionCategoryService.selectList(exam).size() > 0)
|
||||
{
|
||||
if (examQuestionCategoryService.selectList(exam).size() > 0) {
|
||||
return error(1, "存在下级分类,不允许删除");
|
||||
}
|
||||
ExamQuestion examQuestion = new ExamQuestion();
|
||||
examQuestion.setCategoryId(id.toString());
|
||||
|
||||
if (examQuestionService.selectList(examQuestion).size() > 0) {
|
||||
return error(1, "分类包含试题,不允许删除");
|
||||
}
|
||||
|
||||
return toAjax(examQuestionCategoryService.deleteById(id));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="formId">
|
||||
<input type="hidden" id="categoryId" name="categoryId">
|
||||
<input type="hidden" id="categoryId" name="categoryId" >
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue