Skip to content

Commit

Permalink
미사용 코드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
seungh0 committed Jul 22, 2024
1 parent e3e4aa9 commit 67aea30
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
* PackageConstants
*
* @author seungh0
* @since 2024-07-01
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PackageConstants {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,25 @@

import lombok.Getter;

import java.util.Collections;
import java.util.List;

/**
* BaseException
*
* @author seungh0
* @since 2024-07-01
*/
@Getter
public abstract class BaseException extends RuntimeException {

private final ErrorCode errorCode;
private final List<String> reasons;

protected BaseException(String message, ErrorCode errorCode) {
super(message);
this.errorCode = errorCode;
this.reasons = Collections.emptyList();
}

protected BaseException(String message, ErrorCode errorCode, Throwable cause) {
super(message, cause);
this.errorCode = errorCode;
this.reasons = Collections.emptyList();
}

protected BaseException(String message, ErrorCode errorCode, List<String> reasons) {
super(message);
this.errorCode = errorCode;
this.reasons = reasons;
}

protected BaseException(String message, ErrorCode errorCode, Throwable cause, List<String> reasons) {
super(message, cause);
this.errorCode = errorCode;
this.reasons = reasons;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

import lombok.Getter;

/**
* ErrorCode
*
* @author seungh0
* @since 2024-07-01
*/
@Getter
public enum ErrorCode {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
* Jsons
*
* @author seungh0
* @since 2024-07-01
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class Jsons {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
/**
* ClusterException
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
public class ClusterException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
/**
* ClusterKeyspaceException
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
public class ClusterKeyspaceException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
/**
* ClusterTableException
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
public class ClusterTableException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
/**
* ClusterUDTTypeException
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
public class ClusterUDTTypeException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
/**
* ClusterConnectionTest
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
class ClusterConnectionTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
/**
* ClusterQueryCommanderArgsTest
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
class ClusterQueryCommanderArgsTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
/**
* ColumnKindTest
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
class ColumnKindTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
/**
* ClusterUDTTypeGetCommanderTest
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
class ClusterUDTTypeGetCommanderTest extends IntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
/**
* ClusterUDTTypeListCommanderTest
*
* @author Seungho Kang ([email protected])
* @version 1.0.0
* @since 2024. 07. 07.
* @author seungh0
* @since 2024-07-07
*/
class ClusterUDTTypeListCommanderTest extends IntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,38 @@
package kr.hakdang.cassdio.web.common.dto.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import kr.hakdang.cassdio.common.error.ErrorCode;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Collections;
import java.util.List;

@EqualsAndHashCode
@ToString
@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ApiResponse<T> {

public static final ApiResponse<Object> OK = ok(null);

private boolean ok;

private String error;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<String> reasons;

private T result;

private ApiResponse(boolean ok, String error, List<String> reasons, T result) {
private ApiResponse(boolean ok, String error,, T result) {
this.ok = ok;
this.error = error;
this.reasons = reasons;
this.result = result;
}

public static <T> ApiResponse<T> ok(T result) {
return new ApiResponse<>(true, null, Collections.emptyList(), result);
return new ApiResponse<>(true, null, result);
}

public static ApiResponse<Void> ok() {
return new ApiResponse<>(true, null, Collections.emptyList(), null);
return new ApiResponse<>(true, null, null);
}

public static <T> ApiResponse<T> fail(ErrorCode errorCode) {
return new ApiResponse<>(false, errorCode.getCode(), Collections.emptyList(), null);
}

public static <T> ApiResponse<T> fail(ErrorCode errorCode, List<String> reasons) {
return new ApiResponse<>(false, errorCode.getCode(), reasons, null);
return new ApiResponse<>(false, errorCode.getCode(), null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
import kr.hakdang.cassdio.common.error.ErrorCode;
import kr.hakdang.cassdio.web.common.dto.response.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.List;

import static kr.hakdang.cassdio.common.error.ErrorCode.E400_INVALID_PARAMETER;

/**
* ControllerExceptionAdvice
*
* @author seungh0
* @since 2024-07-01
*/
@Slf4j
@RestControllerAdvice
public class ControllerExceptionAdvice {

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(BindException.class)
private ApiResponse<Object> handleBadRequest(BindException exception) {
List<String> reasons = exception.getBindingResult().getFieldErrors().stream()
.map(DefaultMessageSourceResolvable::getDefaultMessage)
.toList();
log.warn(exception.getMessage(), exception);
return ApiResponse.fail(E400_INVALID_PARAMETER, reasons);
return ApiResponse.fail(E400_INVALID_PARAMETER);
}

@ExceptionHandler(BaseException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* JsonConfig
*
* @author seungh0
* @since 2024-07-01
*/
@Configuration
class JsonConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
* WebDataBinderAdvice
*
* @author seungh0
* @since 2024-07-01
*/
@RestControllerAdvice
public class WebDataBinderAdvice {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kr.hakdang.cassdio.web.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
Expand All @@ -14,6 +15,7 @@
* @author akageun
* @since 2024-07-18
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import java.util.Map;
import java.util.UUID;

import static java.util.Collections.emptyMap;

/**
* ClusterApi
*
Expand Down Expand Up @@ -75,7 +73,7 @@ public ApiResponse<Map<String, Object>> getCassandraClusterDetail(
}

@PostMapping("")
public ApiResponse<Map<String, Object>> clusterRegister(
public ApiResponse<Void> clusterRegister(
@Valid @RequestBody ClusterRegisterRequest request
) {
try (CqlSession session = clusterConnector.makeSession(request.makeClusterConnector())) {
Expand All @@ -88,11 +86,11 @@ public ApiResponse<Map<String, Object>> clusterRegister(
clusterManager.register(args);
}

return ApiResponse.ok(emptyMap());
return ApiResponse.ok();
}

@PutMapping("/{clusterId}")
public ApiResponse<Map<String, Object>> clusterUpdate(
public ApiResponse<Void> clusterUpdate(
@PathVariable String clusterId,
@Valid @RequestBody ClusterRegisterRequest request
) {
Expand All @@ -105,7 +103,7 @@ public ApiResponse<Map<String, Object>> clusterUpdate(
clusterManager.update(clusterId, args);
}

return ApiResponse.ok(emptyMap());
return ApiResponse.ok();
}

@DeleteMapping("/{clusterId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public ApiResponse<Map<String, Object>> keyspaceNames(
}

@PutMapping("/keyspace/cache-evict")
public ApiResponse<Object> evictKeyspaceListCache(
public ApiResponse<Void> evictKeyspaceListCache(
@PathVariable String clusterId
) {
clusterKeyspaceReader.refreshKeyspaceCache(clusterId);
return ApiResponse.OK;
return ApiResponse.ok();
}

@GetMapping("/keyspace/{keyspace}")
Expand Down
Loading

0 comments on commit 67aea30

Please sign in to comment.