Search in sources :

Example 41 with AjaxJson

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

the class MenuOperateController method saveMenu.

@ResponseBody
@RequestMapping(value = "saveMenu")
@SystemLog(desc = "更新权限菜单", opType = SysOpType.INSERT, tableName = "sys_menu")
public AjaxJson saveMenu(SysMenu sysMenu) {
    AjaxJson ajaxJson = new AjaxJson();
    try {
        SysMenu menu = sysMenuService.findOneById(sysMenu.getId());
        if (menu != null && menu.getAllowEdit() == 1) {
            if (menu.getType() == sysMenu.getType()) {
                sysMenuService.update(sysMenu);
                ajaxJson.setMsg(MessageConstant.SUCCESS_UPDATE_MESSAGE);
            } else {
                if (!sysMenuService.hasChildren(sysMenu.getId())) {
                    sysMenuService.update(sysMenu);
                    ajaxJson.setMsg(MessageConstant.SUCCESS_UPDATE_MESSAGE);
                } else {
                    ajaxJson.setSuccess(false);
                    ajaxJson.setMsg(MessageConstant.MSG_HAS_CHILD);
                }
            }
        } else {
            ajaxJson.setSuccess(false);
            ajaxJson.setMsg("不支持更新操作");
        }
    } catch (Exception e) {
        ajaxJson.setMsg(MessageConstant.FAILURE_UPDATE_MESSAGE);
        ajaxJson.setSuccess(false);
    }
    return ajaxJson;
}
Also used : SysMenu(com.cdeledu.model.rbac.SysMenu) 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 42 with AjaxJson

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

the class MenuOperateController method editDisable.

@ResponseBody
@RequestMapping(value = "updateMenu", params = "editDisable")
@SystemLog(desc = "禁止编辑菜单", opType = SysOpType.UPDATE, tableName = "sys_menu")
public AjaxJson editDisable(SysMenu sysMenu) {
    AjaxJson ajaxJson = new AjaxJson();
    ajaxJson.setMsg(MessageConstant.SUCCESS_ENABLE_FALSE);
    return ajaxJson;
}
Also used : 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 43 with AjaxJson

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

the class GlobalExceptionHandler method handleHttpRequestMethodNotSupportedException.

/**
 * 405 - Method Not Allowed
 */
@ResponseBody
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public AjaxJson handleHttpRequestMethodNotSupportedException(final HttpRequestMethodNotSupportedException e) {
    AjaxJson result = new AjaxJson();
    if (logger.isDebugEnabled()) {
        logger.error(HttpStatus.METHOD_NOT_ALLOWED.getReasonPhrase(), e);
    }
    result.setSuccess(false);
    result.setMsg(e.getMessage());
    result.setResultCode(405);
    return result;
}
Also used : AjaxJson(com.cdeledu.common.base.AjaxJson) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 44 with AjaxJson

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

the class GlobalExceptionHandler method requestMissingServletRequest.

/**
 * 400 - Bad Request
 */
@ResponseBody
@ExceptionHandler(MissingServletRequestParameterException.class)
public AjaxJson requestMissingServletRequest(MissingServletRequestParameterException ex) {
    AjaxJson result = new AjaxJson();
    if (logger.isDebugEnabled()) {
        logger.error("MissingServletRequestParameterException", 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)

Example 45 with AjaxJson

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

the class GlobalExceptionHandler method handleSQLException.

/**
 * 400 - Bad Request
 */
@ResponseBody
@ExceptionHandler(SQLException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public AjaxJson handleSQLException(final SQLException e) {
    AjaxJson result = new AjaxJson();
    if (logger.isDebugEnabled()) {
        logger.error("SQLException", e);
    }
    result.setSuccess(false);
    result.setMsg(e.getMessage());
    result.setResultCode(400);
    return result;
}
Also used : AjaxJson(com.cdeledu.common.base.AjaxJson) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) 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