package org.flowcolab.account.service.controllers;

import org.flowcolab.account.service.client.dto.role.RoleResponse;
import org.flowcolab.account.service.client.services.AccountRoleWebService;
import org.flowcolab.account.service.services.AccountRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Primary
@RequestMapping("/v1/account")
public class AccountRoleController implements AccountRoleWebService {

    private AccountRoleService accountRoleService;

    @Autowired
    public AccountRoleController(AccountRoleService accountRoleService) {
        this.accountRoleService = accountRoleService;
    }

    @Override
    @GetMapping("/{accountId}/role")
    public List<RoleResponse> findByAccountId(@PathVariable("accountId") long accountId) {
        List<RoleResponse> roleResponses = accountRoleService.findByAccountId(accountId);
        return roleResponses;
    }
}