yaobo 7 năm trước cách đây
mục cha
commit
f3e67d4950

+ 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);