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

import com.its.op.dto.its.rse.TbRseOffrDrctDto;
import com.its.op.entity.its.rse.TbRseOffrDrctKey;
import com.its.op.service.its.rse.TbRseOffrDrctService;
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_offr_drct")
public class TbRseOffrDrctController {

    private final TbRseOffrDrctService service;

    @ApiOperation(value = "RSE 제공 방향 정보 전체조회(TB_RSE_OFFR_DRCT)", response = TbRseOffrDrctDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseOffrDrctDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "RSE 제공 방향 정보 개별조회(TB_RSE_OFFR_DRCT)", response = TbRseOffrDrctDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseOffrDrctDto findById(@PathVariable final TbRseOffrDrctKey id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "RSE 제공 방향 정보 정보변경(TB_RSE_OFFR_DRCT)", response = TbRseOffrDrctDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseOffrDrctDto updateById(@PathVariable final TbRseOffrDrctKey id, @RequestBody @Valid final TbRseOffrDrctDto.TbRseOffrDrctUpdReq req) {
        return this.service.updateById(id, req);
    }

    @ApiOperation(value = "RSE 제공 방향 정보 정보변경/생성-목록(TB_RSE_OFFR_DRCT)", response = TbRseOffrDrctDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseOffrDrctDto> mergeInfoList(@RequestBody @Valid final List<TbRseOffrDrctDto.TbRseOffrDrctUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "RSE 제공 방향 정보 정보변경/생성-개별(TB_RSE_OFFR_DRCT)", response = TbRseOffrDrctDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseOffrDrctDto mergeInfo(@PathVariable("id") TbRseOffrDrctKey id, @RequestBody @Valid final TbRseOffrDrctDto.TbRseOffrDrctUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "RSE 제공 방향 정보 정보삭제-개별(TB_RSE_OFFR_DRCT)", response = TbRseOffrDrctDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseOffrDrctDto deleteDataById(@PathVariable("id") TbRseOffrDrctKey id) {
        return this.service.deleteById(id);
    }

    @ApiOperation(value = "RSE 제공 방향 정보 정보삭제-목록(TB_RSE_OFFR_DRCT)", response = TbRseOffrDrctDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseOffrDrctDto> deleteDataByIds(@RequestBody @Valid final List<TbRseOffrDrctKey> ids) {
        return this.service.deleteByIds(ids);
    }

}
