package kr.xit.biz.ktgbs.web;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.tags.Tag;
import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest;
import kr.xit.biz.ktgbs.service.IBizKtGbsService;
import kr.xit.core.model.ApiResponseDTO;
import kr.xit.core.model.IApiResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * <pre>
 * description :
 *
 * packageName : kr.xit.biz.ktgbs.web
 * fileName    : BizKtGbsController
 * author      : limju
 * date        : 2024-08-19
 * ======================================================================
 * 변경일         변경자        변경 내용
 * ----------------------------------------------------------------------
 * 2024-08-19    limju       최초 생성
 *
 * </pre>
 */
@Tag(name = "BizKtGbsController", description = "KT GIBIS 업무처리 Controller")
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/api/biz/ktgbs/v1")
@Slf4j
public class BizKtGbsController {
    private static final String PARAM1 = """
                        {
                          "signguCode": "44131",
                          "ffnlgCode": "11",
                          "profile": "local"
                        }
                    """;
    private static final String PARAM2 = """
                        {
                          "signguCode": "44133",
                          "ffnlgCode": "11",
                          "profile": "local"
                        }
                    """;

    private final IBizKtGbsService service;

    @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
        @Content(
            mediaType = "application/json",
            examples = {
                @ExampleObject(
                    name = "천안시동남구청",
                    value = PARAM1),
                @ExampleObject(
                    name = "천안시서북구청",
                    value = PARAM2)
            })
    })
    @Operation(deprecated = true, summary = "기관용 토큰 발급 요청-batch에서 호출", description = "기관용 토큰 발급 요청-batch에서 호출")
    @PostMapping(value = "/requestToken", produces = MediaType.APPLICATION_JSON_VALUE)
    public IApiResponse requestToken(@RequestBody final KtMnsRequest paramDTO) {
        return ApiResponseDTO.success(service.requestToken(paramDTO));
    }
}
