|
@@ -0,0 +1,86 @@
|
|
|
|
+package cn.com.qmth.stmms.admin.exam;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.ui.Model;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
+
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.CollationLabel;
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.CollationLabelService;
|
|
|
|
+import cn.com.qmth.stmms.common.annotation.Logging;
|
|
|
|
+import cn.com.qmth.stmms.common.domain.WebUser;
|
|
|
|
+import cn.com.qmth.stmms.common.enums.LogType;
|
|
|
|
+import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
|
|
+
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping("/admin/exam/collationLabel")
|
|
|
|
+public class CollationLabelController extends BaseExamController {
|
|
|
|
+
|
|
|
|
+ protected static Logger log = LoggerFactory.getLogger(CollationLabelController.class);
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CollationLabelService collationLabelService;
|
|
|
|
+
|
|
|
|
+ @Logging(menu = "查看整理异常", type = LogType.QUERY)
|
|
|
|
+ @RequestMapping
|
|
|
|
+ public String list(HttpServletRequest request, Model model, @RequestParam Integer examId) {
|
|
|
|
+ List<CollationLabel> list = collationLabelService.list(examId);
|
|
|
|
+ model.addAttribute("list", list);
|
|
|
|
+ model.addAttribute("examId", examId);
|
|
|
|
+ return "modules/exam/collationLabelList";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping("/add")
|
|
|
|
+ public String add(CollationLabel collationLabel, Model model, @RequestParam Integer examId) {
|
|
|
|
+ model.addAttribute("collationLabel", collationLabel);
|
|
|
|
+ model.addAttribute("examId", examId);
|
|
|
|
+ return "modules/exam/collationLabelForm";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Logging(menu = "新增整理异常", type = LogType.ADD)
|
|
|
|
+ @RequestMapping("/save")
|
|
|
|
+ public String save(HttpServletRequest request, CollationLabel collationLabel, RedirectAttributes redirectAttributes,
|
|
|
|
+ @RequestParam Integer examId) {
|
|
|
|
+ if (!StringUtils.isNotBlank(collationLabel.getName())) {
|
|
|
|
+ addMessage(redirectAttributes, "名称不能为空");
|
|
|
|
+ return "redirect:/admin/exam/collationLabel/add?examId=" + examId;
|
|
|
|
+ }
|
|
|
|
+ collationLabel.setExamId(examId);
|
|
|
|
+ collationLabel = collationLabelService.save(collationLabel);
|
|
|
|
+ addMessage(redirectAttributes, "创建'" + collationLabel.getCode() + "'成功");
|
|
|
|
+ return "redirect:/admin/exam/collationLabel?examId=" + examId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping("/edit")
|
|
|
|
+ public String edit(@RequestParam Integer examId, @RequestParam String code, Model model) {
|
|
|
|
+ CollationLabel collationLabel = collationLabelService.find(examId, code);
|
|
|
|
+ model.addAttribute("collationLabel", collationLabel);
|
|
|
|
+ return "modules/exam/collationLabelEdit";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Logging(menu = "编辑整理异常", type = LogType.UPDATE)
|
|
|
|
+ @RequestMapping(value = "/edit", method = RequestMethod.POST)
|
|
|
|
+ public String examEdit(HttpServletRequest request, CollationLabel collationLabel) {
|
|
|
|
+ WebUser user = RequestUtils.getWebUser(request);
|
|
|
|
+ CollationLabel old = collationLabelService.find(collationLabel.getExamId(), collationLabel.getCode());
|
|
|
|
+ if (user.isSchoolAdmin() && StringUtils.isNotBlank(collationLabel.getName())) {
|
|
|
|
+ String oldName = old.getName();
|
|
|
|
+ old.setName(collationLabel.getName());
|
|
|
|
+ collationLabelService.save(old);
|
|
|
|
+ RequestUtils.setLog(request, "编辑整理异常,考试ID:" + collationLabel.getExamId() + ",代码:" + collationLabel.getCode()
|
|
|
|
+ + ",原名称:" + oldName + ",新名称:" + collationLabel.getName());
|
|
|
|
+ }
|
|
|
|
+ return "redirect:/admin/exam/collationLabel?examId=" + old.getExamId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|