1
0
Pārlūkot izejas kodu

新增分组删除警告按离线授权设置,在线授权默认不开启(以学校设置为准)

ting.yin 1 gadu atpakaļ
vecāks
revīzija
4d5801c7bf

+ 23 - 0
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/config/service/impl/SystemCache.java

@@ -39,6 +39,8 @@ public class SystemCache {
 
     private boolean doubleTrack;
 
+    private boolean groupDeleteWarn;
+
     private Long expireTime;
 
     private String fileServer;
@@ -61,6 +63,7 @@ public class SystemCache {
             if (httpUtil.getAPP()) {
                 Auth = true;
                 doubleTrack = true;
+                groupDeleteWarn = false;
             }
         } else if (s != null && SystemAuthType.OFFLINE.equals(s.getType())) {
             JSONObject json = AppLicenseUtil.parseLicense(ByteArray.fromBase64(s.getDescription()).value());
@@ -68,6 +71,7 @@ public class SystemCache {
         } else {
             Auth = false;
             doubleTrack = false;
+            groupDeleteWarn = false;
         }
         fileServer = configService.findByType(ConfigType.FILE_SERVER);
         markTime = Long.parseLong(configService.findByType(ConfigType.MARK_TIME));
@@ -113,6 +117,14 @@ public class SystemCache {
         this.doubleTrack = doubleTrack;
     }
 
+    public boolean isGroupDeleteWarn() {
+        return groupDeleteWarn;
+    }
+
+    public void setGroupDeleteWarn(boolean groupDeleteWarn) {
+        this.groupDeleteWarn = groupDeleteWarn;
+    }
+
     public void parseJson(JSONObject json) {
         if (json != null) {
             Auth = true;
@@ -137,9 +149,20 @@ public class SystemCache {
                     e.printStackTrace();
                 }
             }
+            this.groupDeleteWarn = false;
+            if (json.has("control") && json.getJSONObject("control").has("custom")
+                    && json.getJSONObject("control").getJSONObject("custom").has("enable_group_delete_warn")) {
+                try {
+                    this.groupDeleteWarn = json.getJSONObject("control").getJSONObject("custom")
+                            .getBoolean("enable_group_delete_warn");
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
         } else {
             Auth = false;
             doubleTrack = false;
+            groupDeleteWarn = false;
             expireTime = null;
         }
     }

+ 1 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/admin/config/SystemAuthController.java

@@ -65,6 +65,7 @@ public class SystemAuthController extends BaseController {
         view.addObject("typeList", SystemAuthType.values());
         view.addObject("auth", authCache.isAuth());
         view.addObject("doubleTrack", authCache.isDoubleTrack());
+        view.addObject("groupDeleteWarn", authCache.isGroupDeleteWarn());
         view.addObject("expireTime", authCache.getExpireTime() == null ? null : new Date(authCache.getExpireTime()));
         return view;
     }

+ 9 - 4
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/MarkGroupController.java

@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 import cn.com.qmth.stmms.admin.thread.MarkGroupDeleteThread;
+import cn.com.qmth.stmms.biz.config.service.impl.SystemCache;
 import cn.com.qmth.stmms.biz.exam.model.Exam;
 import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
 import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
@@ -123,6 +124,9 @@ public class MarkGroupController extends BaseExamController {
     @Value("${mark.group.delete}")
     private String markDeleteCode;
 
+    @Autowired
+    private SystemCache systemCache;
+
     @Logging(menu = "大题管理查询", type = LogType.QUERY)
     @RequestMapping
     public String list(HttpServletRequest request, Model model, @RequestParam(required = false) String subjectCode) {
@@ -414,7 +418,7 @@ public class MarkGroupController extends BaseExamController {
             model.addAttribute("exam", examService.findById(examId));
             Exam exam = examService.findById(examId);
             School school = schoolService.findById(exam.getSchoolId());
-            model.addAttribute("deleteCheck", school.isGroupDeleteCheck());
+            model.addAttribute("deleteCheck", systemCache.isGroupDeleteWarn() ? true : school.isGroupDeleteCheck());
             return "modules/exam/groupEditFull";
         } else {
             redirectAttributes.addAttribute("subjectCode", subjectCode);
@@ -436,8 +440,8 @@ public class MarkGroupController extends BaseExamController {
         }
         Exam exam = examService.findById(examId);
         School school = schoolService.findById(exam.getSchoolId());
-        if (school.isGroupDeleteCheck() && group.getLibraryCount() != 0 && group.getLeftCount() == 0
-                && !markDeleteCode.equals(deleteCode)) {
+        boolean warn = systemCache.isGroupDeleteWarn() ? true : school.isGroupDeleteCheck();
+        if (warn && group.getLibraryCount() != 0 && group.getLeftCount() == 0 && !markDeleteCode.equals(deleteCode)) {
             addMessage(redirectAttributes, "删除分组授权码不正确");
             redirectAttributes.addAttribute("subjectCode", subjectCode);
             return "redirect:/admin/exam/group";
@@ -493,7 +497,8 @@ public class MarkGroupController extends BaseExamController {
                 if (questionIds != null && reset.booleanValue()) {
                     // advance update
                     School school = schoolService.findById(exam.getSchoolId());
-                    if (school.isGroupDeleteCheck() && group.getLibraryCount() != 0 && group.getLeftCount() == 0
+                    boolean warn = systemCache.isGroupDeleteWarn() ? true : school.isGroupDeleteCheck();
+                    if (warn && group.getLibraryCount() != 0 && group.getLeftCount() == 0
                             && !markDeleteCode.equals(deleteCode)) {
                         addMessage(redirectAttributes, "分组授权码不正确");
                         redirectAttributes.addAttribute("subjectCode", subjectCode);

+ 1 - 0
stmms-web/src/main/webapp/WEB-INF/views/modules/sys/authInfo.jsp

@@ -31,6 +31,7 @@
 	        <div class="controls">
 	        	${systemAuth.type.name }
 	        	<c:if test="${doubleTrack}">:双评轨迹授权</c:if>
+	        	<c:if test="${groupDeleteWarn}">&nbsp; 开启删除分组警告</c:if>
 	        </div>
 	    </div>
 	</form:form>