package com.zioinfo.kintex.cms;

import com.zioinfo.kintex.cms.dto.MicrositeDto;
import com.zioinfo.kintex.common.ApiResponse;
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;

/**
 * 공개 마이크로사이트 조회 (일반 대중·관람객·SEO). 무인증 — {@code /api/public/**} permitAll(SecurityConfig).
 * GET /api/public/microsites/&#123;exhibitorId&#125; → MicrositeDto(섹션·테마·SEO). 미존재 시 404.
 * <p>공개 P5 렌더 팀(후속)이 slug 라우팅/OG/사이트맵을 이 계약 위에 배선한다(impl_cms.md §공개 계약).
 */
@RestController
@RequestMapping("/api/public/microsites")
public class PublicMicrositeController {

    private final MicrositeService service;

    public PublicMicrositeController(MicrositeService service) {
        this.service = service;
    }

    @GetMapping("/{exhibitorId}")
    public ApiResponse<MicrositeDto> view(@PathVariable String exhibitorId) {
        return ApiResponse.ok(service.publicView(exhibitorId));
    }
}
