|
@@ -3,7 +3,9 @@ package cn.efunbox.audio.controller;
|
|
import cn.efunbox.audio.consts.Consts;
|
|
import cn.efunbox.audio.consts.Consts;
|
|
import cn.efunbox.audio.consts.Status;
|
|
import cn.efunbox.audio.consts.Status;
|
|
import cn.efunbox.audio.entity.Admin;
|
|
import cn.efunbox.audio.entity.Admin;
|
|
|
|
+import cn.efunbox.audio.entity.Trail;
|
|
import cn.efunbox.audio.service.AdminService;
|
|
import cn.efunbox.audio.service.AdminService;
|
|
|
|
+import cn.efunbox.audio.service.TrailService;
|
|
import cn.efunbox.audio.utils.ApiCode;
|
|
import cn.efunbox.audio.utils.ApiCode;
|
|
import cn.efunbox.audio.utils.Common;
|
|
import cn.efunbox.audio.utils.Common;
|
|
import cn.efunbox.audio.utils.HttpUtil;
|
|
import cn.efunbox.audio.utils.HttpUtil;
|
|
@@ -36,6 +38,9 @@ public class AdminController {
|
|
AdminService adminService;
|
|
AdminService adminService;
|
|
@Autowired
|
|
@Autowired
|
|
StringRedisTemplate stringRedisTemplate;
|
|
StringRedisTemplate stringRedisTemplate;
|
|
|
|
+ @Autowired
|
|
|
|
+ TrailService trailService;
|
|
|
|
+
|
|
@Value("${admin.token.expire}")
|
|
@Value("${admin.token.expire}")
|
|
int tokenExpire = 24*30;
|
|
int tokenExpire = 24*30;
|
|
|
|
|
|
@@ -141,11 +146,24 @@ public class AdminController {
|
|
|
|
|
|
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
|
public void Register(HttpServletRequest request, HttpServletResponse response, @RequestBody Admin admin){
|
|
public void Register(HttpServletRequest request, HttpServletResponse response, @RequestBody Admin admin){
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ TrailController.Insert(adminService, trailService, request, "admin", admin.getId(), " 创建管理员:" + admin.getName());
|
|
InsertUpdate(request, response, admin);
|
|
InsertUpdate(request, response, admin);
|
|
}
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
|
public void Update(HttpServletRequest request, HttpServletResponse response, @RequestBody Admin admin){
|
|
public void Update(HttpServletRequest request, HttpServletResponse response, @RequestBody Admin admin){
|
|
|
|
+ if(admin.getName().equalsIgnoreCase("superadmin")){
|
|
|
|
+ HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ TrailController.Insert(adminService, trailService, request, "admin", admin.getId(), " 修改管理员:" + admin.getName());
|
|
InsertUpdate(request, response, admin);
|
|
InsertUpdate(request, response, admin);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -154,22 +172,23 @@ public class AdminController {
|
|
String idAdmin = request.getParameter("idAdmin");
|
|
String idAdmin = request.getParameter("idAdmin");
|
|
adminService.Delete(Long.valueOf(idAdmin));
|
|
adminService.Delete(Long.valueOf(idAdmin));
|
|
HttpUtil.responseOk(request, response);
|
|
HttpUtil.responseOk(request, response);
|
|
|
|
+ TrailController.Insert(adminService, trailService, request, "admin", Long.valueOf(idAdmin), " 删除管理员:" + idAdmin);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- public void InsertUpdate(HttpServletRequest request, HttpServletResponse response, Admin admin){
|
|
|
|
|
|
+ public Admin InsertUpdate(HttpServletRequest request, HttpServletResponse response, Admin admin){
|
|
String name = admin.getName();
|
|
String name = admin.getName();
|
|
String pwd = admin.getPwd();
|
|
String pwd = admin.getPwd();
|
|
if(admin.getId()==null){
|
|
if(admin.getId()==null){
|
|
|
|
|
|
if(name==null || name.length()<4 || pwd==null || pwd.length()<4){
|
|
if(name==null || name.length()<4 || pwd==null || pwd.length()<4){
|
|
HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
|
|
HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
|
|
- return;
|
|
|
|
|
|
+ return admin;
|
|
}
|
|
}
|
|
List<Admin> list = adminService.SearchByName(name);
|
|
List<Admin> list = adminService.SearchByName(name);
|
|
if(list!=null && list.size()>0){
|
|
if(list!=null && list.size()>0){
|
|
HttpUtil.responseApiCode(request, response, ApiCode.RECORD_EXIST);
|
|
HttpUtil.responseApiCode(request, response, ApiCode.RECORD_EXIST);
|
|
- return;
|
|
|
|
|
|
+ return admin;
|
|
}
|
|
}
|
|
admin.setStatus(Status.ONLINE.getCode());
|
|
admin.setStatus(Status.ONLINE.getCode());
|
|
admin.setCreated(new Timestamp(new Date().getTime()));
|
|
admin.setCreated(new Timestamp(new Date().getTime()));
|
|
@@ -177,7 +196,7 @@ public class AdminController {
|
|
Admin adminOld = adminService.GetOne(admin.getId());
|
|
Admin adminOld = adminService.GetOne(admin.getId());
|
|
if(adminOld==null){
|
|
if(adminOld==null){
|
|
HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
|
|
HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
|
|
- return;
|
|
|
|
|
|
+ return admin;
|
|
}
|
|
}
|
|
admin = (Admin)Common.CopyValue(admin, adminOld);
|
|
admin = (Admin)Common.CopyValue(admin, adminOld);
|
|
}
|
|
}
|
|
@@ -194,7 +213,7 @@ public class AdminController {
|
|
SaveRedis(admin);
|
|
SaveRedis(admin);
|
|
|
|
|
|
HttpUtil.responseOkData(request, response, admin);
|
|
HttpUtil.responseOkData(request, response, admin);
|
|
- return;
|
|
|
|
|
|
+ return admin;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|