공통코드 중복체크,등록,수정,순서저장 API 커밋
This commit is contained in:
@@ -89,7 +89,7 @@ public class CommonCodeApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping
|
||||
public ApiResponseDto<Long> save(
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> save(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "공통코드 생성 요청 정보",
|
||||
required = true,
|
||||
@@ -100,7 +100,7 @@ public class CommonCodeApiController {
|
||||
@RequestBody
|
||||
@Valid
|
||||
CommonCodeDto.AddReq req) {
|
||||
return ApiResponseDto.createOK(commonCodeService.save(req));
|
||||
return ApiResponseDto.okObject(commonCodeService.save(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "수정", description = "공통코드를 수정 합니다.")
|
||||
@@ -118,7 +118,7 @@ public class CommonCodeApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public ApiResponseDto<Void> update(
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> update(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "공통코드 수정 요청 정보",
|
||||
required = true,
|
||||
@@ -129,8 +129,7 @@ public class CommonCodeApiController {
|
||||
@PathVariable
|
||||
Long id,
|
||||
@RequestBody @Valid CommonCodeDto.ModifyReq req) {
|
||||
commonCodeService.update(id, req);
|
||||
return ApiResponseDto.deleteOk(null);
|
||||
return ApiResponseDto.okObject(commonCodeService.update(id, req));
|
||||
}
|
||||
|
||||
@Operation(summary = "삭제", description = "공통코드를 삭제 합니다.")
|
||||
@@ -172,7 +171,7 @@ public class CommonCodeApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PutMapping("/order")
|
||||
public ApiResponseDto<Void> updateOrder(
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> updateOrder(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "공통코드 순서변경 요청 정보",
|
||||
required = true,
|
||||
@@ -183,8 +182,8 @@ public class CommonCodeApiController {
|
||||
@RequestBody
|
||||
@Valid
|
||||
CommonCodeDto.OrderReq req) {
|
||||
commonCodeService.updateOrder(req);
|
||||
return ApiResponseDto.deleteOk(null);
|
||||
|
||||
return ApiResponseDto.okObject(commonCodeService.updateOrder(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "code 기반 조회", description = "code 기반 조회")
|
||||
@@ -192,7 +191,7 @@ public class CommonCodeApiController {
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "공통코드 순서 변경 성공",
|
||||
description = "code 기반 조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
@@ -222,4 +221,26 @@ public class CommonCodeApiController {
|
||||
|
||||
return ApiResponseDto.ok(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "공통코드 중복여부 체크", description = "공통코드 중복여부 체크")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = CommonCodeDto.Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/check-duplicate")
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> getCodeCheckDuplicate(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "단건 조회", required = true)
|
||||
@RequestParam
|
||||
Long parentId,
|
||||
@RequestParam String code) {
|
||||
return ApiResponseDto.okObject(commonCodeService.getCodeCheckDuplicate(parentId, code));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.kamco.cd.kamcoback.code.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -39,10 +38,8 @@ public class CommonCodeDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ModifyReq {
|
||||
@NotEmpty private String code;
|
||||
@NotEmpty private String name;
|
||||
private String description;
|
||||
private int order;
|
||||
private boolean used;
|
||||
|
||||
private String props1;
|
||||
@@ -56,7 +53,8 @@ public class CommonCodeDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class OrderReq {
|
||||
@Valid List<OrderReqDetail> orders;
|
||||
@NotNull private Long id;
|
||||
@NotNull private Integer order;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -65,7 +63,6 @@ public class CommonCodeDto {
|
||||
@AllArgsConstructor
|
||||
public static class OrderReqDetail {
|
||||
@NotNull private Long id;
|
||||
|
||||
@NotNull private Integer order;
|
||||
}
|
||||
|
||||
@@ -90,8 +87,7 @@ public class CommonCodeDto {
|
||||
private String props2;
|
||||
private String props3;
|
||||
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime deletedDttm;
|
||||
@JsonFormatDttm private ZonedDateTime deletedDttm;
|
||||
|
||||
public Basic(
|
||||
Long id,
|
||||
@@ -107,8 +103,7 @@ public class CommonCodeDto {
|
||||
String props1,
|
||||
String props2,
|
||||
String props3,
|
||||
ZonedDateTime deletedDttm
|
||||
) {
|
||||
ZonedDateTime deletedDttm) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
|
||||
@@ -44,8 +44,8 @@ public class CommonCodeService {
|
||||
* @return 생성된 코드 id
|
||||
*/
|
||||
@Transactional
|
||||
public Long save(AddReq req) {
|
||||
return commonCodeCoreService.save(req).getId();
|
||||
public ApiResponseDto.ResponseObj save(AddReq req) {
|
||||
return commonCodeCoreService.save(req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,8 +55,8 @@ public class CommonCodeService {
|
||||
* @param req 수정요청 정보
|
||||
*/
|
||||
@Transactional
|
||||
public void update(Long id, ModifyReq req) {
|
||||
commonCodeCoreService.update(id, req);
|
||||
public ApiResponseDto.ResponseObj update(Long id, ModifyReq req) {
|
||||
return commonCodeCoreService.update(id, req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,8 +75,8 @@ public class CommonCodeService {
|
||||
* @param req id, order 정보를 가진 List
|
||||
*/
|
||||
@Transactional
|
||||
public void updateOrder(OrderReq req) {
|
||||
commonCodeCoreService.updateOrder(req);
|
||||
public ApiResponseDto.ResponseObj updateOrder(OrderReq req) {
|
||||
return commonCodeCoreService.updateOrder(req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,4 +88,15 @@ public class CommonCodeService {
|
||||
public List<Basic> findByCode(String code) {
|
||||
return commonCodeCoreService.findByCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 중복 체크
|
||||
*
|
||||
* @param parentId
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public ApiResponseDto.ResponseObj getCodeCheckDuplicate(Long parentId, String code) {
|
||||
return commonCodeCoreService.getCodeCheckDuplicate(parentId, code);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user