Search in sources :

Example 1 with SystemLog

use of com.cdeledu.core.annotation.SystemLog in project wechat by dllwh.

the class MenuOperateController method delMenu.

/**
 * @方法描述: 删除菜单,根据ID,但是删除权限的时候,需要查询是否有赋予给角色,如果有角色在使用,那么就不能删除。
 * @param menu
 * @return
 */
@ResponseBody
@RequestMapping(value = "del")
@SystemLog(desc = "删除权限菜单", opType = SysOpType.DEL, tableName = "sys_menu,sys_role_menu")
public AjaxJson delMenu(SysMenu sysMenu) {
    AjaxJson ajaxJson = new AjaxJson();
    try {
        Integer id = sysMenu.getId();
        SysMenu menu = sysMenuService.findOneById(id);
        if (menu != null && menu.getAllowDelete() == 1) {
            // 删除权限菜单时先删除权限菜单与角色之间关联表信息
            if (sysMenuService.hasRole(id)) {
                ajaxJson.setSuccess(false);
                ajaxJson.setMsg(MessageConstant.MSG_HAS_CHILD);
            } else {
                if (sysMenuService.hasChildren(id)) {
                    // 子节点
                    ajaxJson.setSuccess(false);
                    ajaxJson.setMsg(MessageConstant.MSG_HAS_CHILD);
                } else {
                    sysMenuService.delete(id);
                    ajaxJson.setMsg(MessageConstant.SUCCESS_DELETE_MESSAGE);
                }
            }
        } else {
            ajaxJson.setSuccess(false);
            ajaxJson.setMsg(MessageConstant.SUCCESS_DELETE_MESSAGE);
        }
    } catch (Exception e) {
        ajaxJson.setSuccess(false);
        ajaxJson.setResultCode(500);
        ajaxJson.setMsg(MessageConstant.FAILURE_DELETE_MESSAGE);
    }
    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 2 with SystemLog

use of com.cdeledu.core.annotation.SystemLog in project wechat by dllwh.

the class RoleOperateController method addRole.

/**
 * ----------------------------------------------------- Fields end
 */
/**
 * @方法描述 : 角色创建的时候,必须要自动添加到管理员下,保证管理员的权限是最大最全的
 * @param role
 * @return
 */
@ResponseBody
@RequestMapping(value = "addRole", method = RequestMethod.POST)
@SystemLog(desc = "角色添加", opType = SysOpType.INSERT, tableName = "sys_role")
public AjaxJson addRole(SysRole role) {
    AjaxJson resultMsg = new AjaxJson();
    try {
        if (roleService.existRoleWithRoleCode(role.getRoleCode())) {
            resultMsg.setSuccess(false);
            resultMsg.setMsg(MessageConstant.EXISTED);
            resultMsg.setResultCode(201);
        } else {
            roleService.insert(role);
        }
    } catch (Exception e) {
        e.printStackTrace();
        resultMsg.setSuccess(false);
        resultMsg.setMsg(MessageConstant.FAILURE_SAVE_MESSAGE);
        resultMsg.setResultCode(500);
    }
    return resultMsg;
}
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 3 with SystemLog

use of com.cdeledu.core.annotation.SystemLog in project wechat by dllwh.

the class RoleOperateController method updateMenuByRole.

@ResponseBody
@RequestMapping(value = "updateMenuByRole")
@SystemLog(desc = "更新角色的权限", opType = SysOpType.UPDATE, tableName = "sys_role_menu")
public AjaxJson updateMenuByRole(Integer roleId, String ids) {
    AjaxJson ajaxJson = new AjaxJson();
    if (roleId != null && StringUtils.isNoneBlank(ids)) {
        if (roleId != 1) {
            roleService.delRoleAccess(roleId);
            String[] str = ids.split(",");
            for (int i = 0; i < str.length; i++) {
                try {
                    roleService.saveRoleAccess(roleId, Integer.parseInt(str[i]));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } else {
            ajaxJson.setSuccess(false);
            ajaxJson.setResultCode(10005);
            ajaxJson.setMsg("该资源需要appkey拥有授权");
        }
    } else {
        ajaxJson.setSuccess(false);
        ajaxJson.setResultCode(10006);
        ajaxJson.setMsg("缺少source (appkey) 参数");
    }
    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 4 with SystemLog

use of com.cdeledu.core.annotation.SystemLog 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 5 with SystemLog

use of com.cdeledu.core.annotation.SystemLog 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)

Aggregations

SystemLog (com.cdeledu.core.annotation.SystemLog)26 AjaxJson (com.cdeledu.common.base.AjaxJson)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)25 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)25 SysUser (com.cdeledu.model.rbac.SysUser)7 SysRole (com.cdeledu.model.rbac.SysRole)4 SysMenu (com.cdeledu.model.rbac.SysMenu)3 SysUserRole (com.cdeledu.model.rbac.SysUserRole)1 SysLogEntity (com.cdeledu.model.system.SysLogEntity)1 Method (java.lang.reflect.Method)1 JoinPoint (org.aspectj.lang.JoinPoint)1 MethodSignature (org.aspectj.lang.reflect.MethodSignature)1