package com.xindazhou.user.api.permission;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.user.controller.admin.permission.vo.role.RoleSaveReqVO;
import com.xindazhou.user.dal.dataobject.permission.RoleDO;
import com.xindazhou.user.service.permission.RoleService;
import org.springframework.context.annotation.Primary;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.Collection;
import java.util.List;

import static com.xindazhou.framework.common.pojo.CommonResult.success;

/**
 * 角色 RPC 接口实现类
 *
 * @author xindazhou
 */
@RestController
@Validated
@Primary
public class RoleApiImpl implements RoleApi {

    @Resource
    private RoleService roleService;

    @Override
    public CommonResult<List<RoleDO>> getRoleList(Collection<Long> ids) {
        return success(roleService.getRoleList(ids));
    }

    @Override
    public CommonResult<List<RoleDO>> getRoleList() {
        return success(roleService.getRoleList());
    }

    @Override
    public CommonResult<List<RoleDO>> getRoleListFromCache(Collection<Long> ids) {
        return success(roleService.getRoleListFromCache(ids));
    }

    @Override
    public CommonResult<Long> createRole(RoleSaveReqVO reqVO, Integer type) {
        return success(roleService.createRole(reqVO, type));
    }

    @Override
    public CommonResult<List<RoleDO>> getRoleListByStatus(Collection<Integer> statuses) {
        return success(roleService.getRoleListByStatus(statuses));
    }

}

