修改试卷分类,试题分类卡控,试卷递归呢查找
This commit is contained in:
parent
4a3435d712
commit
923a6e49e8
|
|
@ -5,6 +5,8 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ruoyi.exam.domain.ExamPaper;
|
||||||
|
import com.ruoyi.exam.service.IExamPaperService;
|
||||||
import com.ruoyi.framework.web.util.ShiroUtils;
|
import com.ruoyi.framework.web.util.ShiroUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -38,6 +40,9 @@ public class ExamPaperCategoryController extends BaseController
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IExamPaperCategoryService examPaperCategoryService;
|
private IExamPaperCategoryService examPaperCategoryService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IExamPaperService examPaperService;
|
||||||
|
|
||||||
@RequiresPermissions("exam:examPaperCategory:view")
|
@RequiresPermissions("exam:examPaperCategory:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
|
|
@ -57,8 +62,8 @@ public class ExamPaperCategoryController extends BaseController
|
||||||
List<ExamPaperCategory> list = examPaperCategoryService.selectExamPaperCategoryPage(examPaperCategory);
|
List<ExamPaperCategory> list = examPaperCategoryService.selectExamPaperCategoryPage(examPaperCategory);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出试卷分类列表
|
* 导出试卷分类列表
|
||||||
*/
|
*/
|
||||||
|
|
@ -91,6 +96,11 @@ public class ExamPaperCategoryController extends BaseController
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(ExamPaperCategory examPaperCategory)
|
public AjaxResult addSave(ExamPaperCategory examPaperCategory)
|
||||||
{
|
{
|
||||||
|
ExamPaper examPaper = new ExamPaper();
|
||||||
|
examPaper.setExamPaperCategoryId(examPaperCategory.getParentId());
|
||||||
|
if(examPaperService.selectList(examPaper).size()>0){
|
||||||
|
return error(1, "分类包含试卷,不允许扩展分类");
|
||||||
|
}
|
||||||
examPaperCategory.setCreateBy(ShiroUtils.getLoginName());
|
examPaperCategory.setCreateBy(ShiroUtils.getLoginName());
|
||||||
examPaperCategory.setCreateDate(new Date());
|
examPaperCategory.setCreateDate(new Date());
|
||||||
examPaperCategory.setDelFlag("0");
|
examPaperCategory.setDelFlag("0");
|
||||||
|
|
@ -104,7 +114,9 @@ public class ExamPaperCategoryController extends BaseController
|
||||||
public String edit(@PathVariable("id") Integer id, ModelMap mmap)
|
public String edit(@PathVariable("id") Integer id, ModelMap mmap)
|
||||||
{
|
{
|
||||||
ExamPaperCategory examPaperCategory = examPaperCategoryService.selectById(id);
|
ExamPaperCategory examPaperCategory = examPaperCategoryService.selectById(id);
|
||||||
|
ExamPaperCategory parent = examPaperCategoryService.selectById(examPaperCategory.getParentId());
|
||||||
mmap.put("examPaperCategory", examPaperCategory);
|
mmap.put("examPaperCategory", examPaperCategory);
|
||||||
|
mmap.put("parentName", parent.getName());
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +131,21 @@ public class ExamPaperCategoryController extends BaseController
|
||||||
{
|
{
|
||||||
examPaperCategory.setUpdateBy(ShiroUtils.getLoginName());
|
examPaperCategory.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
examPaperCategory.setUpdateDate(new Date());
|
examPaperCategory.setUpdateDate(new Date());
|
||||||
return toAjax(examPaperCategoryService.updateSelectiveById(examPaperCategory));
|
|
||||||
|
ExamPaper examPaper = new ExamPaper();
|
||||||
|
examPaper.setExamPaperCategoryId(examPaperCategory.getParentId());
|
||||||
|
if(examPaperService.selectList(examPaper).size()>0){
|
||||||
|
return error(1,"父级分类下面包含试卷,无法移动");
|
||||||
|
}
|
||||||
|
|
||||||
|
ExamPaperCategory exam = new ExamPaperCategory();
|
||||||
|
exam.setParentId(examPaperCategory.getId());
|
||||||
|
if (examPaperCategoryService.selectList(exam).size() > 0)
|
||||||
|
{
|
||||||
|
return error(1, "此分类存在下级分类,无法移动");
|
||||||
|
}
|
||||||
|
|
||||||
|
return toAjax(examPaperCategoryService.updateSelectiveById(examPaperCategory));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -151,16 +177,8 @@ public class ExamPaperCategoryController extends BaseController
|
||||||
public List<Map<String, Object>> treeDataForAdd()
|
public List<Map<String, Object>> treeDataForAdd()
|
||||||
{
|
{
|
||||||
List<Map<String, Object>> tree = examPaperCategoryService.selectDeptTree();
|
List<Map<String, Object>> tree = examPaperCategoryService.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 tree;
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -178,6 +196,12 @@ public class ExamPaperCategoryController extends BaseController
|
||||||
{
|
{
|
||||||
return error(1, "存在下级分类,不允许删除");
|
return error(1, "存在下级分类,不允许删除");
|
||||||
}
|
}
|
||||||
|
ExamPaper examPaper = new ExamPaper();
|
||||||
|
examPaper.setExamPaperCategoryId(id);
|
||||||
|
if(examPaperService.selectList(examPaper).size()>0){
|
||||||
|
return error(1, "分类包含试卷,不允许删除分类");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return toAjax(examPaperCategoryService.deleteById(id));
|
return toAjax(examPaperCategoryService.deleteById(id));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
package com.ruoyi.exam.controller;
|
package com.ruoyi.exam.controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.exam.domain.ExamPaperCategory;
|
||||||
|
import com.ruoyi.exam.domain.ExamQuestion;
|
||||||
|
import com.ruoyi.exam.domain.ExamQuestionCategory;
|
||||||
|
import com.ruoyi.exam.service.IExamPaperCategoryService;
|
||||||
import com.ruoyi.exam.service.IExamPaperQuestionService;
|
import com.ruoyi.exam.service.IExamPaperQuestionService;
|
||||||
import com.ruoyi.framework.web.util.ShiroUtils;
|
import com.ruoyi.framework.web.util.ShiroUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
|
@ -34,6 +39,9 @@ public class ExamPaperController extends BaseController
|
||||||
@Autowired
|
@Autowired
|
||||||
private IExamPaperService examPaperService;
|
private IExamPaperService examPaperService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IExamPaperCategoryService examPaperCategoryService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IExamPaperQuestionService examPaperQuestionService;
|
private IExamPaperQuestionService examPaperQuestionService;
|
||||||
|
|
||||||
|
|
@ -52,8 +60,28 @@ public class ExamPaperController extends BaseController
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(ExamPaper examPaper)
|
public TableDataInfo list(ExamPaper examPaper)
|
||||||
{
|
{
|
||||||
List<ExamPaper> list = examPaperService.selectExamPaperPage(examPaper);
|
List<ExamPaper> list = new ArrayList<>();
|
||||||
return getDataTable(list);
|
List<ExamPaper> listByIds = getListByIds(list, examPaper);
|
||||||
|
return getDataTable(listByIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归找到所有下级的试卷
|
||||||
|
* @param list
|
||||||
|
* @param examPaper
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<ExamPaper> getListByIds(List<ExamPaper> list,ExamPaper examPaper){
|
||||||
|
list.addAll(examPaperService.selectExamPaperList(examPaper));
|
||||||
|
String categoryId = examPaper.getExamPaperCategoryId().toString();
|
||||||
|
ExamPaperCategory examPaperCategory = new ExamPaperCategory();
|
||||||
|
examPaperCategory.setParentId(Integer.parseInt(categoryId));
|
||||||
|
List<ExamPaperCategory> examPaperCategorys = examPaperCategoryService.selectList(examPaperCategory);
|
||||||
|
for (ExamPaperCategory questionCategory : examPaperCategorys) {
|
||||||
|
examPaper.setExamPaperCategoryId(questionCategory.getId());
|
||||||
|
getListByIds(list,examPaper);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,9 @@ public class ExamQuestionCategoryController extends BaseController {
|
||||||
@GetMapping("/edit/{id}")
|
@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);
|
ExamQuestionCategory examQuestionCategory = examQuestionCategoryService.selectExamQuestionCategoryById(id);
|
||||||
|
ExamQuestionCategory parent = examQuestionCategoryService.selectExamQuestionCategoryById(examQuestionCategory.getParentId().toString());
|
||||||
mmap.put("examQuestionCategory", examQuestionCategory);
|
mmap.put("examQuestionCategory", examQuestionCategory);
|
||||||
|
mmap.put("parentName", parent.getName());
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,6 +123,18 @@ public class ExamQuestionCategoryController extends BaseController {
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(ExamQuestionCategory examQuestionCategory) {
|
public AjaxResult editSave(ExamQuestionCategory examQuestionCategory) {
|
||||||
|
ExamQuestion examQuestion = new ExamQuestion();
|
||||||
|
examQuestion.setCategoryId(examQuestionCategory.getParentId().toString());
|
||||||
|
|
||||||
|
if (examQuestionService.selectList(examQuestion).size() > 0) {
|
||||||
|
return error(1, "父级分类下包含试题,无法移动");
|
||||||
|
}
|
||||||
|
|
||||||
|
ExamQuestionCategory exam = new ExamQuestionCategory();
|
||||||
|
exam.setParentId(exam.getId());
|
||||||
|
if (examQuestionCategoryService.selectList(exam).size() > 0) {
|
||||||
|
return error(1, "此分类存在下级分类,无法移动");
|
||||||
|
}
|
||||||
return toAjax(examQuestionCategoryService.updateExamQuestionCategory(examQuestionCategory));
|
return toAjax(examQuestionCategoryService.updateExamQuestionCategory(examQuestionCategory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,10 @@ private static final long serialVersionUID = 1L;
|
||||||
private String remarks;
|
private String remarks;
|
||||||
/** 删除标记 */
|
/** 删除标记 */
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/** 设置试卷分类 */
|
|
||||||
|
|
||||||
|
/** 设置试卷分类 */
|
||||||
public void setId(Integer id)
|
public void setId(Integer id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ public class ExamQuestionCategory
|
||||||
|
|
||||||
private String orderNum;
|
private String orderNum;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getOrderNum() {
|
public String getOrderNum() {
|
||||||
return orderNum;
|
return orderNum;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
$('body').layout({west__size: 185});
|
$('body').layout({west__size: 185});
|
||||||
queryExamPaperList();
|
queryExamPaperList();
|
||||||
|
$("#examPaperCategoryId").val(1);
|
||||||
|
$.table.search();
|
||||||
queryExamPaperCategoryTree();
|
queryExamPaperCategoryTree();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -206,9 +208,8 @@
|
||||||
|
|
||||||
|
|
||||||
function add(){
|
function add(){
|
||||||
if($("#examPaperCategoryId").val() == null||$("#examPaperCategoryId").val() == ''){
|
if(!$.tree.notAllowParents($._tree)){
|
||||||
alert("请选分类库!")
|
return ;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var url = prefix + "/add/"+$("#examPaperCategoryId").val();
|
var url = prefix + "/add/"+$("#examPaperCategoryId").val();
|
||||||
$.operate.jumpModeltoUrl("添加试卷",url);
|
$.operate.jumpModeltoUrl("添加试卷",url);
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,19 @@
|
||||||
<head th:include="include :: header"></head>
|
<head th:include="include :: header"></head>
|
||||||
<body class="white-bg">
|
<body class="white-bg">
|
||||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||||
|
|
||||||
<form class="form-horizontal m" id="form-examPaperCategory-edit" th:object="${examPaperCategory}">
|
<form class="form-horizontal m" id="form-examPaperCategory-edit" th:object="${examPaperCategory}">
|
||||||
|
<input id="treeId" name="parentId" type="hidden" th:value="${examPaperCategory.parentId}" />
|
||||||
<input id="id" name="id" th:field="*{id}" type="hidden">
|
<input id="id" name="id" th:field="*{id}" type="hidden">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label ">上级名称:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input class="form-control" type="text" onclick="selectExamPaperCategoryTree()" id="treeName" readonly="true" th:value="${parentName}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
|
||||||
<label class="col-sm-3 control-label">分类:</label>
|
<label class="col-sm-3 control-label">分类:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
|
<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
|
||||||
|
|
@ -46,6 +56,23 @@
|
||||||
$.operate.save(prefix + "/edit", $('#form-examPaperCategory-edit').serialize());
|
$.operate.save(prefix + "/edit", $('#form-examPaperCategory-edit').serialize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectExamPaperCategoryTree() {
|
||||||
|
var options = {
|
||||||
|
title: '分类选择',
|
||||||
|
width: "380",
|
||||||
|
url: prefix + "/selectExamPaperCategoryTree/" + $("#treeId").val(),
|
||||||
|
callBack: doSubmit
|
||||||
|
};
|
||||||
|
$.modal.openOptions(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function doSubmit(index, layero){
|
||||||
|
var body = layer.getChildFrame('body', index);
|
||||||
|
$("#treeId").val(body.find('#treeId').val());
|
||||||
|
$("#treeName").val(body.find('#treeName').val());
|
||||||
|
layer.close(index);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
align: 'center',
|
align: 'left',
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
if(row.id == 1){
|
if(row.id == 1){
|
||||||
return '';
|
return '';
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@
|
||||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||||
<form class="form-horizontal m" id="form-examQuestionCategory-edit" th:object="${examQuestionCategory}">
|
<form class="form-horizontal m" id="form-examQuestionCategory-edit" th:object="${examQuestionCategory}">
|
||||||
<input id="id" name="id" th:field="*{id}" type="hidden">
|
<input id="id" name="id" th:field="*{id}" type="hidden">
|
||||||
|
<input id="treeId" name="parentId" type="hidden" th:value="${examQuestionCategory.parentId }" />
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label ">上级名称:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input class="form-control" type="text" onclick="selectExamQuestionCategoryTree()" id="treeName" readonly="true" th:value="${parentName}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">分类:</label>
|
<label class="col-sm-3 control-label">分类:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
|
|
@ -78,6 +85,23 @@
|
||||||
$.operate.save(prefix + "/edit", $('#form-examQuestionCategory-edit').serialize());
|
$.operate.save(prefix + "/edit", $('#form-examQuestionCategory-edit').serialize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectExamQuestionCategoryTree() {
|
||||||
|
var options = {
|
||||||
|
title: '分类选择',
|
||||||
|
width: "380",
|
||||||
|
url: prefix + "/selectExamQuestionCategoryTree/" + $("#treeId").val(),
|
||||||
|
callBack: doSubmit
|
||||||
|
};
|
||||||
|
$.modal.openOptions(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function doSubmit(index, layero){
|
||||||
|
var body = layer.getChildFrame('body', index);
|
||||||
|
$("#treeId").val(body.find('#treeId').val());
|
||||||
|
$("#treeName").val(body.find('#treeName').val());
|
||||||
|
layer.close(index);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue