Skip to content

Commit

Permalink
[#37] db 모듈, common 모듈 분리 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
sssukho authored Jan 12, 2025
2 parents a561ce2 + 4e4abae commit 168df3b
Show file tree
Hide file tree
Showing 127 changed files with 802 additions and 974 deletions.
3 changes: 2 additions & 1 deletion bp-app-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ dependencies {
implementation project(':bp-kafka-event-publisher')
implementation project(':bp-utils')
implementation project(':bp-s3-client')
implementation project(':bp-domain-mysql')
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.apache.commons:commons-lang3:3.14.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;

@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"com.beautify_project"})
@ConfigurationPropertiesScan("com.beautify_project.bp_app_api.config")
public class BpAppApiApplication {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.beautify_project.bp_app_api.bean;


import com.beautify_project.bp_app_api.config.properties.NaverCloudPlatformObjectStorageConfig;
import com.beautify_project.bp_app_api.config.properties.NaverCloudPlatformObjectStorageConfigProperties;
import com.beautify_project.bp_app_api.config.properties.StorageConfig;
import com.beautify_project.bp_app_api.dto.common.ErrorResponseMessage.ErrorCode;
import com.beautify_project.bp_app_api.exception.ConfigurationException;
import com.beautify_project.bp_app_api.repository.image.ImageRepository;
import com.beautify_project.bp_app_api.repository.image.NaverCloudPlatformObjectStorageRepository;
import com.beautify_project.bp_app_api.exception.BpCustomException;
import com.beautify_project.bp_app_api.response.ErrorResponseMessage.ErrorCode;
import com.beautify_project.bp_app_api.provider.image.ImageProvider;
import com.beautify_project.bp_app_api.provider.image.NCPImageProvider;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -16,19 +15,18 @@
@Slf4j
@Configuration
@RequiredArgsConstructor
public class ImageRepositoryBean {
public class ImageProviderBean {

private static final String STORAGE_TYPE_NAVER_CLOUD_PLATFORM_OBJECT_STORAGE = "NAVER-CLOUD-PLATFORM-OBJECT-STORAGE";
private final StorageConfig storageConfig;
private final NaverCloudPlatformObjectStorageConfig ncpObjectStorageConfig;
private final NaverCloudPlatformObjectStorageConfigProperties ncpObjectStorageConfig;

@Bean
ImageRepository imageRepository() {
ImageProvider imageProvider() {
final String storageType = storageConfig.type().toUpperCase();
if (StringUtils.equals(STORAGE_TYPE_NAVER_CLOUD_PLATFORM_OBJECT_STORAGE, storageType)) {
return new NaverCloudPlatformObjectStorageRepository(ncpObjectStorageConfig);
return new NCPImageProvider(ncpObjectStorageConfig);
}

throw new ConfigurationException("설정값이 맞지 않아 등록할 repository 가 없습니다", ErrorCode.IS001);
throw new BpCustomException("설정값이 올바르지 않아 등록할 image provider 가 없습니다.", ErrorCode.IS001);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.beautify_project.bp_app_api.config;

import com.beautify_project.bp_app_api.dto.common.ErrorResponseMessage;
import com.beautify_project.bp_app_api.dto.common.ErrorResponseMessage.ErrorCode;
import com.beautify_project.bp_app_api.response.ErrorResponseMessage;
import com.beautify_project.bp_app_api.response.ErrorResponseMessage.ErrorCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.ServletException;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.beautify_project.bp_app_api.config.properties;

import com.beautify_project.bp_app_api.exception.BpCustomException;
import com.beautify_project.bp_app_api.response.ErrorResponseMessage.ErrorCode;
import com.beautify_project.bp_utils.Validator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;


@ConfigurationProperties(prefix = "ncp")
@Slf4j
public record NaverCloudPlatformObjectStorageConfigProperties(String enabled, String endpoint, String regionName, String bucketName, String accessKey,
String secretKey) {

public NaverCloudPlatformObjectStorageConfigProperties {
validate(enabled, endpoint, regionName, bucketName, accessKey, secretKey);
}

private void validate(String enabled, String endpoint, String regionName, String bucketName, String accessKey,
String secretKey) {

if (Validator.isEmptyOrBlank(enabled) || StringUtils.equals("FALSE",
enabled.toUpperCase())) {
log.info("NaverCloudPlatformObjectStorageRepository is disabled");
return;
}

if (Validator.isEmptyOrBlank(endpoint) || Validator.isEmptyOrBlank(regionName)
|| Validator.isEmptyOrBlank(bucketName) || Validator.isEmptyOrBlank(accessKey)) {
throw new BpCustomException("Naver cloud paltform 관련 설정값이 올바르지 않습니다.", ErrorCode.IS001);
}
}

@Override
public String toString() {
return "NaverCloudPlatformObjectStorageConfig{" +
"bucketName='" + bucketName + '\'' +
", regionName='" + regionName + '\'' +
", endpoint='" + endpoint + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.beautify_project.bp_app_api.config.properties;

import com.beautify_project.bp_app_api.dto.common.ErrorResponseMessage.ErrorCode;
import com.beautify_project.bp_app_api.exception.ConfigurationException;
import com.beautify_project.bp_app_api.exception.BpCustomException;
import com.beautify_project.bp_app_api.response.ErrorResponseMessage.ErrorCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;

Expand All @@ -14,7 +14,7 @@ public record StorageConfig (String type) {

private void validate(final String type) {
if (StringUtils.isEmpty(type)) {
throw new ConfigurationException("storage 설정값이 올바르지 않습니다.", ErrorCode.IS001);
throw new BpCustomException("storage 설정값이 올바르지 않습니다.", ErrorCode.IS001);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.beautify_project.bp_app_api.controller;

import com.beautify_project.bp_app_api.dto.auth.EmailCertificationRequest;
import com.beautify_project.bp_app_api.dto.auth.EmailCertificationVerificationRequest;
import com.beautify_project.bp_app_api.dto.auth.EmailDuplicatedRequest;
import com.beautify_project.bp_app_api.dto.common.ResponseMessage;
import com.beautify_project.bp_app_api.request.auth.EmailCertificationRequest;
import com.beautify_project.bp_app_api.request.auth.EmailCertificationVerificationRequest;
import com.beautify_project.bp_app_api.request.auth.EmailDuplicatedRequest;
import com.beautify_project.bp_app_api.response.ResponseMessage;
import com.beautify_project.bp_app_api.service.AuthService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.beautify_project.bp_app_api.controller;

import com.beautify_project.bp_app_api.dto.common.ResponseMessage;
import com.beautify_project.bp_app_api.service.ImageService;
import com.beautify_project.bp_app_api.provider.image.ImageProvider;
import com.beautify_project.bp_app_api.response.ResponseMessage;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -12,14 +12,14 @@
@RequiredArgsConstructor
public class ImageController {

private final ImageService imageService;
private final ImageProvider imageProvider;

/**
* Shop 이미지 등록을 위한 preSignedUrl 발급
*/
@GetMapping("/v1/images/presigned-put-url")
@ResponseStatus(code = HttpStatus.OK)
ResponseMessage issuePreSignedPutUrl() {
return imageService.issuePreSignedPutUrlWrappingResponseMessage();
return ResponseMessage.createResponseMessage(imageProvider.providePreSignedPutUrl());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.beautify_project.bp_app_api.controller;

import com.beautify_project.bp_app_api.dto.common.ResponseMessage;
import com.beautify_project.bp_app_api.dto.member.UserRoleMemberRegistrationRequest;
import com.beautify_project.bp_app_api.request.member.UserRoleMemberRegistrationRequest;
import com.beautify_project.bp_app_api.response.ResponseMessage;
import com.beautify_project.bp_app_api.service.MemberService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.beautify_project.bp_app_api.controller;

import com.beautify_project.bp_app_api.dto.common.ResponseMessage;
import com.beautify_project.bp_app_api.dto.review.FindReviewListRequestParameters;
import com.beautify_project.bp_app_api.enumeration.OrderType;
import com.beautify_project.bp_app_api.enumeration.ReviewSortBy;
import com.beautify_project.bp_app_api.request.review.FindReviewListRequestParameters;
import com.beautify_project.bp_app_api.response.ResponseMessage;
import com.beautify_project.bp_app_api.service.ReviewService;
import com.beautify_project.bp_mysql.enums.OrderType;
import com.beautify_project.bp_mysql.enums.ReviewSortBy;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.beautify_project.bp_app_api.controller;

import com.beautify_project.bp_app_api.dto.common.ResponseMessage;
import com.beautify_project.bp_app_api.dto.shop.ShopListFindRequestParameters;
import com.beautify_project.bp_app_api.dto.shop.ShopRegistrationRequest;
import com.beautify_project.bp_app_api.enumeration.OrderType;
import com.beautify_project.bp_app_api.request.shop.ShopListFindRequestParameters;
import com.beautify_project.bp_app_api.request.shop.ShopRegistrationRequest;
import com.beautify_project.bp_app_api.response.ResponseMessage;
import com.beautify_project.bp_mysql.enums.OrderType;
import com.beautify_project.bp_app_api.enumeration.ShopSearchType;
import com.beautify_project.bp_app_api.service.ShopService;
import jakarta.validation.Valid;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.beautify_project.bp_app_api.enumeration;

import com.beautify_project.bp_app_api.exception.EnumMismatchException;
import com.beautify_project.bp_app_api.exception.BpCustomException;
import com.beautify_project.bp_app_api.response.ErrorResponseMessage.ErrorCode;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -28,7 +29,8 @@ public static ShopSearchType from(final String input) {
try {
return valueOf(inputUpperCase);
} catch (IllegalArgumentException e) {
throw new EnumMismatchException("ShopSearchType", input);
throw new BpCustomException("ShopSearchType 에 해당하는 값 '" + input + "' 은 올바르지 않습니다.",
ErrorCode.BR001);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.beautify_project.bp_app_api.exception;

import com.beautify_project.bp_app_api.response.ErrorResponseMessage.ErrorCode;
import lombok.Getter;

@Getter
public class BpCustomException extends RuntimeException {

private final ErrorCode errorCode;

public BpCustomException(final ErrorCode errorCode) {
super(errorCode.getErrorMessage());
this.errorCode = errorCode;
}

public BpCustomException(final String message, final ErrorCode errorCode) {
super(message);
this.errorCode = errorCode;
}
}

This file was deleted.

Loading

0 comments on commit 168df3b

Please sign in to comment.