package com.its.op.controller.database; import com.its.op.model.dto.IfscDto; import com.its.op.model.dto.IfscLinkRltnDto; import com.its.op.model.entity.Ifsc; import com.its.op.model.entity.IfscLinkRltn; import com.its.op.service.database.TbIfscService; 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 java.util.ArrayList; import java.util.List; @Slf4j @RequiredArgsConstructor @RestController @RequestMapping("/api/database/tb-ifsc") @Api(tags = "09.기초데이터관리-03.서비스링크", description="서비스링크") public class TbIfscController { private final TbIfscService service; @ApiOperation(value = "전체조회(TB_IFSC)", response = IfscDto.IfscInfo.class) @GetMapping(value = "", produces = {"application/json; charset=utf8"}) public ResponseEntity> findAll() { List data = this.service.findAll(); List result = new ArrayList<>(); for (Ifsc obj: data) { result.add(new IfscDto.IfscInfo(obj)); } return new ResponseEntity<>(result, HttpStatus.OK); } @ApiOperation(value = "개별조회(TB_IFSC)", response = IfscDto.IfscInfo.class) @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"}) public ResponseEntity findById(@PathVariable final Long id) { Ifsc obj = this.service.findById(id); if (obj != null) { return new ResponseEntity<>(new IfscDto.IfscInfo(obj), HttpStatus.OK); } return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT); } @ApiOperation(value = "구간명변경(TB_IFSC)", response = IfscDto.IfscInfo.class) @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"}) public ResponseEntity updateNameById(@PathVariable final Long id, @RequestBody final IfscDto.IfscNameUpdateReq req) { Ifsc obj = this.service.updateNameById(id, req); if (obj != null) { return new ResponseEntity<>(new IfscDto.IfscInfo(obj), HttpStatus.OK); } return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT); } @ApiOperation(value = "개별구성정보조회(TB_IFSC_LINK_RLTN)", response = IfscLinkRltnDto.IfscLinkRltnInfo.class) @GetMapping(value = "/rltn/{id}", produces = {"application/json; charset=utf8"}) public ResponseEntity> findLinkRltnById(@PathVariable final Long id) { List objs = this.service.findLinkRltnById(id); if (objs != null) { List result = new ArrayList<>(); for (IfscLinkRltn obj : objs) { result.add(new IfscLinkRltnDto.IfscLinkRltnInfo(obj)); } return new ResponseEntity<>(result, HttpStatus.OK); } return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT); } @ApiOperation(value = "개별구성정보변경/생성(TB_IFSC_LINK_RLTN)", response = IfscDto.IfscInfo.class) @PutMapping(value = "/rltn/{id}", produces = {"application/json; charset=utf8"}) public ResponseEntity> updateRltn( @PathVariable final Long id, @RequestBody final List req) { List obj = this.service.updateRltn(id, req); if (obj != null) { return new ResponseEntity<>(obj, HttpStatus.OK); } return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT); } }