-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Re-4aliens/feat/#33_matching-round
Feat/#33 매칭 도메인 기능 개발
- Loading branch information
Showing
44 changed files
with
1,693 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/com/aliens/backend/global/config/ClockConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.aliens.backend.global.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.time.Clock; | ||
|
||
@Configuration | ||
public class ClockConfig { | ||
|
||
@Bean | ||
public Clock clock() { | ||
return Clock.systemDefaultZone(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/aliens/backend/global/error/MatchingError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.aliens.backend.global.error; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public enum MatchingError implements ErrorCode { | ||
NOT_FOUND_MATCHING_ROUND(HttpStatus.NOT_FOUND, "MA1", "매칭 회차를 찾을 수 없음"), | ||
NOT_VALID_MATCHING_RECEPTION_TIME(HttpStatus.BAD_REQUEST, "MA2", "매칭 접수 시간이 아님"), | ||
NOT_FOUND_MATCHING_APPLICATION_INFO(HttpStatus.NOT_FOUND, "MA3", "매칭 신청 정보 찾을 수 없음"), | ||
NOT_FOUND_PREFER_LANGUAGE(HttpStatus.NOT_FOUND, "MA4", "선호 언어를 찾을 수 없음"), | ||
INVALID_LANGUAGE_INPUT(HttpStatus.BAD_REQUEST, "MA5", "두 선호 언어가 같을 수 없음"), | ||
|
||
; | ||
|
||
private final HttpStatus httpStatusCode; | ||
private final String developCode; | ||
private final String message; | ||
|
||
MatchingError(final HttpStatus httpStatusCode, final String developCode, final String message) { | ||
this.httpStatusCode = httpStatusCode; | ||
this.developCode = developCode; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return httpStatusCode; | ||
} | ||
|
||
@Override | ||
public String getDevelopCode() { | ||
return developCode; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/aliens/backend/global/property/MatchingRuleProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.aliens.backend.global.property; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class MatchingRuleProperties { | ||
@Value("${matching.rule.max-matches.partner}") | ||
private String maxPartners; | ||
|
||
@Value("${matching.rule.max-matches.normal-partner}") | ||
private String maxNormalPartners; | ||
|
||
@Value("${matching.rule.max-tries}") | ||
private String maxTries; | ||
|
||
public Integer getMaxNormalPartners() { | ||
return Integer.parseInt(maxNormalPartners); | ||
} | ||
|
||
public Integer getMaxTries() { | ||
return Integer.parseInt(maxTries); | ||
} | ||
|
||
public Integer getMaxPartners() { | ||
return Integer.parseInt(maxPartners); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/aliens/backend/global/property/MatchingTimeProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.aliens.backend.global.property; | ||
|
||
import com.aliens.backend.global.error.MatchingError; | ||
import com.aliens.backend.global.exception.RestApiException; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.DayOfWeek; | ||
|
||
@Component | ||
public class MatchingTimeProperties { | ||
@Value("${matching.request.time.hours}") | ||
private String matchingRequestAvailableTime; | ||
|
||
@Value("${matching.valid.time.hours}") | ||
private String matchingValidBeginHours; | ||
|
||
@Value("${matching.valid.day-of-week.if.monday.hours}") | ||
private String mondayMatchingValidHours; | ||
|
||
@Value("${matching.valid.day-of-week.if.thursday.hours}") | ||
private String thursdayMatchingValidHours; | ||
|
||
@Value("${matching.valid.day-of-week.if.default.hours}") | ||
private String defaultMatchingValidHours; | ||
|
||
public Long getMatchingRequestAvailableTime() { | ||
return Long.parseLong(matchingRequestAvailableTime); | ||
} | ||
|
||
public Integer getMatchingValidBeginHours() { | ||
return Integer.parseInt(matchingValidBeginHours); | ||
} | ||
|
||
public Long getMatchingValidHours(final DayOfWeek dayOfWeek) { | ||
if (dayOfWeek.equals(DayOfWeek.MONDAY)) { | ||
return Long.parseLong(mondayMatchingValidHours); | ||
} | ||
if (dayOfWeek.equals(DayOfWeek.THURSDAY)) { | ||
return Long.parseLong(thursdayMatchingValidHours); | ||
} | ||
return Long.parseLong(defaultMatchingValidHours); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/aliens/backend/global/success/AuthSuccessCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.aliens.backend.global.success; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public enum AuthSuccessCode implements SuccessCode { | ||
GENERATE_AUTHTOKEN_SUCCESS(HttpStatus.CREATED, "A001", "인증 토큰 발행에 성공했습니다."), | ||
LOGOUT_SUCCESS(HttpStatus.OK, "A002", "로그아웃에 성공했습니다."), | ||
REISSUE_AUTHTOKEN_SUCCESS(HttpStatus.CREATED, "A003", "토큰 재발급에 성공했습니다"), | ||
|
||
; | ||
|
||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
|
||
AuthSuccessCode(final HttpStatus httpStatus, final String code, final String message) { | ||
this.httpStatus = httpStatus; | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return httpStatus; | ||
} | ||
|
||
@Override | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/aliens/backend/global/success/MatchingSuccessCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.aliens.backend.global.success; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public enum MatchingSuccessCode implements SuccessCode { | ||
APPLY_MATCHING_SUCCESS(HttpStatus.CREATED, "MA001", "매칭 신청 성공"), | ||
GET_MATCHING_APPLICATION_STATUS_SUCCESS(HttpStatus.OK, "MA002", "매칭 신청 정보 조회 성공"), | ||
CANCEL_MATCHING_APPLICATION_SUCCESS(HttpStatus.OK, "MA003", "매칭 신청 취소 성공"), | ||
GET_MATCHING_PARTNERS_SUCCESS(HttpStatus.OK, "MA004", "매칭 파트너 조회 성공"), | ||
|
||
; | ||
|
||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
|
||
MatchingSuccessCode(final HttpStatus httpStatus, final String code, final String message) { | ||
this.httpStatus = httpStatus; | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return httpStatus; | ||
} | ||
|
||
@Override | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/aliens/backend/global/success/MemberSuccessCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.aliens.backend.global.success; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public enum MemberSuccessCode implements SuccessCode { | ||
SIGN_UP_SUCCESS(HttpStatus.CREATED, "M001", "회원가입이 완료되었습니다."), | ||
WITHDRAW_SUCCESS(HttpStatus.OK, "M002", "회원 탈퇴되었습니다."), | ||
TEMPORARY_PASSWORD_GENERATED_SUCCESS(HttpStatus.OK, "M003", "임시 비밀번호가 발급되었습니다. 이메일을 확인해주세요."), | ||
PASSWORD_CHANGE_SUCCESS(HttpStatus.OK, "M004", "비밀번호 변경이 완료되었습니다."), | ||
PROFILE_IMAGE_CHANGE_SUCCESS(HttpStatus.OK, "M005", "프로필 이미지 변경이 완료되었습니다."), | ||
ABOUT_ME_CHANGE_SUCCESS(HttpStatus.OK, "M006", "자기소개 변경이 완료되었습니다."), | ||
MBTI_CHANGE_SUCCESS(HttpStatus.OK, "M007", "MBTI 변경이 완료되었습니다."), | ||
GET_MEMBER_MATCHING_STATUS_SUCCESS(HttpStatus.OK, "M008", "회원 상태 조회를 완료했습니다."), | ||
GET_MEMBER_PAGE_SUCCESS(HttpStatus.OK, "M009", "회원 페이지 조회를 완료했습니다."), | ||
|
||
; | ||
|
||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
|
||
MemberSuccessCode(final HttpStatus httpStatus, final String code, final String message) { | ||
this.httpStatus = httpStatus; | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return httpStatus; | ||
} | ||
|
||
@Override | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/aliens/backend/global/success/SuccessCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.aliens.backend.global.success; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public interface SuccessCode { | ||
HttpStatus getHttpStatus(); | ||
String getCode(); | ||
String getMessage(); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/aliens/backend/global/success/SuccessResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.aliens.backend.global.success; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
|
||
public class SuccessResponse<T> { | ||
|
||
private String code; | ||
private String message; | ||
private T result; | ||
|
||
public SuccessResponse(final String code, final String message, final T result) { | ||
this.code = code; | ||
this.message = message; | ||
this.result = result; | ||
} | ||
|
||
public static ResponseEntity<SuccessResponse> toResponseEntity(final SuccessCode successCode, final Object result) { | ||
SuccessResponse res = new SuccessResponse(successCode.getCode(), successCode.getMessage(), result); | ||
return new ResponseEntity<>(res, successCode.getHttpStatus()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/aliens/backend/global/success/SuccessResponseWithoutResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.aliens.backend.global.success; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
|
||
public class SuccessResponseWithoutResult { | ||
private String code; | ||
private String message; | ||
|
||
public SuccessResponseWithoutResult(final String code, final String message) { | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
public static ResponseEntity<SuccessResponseWithoutResult> toResponseEntity(final SuccessCode successCode) { | ||
SuccessResponseWithoutResult res = new SuccessResponseWithoutResult(successCode.getCode(), successCode.getMessage()); | ||
return new ResponseEntity<>(res, successCode.getHttpStatus()); | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
} |
Oops, something went wrong.