yaobo 7 년 전
부모
커밋
f3e67d4950
1개의 변경된 파일13개의 추가작업 그리고 3개의 파일을 삭제
  1. 13 3
      src/main/java/cn/efunbox/audio/controller/AdminController.java

+ 13 - 3
src/main/java/cn/efunbox/audio/controller/AdminController.java

@@ -146,15 +146,19 @@ public class AdminController {
 
     @RequestMapping(value = "/register", method = RequestMethod.POST)
     public void Register(HttpServletRequest request, HttpServletResponse response, @RequestBody Admin admin){
-
+        if(admin.getName().equalsIgnoreCase("superadmin")){
+            HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
+            return;
+        }
         String id = request.getHeader("id");
         Admin superAdmin = adminService.GetOne(Long.valueOf(id));
         if(superAdmin==null || false==superAdmin.getName().equalsIgnoreCase("superadmin")){
             HttpUtil.responseApiCode(request, response, ApiCode.ACCESS_DENIED);
             return;
         }
+
+        admin = InsertUpdate(request, response, admin);
         TrailController.Insert(adminService, trailService, request, "admin", admin.getId(), " 创建管理员:" + admin.getName());
-        InsertUpdate(request, response, admin);
     }
 
     @RequestMapping(value = "/update", method = RequestMethod.POST)
@@ -163,12 +167,18 @@ public class AdminController {
             HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
             return;
         }
+        admin = InsertUpdate(request, response, admin);
         TrailController.Insert(adminService, trailService, request, "admin", admin.getId(), " 修改管理员:" + admin.getName());
-        InsertUpdate(request, response, admin);
     }
 
     @RequestMapping(value = "/delete", method = RequestMethod.POST)
     public void Delete(HttpServletRequest request, HttpServletResponse response){
+        String id = request.getHeader("id");
+        Admin superAdmin = adminService.GetOne(Long.valueOf(id));
+        if(superAdmin==null || false==superAdmin.getName().equalsIgnoreCase("superadmin")){
+            HttpUtil.responseApiCode(request, response, ApiCode.ACCESS_DENIED);
+            return;
+        }
         String idAdmin = request.getParameter("idAdmin");
         adminService.Delete(Long.valueOf(idAdmin));
         HttpUtil.responseOk(request, response);