package com.zioinfo.kintex.exhibitor;

import com.zioinfo.kintex.auth.EventAccessGuard;
import com.zioinfo.kintex.auth.EventRole;
import com.zioinfo.kintex.auth.KintexPrincipal;
import com.zioinfo.kintex.common.ApiResponse;
import com.zioinfo.kintex.exhibitor.dto.ExhibitorListDto;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 주최자용 참가업체 관리 API (#41 · SCR /exhibitors).
 * 참가사 로스터(회사·부스·설계/정산 상태·연락)를 행사 스코프로 반환한다.
 * RBAC: 주최자·홀매니저만(참가업체 상호 연락처 비노출 — 타 참가사 프라이버시 보호).
 */
@RestController
@RequestMapping("/api/events/{eventId}/exhibitors")
public class ExhibitorController {

    private final ExhibitorService service;
    private final EventAccessGuard guard;

    public ExhibitorController(ExhibitorService service, EventAccessGuard guard) {
        this.service = service;
        this.guard = guard;
    }

    /** GET — 행사별 참가업체 로스터 + 요약. */
    @GetMapping
    public ApiResponse<ExhibitorListDto> list(@AuthenticationPrincipal KintexPrincipal principal,
                                              @PathVariable String eventId) {
        guard.requireRole(principal, eventId, EventRole.ORGANIZER, EventRole.HALL_MANAGER);
        return ApiResponse.ok(service.list(eventId));
    }
}
