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

import com.its.op.dto.its.rse.TbRseOffrSectDto;
import com.its.op.service.its.rse.TbRseOffrSectService;
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_sect")
public class TbRseOffrSectController {

    private final TbRseOffrSectService service;

    @ApiOperation(value = "RSE 제공 구간 전체조회(TB_RSE_OFFR_SECT)", response = TbRseOffrSectDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseOffrSectDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "RSE 제공 구간 개별조회(TB_RSE_OFFR_SECT)", response = TbRseOffrSectDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseOffrSectDto findById(@PathVariable final Long id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "RSE 제공 구간 정보변경(TB_RSE_OFFR_SECT)", response = TbRseOffrSectDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseOffrSectDto updateById(@PathVariable final Long id, @RequestBody @Valid final TbRseOffrSectDto.TbRseOffrSectUpdReq req) {
        return this.service.updateById(id, req);
    }

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

    @ApiOperation(value = "RSE 제공 구간 정보변경/생성-개별(TB_RSE_OFFR_SECT)", response = TbRseOffrSectDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseOffrSectDto mergeInfo(@PathVariable("id") Long id, @RequestBody @Valid final TbRseOffrSectDto.TbRseOffrSectUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "RSE 제공 구간 정보삭제-개별(TB_RSE_OFFR_SECT)", response = TbRseOffrSectDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseOffrSectDto deleteDataById(@PathVariable("id") Long id) {
        return this.service.deleteById(id);
    }

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

}
