TbIfscController.java 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package com.its.op.controller.database;
  2. import com.its.op.model.dto.IfscDto;
  3. import com.its.op.model.dto.IfscLinkRltnDto;
  4. import com.its.op.model.entity.Ifsc;
  5. import com.its.op.model.entity.IfscLinkRltn;
  6. import com.its.op.service.database.TbIfscService;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiOperation;
  9. import lombok.RequiredArgsConstructor;
  10. import lombok.extern.slf4j.Slf4j;
  11. import org.springframework.http.HttpStatus;
  12. import org.springframework.http.ResponseEntity;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.util.ArrayList;
  15. import java.util.List;
  16. @Slf4j
  17. @RequiredArgsConstructor
  18. @RestController
  19. @RequestMapping("/api/database/tb-ifsc")
  20. @Api(tags = "09.기초데이터관리-03.서비스링크", description="서비스링크")
  21. public class TbIfscController {
  22. private final TbIfscService service;
  23. @ApiOperation(value = "전체조회(TB_IFSC)", response = IfscDto.IfscInfo.class)
  24. @GetMapping(value = "", produces = {"application/json; charset=utf8"})
  25. public ResponseEntity<List<IfscDto.IfscInfo>> findAll() {
  26. List<Ifsc> data = this.service.findAll();
  27. List<IfscDto.IfscInfo> result = new ArrayList<>();
  28. for (Ifsc obj: data) {
  29. result.add(new IfscDto.IfscInfo(obj));
  30. }
  31. return new ResponseEntity<>(result, HttpStatus.OK);
  32. }
  33. @ApiOperation(value = "개별조회(TB_IFSC)", response = IfscDto.IfscInfo.class)
  34. @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
  35. public ResponseEntity<IfscDto.IfscInfo> findById(@PathVariable final Long id) {
  36. Ifsc obj = this.service.findById(id);
  37. if (obj != null) {
  38. return new ResponseEntity<>(new IfscDto.IfscInfo(obj), HttpStatus.OK);
  39. }
  40. return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
  41. }
  42. @ApiOperation(value = "구간명변경(TB_IFSC)", response = IfscDto.IfscInfo.class)
  43. @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
  44. public ResponseEntity<IfscDto.IfscInfo> updateNameById(@PathVariable final Long id, @RequestBody final IfscDto.IfscNameUpdateReq req) {
  45. Ifsc obj = this.service.updateNameById(id, req);
  46. if (obj != null) {
  47. return new ResponseEntity<>(new IfscDto.IfscInfo(obj), HttpStatus.OK);
  48. }
  49. return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
  50. }
  51. @ApiOperation(value = "개별구성정보조회(TB_IFSC_LINK_RLTN)", response = IfscLinkRltnDto.IfscLinkRltnInfo.class)
  52. @GetMapping(value = "/rltn/{id}", produces = {"application/json; charset=utf8"})
  53. public ResponseEntity<List<IfscLinkRltnDto.IfscLinkRltnInfo>> findLinkRltnById(@PathVariable final Long id) {
  54. List<IfscLinkRltn> objs = this.service.findLinkRltnById(id);
  55. if (objs != null) {
  56. List<IfscLinkRltnDto.IfscLinkRltnInfo> result = new ArrayList<>();
  57. for (IfscLinkRltn obj : objs) {
  58. result.add(new IfscLinkRltnDto.IfscLinkRltnInfo(obj));
  59. }
  60. return new ResponseEntity<>(result, HttpStatus.OK);
  61. }
  62. return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
  63. }
  64. @ApiOperation(value = "개별구성정보변경/생성(TB_IFSC_LINK_RLTN)", response = IfscDto.IfscInfo.class)
  65. @PutMapping(value = "/rltn/{id}", produces = {"application/json; charset=utf8"})
  66. public ResponseEntity<List<IfscLinkRltnDto.IfscLinkRltnUpdateReq>> updateRltn(
  67. @PathVariable final Long id,
  68. @RequestBody final List<IfscLinkRltnDto.IfscLinkRltnUpdateReq> req) {
  69. List<IfscLinkRltnDto.IfscLinkRltnUpdateReq> obj = this.service.updateRltn(id, req);
  70. if (obj != null) {
  71. return new ResponseEntity<>(obj, HttpStatus.OK);
  72. }
  73. return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
  74. }
  75. }