package com.its.api.its.controller.database;

import com.its.api.its.model.dto.link.TbLinkDto;
import com.its.api.its.model.dto.node.TbNodeDto;
import com.its.api.its.service.link.TbLinkService;
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 = "09.기초데이터관리-02.링크")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/database/link")
public class TbLinkController {

    private final TbLinkService service;

    @ApiOperation(value = "링크정보 전체조회(TB_LINK)", response = TbLinkDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbLinkDto> findAll() {
        return service.findAll();
    }

    @ApiOperation(value = "링크정보 전체조회-삭제되지 않은 정보(TB_LINK)", response = TbLinkDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/list", produces = {"application/json; charset=utf8"})
    public List<TbLinkDto> findAllList() {
        return service.findAllList();
    }

    @ApiOperation(value = "링크정보 전체조회-지역센터(TB_LINK)", response = TbLinkDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/local", produces = {"application/json; charset=utf8"})
    public List<TbLinkDto> findLocalAll() {
        return service.findLocalAll();
    }

    @ApiOperation(value = "링크정보 개별조회(TB_LINK)", response = TbLinkDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbLinkDto findById(@PathVariable final Long id) {
        return this.service.findById(id);
    }

/*
    @ApiOperation(value = "링크정보 정보변경(TB_LINK)", response = TbLinkDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbLinkDto updateById(@PathVariable final Long id, @RequestBody @Valid final TbLinkDto.TbLinkUpdReq req) {
        return this.service.updateById(id, req);
    }
*/

    @ApiOperation(value = "링크정보 도로명변경(TB_NODE)", response = TbNodeDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbLinkDto updateNameById(@PathVariable final Long id, @RequestBody @Valid final TbLinkDto.TbLinkNameUpdReq req) {
        return this.service.updateNameById(id, req);
    }

}
