Skip to content

Commit

Permalink
Merge pull request #37 from YAPP-Github/refactor/PC-425-common-module…
Browse files Browse the repository at this point in the history
…-split

[PC-425] Common 모듈 분리
  • Loading branch information
Lujaec authored Jan 31, 2025
2 parents db8e128 + 749e8b9 commit c4f953a
Show file tree
Hide file tree
Showing 160 changed files with 1,614 additions and 2,064 deletions.
8 changes: 4 additions & 4 deletions admin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ repositories {
}

dependencies {
implementation project(':common:domain')
implementation project(':common:format')
implementation project(':common:exception')
implementation project(':common:auth')
implementation project(':core:domain')
implementation project(':core:format')
implementation project(':core:exception')
implementation project(':core:auth')

testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
Expand Down
10 changes: 5 additions & 5 deletions admin/src/main/java/org/yapp/auth/application/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.yapp.auth.AuthToken;
import org.yapp.auth.AuthTokenGenerator;
import org.yapp.auth.application.dto.LoginDto;
import org.yapp.domain.user.User;
import org.yapp.error.code.auth.AuthErrorCode;
import org.yapp.error.exception.ApplicationException;
import org.yapp.core.auth.AuthToken;
import org.yapp.core.auth.AuthTokenGenerator;
import org.yapp.core.domain.user.User;
import org.yapp.core.exception.ApplicationException;
import org.yapp.core.exception.error.code.AuthErrorCode;
import org.yapp.user.application.UserService;

@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yapp.auth.AuthToken;
import org.yapp.auth.application.AuthService;
import org.yapp.auth.presentation.request.LoginRequest;
import org.yapp.util.CommonResponse;
import org.yapp.core.auth.AuthToken;
import org.yapp.format.CommonResponse;

@RestController
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import org.springframework.stereotype.Service;
import org.yapp.block.dao.UserBlockRepository;
import org.yapp.block.presentation.response.UserBlockResponse;
import org.yapp.domain.block.UserBlock;
import org.yapp.domain.user.User;
import org.yapp.util.PageResponse;
import org.yapp.core.domain.block.UserBlock;
import org.yapp.core.domain.user.User;
import org.yapp.format.PageResponse;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.yapp.domain.block.UserBlock;
import org.yapp.core.domain.block.UserBlock;

@Repository
public interface UserBlockRepository extends JpaRepository<UserBlock, Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.springframework.web.bind.annotation.RestController;
import org.yapp.block.application.UserBlockService;
import org.yapp.block.presentation.response.UserBlockResponse;
import org.yapp.util.CommonResponse;
import org.yapp.util.PageResponse;
import org.yapp.format.CommonResponse;
import org.yapp.format.PageResponse;

@RestController()
@RequiredArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion admin/src/main/java/org/yapp/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.springframework.security.web.util.matcher.RequestMatchers;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.yapp.jwt.JwtFilter;
import org.yapp.core.auth.jwt.JwtFilter;

@Configuration
@EnableWebSecurity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yapp.domain.profile.Profile;
import org.yapp.domain.profile.ProfileRejectHistory;
import org.yapp.domain.profile.ProfileStatus;
import org.yapp.domain.user.RoleStatus;
import org.yapp.domain.user.User;
import org.yapp.error.dto.ProfileErrorCode;
import org.yapp.error.exception.ApplicationException;
import org.yapp.core.domain.profile.Profile;
import org.yapp.core.domain.profile.ProfileRejectHistory;
import org.yapp.core.domain.profile.ProfileStatus;
import org.yapp.core.domain.user.RoleStatus;
import org.yapp.core.domain.user.User;
import org.yapp.core.exception.ApplicationException;
import org.yapp.core.exception.error.code.ProfileErrorCode;
import org.yapp.profile.dao.ProfileRejectHistoryRepository;
import org.yapp.user.application.UserService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.yapp.domain.profile.ProfileRejectHistory;
import org.yapp.core.domain.profile.ProfileRejectHistory;

@Repository
public interface ProfileRejectHistoryRepository extends JpaRepository<ProfileRejectHistory, Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.yapp.domain.profile.ProfileValueTalk;
import org.yapp.core.domain.profile.ProfileValueTalk;

@Repository
public interface ProfileValueTalkRepository extends JpaRepository<ProfileValueTalk, Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.yapp.domain.report.Report;
import org.yapp.core.domain.report.Report;
import org.yapp.format.PageResponse;
import org.yapp.report.application.dto.ReportedUserWithReasonDto;
import org.yapp.report.dao.ReportRepository;
import org.yapp.report.presentation.response.ReportDetailResponse;
import org.yapp.report.presentation.response.ReportUserResponse;
import org.yapp.util.PageResponse;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.yapp.domain.user.User;
import org.yapp.core.domain.user.User;

@Getter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.yapp.domain.report.Report;
import org.yapp.core.domain.report.Report;
import org.yapp.report.application.dto.ReportedUserWithReasonDto;

@Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.yapp.format.CommonResponse;
import org.yapp.format.PageResponse;
import org.yapp.report.application.ReportService;
import org.yapp.report.presentation.response.ReportDetailResponse;
import org.yapp.report.presentation.response.ReportUserResponse;
import org.yapp.util.CommonResponse;
import org.yapp.util.PageResponse;

@RestController()
@RequiredArgsConstructor
Expand Down
16 changes: 8 additions & 8 deletions admin/src/main/java/org/yapp/user/application/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yapp.domain.profile.Profile;
import org.yapp.domain.profile.ProfileRejectHistory;
import org.yapp.domain.profile.ProfileValueTalk;
import org.yapp.domain.user.User;
import org.yapp.error.dto.ProfileErrorCode;
import org.yapp.error.dto.UserErrorCode;
import org.yapp.error.exception.ApplicationException;
import org.yapp.core.domain.profile.Profile;
import org.yapp.core.domain.profile.ProfileRejectHistory;
import org.yapp.core.domain.profile.ProfileValueTalk;
import org.yapp.core.domain.user.User;
import org.yapp.core.exception.ApplicationException;
import org.yapp.core.exception.error.code.ProfileErrorCode;
import org.yapp.core.exception.error.code.UserErrorCode;
import org.yapp.format.PageResponse;
import org.yapp.profile.dao.ProfileRejectHistoryRepository;
import org.yapp.profile.dao.ProfileValueTalkRepository;
import org.yapp.user.dao.UserRepository;
import org.yapp.user.presentation.response.UserProfileDetailResponses;
import org.yapp.user.presentation.response.UserProfileValidationResponse;
import org.yapp.util.PageResponse;

@Service
@RequiredArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion admin/src/main/java/org/yapp/user/dao/UserRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.yapp.domain.user.User;
import org.yapp.core.domain.user.User;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.yapp.format.CommonResponse;
import org.yapp.format.PageResponse;
import org.yapp.profile.application.AdminProfileService;
import org.yapp.user.application.UserService;
import org.yapp.user.presentation.response.UserProfileDetailResponses;
import org.yapp.user.presentation.response.UserProfileValidationResponse;
import org.yapp.util.CommonResponse;
import org.yapp.util.PageResponse;

@RestController()
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.yapp.user.presentation.response;

import org.yapp.domain.profile.ProfileValueTalk;
import org.yapp.core.domain.profile.ProfileValueTalk;

public record UserProfileDetailResponse(
String category,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.yapp.user.presentation.response;

import java.util.List;
import org.yapp.domain.profile.ProfileValueTalk;
import org.yapp.core.domain.profile.ProfileValueTalk;

public record UserProfileDetailResponses(String nickname, String imageUrl,
List<UserProfileDetailResponse> responses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.time.LocalDate;
import lombok.Builder;
import org.yapp.domain.profile.Profile;
import org.yapp.domain.user.User;
import org.yapp.core.domain.profile.Profile;
import org.yapp.core.domain.user.User;

@Builder
public record UserProfileValidationResponse(Long userId, String description,
Expand Down
11 changes: 9 additions & 2 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ repositories {
}

dependencies {
implementation project(':common')
implementation project(':common:domain')
implementation project(':core:domain')
implementation project(':core:format')
implementation project(':core:exception')
implementation project(':core:auth')
implementation project(':infra:s3')
implementation project(':infra:redis')
implementation project(':infra:sms')

implementation('org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0');
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'

Expand Down
20 changes: 3 additions & 17 deletions api/src/main/java/org/yapp/ApiApplication.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
package org.yapp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

import jakarta.annotation.PostConstruct;

@EnableScheduling
@SpringBootApplication
public class ApiApplication {
private final TestBean testBean;

@Autowired
public ApiApplication(TestBean testBean) {
this.testBean = testBean;
}

public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
}

@PostConstruct
public void dependencyTest() {
testBean.dependencyTest();
}
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -1,53 +1,54 @@
package org.yapp.domain.auth.application.authorization;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.yapp.error.code.auth.SmsAuthErrorCode;
import org.yapp.error.exception.ApplicationException;
import org.yapp.global.application.RedisService;
import org.yapp.core.exception.ApplicationException;
import org.yapp.core.exception.error.code.SmsAuthErrorCode;
import org.yapp.global.application.SmsSenderService;

import lombok.RequiredArgsConstructor;
import org.yapp.infra.redis.application.RedisService;

/**
* SMS 인증 서비스
*/
@Service
@RequiredArgsConstructor
public class SmsAuthService {
private static final long AUTH_CODE_EXPIRE_TIME = 300000;
private static final String AUTH_CODE_KEY_PREFIX = "authcode:";
private static final String AUTH_CODE_FORMAT = "[PIECE] 인증 번호는 %06d 입니다.";
private final AuthCodeGenerator authCodeGenerator;
private final SmsSenderService smsSenderService;
private final RedisService redisService;

/**
* 인증번호 전송
*
* @param phoneNumber 인증 번호를 받을 핸드폰 번호
*/
public void sendAuthCodeTo(String phoneNumber) {
int authCode = authCodeGenerator.generate();
redisService.setKeyWithExpiration(AUTH_CODE_KEY_PREFIX + phoneNumber, String.valueOf(authCode),
AUTH_CODE_EXPIRE_TIME);
String authCodeMessage = String.format(AUTH_CODE_FORMAT, authCode);
smsSenderService.sendSMS(phoneNumber, authCodeMessage);
}
private static final long AUTH_CODE_EXPIRE_TIME = 300000;
private static final String AUTH_CODE_KEY_PREFIX = "authcode:";
private static final String AUTH_CODE_FORMAT = "[PIECE] 인증 번호는 %06d 입니다.";
private final AuthCodeGenerator authCodeGenerator;
private final SmsSenderService smsSenderService;
private final RedisService redisService;

/**
* 인증번호 인증
*
* @param phoneNumber 핸드폰번호
* @param code 인증 번호
* @return 인증번호 일치 여부
*/
public void verifySmsAuthCode(String phoneNumber, String code) {
String expectedCode = redisService.getValue(AUTH_CODE_KEY_PREFIX + phoneNumber);
if (expectedCode == null) {
throw new ApplicationException(SmsAuthErrorCode.CODE_NOT_EXIST);
/**
* 인증번호 전송
*
* @param phoneNumber 인증 번호를 받을 핸드폰 번호
*/
public void sendAuthCodeTo(String phoneNumber) {
int authCode = authCodeGenerator.generate();
redisService.setKeyWithExpiration(AUTH_CODE_KEY_PREFIX + phoneNumber,
String.valueOf(authCode),
AUTH_CODE_EXPIRE_TIME);
String authCodeMessage = String.format(AUTH_CODE_FORMAT, authCode);
smsSenderService.sendSMS(phoneNumber, authCodeMessage);
}
if (!expectedCode.equals(code)) {
throw new ApplicationException(SmsAuthErrorCode.CODE_NOT_CORRECT);

/**
* 인증번호 인증
*
* @param phoneNumber 핸드폰번호
* @param code 인증 번호
* @return 인증번호 일치 여부
*/
public void verifySmsAuthCode(String phoneNumber, String code) {
String expectedCode = redisService.getValue(AUTH_CODE_KEY_PREFIX + phoneNumber);
if (expectedCode == null) {
throw new ApplicationException(SmsAuthErrorCode.CODE_NOT_EXIST);
}
if (!expectedCode.equals(code)) {
throw new ApplicationException(SmsAuthErrorCode.CODE_NOT_CORRECT);
}
}
}
}
Loading

0 comments on commit c4f953a

Please sign in to comment.