Search in sources :

Example 6 with SysUser

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;
}
Also used : SysUser(com.cdeledu.model.rbac.SysUser) AjaxJson(com.cdeledu.common.base.AjaxJson) SysUserRole(com.cdeledu.model.rbac.SysUserRole) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with SysUser

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;
}
Also used : SysUser(com.cdeledu.model.rbac.SysUser) AjaxJson(com.cdeledu.common.base.AjaxJson) SystemLog(com.cdeledu.core.annotation.SystemLog) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with SysUser

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;
}
Also used : SysUser(com.cdeledu.model.rbac.SysUser) AjaxJson(com.cdeledu.common.base.AjaxJson) SystemLog(com.cdeledu.core.annotation.SystemLog) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with SysUser

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;
}
Also used : SysUser(com.cdeledu.model.rbac.SysUser) AjaxJson(com.cdeledu.common.base.AjaxJson) SystemLog(com.cdeledu.core.annotation.SystemLog) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with SysUser

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;
}
Also used : SysUser(com.cdeledu.model.rbac.SysUser) AjaxJson(com.cdeledu.common.base.AjaxJson) SystemLog(com.cdeledu.core.annotation.SystemLog) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SysUser (com.cdeledu.model.rbac.SysUser)21 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 AjaxJson (com.cdeledu.common.base.AjaxJson)8 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 SystemLog (com.cdeledu.core.annotation.SystemLog)7 SysUserRole (com.cdeledu.model.rbac.SysUserRole)4 HttpSession (javax.servlet.http.HttpSession)3 AuthenticationException (org.apache.shiro.authc.AuthenticationException)2 DisabledAccountException (org.apache.shiro.authc.DisabledAccountException)2 ExcessiveAttemptsException (org.apache.shiro.authc.ExcessiveAttemptsException)2 LockedAccountException (org.apache.shiro.authc.LockedAccountException)2 UnknownAccountException (org.apache.shiro.authc.UnknownAccountException)2 Transactional (org.springframework.transaction.annotation.Transactional)2 OnlineUser (com.cdeledu.model.system.OnlineUser)1 HashMap (java.util.HashMap)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)1 UsernamePasswordToken (org.apache.shiro.authc.UsernamePasswordToken)1 SimpleAuthorizationInfo (org.apache.shiro.authz.SimpleAuthorizationInfo)1 SimplePrincipalCollection (org.apache.shiro.subject.SimplePrincipalCollection)1