From fa4aa371ab1bfa9b2864d96bf39d0f337d48b9a2 Mon Sep 17 00:00:00 2001 From: flower Date: Sun, 16 Dec 2018 22:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E5=88=86=E7=B1=BB=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExamPaperCategoryController.java | 184 +++++++++++++++++ .../ruoyi/exam/domain/ExamPaperCategory.java | 194 ++++++++++++++++++ .../exam/mapper/ExamPaperCategoryMapper.java | 24 +++ .../service/IExamPaperCategoryService.java | 33 +++ .../impl/ExamPaperCategoryServiceImpl.java | 81 ++++++++ .../mapper/exam/ExamPaperCategoryMapper.xml | 46 +++++ .../templates/exam/examPaperCategory/add.html | 72 +++++++ .../exam/examPaperCategory/edit.html | 51 +++++ .../examPaperCategory/examPaperCategory.html | 120 +++++++++++ .../exam/examPaperCategory/tree.html | 48 +++++ .../exam/examQuestionCategory/edit.html | 2 +- 11 files changed, 854 insertions(+), 1 deletion(-) create mode 100644 ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamPaperCategoryController.java create mode 100644 ruoyi-exam/src/main/java/com/ruoyi/exam/domain/ExamPaperCategory.java create mode 100644 ruoyi-exam/src/main/java/com/ruoyi/exam/mapper/ExamPaperCategoryMapper.java create mode 100644 ruoyi-exam/src/main/java/com/ruoyi/exam/service/IExamPaperCategoryService.java create mode 100644 ruoyi-exam/src/main/java/com/ruoyi/exam/service/impl/ExamPaperCategoryServiceImpl.java create mode 100644 ruoyi-exam/src/main/resources/mapper/exam/ExamPaperCategoryMapper.xml create mode 100644 ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/add.html create mode 100644 ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/edit.html create mode 100644 ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/examPaperCategory.html create mode 100644 ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/tree.html diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamPaperCategoryController.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamPaperCategoryController.java new file mode 100644 index 000000000..21fdd35a1 --- /dev/null +++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamPaperCategoryController.java @@ -0,0 +1,184 @@ +package com.ruoyi.exam.controller; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.ruoyi.framework.web.util.ShiroUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.exam.domain.ExamPaperCategory; +import com.ruoyi.exam.service.IExamPaperCategoryService; +import com.ruoyi.framework.web.base.BaseController; +import com.ruoyi.framework.web.page.TableDataInfo; +import com.ruoyi.common.base.AjaxResult; +import com.ruoyi.common.utils.ExcelUtil; + +/** + * 试卷分类 信息操作处理 + * + * @author zhujj + * @date 2018-12-11 + */ +@Controller +@RequestMapping("/exam/examPaperCategory") +public class ExamPaperCategoryController extends BaseController +{ + private String prefix = "exam/examPaperCategory"; + + @Autowired + private IExamPaperCategoryService examPaperCategoryService; + + @RequiresPermissions("exam:examPaperCategory:view") + @GetMapping() + public String examPaperCategory() + { + return prefix + "/examPaperCategory"; + } + + /** + * 查询试卷分类列表 + */ + @RequiresPermissions("exam:examPaperCategory:list") + @GetMapping("/list") + @ResponseBody + public List list(ExamPaperCategory examPaperCategory) + { + List list = examPaperCategoryService.selectExamPaperCategoryPage(examPaperCategory); + return list; + } + + + /** + * 导出试卷分类列表 + */ + @RequiresPermissions("exam:examPaperCategory:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ExamPaperCategory examPaperCategory) + { + List list = examPaperCategoryService.selectExamPaperCategoryList(examPaperCategory); + ExcelUtil util = new ExcelUtil(ExamPaperCategory.class); + return util.exportExcel(list, "examPaperCategory"); + } + + /** + * 新增试卷分类 + */ + @GetMapping("/add/{parentId}") + public String add(@PathVariable("parentId") String parentId, ModelMap mmap) + { + mmap.put("examPaperCategory",examPaperCategoryService.selectById(parentId)); + return prefix + "/add"; + } + + /** + * 新增保存试卷分类 + */ + @RequiresPermissions("exam:examPaperCategory:add") + @Log(title = "试卷分类", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(ExamPaperCategory examPaperCategory) + { + examPaperCategory.setCreateBy(ShiroUtils.getLoginName()); + examPaperCategory.setCreateDate(new Date()); + examPaperCategory.setDelFlag("0"); + return toAjax(examPaperCategoryService.insert(examPaperCategory)); + } + + /** + * 修改试卷分类 + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") Integer id, ModelMap mmap) + { + ExamPaperCategory examPaperCategory = examPaperCategoryService.selectById(id); + mmap.put("examPaperCategory", examPaperCategory); + return prefix + "/edit"; + } + + /** + * 修改保存试卷分类 + */ + @RequiresPermissions("exam:examPaperCategory:edit") + @Log(title = "试卷分类", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(ExamPaperCategory examPaperCategory) + { + examPaperCategory.setUpdateBy(ShiroUtils.getLoginName()); + examPaperCategory.setUpdateDate(new Date()); + return toAjax(examPaperCategoryService.updateSelectiveById(examPaperCategory)); + } + + /** + * 删除试卷分类 + */ + @RequiresPermissions("exam:examPaperCategory:remove") + @Log(title = "试卷分类", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(examPaperCategoryService.deleteByIds(ids)); + } + + + + @GetMapping("/selectExamPaperCategoryTree/{examPaperCategoryId}") + public String selectDeptTree(@PathVariable("examPaperCategoryId") String examPaperCategoryId, ModelMap mmap) + { + mmap.put("examPaperCategory", examPaperCategoryService.selectById(examPaperCategoryId)); + return prefix + "/tree"; + } + + /** + * 选择试卷分类树 + */ + @GetMapping("/treeDataForAdd") + @ResponseBody + public List> treeDataForAdd() + { + List> tree = examPaperCategoryService.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); + } + + } + + return res; + } + + /** + * 删除 + */ + @Log(title = "部门管理", businessType = BusinessType.DELETE) + @RequiresPermissions("system:examPaperCategory:remove") + @PostMapping("/remove/{id}") + @ResponseBody + public AjaxResult remove(@PathVariable("id") Integer id) + { + ExamPaperCategory examPaperCategory = new ExamPaperCategory(); + examPaperCategory.setParentId(id); + if (examPaperCategoryService.selectList(examPaperCategory).size() > 0) + { + return error(1, "存在下级分类,不允许删除"); + } + + return toAjax(examPaperCategoryService.deleteById(id)); + } +} diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/domain/ExamPaperCategory.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/domain/ExamPaperCategory.java new file mode 100644 index 000000000..0dd323825 --- /dev/null +++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/domain/ExamPaperCategory.java @@ -0,0 +1,194 @@ +package com.ruoyi.exam.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.base.BaseEntity; + import javax.persistence.Id; + import java.util.Date; + +/** + * 试卷分类表 exam_paper_category + * + * @author zhujj + * @date 2018-12-11 + */ +public class ExamPaperCategory +{ +private static final long serialVersionUID = 1L; + + /** 试卷分类 */ + @Id + private Integer id; + /** 部门ID */ + private Integer deptId; + /** */ + private Integer parentId; + /** */ + private String parentIds; + /** 分类 */ + private String name; + /** 排序号 */ + private Integer orderNum; + /** 创建者 */ + private String createBy; + /** 创建时间 */ + private Date createDate; + /** 更新者 */ + private String updateBy; + /** 更新时间 */ + private Date updateDate; + /** 备注信息 */ + private String remarks; + /** 删除标记 */ + private String delFlag; + + /** 设置试卷分类 */ + public void setId(Integer id) + { + this.id = id; + } + + /** 获取试卷分类 */ + public Integer getId() + { + return id; + } + /** 设置部门ID */ + public void setDeptId(Integer deptId) + { + this.deptId = deptId; + } + + /** 获取部门ID */ + public Integer getDeptId() + { + return deptId; + } + /** 设置 */ + public void setParentId(Integer parentId) + { + this.parentId = parentId; + } + + /** 获取 */ + public Integer getParentId() + { + return parentId; + } + /** 设置 */ + public void setParentIds(String parentIds) + { + this.parentIds = parentIds; + } + + /** 获取 */ + public String getParentIds() + { + return parentIds; + } + /** 设置分类 */ + public void setName(String name) + { + this.name = name; + } + + /** 获取分类 */ + public String getName() + { + return name; + } + /** 设置排序号 */ + public void setOrderNum(Integer orderNum) + { + this.orderNum = orderNum; + } + + /** 获取排序号 */ + public Integer getOrderNum() + { + return orderNum; + } + /** 设置创建者 */ + public void setCreateBy(String createBy) + { + this.createBy = createBy; + } + + /** 获取创建者 */ + public String getCreateBy() + { + return createBy; + } + /** 设置创建时间 */ + public void setCreateDate(Date createDate) + { + this.createDate = createDate; + } + + /** 获取创建时间 */ + public Date getCreateDate() + { + return createDate; + } + /** 设置更新者 */ + public void setUpdateBy(String updateBy) + { + this.updateBy = updateBy; + } + + /** 获取更新者 */ + public String getUpdateBy() + { + return updateBy; + } + /** 设置更新时间 */ + public void setUpdateDate(Date updateDate) + { + this.updateDate = updateDate; + } + + /** 获取更新时间 */ + public Date getUpdateDate() + { + return updateDate; + } + /** 设置备注信息 */ + public void setRemarks(String remarks) + { + this.remarks = remarks; + } + + /** 获取备注信息 */ + public String getRemarks() + { + return remarks; + } + /** 设置删除标记 */ + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + /** 获取删除标记 */ + public String getDelFlag() + { + return delFlag; + } + +public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("deptId", getDeptId()) + .append("parentId", getParentId()) + .append("parentIds", getParentIds()) + .append("name", getName()) + .append("orderNum", getOrderNum()) + .append("createBy", getCreateBy()) + .append("createDate", getCreateDate()) + .append("updateBy", getUpdateBy()) + .append("updateDate", getUpdateDate()) + .append("remarks", getRemarks()) + .append("delFlag", getDelFlag()) + .toString(); + } + } diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/mapper/ExamPaperCategoryMapper.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/mapper/ExamPaperCategoryMapper.java new file mode 100644 index 000000000..773f94381 --- /dev/null +++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/mapper/ExamPaperCategoryMapper.java @@ -0,0 +1,24 @@ +package com.ruoyi.exam.mapper; + +import com.ruoyi.exam.domain.ExamPaperCategory; +import java.util.List; +import com.ruoyi.framework.web.base.MyMapper; + +/** + * 试卷分类 数据层 + * + * @author zhujj + * @date 2018-12-11 + */ +public interface ExamPaperCategoryMapper extends MyMapper +{ + + /** + * 查询试卷分类列表 + * + * @param examPaperCategory 试卷分类信息 + * @return 试卷分类集合 + */ + public List selectExamPaperCategoryList(ExamPaperCategory examPaperCategory); + +} \ No newline at end of file diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/service/IExamPaperCategoryService.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/service/IExamPaperCategoryService.java new file mode 100644 index 000000000..ed6ca37ba --- /dev/null +++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/service/IExamPaperCategoryService.java @@ -0,0 +1,33 @@ +package com.ruoyi.exam.service; + +import com.ruoyi.exam.domain.ExamPaperCategory; +import java.util.List; +import java.util.Map; + +import com.ruoyi.framework.web.base.AbstractBaseService; +/** + * 试卷分类 服务层 + * + * @author zhujj + * @date 2018-12-11 + */ +public interface IExamPaperCategoryService extends AbstractBaseService +{ + /** + * 查询试卷分类分页列表 + * + * @param examPaperCategory 试卷分类信息 + * @return 试卷分类集合 + */ + public List selectExamPaperCategoryPage(ExamPaperCategory examPaperCategory); + /** + * 查询试卷分类列表 + * + * @param examPaperCategory 试卷分类信息 + * @return 试卷分类集合 + */ + public List selectExamPaperCategoryList(ExamPaperCategory examPaperCategory); + + + List> selectDeptTree(); +} diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/service/impl/ExamPaperCategoryServiceImpl.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/service/impl/ExamPaperCategoryServiceImpl.java new file mode 100644 index 000000000..84befc17b --- /dev/null +++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/service/impl/ExamPaperCategoryServiceImpl.java @@ -0,0 +1,81 @@ +package com.ruoyi.exam.service.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.ruoyi.exam.domain.ExamQuestionCategory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.exam.mapper.ExamPaperCategoryMapper; +import com.ruoyi.exam.domain.ExamPaperCategory; +import com.ruoyi.exam.service.IExamPaperCategoryService; +import com.ruoyi.common.support.Convert; +import com.ruoyi.framework.web.base.AbstractBaseServiceImpl; +/** + * 试卷分类 服务层实现 + * + * @author zhujj + * @date 2018-12-11 + */ +@Service +public class ExamPaperCategoryServiceImpl extends AbstractBaseServiceImpl implements IExamPaperCategoryService +{ + @Autowired + private ExamPaperCategoryMapper examPaperCategoryMapper; + + + /** + * 查询试卷分类列表 + * + * @param examPaperCategory 试卷分类信息 + * @return 试卷分类集合 + */ + @Override + public List selectExamPaperCategoryList(ExamPaperCategory examPaperCategory) + { + return examPaperCategoryMapper.selectExamPaperCategoryList(examPaperCategory); + } + + @Override + public List> selectDeptTree() { + List> trees = new ArrayList>(); + List deptList = selectExamPaperCategoryList(new ExamPaperCategory()); + trees = getTrees(deptList, false, null); + return trees; + } + + private List> getTrees(List deptList, boolean isCheck, List roleDeptList) { + List> trees = new ArrayList>(); + for (ExamPaperCategory dept : deptList) { + + Map deptMap = new HashMap(); + deptMap.put("id", dept.getId()); + deptMap.put("pId", dept.getParentId()); + deptMap.put("name", dept.getName()); + deptMap.put("title", dept.getName()); + if (isCheck) { + deptMap.put("checked", roleDeptList.contains(dept.getId() + dept.getName())); + } else { + deptMap.put("checked", false); + } + trees.add(deptMap); + } + return trees; + } + + /** + * 查询试卷分类分页列表 + * + * @param examPaperCategory 试卷分类信息 + * @return 试卷分类集合 + */ + @Override + public List selectExamPaperCategoryPage(ExamPaperCategory examPaperCategory) + { + startPage(); + return examPaperCategoryMapper.selectExamPaperCategoryList(examPaperCategory); + } + +} diff --git a/ruoyi-exam/src/main/resources/mapper/exam/ExamPaperCategoryMapper.xml b/ruoyi-exam/src/main/resources/mapper/exam/ExamPaperCategoryMapper.xml new file mode 100644 index 000000000..6c6806bcc --- /dev/null +++ b/ruoyi-exam/src/main/resources/mapper/exam/ExamPaperCategoryMapper.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + id, dept_id, parent_id, parent_ids, name, order_num, create_by, create_date, update_by, update_date, remarks, del_flag + + + + + \ No newline at end of file diff --git a/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/add.html b/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/add.html new file mode 100644 index 000000000..ca68a348a --- /dev/null +++ b/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/add.html @@ -0,0 +1,72 @@ + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + + diff --git a/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/edit.html b/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/edit.html new file mode 100644 index 000000000..c0530385e --- /dev/null +++ b/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/edit.html @@ -0,0 +1,51 @@ + + + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ +
+
+
+ + + diff --git a/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/examPaperCategory.html b/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/examPaperCategory.html new file mode 100644 index 000000000..ec3075c8b --- /dev/null +++ b/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/examPaperCategory.html @@ -0,0 +1,120 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/tree.html b/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/tree.html new file mode 100644 index 000000000..8caca9774 --- /dev/null +++ b/ruoyi-exam/src/main/resources/templates/exam/examPaperCategory/tree.html @@ -0,0 +1,48 @@ + + + + + + + + + +
+ + +
+ +
+ 展开 / + 折叠 +
+
+
+
+ + + + diff --git a/ruoyi-exam/src/main/resources/templates/exam/examQuestionCategory/edit.html b/ruoyi-exam/src/main/resources/templates/exam/examQuestionCategory/edit.html index b2dc411e8..2c5869902 100644 --- a/ruoyi-exam/src/main/resources/templates/exam/examQuestionCategory/edit.html +++ b/ruoyi-exam/src/main/resources/templates/exam/examQuestionCategory/edit.html @@ -67,7 +67,7 @@ var prefix = ctx + "exam/examQuestionCategory" $("#form-examQuestionCategory-edit").validate({ rules:{ - xxxx:{ + name:{ required:true, }, }