Search in sources :

Example 26 with AjaxJson

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

the class ScheduledController method create.

@ResponseBody
@RequestMapping("create")
@SystemLog(desc = "创建定时任务", opType = SysOpType.INSERT, tableName = "sys_schedule_job")
public AjaxJson create(@RequestBody ScheduleJob scheduleJob) {
    AjaxJson ajaxJson = new AjaxJson();
    scheduleJobService.save(scheduleJob);
    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 27 with AjaxJson

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

the class ScheduledController method pause.

@ResponseBody
@RequestMapping("pause")
@SystemLog(desc = "暂停定时任务", opType = SysOpType.UPDATE, tableName = "sys_schedule_job")
public AjaxJson pause(@RequestBody Long[] jobIds) {
    AjaxJson ajaxJson = new AjaxJson();
    scheduleJobService.pause(jobIds);
    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 28 with AjaxJson

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

the class GlobalExceptionHandler method defaultExceptionHandler.

/**
 *	@ExceptionHandler(value = Exception.class)
 *	public void defaultExceptionHandler(HttpServletRequest request, Exception e){
 *		if (logger.isDebugEnabled()) {
 *			logger.error(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), e);
 *		}
 *	}
 */
@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
public AjaxJson defaultExceptionHandler(final Exception e) {
    AjaxJson result = new AjaxJson();
    if (logger.isDebugEnabled()) {
        logger.error(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), e);
    }
    result.setSuccess(false);
    result.setMsg(e.getMessage());
    result.setResultCode(500);
    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 29 with AjaxJson

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

the class RoleOperateController method roleVisibleButton.

@ResponseBody
@RequestMapping("roleVisibleButton")
@SystemLog(desc = "启用、禁用账户", opType = SysOpType.UPDATE, tableName = "sys_role_menu")
public AjaxJson roleVisibleButton(@RequestParam(name = "id", required = true, defaultValue = "") int id, @RequestParam(name = "visible", required = true, defaultValue = "1") int visible) {
    AjaxJson resultMsg = new AjaxJson();
    SysRole role = new SysRole();
    role.setId(id);
    role.setIfVisible(visible);
    try {
        if (!roleService.hasMenuByRole(id) && !roleService.hasUserByRole(id) && id != 1) {
            roleService.update(role);
            resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
        } else {
            resultMsg.setSuccess(false);
            resultMsg.setMsg("错误提示:该角色下尚有用户未解除!");
        }
    } catch (Exception e) {
        resultMsg.setSuccess(false);
        resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
    }
    return resultMsg;
}
Also used : SysRole(com.cdeledu.model.rbac.SysRole) 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 30 with AjaxJson

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

the class RoleOperateController method delRole.

/**
 * @方法描述: 删除角色,根据ID,但是删除角色的时候,需要查询是否有赋予给用户,如果有用户在使用,那么就不能删除
 * @param role
 * @return
 */
@ResponseBody
@RequestMapping(value = "delRole")
@SystemLog(desc = "角色删除", opType = SysOpType.DEL, tableName = "sys_role")
public AjaxJson delRole(@RequestParam(name = "delId", required = true, defaultValue = "-1") int roleId) {
    AjaxJson resultMsg = new AjaxJson();
    try {
        if (roleId != 1) {
            SysRole seacherRole = roleService.getRoleById(roleId);
            if (seacherRole != null && seacherRole.getAllowDelete() == 1) {
                // 角色允许删除
                if (roleService.hasMenuByRole(roleId)) {
                    resultMsg.setSuccess(false);
                    resultMsg.setResultCode(201);
                    resultMsg.setMsg("该角色已经含有权限,无法直接删除!");
                } else {
                    if (roleService.hasUserByRole(roleId)) {
                        resultMsg.setSuccess(false);
                        resultMsg.setResultCode(201);
                        resultMsg.setMsg("该角色已被使用,无法直接删除!");
                    } else {
                        roleService.delete(roleId);
                        resultMsg.setSuccess(true);
                        resultMsg.setResultCode(200);
                        resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
                    }
                }
            } else {
                resultMsg.setSuccess(false);
                resultMsg.setResultCode(201);
                resultMsg.setMsg("该角色不允许删除");
            }
        } else {
            resultMsg.setSuccess(false);
            resultMsg.setResultCode(201);
            resultMsg.setMsg("无法删除超级管理员");
        }
    } catch (Exception e) {
        resultMsg.setSuccess(false);
        resultMsg.setResultCode(500);
        resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
    }
    return resultMsg;
}
Also used : SysRole(com.cdeledu.model.rbac.SysRole) 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

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