Search in sources :

Example 11 with AjaxJson

use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.

the class SysUserOperateController method singUp.

/**
 * ----------------------------------------------------- Fields end
 */
/**
 * @方法描述: 用户注册
 * @param managerUser
 * @param request
 * @return
 */
@ResponseBody
@RequestMapping(value = "singUp")
public AjaxJson singUp(SysUser managerUser) {
    AjaxJson resultMsg = new AjaxJson();
    try {
        if (manageruserService.getUserByName(managerUser.getUserName()) == null) {
            manageruserService.insert(managerUser);
            resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
        } else {
            resultMsg.setSuccess(false);
            resultMsg.setMsg(MessageConstant.EXISTED);
        }
    } catch (Exception e) {
        resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
        resultMsg.setSuccess(false);
    }
    return resultMsg;
}
Also used : AjaxJson(com.cdeledu.common.base.AjaxJson) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with AjaxJson

use of com.cdeledu.common.base.AjaxJson 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 13 with AjaxJson

use of com.cdeledu.common.base.AjaxJson 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 14 with AjaxJson

use of com.cdeledu.common.base.AjaxJson 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)

Example 15 with AjaxJson

use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.

the class GlobalExceptionHandler method requestTypeMismatch.

/**
 * 400 - Bad Request
 */
@ResponseBody
@ExceptionHandler(TypeMismatchException.class)
public AjaxJson requestTypeMismatch(TypeMismatchException ex) {
    AjaxJson result = new AjaxJson();
    if (logger.isDebugEnabled()) {
        logger.error("TypeMismatchException", ex);
    }
    result.setSuccess(false);
    result.setMsg(ex.getMessage());
    result.setResultCode(400);
    return result;
}
Also used : AjaxJson(com.cdeledu.common.base.AjaxJson) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AjaxJson (com.cdeledu.common.base.AjaxJson)46 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)44 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)33 SystemLog (com.cdeledu.core.annotation.SystemLog)25 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)12 SysUser (com.cdeledu.model.rbac.SysUser)8 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)6 SysRole (com.cdeledu.model.rbac.SysRole)4 SysMenu (com.cdeledu.model.rbac.SysMenu)3 SysUserRole (com.cdeledu.model.rbac.SysUserRole)2 SysIcon (com.cdeledu.model.system.SysIcon)1 Map (java.util.Map)1 HttpSession (javax.servlet.http.HttpSession)1 AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 DisabledAccountException (org.apache.shiro.authc.DisabledAccountException)1 ExcessiveAttemptsException (org.apache.shiro.authc.ExcessiveAttemptsException)1 ExpiredCredentialsException (org.apache.shiro.authc.ExpiredCredentialsException)1 IncorrectCredentialsException (org.apache.shiro.authc.IncorrectCredentialsException)1 LockedAccountException (org.apache.shiro.authc.LockedAccountException)1 UnknownAccountException (org.apache.shiro.authc.UnknownAccountException)1