|
|
@@ -0,0 +1,126 @@
|
|
|
+package com.its.op.controller.database;
|
|
|
+
|
|
|
+import com.its.op.model.dto.database.CmmnCdDto;
|
|
|
+import com.its.op.model.dto.database.CmmnClsfCdDto;
|
|
|
+import com.its.op.model.entity.database.CmmnCd;
|
|
|
+import com.its.op.model.entity.database.CmmnClsfCd;
|
|
|
+import com.its.op.service.database.CmmnCdService;
|
|
|
+import com.its.op.service.database.CmmnClsfCdService;
|
|
|
+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/code")
|
|
|
+@Api(tags = "09.기초데이터관리-09.코드관리")
|
|
|
+public class CodeController {
|
|
|
+
|
|
|
+ private final CmmnClsfCdService cmmnClsfCdService;
|
|
|
+ private final CmmnCdService cmmnCdService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "대분류코드-전체조회(TB_CMMN_CLSF_CD)", response = CmmnClsfCdDto.CmmnClsfCdInfo.class)
|
|
|
+ @GetMapping(value = "/clsf-cd", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<List<CmmnClsfCdDto.CmmnClsfCdInfo>> findAllCmmnClsfCd() {
|
|
|
+ List<CmmnClsfCdDto.CmmnClsfCdInfo> result = new ArrayList<>();
|
|
|
+ List<CmmnClsfCd> data = this.cmmnClsfCdService.findAll();
|
|
|
+ for (CmmnClsfCd obj: data) {
|
|
|
+ result.add(new CmmnClsfCdDto.CmmnClsfCdInfo(obj));
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(result, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "대분류코드-개별조회(TB_CMMN_CLSF_CD)", response = CmmnClsfCdDto.CmmnClsfCdInfo.class)
|
|
|
+ @GetMapping(value = "/clsf-cd/{id}", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<CmmnClsfCdDto.CmmnClsfCdInfo> findByIdCmmnClsfCd(@PathVariable final String id) {
|
|
|
+ CmmnClsfCd obj = this.cmmnClsfCdService.findById(id);
|
|
|
+ if (obj != null) {
|
|
|
+ return new ResponseEntity<>(new CmmnClsfCdDto.CmmnClsfCdInfo(obj), HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(null, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "대분류코드-정보변경/생성(TB_CMMN_CLSF_CD)", response = CmmnClsfCdDto.CmmnClsfCdInfo.class)
|
|
|
+ @PostMapping(value = "/clsf-cd", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<CmmnClsfCdDto.CmmnClsfCdInfo> mergeInfoCmmnClsfCd(@RequestBody @Valid final CmmnClsfCdDto.CmmnClsfCdUpdateReq req) {
|
|
|
+ CmmnClsfCd data = this.cmmnClsfCdService.mergeInfo(req);
|
|
|
+ if (data != null) {
|
|
|
+ return new ResponseEntity<>(new CmmnClsfCdDto.CmmnClsfCdInfo(data), HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "대분류코드-정보삭제(TB_CMMN_CLSF_CD)", response = CmmnClsfCdDto.CmmnClsfCdInfo.class)
|
|
|
+ @DeleteMapping(value = "/clsf-cd/{id}", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<CmmnClsfCdDto.CmmnClsfCdInfo> deleteDataByIdCmmnClsfCd(@PathVariable("id") String id) {
|
|
|
+ CmmnClsfCd obj = this.cmmnClsfCdService.deleteById(id);
|
|
|
+ if (obj != null) {
|
|
|
+ return new ResponseEntity<>(new CmmnClsfCdDto.CmmnClsfCdInfo(obj), HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ////////////////////////////////////// 소분류코드
|
|
|
+ @ApiOperation(value = "소분류코드-전체조회(TB_CMMN_CLSF_CD)", response = CmmnCdDto.CmmnCdInfo.class)
|
|
|
+ @GetMapping(value = "/cmmn-cd", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<List<CmmnCdDto.CmmnCdInfo>> findAllCmmnCd() {
|
|
|
+ List<CmmnCdDto.CmmnCdInfo> result = new ArrayList<>();
|
|
|
+ List<CmmnCd> data = this.cmmnCdService.findAll();
|
|
|
+ for (CmmnCd obj: data) {
|
|
|
+ result.add(new CmmnCdDto.CmmnCdInfo(obj));
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(result, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "소분류코드-개별조회-목록(TB_CMMN_CLSF_CD)", response = CmmnCdDto.CmmnCdInfo.class)
|
|
|
+ @GetMapping(value = "/cmmn-cd/{id}", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<List<CmmnCdDto.CmmnCdInfo>> findByIdCmmnCd(@PathVariable final String id) {
|
|
|
+ List<CmmnCdDto.CmmnCdInfo> result = new ArrayList<>();
|
|
|
+ List<CmmnCd> data = this.cmmnCdService.findAllByCmmnClsfCd(id);
|
|
|
+ for (CmmnCd obj: data) {
|
|
|
+ result.add(new CmmnCdDto.CmmnCdInfo(obj));
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(result, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "소분류코드-개별조회-단일(TB_CMMN_CLSF_CD)", response = CmmnCdDto.CmmnCdInfo.class)
|
|
|
+ @GetMapping(value = "/cmmn-cd/{id}/{sub}", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<CmmnCdDto.CmmnCdInfo> findByIdCmmnCd(@PathVariable final String id, @PathVariable final String sub) {
|
|
|
+ CmmnCd data = this.cmmnCdService.findAllByCmmnClsfCdCmmnCd(id, sub);
|
|
|
+ if (data != null) {
|
|
|
+ return new ResponseEntity<>(new CmmnCdDto.CmmnCdInfo(data), HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "소분류코드-정보변경/생성(TB_CMMN_CLSF_CD)", response = CmmnCdDto.CmmnCdInfo.class)
|
|
|
+ @PostMapping(value = "/cmmn-cd", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<CmmnCdDto.CmmnCdInfo> mergeInfoCmmnCd(@RequestBody @Valid final CmmnCdDto.CmmnCdUpdateReq req) {
|
|
|
+ CmmnCd data = this.cmmnCdService.mergeInfo(req);
|
|
|
+ if (data != null) {
|
|
|
+ return new ResponseEntity<>(new CmmnCdDto.CmmnCdInfo(data), HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "소분류코드-정보삭제(TB_CMMN_CLSF_CD)", response = CmmnCdDto.CmmnCdInfo.class)
|
|
|
+ @DeleteMapping(value = "/cmmn-cd/{id}/sub", produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<CmmnCdDto.CmmnCdInfo> deleteDataByIdCmmnCd(@PathVariable("id") String id, @PathVariable("id") String sub) {
|
|
|
+ CmmnCd obj = this.cmmnCdService.deleteById(id, sub);
|
|
|
+ if (obj != null) {
|
|
|
+ return new ResponseEntity<>(new CmmnCdDto.CmmnCdInfo(obj), HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);//NO_CONTENT);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|