use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class SysUserOperateController method delUser.
/**
* @方法描述: 用户删除
* @创建者: 皇族灬战狼
* @创建时间: 2016年9月27日 下午4:51:19
* @param managerUser
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "deleteUser")
public AjaxJson delUser(@RequestParam(value = "id", required = true, defaultValue = "-1") Integer id) {
AjaxJson resultMsg = new AjaxJson();
try {
if (id != 1) {
SysUser sysUser = new SysUser();
sysUser.setId(id);
List<SysUserRole> userRoleList = manageruserService.getUserRole(sysUser);
if (userRoleList == null || userRoleList.isEmpty() || userRoleList.size() == 0) {
manageruserService.delete(id);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
} else {
resultMsg.setSuccess(false);
resultMsg.setMsg("删除失败,该用户已分配角色");
}
} else {
resultMsg.setSuccess(false);
resultMsg.setResultCode(403);
resultMsg.setMsg("无法删除超级管理员账号");
}
} catch (Exception e) {
resultMsg.setSuccess(false);
resultMsg.setResultCode(10001);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
}
return resultMsg;
}
use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class SysUserOperateController method updateUserDisable.
@ResponseBody
@RequestMapping("disable")
@SystemLog(desc = " 禁用账户", opType = SysOpType.UPDATE, tableName = { "sys_user" })
public AjaxJson updateUserDisable(int userId) {
AjaxJson resultMsg = new AjaxJson();
SysUser user = new SysUser();
user.setId(userId);
try {
SysUser sysUser = manageruserService.findOneForJdbc(user);
// 超级管理员不能操作
if (sysUser != null && sysUser.getUserType() != -1 && WebUtilHelper.getCurrentUserId() != userId) {
sysUser.setIfVisible(0);
manageruserService.update(sysUser);
}
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resultMsg.setSuccess(false);
resultMsg.setResultCode(500);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
}
return resultMsg;
}
use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class SysUserOperateController method unlockUser.
@ResponseBody
@RequestMapping(value = "unlockUser")
@SystemLog(desc = "解锁用户", opType = SysOpType.UPDATE, tableName = { "sys_user" })
public AjaxJson unlockUser(@RequestParam(name = "id", required = true) int userId) {
AjaxJson resultMsg = new AjaxJson();
SysUser user = new SysUser();
user.setId(userId);
try {
SysUser sysUser = manageruserService.findOneForJdbc(user);
if (sysUser != null && sysUser.getUserType() != -1 && WebUtilHelper.getCurrentUserId() != userId) {
sysUser.setIfLocked(1);
manageruserService.update(sysUser);
}
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resultMsg.setSuccess(false);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
}
return resultMsg;
}
use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class SysUserOperateController method forbidUserById.
/**
* @方法描述: 禁止登录
* @param status
* 1:有效,0:禁止登录
* @return
*/
@ResponseBody
@RequestMapping(value = "forbidUserById", method = RequestMethod.POST)
@SystemLog(desc = "禁止登录/允许登录", opType = SysOpType.UPDATE, tableName = { "sys_user" })
public AjaxJson forbidUserById(@RequestParam(name = "id", required = true) int userId, @RequestParam(name = "status", required = true, defaultValue = "1") int status) {
AjaxJson resultMsg = new AjaxJson();
SysUser user = new SysUser();
user.setId(userId);
try {
SysUser sysUser = manageruserService.findOneForJdbc(user);
if (sysUser != null && sysUser.getUserType() != -1 && WebUtilHelper.getCurrentUserId() != userId) {
sysUser.setLoginFlag(status);
manageruserService.update(sysUser);
}
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resultMsg.setSuccess(false);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
}
return resultMsg;
}
use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class SysUserOperateController method lockUser.
@ResponseBody
@RequestMapping(value = "lockUser", method = RequestMethod.POST)
@SystemLog(desc = "锁定用户", opType = SysOpType.UPDATE, tableName = { "sys_user" })
public AjaxJson lockUser(@RequestParam(name = "id", required = true) int userId) {
AjaxJson resultMsg = new AjaxJson();
SysUser user = new SysUser();
user.setId(userId);
try {
SysUser sysUser = manageruserService.findOneForJdbc(user);
if (sysUser != null && sysUser.getUserType() != -1 && WebUtilHelper.getCurrentUserId() != userId) {
sysUser.setIfLocked(0);
manageruserService.update(sysUser);
}
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resultMsg.setSuccess(false);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
}
return resultMsg;
}
Aggregations