package com.zioinfo.kintex.auction;

import com.zioinfo.kintex.auction.dto.AuctionDtos.ContractorDashboard;
import com.zioinfo.kintex.auth.EventAccessGuard;
import com.zioinfo.kintex.auth.KintexPrincipal;
import com.zioinfo.kintex.common.ApiResponse;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 업체 포털(SCR-38) — 장치·공사업체 수주 부스·진행 옥션·내 응찰 요약.
 * 자사 응찰 금액만 반환(타사 금액 비노출 — 봉인 규칙 준수).
 */
@RestController
@RequestMapping("/api/contractor")
public class ContractorController {

    private final AuctionService service;
    private final EventAccessGuard guard;

    public ContractorController(AuctionService service, EventAccessGuard guard) {
        this.service = service;
        this.guard = guard;
    }

    /** GET /api/contractor/dashboard — 내 업체 대시보드(소속 없으면 빈 지표). */
    @GetMapping("/dashboard")
    public ApiResponse<ContractorDashboard> dashboard(@AuthenticationPrincipal KintexPrincipal principal) {
        guard.require(principal);
        return ApiResponse.ok(service.contractorDashboard(principal));
    }
}
