/** 删除该用户 */ @RequestMapping("/del/{userId}") @ResponseBody public Object delete(@PathVariable String userId, HttpSession session) { try { if (StringUtils.isBlank(userId)) { return new ExtReturn(false, "用户主键不能为空!"); } // 不能删除自己 BaseUsers user = (BaseUsers) session.getAttribute(WebConstants.CURRENT_USER); if (userId.equals(user.getUserId())) { return new ExtReturn(false, "不能删除自己的帐号!"); } Criteria criteria = new Criteria(); criteria.put("userId", userId); String result = this.baseUsersService.deleteByPrimaryKey(criteria); if ("01".equals(result)) { return new ExtReturn(true, "删除成功!"); } else if ("00".equals(result)) { return new ExtReturn(false, "删除失败!"); } else { return new ExtReturn(false, result); } } catch (Exception e) { logger.error("Exception: ", e); return new ExceptionReturn(e); } }
/** 保存用户信息 */ @RequestMapping("/save") @ResponseBody public Object save(BaseUsers user, @RequestParam Collection<String> roleIds) { try { if (roleIds == null || roleIds.size() == 0) { return new ExtReturn(false, "请至少选择一个角色!"); } if (StringUtils.isBlank(user.getAccount())) { return new ExtReturn(false, "帐号不能为空!"); } Criteria criteria = new Criteria(); criteria.put("roleIds", roleIds); criteria.put("user", user); String result = this.baseUsersService.saveUser(criteria); if ("01".equals(result)) { return new ExtReturn(true, "保存成功!"); } else if ("00".equals(result)) { return new ExtReturn(false, "保存失败!"); } else { return new ExtReturn(false, result); } } catch (Exception e) { logger.error("Exception: ", e); return new ExceptionReturn(e); } }
/** 保存用户自己编辑的信息 */ @RequestMapping(value = "/myinfo", method = RequestMethod.POST) @ResponseBody public Object saveMyinfo(BaseUsers user) { try { if (user == null) { return new ExtReturn(false, "用户不能为空!"); } if (StringUtils.isBlank(user.getUserId())) { return new ExtReturn(false, "用户ID不能为空!"); } String result = this.baseUsersService.updateByPrimaryKeySelective(user); if ("01".equals(result)) { return new ExtReturn(true, "用户信息更新成功!请重新登录!"); } else if ("00".equals(result)) { return new ExtReturn(false, "用户信息更新失败!"); } else { return new ExtReturn(false, result); } } catch (Exception e) { logger.error("Exception: ", e); return new ExceptionReturn(e); } }