package com.its.op.controller.its.database;

import com.its.op.dto.its.code.TbCmtrGradClsfDto;
import com.its.op.service.its.code.TbSectGradStupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "09.기초데이터관리-07.소통등급관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/database/cmtr-grad-clsf")
public class TbCmtrGradClsfController {

    private final TbSectGradStupService service;

    @ApiOperation(value = "소통 등급 분류 전체조회(TB_SECT_GRAD_STUP)", response = TbCmtrGradClsfDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbCmtrGradClsfDto> findAll() {
        return service.findAll();
    }

    @ApiOperation(value = "구간등급에 따른 소통등급 분류 목록 조회(TB_SECT_GRAD_STUP)", response = TbCmtrGradClsfDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/list/{sectGradCd}", produces = {"application/json; charset=utf8"})
    public List<TbCmtrGradClsfDto> findAllGradeList(
            @ApiParam(name = "sectGradCd", value = "구간등급코드", example = "SRT1", required = true)
            @PathVariable final String sectGradCd
    ) {
        return service.findAllGradeList(sectGradCd);
    }

    @ApiOperation(value = "소통 등급 분류 정보변경/생성-목록(TB_SECT_GRAD_STUP)", response = TbCmtrGradClsfDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbCmtrGradClsfDto> mergeInfoList(@RequestBody @Valid final List<TbCmtrGradClsfDto.TbCmtrGradClsfUpdReq> req) {
        return this.service.mergeInfoList(req);
    }

}
