Search in sources :

Example 1 with AdminLog

use of com.ibeiliao.deployment.admin.annotation.log.AdminLog in project Corgi by kevinYin.

the class EditRoleController method updateRole.

/**
 * 增加或修改角色信息
 * @param role JSON格式数据, {roleId:角色ID, rolename:角色名称, remarks:备注}
 * @param menuIds JSON格式数据,菜单ID列表 []
 * @param resIds JSON格式数据,资源ID列表 []
 * @param appIds JSON格式数据,APP ID 列表 []
 * @return result.success=true表示成功
 */
@MenuResource("增加/修改角色信息")
@RequestMapping(value = "updateRole.do", method = RequestMethod.POST)
@AdminLog
@ResponseBody
public RestResult<Object> updateRole(String role, String menuIds, String resIds, String appIds) {
    logger.info("admin#role#updateRole | 新增/修改角色 | role: " + role + ", menuIds: " + menuIds + ", resIds: " + resIds + ", appIds: " + appIds);
    ParameterUtil.assertNotBlank(role, "role不能为空");
    ParameterUtil.assertNotBlank(menuIds, "menuIds不能为空");
    ParameterUtil.assertNotBlank(resIds, "resIds不能为空");
    Map<String, Object> myRole = JsonUtil.parseObject(role, new TypeReference<HashMap<String, Object>>() {
    });
    List<Integer> menuIdList = JsonUtil.parseObject(menuIds, new TypeReference<List<Integer>>() {
    });
    List<Integer> appIdList = JsonUtil.parseObject(appIds, new TypeReference<List<Integer>>() {
    });
    List<Integer> resIdList = JsonUtil.parseObject(resIds, new TypeReference<List<Integer>>() {
    });
    logger.info("admin#role#updateRole | 新增/修改角色 | role: {}, menuIdList: {}, appIdList: {} ", JsonUtil.toJSONString(myRole), JsonUtil.toJSONString(menuIdList), JsonUtil.toJSONString(appIdList));
    Role theRole = validateRole(myRole, menuIdList, appIdList);
    roleService.authRole(theRole, ListUtils.toSet(appIdList), ListUtils.toSet(menuIdList), ListUtils.toSet(resIdList));
    return new RestResult<>(ApiCode.SUCCESS, "操作成功.");
}
Also used : Role(com.ibeiliao.deployment.admin.vo.account.Role) RestResult(com.ibeiliao.deployment.admin.common.RestResult) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) AdminLog(com.ibeiliao.deployment.admin.annotation.log.AdminLog) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with AdminLog

use of com.ibeiliao.deployment.admin.annotation.log.AdminLog in project Corgi by kevinYin.

the class ListAccountController method lockOrUnlockAccount.

/**
 * 冻结解冻管理员帐号,调用一次接口,做一次反操作。
 * 比如当前是正常状态,操作一次后变成冻结,再操作一次变成解冻
 * @param uid 管理员ID
 * @return result.success=true为成功, result.object=新的状态
 */
@RequestMapping(value = "lockOrUnlockAccount.do", method = RequestMethod.POST)
@MenuResource("冻结/解冻管理员")
@ResponseBody
@AdminLog
public RestResult<Integer> lockOrUnlockAccount(long uid) {
    AdminAccount account = adminAccountService.getById(uid);
    RestResult<Integer> result = null;
    if (account == null) {
        result = new RestResult<>(ApiCode.FAILURE, "帐号不存在,uid=" + uid);
    } else {
        String message = null;
        int newStatus = 0;
        if (account.getAccountStatus() == AdminAccount.LOCKED) {
            adminAccountService.unlockAccount(uid);
            message = "解冻帐号成功.";
            newStatus = AdminAccount.NOMAL;
            logger.info("admin#account#lockOrUnlockAccount | 解冻帐号成功 | uid: " + uid);
        } else {
            adminAccountService.lockAccount(uid);
            newStatus = AdminAccount.LOCKED;
            message = "冻结帐号成功.";
        }
        result = new RestResult<>(ApiCode.SUCCESS, message, newStatus);
        logger.info("admin#account#lockOrUnlockAccount | 冻结帐号成功 | uid: " + uid);
    }
    return result;
}
Also used : AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) AdminLog(com.ibeiliao.deployment.admin.annotation.log.AdminLog) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AdminLog (com.ibeiliao.deployment.admin.annotation.log.AdminLog)2 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 RestResult (com.ibeiliao.deployment.admin.common.RestResult)1 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 Role (com.ibeiliao.deployment.admin.vo.account.Role)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1