package com.its.op.controller.its.rse;

import com.its.op.dto.its.rse.TbRseCtlrSttsHsDto;
import com.its.op.entity.its.rse.TbRseCtlrSttsHsKey;
import com.its.op.service.its.rse.TbRseCtlrSttsHsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 = "14.RSE-1.RSE 관리-RSE 상태 이력")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/rse/tb_rse_ctlr_stts_hs")
public class TbRseCtlrSttsHsController {

    private final TbRseCtlrSttsHsService service;

    @ApiOperation(value = "RSE 상태 이력 전체조회(TB_RSE_CTLR_STTS_HS)", response = TbRseCtlrSttsHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseCtlrSttsHsDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "RSE 상태 이력 개별조회(TB_RSE_CTLR_STTS_HS)", response = TbRseCtlrSttsHsDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseCtlrSttsHsDto findById(@PathVariable final TbRseCtlrSttsHsKey id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "RSE 상태 이력 정보변경(TB_RSE_CTLR_STTS_HS)", response = TbRseCtlrSttsHsDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseCtlrSttsHsDto updateById(@PathVariable final TbRseCtlrSttsHsKey id, @RequestBody @Valid final TbRseCtlrSttsHsDto.TbRseCtlrSttsHsUpdReq req) {
        return this.service.updateById(id, req);
    }

    @ApiOperation(value = "RSE 상태 이력 정보변경/생성-목록(TB_RSE_CTLR_STTS_HS)", response = TbRseCtlrSttsHsDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseCtlrSttsHsDto> mergeInfoList(@RequestBody @Valid final List<TbRseCtlrSttsHsDto.TbRseCtlrSttsHsUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "RSE 상태 이력 정보변경/생성-개별(TB_RSE_CTLR_STTS_HS)", response = TbRseCtlrSttsHsDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseCtlrSttsHsDto mergeInfo(@PathVariable("id") TbRseCtlrSttsHsKey id, @RequestBody @Valid final TbRseCtlrSttsHsDto.TbRseCtlrSttsHsUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "RSE 상태 이력 정보삭제-개별(TB_RSE_CTLR_STTS_HS)", response = TbRseCtlrSttsHsDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseCtlrSttsHsDto deleteDataById(@PathVariable("id") TbRseCtlrSttsHsKey id) {
        return this.service.deleteById(id);
    }

    @ApiOperation(value = "RSE 상태 이력 정보삭제-목록(TB_RSE_CTLR_STTS_HS)", response = TbRseCtlrSttsHsDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseCtlrSttsHsDto> deleteDataByIds(@RequestBody @Valid final List<TbRseCtlrSttsHsKey> ids) {
        return this.service.deleteByIds(ids);
    }

}
