Browse Source

admin用户可以任意修改

chenminghua 1 year ago
parent
commit
53149eeb49

+ 10 - 8
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/service/impl/ExamServiceImpl.java

@@ -37,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.stream.Collectors;
 
@@ -79,17 +80,18 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements Ex
 
     @Override
     public void save(ExamSaveReqDTO reqDTO) {
-
         // 从token中获得用户ID
         String userId = UserUtils.getUserId(false);
-        if (reqDTO.getCreateBy() != null && !reqDTO.getCreateBy().equals(userId)) {
-            throw new ServiceException("非创建人不允许修改");
-        }
-
-       int count =  paperService.allProcess(reqDTO.getId());
+        String userName = UserUtils.getUser(false).getUserName();
+        if (!StringUtils.isEmpty(userName) && !userName.toLowerCase().contains("admin")){
+            if (reqDTO.getCreateBy() != null && !reqDTO.getCreateBy().equals(userId)) {
+                throw new ServiceException("非创建人不允许修改");
+            }
 
-        if (count > 0){
-            throw new ServiceException("已有人员参加考试,不允许修改试卷");
+            int count =  paperService.allProcess(reqDTO.getId());
+            if (count > 0){
+                throw new ServiceException("已有人员参加考试,不允许修改试卷");
+            }
         }
         // ID
         String id = reqDTO.getId();