| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- package com.its.op.controller.database;
- import com.its.op.model.dto.AtrdDto;
- import com.its.op.model.dto.AtrdRoadRltnDto;
- import com.its.op.model.dto.RoadIfscRltnDto;
- import com.its.op.model.entity.Atrd;
- import com.its.op.model.entity.AtrdRoadRltn;
- import com.its.op.service.database.TbAtrdService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.bind.annotation.*;
- import javax.validation.Valid;
- import java.util.ArrayList;
- import java.util.List;
- @Slf4j
- @RequiredArgsConstructor
- @RestController
- @RequestMapping("/api/database/tb-atrd")
- @Api(tags = "09.기초데이터관리-05.간선도로관리", description="간선도로관리")
- public class TbAtrdController {
- private final TbAtrdService service;
- @ApiOperation(value = "전체조회(TB_ATRD)", response = AtrdDto.AtrdInfo.class)
- @GetMapping(value = "", produces = {"application/json; charset=utf8"})
- public ResponseEntity<List<AtrdDto.AtrdInfo>> findAll() {
- List<Atrd> data = this.service.findAll();
- List<AtrdDto.AtrdInfo> result = new ArrayList<>();
- for (Atrd obj: data) {
- result.add(new AtrdDto.AtrdInfo(obj));
- }
- return new ResponseEntity<>(result, HttpStatus.OK);
- }
- @ApiOperation(value = "개별조회(TB_ATRD)", response = AtrdDto.AtrdInfo.class)
- @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
- public ResponseEntity<AtrdDto.AtrdInfo> findById(@PathVariable final String id) {
- Atrd obj = this.service.findById(id);
- if (obj != null) {
- return new ResponseEntity<>(new AtrdDto.AtrdInfo(obj), HttpStatus.OK);
- }
- return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
- }
- @ApiOperation(value = "구간명변경(TB_ATRD)", response = AtrdDto.AtrdInfo.class)
- @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
- public ResponseEntity<AtrdDto.AtrdInfo> updateNameById(@PathVariable final String id, @RequestBody final AtrdDto.AtrdNameUpdateReq req) {
- Atrd obj = this.service.updateNameById(id, req);
- if (obj != null) {
- return new ResponseEntity<>(new AtrdDto.AtrdInfo(obj), HttpStatus.OK);
- }
- return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
- }
- @ApiOperation(value = "간선도로구간개별구성정보조회(TB_ATRD_ROAD_RLTN)", response = RoadIfscRltnDto.RoadIfscRltnUpdateReq.class)
- @GetMapping(value = "/road-rltn/{id}", produces = {"application/json; charset=utf8"})
- public ResponseEntity<List<AtrdRoadRltnDto.AtrdRoadRltnInfo>> findLinkRltnById(@PathVariable final String id) {
- List<AtrdRoadRltn> objs = this.service.findRltnById(id);
- if (objs != null) {
- List<AtrdRoadRltnDto.AtrdRoadRltnInfo> result = new ArrayList<>();
- for (AtrdRoadRltn obj : objs) {
- result.add(new AtrdRoadRltnDto.AtrdRoadRltnInfo(obj));
- }
- return new ResponseEntity<>(result, HttpStatus.OK);
- }
- return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
- }
- // 간선도로정보 + 도로구성정보
- @ApiOperation(value = "간선도로구간개별구성정보변경/생성(TB_ATRD_ROAD_RLTN)", response = AtrdDto.AtrdInfo.class)
- @PostMapping(value = "/road-rltn/{id}", produces = {"application/json; charset=utf8"})
- public ResponseEntity<List<AtrdRoadRltnDto.AtrdRoadRltnUpdateReq>> updateRltn(
- @PathVariable final String id,
- @RequestBody final List<AtrdRoadRltnDto.AtrdRoadRltnUpdateReq> req) {
- List<AtrdRoadRltnDto.AtrdRoadRltnUpdateReq> obj = this.service.updateRltn(id, req);
- if (obj != null) {
- return new ResponseEntity<>(obj, HttpStatus.OK);
- }
- return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
- }
- // 간선도로정보 생성-업데이트
- @ApiOperation(value = "간선도로정보변경/생성(TB_ATRD)", response = AtrdDto.AtrdInfo.class)
- @PostMapping(value = "", produces = {"application/json; charset=utf8"})
- public ResponseEntity<AtrdDto.AtrdInfo> mergeInfo(@RequestBody @Valid final AtrdDto.AtrdUpdateReq req) {
- log.error("{}", req);
- Atrd obj = this.service.mergeInfo(req);
- if (obj != null) {
- return new ResponseEntity<>(new AtrdDto.AtrdInfo(obj), HttpStatus.OK);
- }
- return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
- }
- }
|