- /**
- * 用户信息录入和更新
- *
- * @param user
- * @param req
- * @return
- */
- @RequestMapping(params = "del")
- @ResponseBody
- public AjaxJson del(TSUser user, HttpServletRequest req) {
- AjaxJson j = new AjaxJson();
- if ("admin".equals(user.getUserName())) {
- message = "超级管理员[admin]不可删除";
- j.setMsg(message);
- return j;
- }
- user = systemService.getEntity(TSUser.class, user.getId());
- List<TSRoleUser> roleUser = systemService.findByProperty(TSRoleUser.class,
- "TSUser.id",
- user.getId());
- List<TSLog> logUser = systemService.findByProperty(TSLog.class, "TSUser.id", user.getId());
- if (!user.getStatus().equals(Globals.User_ADMIN)) {
- if (roleUser.size() > 0) {
- // 删除用户时先删除用户和角色关系表
- delRoleUser(user);
- userService.delete(user);
- message = "用户:" + user.getUserName() + "删除成功";
- systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
- } else if (logUser.size() > 0) {
- // 删除用户时先删除用户日志
- delLogUser(user);
- userService.delete(user);
- message = "用户:" + user.getUserName() + "删除成功";
- systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
- } else {
- userService.delete(user);
- message = "用户:" + user.getUserName() + "删除成功";
- }
- } else {
- message = "超级管理员不可删除";
- }
- j.setMsg(message);
- return j;
- }
- // 同步删除用户角色关联表
- public void delRoleUser(TSUser user) {
- List<TSRoleUser> roleUserList = systemService.findByProperty(TSRoleUser.class,
- "TSUser.id",
- user.getId());
- if (roleUserList.size() >= 1) {
- for (TSRoleUser tRoleUser : roleUserList) {
- systemService.delete(tRoleUser);
- }
- }
- }
- // 同步删除用户关联日志
- public void delLogUser(TSUser user) {
- List<TSLog> logUserLisst = systemService.findByProperty(TSLog.class,
- "TSUser.id",
- user.getId());
- if (logUserLisst.size() >= 1) {
- for (TSLog tSLog : logUserLisst) {
- systemService.delete(tSLog);
- }
- }
- }
复制代码 |