From 2096fad52a06cb5f2d7b0681f8ef2a48668d02c9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 18:22:46 +0900 Subject: [PATCH 001/770] feat: add members entity --- .../domain/members/entity/Members.java | 40 +++++++++++++++++++ src/main/resources/application-local.yml | 10 ++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/entity/Members.java diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java new file mode 100644 index 00000000..58dba798 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -0,0 +1,40 @@ +package com.gachtaxi.domain.members.entity; + +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Entity; + +@Entity +public class Members extends BaseEntity { + + private String email; + + private String real_name; + + private String nickName; + + private String gender; + + private String phoneNumber; + + private String profile_picture; + + private Long kakaoId; + + private Long googleId; + + boolean marketing_agreement; + + boolean privacy_agreement; + + boolean terms_agreement; + + boolean two_factor_authentication; + + /* + * 추가할 사항 + * blackList + * notification + * friend_info + * */ + +} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 6c0cb337..e45d17f7 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -17,4 +17,12 @@ spring: # port: ${REDIS_PORT} # password: ${REDIS_PASSWORD} # mongodb: -# uri: ${MONGODB_URI} \ No newline at end of file +# uri: ${MONGODB_URI} + +gachtaxi: + auth: + kakao: + client: ${KAKAO_CLIENT_API_KEY} + redirect: ${KAKAO_REDIRECT_URL} + token_uri: ${KAKAO_TOKEN_URI} + user_profile: ${KAKAO_USER_PROFILE} \ No newline at end of file From b372ad8bf0a74c577a0d86098f2ff2bf77b4bc5d Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 18:23:32 +0900 Subject: [PATCH 002/770] =?UTF-8?q?feat:=20MemberService=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/MemberService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/service/MemberService.java diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java new file mode 100644 index 00000000..07d18a84 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.members.service; + +import com.gachtaxi.domain.members.repository.MemberRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class MemberService { + + private final MemberRepository memberRepository; +} From 7a076c537098b71f428d2114cd28d5b974c798cb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 18:23:48 +0900 Subject: [PATCH 003/770] =?UTF-8?q?feat:=20MemberRepository=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/repository/MemberRepository.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java new file mode 100644 index 00000000..c3adfb2d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.members.repository; + +import com.gachtaxi.domain.members.entity.Members; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MemberRepository extends JpaRepository { + +} From bf44e5e1c8f7a8ff93d1c483230b56b63d4ebd34 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 18:24:06 +0900 Subject: [PATCH 004/770] =?UTF-8?q?feat:=20BaseEntity=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/entity/BaseEntity.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/common/entity/BaseEntity.java diff --git a/src/main/java/com/gachtaxi/global/common/entity/BaseEntity.java b/src/main/java/com/gachtaxi/global/common/entity/BaseEntity.java new file mode 100644 index 00000000..d6d8f889 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/entity/BaseEntity.java @@ -0,0 +1,31 @@ +package com.gachtaxi.global.common.entity; + + +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import java.time.LocalDateTime; + +@Getter +@MappedSuperclass +@SuperBuilder +@NoArgsConstructor +@EntityListeners(AuditingEntityListener.class) +public abstract class BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @CreatedDate + @Column(updatable = false) + private LocalDateTime createDate; + + @LastModifiedDate + private LocalDateTime updateDate; +} \ No newline at end of file From 694fa979a82dbb65becc547ebce0ef436e6721b3 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:01:08 +0900 Subject: [PATCH 005/770] =?UTF-8?q?feat:=20KakaoUtil=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/kakao/util/KakaoUtil.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java b/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java new file mode 100644 index 00000000..c92ca097 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java @@ -0,0 +1,27 @@ +package com.gachtaxi.global.auth.kakao.util; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + + +/* +* KakaoUtil은 외부 API 통신 및 카카오 관련 작업을 담당(책임)한다. +* */ + +@Slf4j +@Component +public class KakaoUtil { + + @Value("${gachtaxi.auth.kakao.client}") + private String kakaoClient; + + @Value("${gachtaxi.auth.kakao.redirect}") + private String kakaoRedirect; + + @Value("${gachtaxi.auth.kakao.token_uri}") + private String kakaoTokenUri; + + @Value("${gachtaxi.auth.kakao.user_profile}") + private String kakaoUserProfileUri; +} From e5b167c32fd481efa210c1918c74f9dcca8bba9a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:01:42 +0900 Subject: [PATCH 006/770] =?UTF-8?q?feat:=20KakaoUtil=20-=20requestKakaoTok?= =?UTF-8?q?en=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/kakao/util/KakaoUtil.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java b/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java index c92ca097..de633d97 100644 --- a/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java +++ b/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java @@ -2,8 +2,13 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.MediaType; import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestClient; +import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; /* * KakaoUtil은 외부 API 통신 및 카카오 관련 작업을 담당(책임)한다. @@ -24,4 +29,21 @@ public class KakaoUtil { @Value("${gachtaxi.auth.kakao.user_profile}") private String kakaoUserProfileUri; + + private final RestClient restClient = RestClient.create(); + + public KakaoAccessToken reqeustKakaoToken(String authCode){ + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("grant_type", "authorization_code"); + params.add("client_id", kakaoClient); + params.add("redirect_url", kakaoRedirect); + params.add("code", authCode); + + return restClient.post() + .uri(kakaoTokenUri) + .body(params) + .contentType(MediaType.APPLICATION_FORM_URLENCODED) + .retrieve() + .body(KakaoAccessToken.class); + } } From 8c5e92f9cef3948955d57f404672b554deba3680 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:02:09 +0900 Subject: [PATCH 007/770] =?UTF-8?q?feat:=20KakaoUtil=20-=20requestKakaoPro?= =?UTF-8?q?file=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/kakao/util/KakaoUtil.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java b/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java index de633d97..b1d0209e 100644 --- a/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java +++ b/src/main/java/com/gachtaxi/global/auth/kakao/util/KakaoUtil.java @@ -46,4 +46,12 @@ public KakaoAccessToken reqeustKakaoToken(String authCode){ .retrieve() .body(KakaoAccessToken.class); } + + public KakaoUserInfoResponse requestKakaoProfile(String Token){ + return restClient.get() + .uri(kakaoUserProfileUri) + .header("Authorization", "Bearer " + Token) + .retrieve() + .body(KakaoUserInfoResponse.class); + } } From ec99b2f279d08b8e0e20aa1796689296a97cfcc2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:03:00 +0900 Subject: [PATCH 008/770] =?UTF-8?q?feat:=20AuthService=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/AuthService.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/service/AuthService.java diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java new file mode 100644 index 00000000..611d6810 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -0,0 +1,23 @@ +package com.gachtaxi.domain.members.service; + +import com.gachtaxi.global.auth.kakao.util.KakaoUtil; +import jakarta.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; + +/* +* AuthService는 인증 로직 책임을 가진다. +* */ + +@Slf4j +@Service +@RequiredArgsConstructor +public class AuthService { + + private final KakaoUtil kakaoUtil; + private final MemberService memberService; + +} From 258edbf912f76b98d19ce3f89c0bb0120192bf68 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:03:37 +0900 Subject: [PATCH 009/770] =?UTF-8?q?feat:=20AuthService=20=EC=B9=B4?= =?UTF-8?q?=EC=B9=B4=EC=98=A4=20=EC=9D=B8=EA=B0=80=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B0=9C=EA=B8=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/AuthService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 611d6810..4081963a 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -20,4 +20,10 @@ public class AuthService { private final KakaoUtil kakaoUtil; private final MemberService memberService; + public String kakaoLogin(String authCode, HttpServletResponse response) { + // 인가 코드로 토큰 발급 + KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); + + return kakaoAccessToken.access_token(); + } } From 5a8bd655d523c33028ee9408f64b5a30e570df2a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:04:06 +0900 Subject: [PATCH 010/770] =?UTF-8?q?feat:=20AuthService=20=ED=86=A0?= =?UTF-8?q?=ED=81=B0=EC=9C=BC=EB=A1=9C=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=A0=95=EB=B3=B4=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/members/service/AuthService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 4081963a..aa0b4ff9 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -24,6 +24,10 @@ public String kakaoLogin(String authCode, HttpServletResponse response) { // 인가 코드로 토큰 발급 KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); + // 토큰으로 사용자 정보(email) 가져오기 + KakaoUserInfoResponse kakaoUserInfoResponse = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); + + return kakaoAccessToken.access_token(); } } From 3aea0c5d136e65df66c9bb169594633369179177 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:04:25 +0900 Subject: [PATCH 011/770] =?UTF-8?q?feat:=20AuthService=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85=20=EC=97=AC=EB=B6=80=EB=A1=9C=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0=20=EC=B2=98=EB=A6=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/AuthService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index aa0b4ff9..ee096aa0 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -27,6 +27,13 @@ public String kakaoLogin(String authCode, HttpServletResponse response) { // 토큰으로 사용자 정보(email) 가져오기 KakaoUserInfoResponse kakaoUserInfoResponse = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); + // 회원가입 여부로 분기 처리 + String email = kakaoUserInfoResponse.kakao_account().email(); + if(memberService.checkByEmail(email)){ + log.info("회원가입 한 사용자"); + }{ + log.info("회원가입 하지 않은 사용자"); + } return kakaoAccessToken.access_token(); } From 756daa35de6e0d106dc621383e68d6f27404266c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:05:02 +0900 Subject: [PATCH 012/770] =?UTF-8?q?feat:=20MemberService=20=EC=9D=B4?= =?UTF-8?q?=EB=A9=94=EC=9D=BC=EB=A1=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/MemberService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 07d18a84..bc60da71 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -9,4 +9,9 @@ public class MemberService { private final MemberRepository memberRepository; + + public Boolean checkByEmail(String email) { + return memberRepository.findByEmail(email).isPresent(); + } + } From f929606574c4399a9990954f6c1d9f2482cea1f4 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:06:11 +0900 Subject: [PATCH 013/770] =?UTF-8?q?feat:=20MemberRepository=20existsByEmai?= =?UTF-8?q?l=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/repository/MemberRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index c3adfb2d..5e6f4709 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -4,7 +4,10 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.Optional; + @Repository public interface MemberRepository extends JpaRepository { + Boolean existsByEmail(String email); } From 5767b575a357fe0abaa3fc5c22222267952cad08 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:06:30 +0900 Subject: [PATCH 014/770] =?UTF-8?q?fix:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/members/service/MemberService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index bc60da71..d7ae963f 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -11,7 +11,7 @@ public class MemberService { private final MemberRepository memberRepository; public Boolean checkByEmail(String email) { - return memberRepository.findByEmail(email).isPresent(); + return memberRepository.existsByEmail(email); } } From 9852da22bc19ad44d77f89990f75a00bf2292db2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:07:19 +0900 Subject: [PATCH 015/770] =?UTF-8?q?feat:=20KakaoDTO=20-=20KakaoAccessToken?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/auth/kakao/dto/KaKaoDTO.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java new file mode 100644 index 00000000..c39e4b99 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java @@ -0,0 +1,13 @@ +package com.gachtaxi.global.auth.kakao.dto; + +public class KaKaoDTO { + + public record KakaoAccessToken( + String access_token, + String token_type, + String refresh_token, + int expires_in, + String scope, + int refresh_token_expires_in + ) {} +} From f87a6b431df7b1b6d9b98b98e62e418470d95494 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:07:55 +0900 Subject: [PATCH 016/770] =?UTF-8?q?feat:=20KakaoDTO=20-=20KakaoUesrInfoRes?= =?UTF-8?q?ponse=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/kakao/dto/KaKaoDTO.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java index c39e4b99..703717bb 100644 --- a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java +++ b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java @@ -10,4 +10,22 @@ public record KakaoAccessToken( String scope, int refresh_token_expires_in ) {} + + public record KakaoUserInfoResponse( + Long id, + KakaoAccount kakao_account + ) {} + + public record KakaoAccount( + Boolean is_email_valid, + Boolean is_email_verified, + String email, + Profile profile + ) {} + + public record Profile( + String nickname, + Boolean is_default_nickname + ) {} + } From da51b34894324d7e5cbfca5f46473859b19a7b8c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:51:10 +0900 Subject: [PATCH 017/770] =?UTF-8?q?feat:=20OauthLoginStatus=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/auth/enums/OauthLoginStatus.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/enums/OauthLoginStatus.java diff --git a/src/main/java/com/gachtaxi/global/auth/enums/OauthLoginStatus.java b/src/main/java/com/gachtaxi/global/auth/enums/OauthLoginStatus.java new file mode 100644 index 00000000..2bcc6a1c --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/enums/OauthLoginStatus.java @@ -0,0 +1,11 @@ +package com.gachtaxi.global.auth.enums; + +/* +* 아래 두 상태를 나타내는 enum +* 이미 회원가입한 사용자 (로그인 처리) +* 회원가입 안된 사용자 (회원가입 처리) +* */ + +public enum OauthLoginStatus { + LOGIN, UN_REGISTER +} From d211efab6a8321df0a904bd4e4a439f351b6e46e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:51:48 +0900 Subject: [PATCH 018/770] =?UTF-8?q?feat:=20OauthLoginResponse=20kakaoLogin?= =?UTF-8?q?Response=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/dto/OauthLoginResponse.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java diff --git a/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java b/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java new file mode 100644 index 00000000..17561f21 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java @@ -0,0 +1,25 @@ +package com.gachtaxi.global.auth.dto; + +import com.gachtaxi.global.auth.enums.OauthLoginStatus; +import lombok.Builder; + +/* +* 카카오와 구글 로그인 시 사용하는 Response +* */ + +public class OauthLoginResponse { + + @Builder + public record kakaoLoginResponse( + Long userId, + Long kakaoId, + OauthLoginStatus status, + String accessToken, + String refreshToken + ){} + + /* + * public record googleLoginResponse(){} + * */ + +} From 73573a57f0e6a00fc57600e551d6b0d28db542be Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:52:41 +0900 Subject: [PATCH 019/770] =?UTF-8?q?feat:=20OauthMapper=20-=20=EC=B9=B4?= =?UTF-8?q?=EC=B9=B4=EC=98=A4=20=EA=B4=80=EB=A0=A8Response=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/mapper/OauthMapper.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java diff --git a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java new file mode 100644 index 00000000..445c80b9 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java @@ -0,0 +1,28 @@ +package com.gachtaxi.global.auth.mapper; + +import org.springframework.stereotype.Component; + +import static com.gachtaxi.global.auth.enums.OauthLoginStatus.*; +import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; +import static com.gachtaxi.global.auth.dto.OauthLoginResponse.*; + +@Component +public class OauthMapper { + + public kakaoLoginResponse toKakaoUnRegisterResponse(KakaoUserInfoResponse userInfo) { + return kakaoLoginResponse.builder() + .kakaoId(userInfo.id()) + .status(UN_REGISTER) + .build(); + } + + // jwt 토큰 추가 할 것. + public kakaoLoginResponse toKakaoLoginResponse(KakaoUserInfoResponse userInfo) { + return kakaoLoginResponse.builder() + .kakaoId(userInfo.id()) + .status(LOGIN) + .build(); + } + + +} From 42ada4604a714e59563965684f99554472fc94f9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:53:16 +0900 Subject: [PATCH 020/770] =?UTF-8?q?feat:=20AuthService=20-=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85=20=EC=97=AC=EB=B6=80=EB=A1=9C=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0=20=EC=B2=98=EB=A6=AC(jwt=20=EB=B0=9C?= =?UTF-8?q?=EA=B8=89=20=EC=A0=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/AuthService.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index ee096aa0..b055aaed 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -1,12 +1,15 @@ package com.gachtaxi.domain.members.service; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; +import com.gachtaxi.global.auth.mapper.OauthMapper; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; +import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; +import static com.gachtaxi.global.auth.dto.OauthLoginResponse.*; + /* * AuthService는 인증 로직 책임을 가진다. @@ -18,23 +21,26 @@ public class AuthService { private final KakaoUtil kakaoUtil; + private final OauthMapper oauthMapper; private final MemberService memberService; - public String kakaoLogin(String authCode, HttpServletResponse response) { + public kakaoLoginResponse kakaoLogin(String authCode, HttpServletResponse response) { // 인가 코드로 토큰 발급 KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); // 토큰으로 사용자 정보(email) 가져오기 - KakaoUserInfoResponse kakaoUserInfoResponse = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); + KakaoUserInfoResponse userInfo = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); // 회원가입 여부로 분기 처리 - String email = kakaoUserInfoResponse.kakao_account().email(); + String email = userInfo.kakao_account().email(); if(memberService.checkByEmail(email)){ log.info("회원가입 한 사용자"); - }{ - log.info("회원가입 하지 않은 사용자"); - } + // jwt 토큰 발급 (추후 추가) - return kakaoAccessToken.access_token(); + // 응답 + return oauthMapper.toKakaoLoginResponse(userInfo); + }else{ + return oauthMapper.toKakaoUnRegisterResponse(userInfo); + } } } From 58a71f3682cbae66d8971cf574eff656002f0dea Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:54:44 +0900 Subject: [PATCH 021/770] =?UTF-8?q?feat:=20AuthController=20-=20kakaoLogin?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80=20(jwt=20?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20=EC=A0=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/controller/AuthController.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java new file mode 100644 index 00000000..bb1f3127 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -0,0 +1,34 @@ +package com.gachtaxi.domain.members.controller; + +import com.gachtaxi.domain.members.service.AuthService; +import com.gachtaxi.global.auth.enums.OauthLoginStatus; +import com.gachtaxi.global.common.response.ApiResponse; +import jakarta.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import static com.gachtaxi.domain.members.controller.SuccessMessage.*; +import static com.gachtaxi.global.auth.dto.OauthLoginResponse.*; + +@Slf4j +@RequestMapping("/auth") +@RestController +@RequiredArgsConstructor +public class AuthController { + + private final AuthService authService; + + @GetMapping("/login/kakao") + public ApiResponse kakaoLogin(@RequestParam("code") String authcode, HttpServletResponse response) { + kakaoLoginResponse res = authService.kakaoLogin(authcode, response); + SuccessMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) + ? LOGIN_SUCCESS + : UN_REGISTER; + return ApiResponse.response(HttpStatus.OK, OAUTH_STATUS.getMessage(), res); + } +} From b7ae741d3f62553beb62f7299acd574c1366a81a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 2 Jan 2025 21:55:18 +0900 Subject: [PATCH 022/770] =?UTF-8?q?feat:=20Member=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20SuccessMessage=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/SuccessMessage.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java new file mode 100644 index 00000000..7967455a --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java @@ -0,0 +1,16 @@ +package com.gachtaxi.domain.members.controller; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum SuccessMessage { + // MemberController + + // AuthController + LOGIN_SUCCESS("로그인 성공에 성공했습니다."), + UN_REGISTER("회원가입을 진행해주세요"); + + private final String message; +} From c218c5fc78565732cb2caba8aca102af9e917104 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 02:22:32 +0900 Subject: [PATCH 023/770] =?UTF-8?q?fix:=20BaseException=20=EB=A7=A4?= =?UTF-8?q?=EA=B0=9C=20=EC=9D=B8=EC=9E=90=20=EC=88=9C=EC=84=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/common/exception/BaseException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/common/exception/BaseException.java b/src/main/java/com/gachtaxi/global/common/exception/BaseException.java index 1819b39c..4d069fa2 100644 --- a/src/main/java/com/gachtaxi/global/common/exception/BaseException.java +++ b/src/main/java/com/gachtaxi/global/common/exception/BaseException.java @@ -8,7 +8,7 @@ public abstract class BaseException extends RuntimeException { private final HttpStatus status; - public BaseException(final String message, final HttpStatus status) { + public BaseException(final HttpStatus status, final String message) { super(message); this.status = status; } From 83a3e4d94a1cc2aad21b21795a25c9daa6193dc5 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:01:41 +0900 Subject: [PATCH 024/770] =?UTF-8?q?feat:=20kakaoLoginResponse=20usreId=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java index 445c80b9..91db7ae4 100644 --- a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java +++ b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java @@ -17,8 +17,9 @@ public kakaoLoginResponse toKakaoUnRegisterResponse(KakaoUserInfoResponse userIn } // jwt 토큰 추가 할 것. - public kakaoLoginResponse toKakaoLoginResponse(KakaoUserInfoResponse userInfo) { + public kakaoLoginResponse toKakaoLoginResponse(KakaoUserInfoResponse userInfo, Long userId) { return kakaoLoginResponse.builder() + .userId(userId) .kakaoId(userInfo.id()) .status(LOGIN) .build(); From 49160f7f79997e4bbd638d607b024823f1aa40fb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:03:10 +0900 Subject: [PATCH 025/770] =?UTF-8?q?fix:=20oauthKakaoResponse=20=ED=86=A0?= =?UTF-8?q?=ED=81=B0=20=ED=95=84=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/dto/OauthLoginResponse.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java b/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java index 17561f21..038f40e3 100644 --- a/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java +++ b/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java @@ -10,12 +10,10 @@ public class OauthLoginResponse { @Builder - public record kakaoLoginResponse( + public record oauthKakaoResponse( Long userId, Long kakaoId, - OauthLoginStatus status, - String accessToken, - String refreshToken + OauthLoginStatus status ){} /* From af40a3df551363e5ea5ed9e1ed2674ef70d1116c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:03:43 +0900 Subject: [PATCH 026/770] =?UTF-8?q?feat:=20Member=20-=20findByEmail()=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/repository/MemberRepository.java | 2 ++ .../com/gachtaxi/domain/members/service/MemberService.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 5e6f4709..0a54885d 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -10,4 +10,6 @@ public interface MemberRepository extends JpaRepository { Boolean existsByEmail(String email); + + Optional findByEmail(String email); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index d7ae963f..835b4707 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,9 +1,12 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.repository.MemberRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.Optional; + @Service @RequiredArgsConstructor public class MemberService { @@ -14,4 +17,8 @@ public Boolean checkByEmail(String email) { return memberRepository.existsByEmail(email); } + public Optional findByEmail(String email) { + return memberRepository.findByEmail(email); + } + } From 6c3aae22391c07785f6de76bbbaee8534a5b8488 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:04:42 +0900 Subject: [PATCH 027/770] =?UTF-8?q?feat:=20JwtTokenDto=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java b/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java new file mode 100644 index 00000000..61108753 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java @@ -0,0 +1,10 @@ +package com.gachtaxi.global.auth.jwt.dto; + +import lombok.Builder; + +@Builder +public record JwtTokenDto( + String accessToken, + String refreshToken +){ +} From a5c499cc85485e8d0444df06b46cd88a3ce44df9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:05:23 +0900 Subject: [PATCH 028/770] =?UTF-8?q?feat:=20JwtProvider=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/JwtProvider.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java new file mode 100644 index 00000000..807f2cde --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java @@ -0,0 +1,54 @@ +package com.gachtaxi.global.auth.jwt.util; + +import com.gachtaxi.domain.members.entity.enums.Role; +import io.jsonwebtoken.*; +import io.jsonwebtoken.security.Keys; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.security.Key; +import java.util.Date; + +// 토큰 생성 +@Component +public class JwtProvider { + + private static final String ACCESS_TOKEN_SUBJECT = "AccessToken"; + private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; + private static final String ID_CLAIM = "id"; + private static final String EMAIL_CLAIM = "email"; + private static final String ROLE_CLAIM = "role"; + private final Key key; + + public JwtProvider(@Value("${gachtaxi.auth.jwt.key}") String secretKey) { + this.key = Keys.hmacShaKeyFor(secretKey.getBytes()); // 키 변환 + } + + @Value("${gachtaxi.auth.jwt.accessTokenExpiration}") + private Long accessTokenExpiration; + + @Value("${gachtaxi.auth.jwt.refreshTokenExpiration}") + private Long refreshTokenExpiration; + + public String generateAccessToken(Long id, String email, Role role) { + return Jwts.builder() + .claim(ID_CLAIM, id) + .claim(EMAIL_CLAIM, email) + .claim(ROLE_CLAIM, role) + .setSubject(ACCESS_TOKEN_SUBJECT) // 사용자 정보(고유 식별자) + .setIssuedAt(new Date()) // 발행 시간 + .setExpiration(new Date(System.currentTimeMillis() + accessTokenExpiration)) // 만료 시간 + .signWith(key, SignatureAlgorithm.HS256) // 서명 알고리즘 + .compact(); // 최종 문자열 생성 + } + + public String generateRefreshToken(Long id) { + return Jwts.builder() + .claim(ID_CLAIM, id) + .setSubject(REFRESH_TOKEN_SUBJECT) // 사용자 정보(고유 식별자) + .setIssuedAt(new Date()) // 발행 시간 + .setExpiration(new Date(System.currentTimeMillis() + refreshTokenExpiration)) // 만료 시간 + .signWith(key, SignatureAlgorithm.HS256) // 서명 알고리즘 + .compact(); // 최종 문자열 생성 + } +} From 9094a17a4651e120ab217e3d20f8fb43072f9817 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:05:42 +0900 Subject: [PATCH 029/770] =?UTF-8?q?feat:=20JwtExtractor=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/JwtExtractor.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java new file mode 100644 index 00000000..69ad20c3 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java @@ -0,0 +1,62 @@ +package com.gachtaxi.global.auth.jwt.util; + +import com.gachtaxi.global.auth.jwt.exception.TokenInvalidException; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.JwtException; +import io.jsonwebtoken.JwtParser; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.security.Keys; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.security.Key; +import java.util.Date; + +// 토큰 추출 및 검증 +@Component +public class JwtExtractor { + + private static final String ID_CLAIM = "id"; + private static final String EMAIL_CLAIM = "email"; + private static final String ROLE_CLAIM = "role"; + + private final Key key; + + public JwtExtractor(@Value("${gachtaxi.auth.jwt.key}") String secretKey) { + this.key = Keys.hmacShaKeyFor(secretKey.getBytes()); // 키 변환 + } + + public String getId(String token){ + return getClaimFromToken(token, ID_CLAIM); + } + + public String getEmail(String token){ + return getClaimFromToken(token, EMAIL_CLAIM); + } + + public String getRole(String token) { + return getClaimFromToken(token, ROLE_CLAIM); + } + + public Boolean isExpired(String token) { + Claims claims = parseClaims(token); + return claims.getExpiration().before(new Date()); + } + + private String getClaimFromToken(String token, String claimName) { + Claims claims = parseClaims(token); + return claims.get(claimName, String.class); + } + + private Claims parseClaims(String token) { + try{ + JwtParser parser = Jwts.parserBuilder() + .setSigningKey(key) + .build(); + return parser.parseClaimsJws(token).getBody(); + }catch (JwtException e){ + throw new TokenInvalidException(); + } + } + +} From ef75afe2593f0e0282b9d045da0528a253baefe5 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:06:17 +0900 Subject: [PATCH 030/770] =?UTF-8?q?feat:=20CookieUtil=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/CookieUtil.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java new file mode 100644 index 00000000..c330055d --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java @@ -0,0 +1,37 @@ +package com.gachtaxi.global.auth.jwt.util; + +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseCookie; +import org.springframework.stereotype.Component; + +@Component +public class CookieUtil { + + @Value("${gachtaxi.auth.jwt.cookieMaxAge}") + private Long cookieMaxAge; + + public void setCookie( String name, String value, HttpServletResponse response) { + ResponseCookie cookie = ResponseCookie.from(name, value) + .maxAge(cookieMaxAge) + .path("/") + .secure(false) //https 적용 시 true + .httpOnly(true) + .sameSite("None") + .build(); + + response.setHeader("Set-Cookie", cookie.toString()); + } + + public void deleteCookie(HttpServletResponse response, String name) { + ResponseCookie cookie = ResponseCookie.from(name, "value") + .maxAge(0) + .path("/") + .secure(false) + .httpOnly(true) + .sameSite("None") + .build(); + + response.setHeader("Set-Cookie", cookie.toString()); + } +} From 11c4af6ee7a973b70fcbc2f1afae4c76a827c5e4 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:08:16 +0900 Subject: [PATCH 031/770] =?UTF-8?q?feat:=20JwtService=20JwtToken=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/service/JwtService.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java new file mode 100644 index 00000000..5bfcf98c --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -0,0 +1,34 @@ +package com.gachtaxi.global.auth.jwt.service; + +import com.gachtaxi.domain.members.entity.enums.Role; +import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; +import com.gachtaxi.global.auth.jwt.util.CookieUtil; +import com.gachtaxi.global.auth.jwt.util.JwtExtractor; +import com.gachtaxi.global.auth.jwt.util.JwtProvider; +import jakarta.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class JwtService { + + private static final String ACCESS_TOKEN_SUBJECT = "AccessToken"; + private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; + + private final CookieUtil cookieUtil; + private final JwtProvider jwtProvider; + private final JwtExtractor jwtExtractor; + + // AccessToken과 RefreshToken 만들기 + private JwtTokenDto generateJwtToken(Long id, String email, Role role) { + String accessToken = jwtProvider.generateAccessToken(id, email, role); + String refreshToken = jwtProvider.generateRefreshToken(id); + return JwtTokenDto.builder() + .accessToken(accessToken) + .refreshToken(refreshToken) + .build(); + } +} From 2b82349bb544b42aea54f023da3e95c06c6adf66 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:08:52 +0900 Subject: [PATCH 032/770] =?UTF-8?q?feat:=20JwtService=20-=20setHeader,=20s?= =?UTF-8?q?etCookie=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/service/JwtService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 5bfcf98c..6eff98a8 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -31,4 +31,12 @@ private JwtTokenDto generateJwtToken(Long id, String email, Role role) { .refreshToken(refreshToken) .build(); } + + private void setHeader(String accessToken, HttpServletResponse response) { + response.setHeader(ACCESS_TOKEN_SUBJECT, accessToken); + } + + private void setCookie(String refreshToken, HttpServletResponse response) { + cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, refreshToken, response); + } } From f0a0eb563a5b6ea9cb1e1761cd2711a25d533b29 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:09:20 +0900 Subject: [PATCH 033/770] =?UTF-8?q?feat:=20JwtService=20-=20responseJwtTok?= =?UTF-8?q?en=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/service/JwtService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 6eff98a8..ed4441a2 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -22,6 +22,14 @@ public class JwtService { private final JwtProvider jwtProvider; private final JwtExtractor jwtExtractor; + public void responseJwtToken(Long id, String email, Role role, HttpServletResponse response) { + JwtTokenDto jwtToken = generateJwtToken(id, email, role); + setHeader(jwtToken.accessToken(), response); + setCookie(jwtToken.refreshToken(), response); + + log.info(jwtToken.toString()); + } + // AccessToken과 RefreshToken 만들기 private JwtTokenDto generateJwtToken(Long id, String email, Role role) { String accessToken = jwtProvider.generateAccessToken(id, email, role); From 98fa6ab882473cc944a8d56efe9244ea8316acac Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:10:48 +0900 Subject: [PATCH 034/770] =?UTF-8?q?feat:=20Members=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20Role=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/members/entity/Members.java | 8 ++++++++ .../com/gachtaxi/domain/members/entity/enums/Role.java | 5 +++++ 2 files changed, 13 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 58dba798..71a0832e 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -1,8 +1,13 @@ package com.gachtaxi.domain.members.entity; +import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.Getter; +@Getter @Entity public class Members extends BaseEntity { @@ -22,6 +27,9 @@ public class Members extends BaseEntity { private Long googleId; + @Enumerated(EnumType.STRING) + private Role role; + boolean marketing_agreement; boolean privacy_agreement; diff --git a/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java b/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java new file mode 100644 index 00000000..671beb79 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.members.entity.enums; + +public enum Role { + MEMBER, ADMIN +} From 673b9060921f7bcbd871f51cb961f7b3438c96cd Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:14:04 +0900 Subject: [PATCH 035/770] =?UTF-8?q?feat:=20application-local.yml=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=20=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-local.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index ace2b097..547fdb38 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -19,6 +19,11 @@ spring: # mongodb: # uri: ${MONGODB_URI} +logging: + level: + org.springframework.messaging: debug + org.springframework.web.socket: debug + gachtaxi: auth: kakao: @@ -26,8 +31,8 @@ gachtaxi: redirect: ${KAKAO_REDIRECT_URL} token_uri: ${KAKAO_TOKEN_URI} user_profile: ${KAKAO_USER_PROFILE} - -logging: - level: - org.springframework.messaging: debug - org.springframework.web.socket: debug \ No newline at end of file + jwt: + key: ${JWT_SECRET_KEY} + accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} + refreshTokenExpiration: ${JWT_REFRESH_TOKEN_EXPIRATION} + cookieMaxAge: ${JWT_COOKIE_MAX_AGE} \ No newline at end of file From 8fcd56485638893e678638b2919950fa48967202 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:14:49 +0900 Subject: [PATCH 036/770] =?UTF-8?q?fix:=20oauthKakaoResponse=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AuthController.java | 9 +++------ .../com/gachtaxi/global/auth/mapper/OauthMapper.java | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index bb1f3127..c3629735 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -7,10 +7,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.members.controller.SuccessMessage.*; import static com.gachtaxi.global.auth.dto.OauthLoginResponse.*; @@ -24,8 +21,8 @@ public class AuthController { private final AuthService authService; @GetMapping("/login/kakao") - public ApiResponse kakaoLogin(@RequestParam("code") String authcode, HttpServletResponse response) { - kakaoLoginResponse res = authService.kakaoLogin(authcode, response); + public ApiResponse kakaoLogin(@RequestParam("code") String authcode, HttpServletResponse response) { + oauthKakaoResponse res = authService.kakaoLogin(authcode, response); SuccessMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) ? LOGIN_SUCCESS : UN_REGISTER; diff --git a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java index 91db7ae4..298490d1 100644 --- a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java +++ b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java @@ -9,16 +9,16 @@ @Component public class OauthMapper { - public kakaoLoginResponse toKakaoUnRegisterResponse(KakaoUserInfoResponse userInfo) { - return kakaoLoginResponse.builder() + public oauthKakaoResponse toKakaoUnRegisterResponse(KakaoUserInfoResponse userInfo) { + return oauthKakaoResponse.builder() .kakaoId(userInfo.id()) .status(UN_REGISTER) .build(); } // jwt 토큰 추가 할 것. - public kakaoLoginResponse toKakaoLoginResponse(KakaoUserInfoResponse userInfo, Long userId) { - return kakaoLoginResponse.builder() + public oauthKakaoResponse toKakaoLoginResponse(KakaoUserInfoResponse userInfo, Long userId) { + return oauthKakaoResponse.builder() .userId(userId) .kakaoId(userInfo.id()) .status(LOGIN) From 61f67322eab32a2ffe99bee338eabbb6f5434ba0 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:15:41 +0900 Subject: [PATCH 037/770] =?UTF-8?q?feat:=20AuthService=20-=20=EC=B9=B4?= =?UTF-8?q?=EC=B9=B4=EC=98=A4=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=8B=9C=20?= =?UTF-8?q?JWT=20=ED=86=A0=ED=81=B0=20=EB=B0=9C=EA=B8=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/AuthService.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index b055aaed..eae45ea1 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -1,11 +1,14 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; import com.gachtaxi.global.auth.mapper.OauthMapper; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.Optional; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; import static com.gachtaxi.global.auth.dto.OauthLoginResponse.*; @@ -22,25 +25,23 @@ public class AuthService { private final KakaoUtil kakaoUtil; private final OauthMapper oauthMapper; + private final JwtService jwtService; private final MemberService memberService; - public kakaoLoginResponse kakaoLogin(String authCode, HttpServletResponse response) { - // 인가 코드로 토큰 발급 + public oauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse response) { KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); - - // 토큰으로 사용자 정보(email) 가져오기 KakaoUserInfoResponse userInfo = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); - // 회원가입 여부로 분기 처리 String email = userInfo.kakao_account().email(); - if(memberService.checkByEmail(email)){ - log.info("회원가입 한 사용자"); - // jwt 토큰 발급 (추후 추가) + Optional optionalMember = memberService.findByEmail(email); - // 응답 - return oauthMapper.toKakaoLoginResponse(userInfo); - }else{ + if(optionalMember.isEmpty()) { return oauthMapper.toKakaoUnRegisterResponse(userInfo); } + + Members member = optionalMember.get(); + jwtService.responseJwtToken(member.getId(), email, member.getRole(), response); + + return oauthMapper.toKakaoLoginResponse(userInfo, member.getId()); } } From da46912345a76a8308a72b45d4eb133bb20cddbe Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:22:29 +0900 Subject: [PATCH 038/770] =?UTF-8?q?feat:=20JwtErrorMessage=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/exception/JwtErrorMessage.java | 13 +++++++++++++ .../auth/jwt/exception/TokenInvalidException.java | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java new file mode 100644 index 00000000..e25d79cf --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java @@ -0,0 +1,13 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum JwtErrorMessage { + + JWT_TOKEN_UN_VALID("유효하지 않은 토큰 입니다."); + + private final String message; +} diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java new file mode 100644 index 00000000..ce697d26 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java @@ -0,0 +1,11 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_UN_VALID; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class TokenInvalidException extends BaseException { + public TokenInvalidException() { + super(BAD_REQUEST, JWT_TOKEN_UN_VALID.getMessage()); + } +} From 2745aa36f3a56503e63be1235d7b63588977ebad Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 04:29:10 +0900 Subject: [PATCH 039/770] =?UTF-8?q?fix:=20oauthKakaoResponse=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 2 +- .../domain/members/service/AuthService.java | 1 - .../global/auth/dto/OauthLoginResponse.java | 23 ------------------- .../global/auth/kakao/dto/KaKaoDTO.java | 10 ++++++++ .../global/auth/mapper/OauthMapper.java | 1 - .../gachtaxi/global/config/RedisConfig.java | 2 +- 6 files changed, 12 insertions(+), 27 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index c3629735..1657f363 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.members.controller.SuccessMessage.*; -import static com.gachtaxi.global.auth.dto.OauthLoginResponse.*; +import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; @Slf4j @RequestMapping("/auth") diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index eae45ea1..92f41bb1 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -11,7 +11,6 @@ import java.util.Optional; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; -import static com.gachtaxi.global.auth.dto.OauthLoginResponse.*; /* diff --git a/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java b/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java deleted file mode 100644 index 038f40e3..00000000 --- a/src/main/java/com/gachtaxi/global/auth/dto/OauthLoginResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gachtaxi.global.auth.dto; - -import com.gachtaxi.global.auth.enums.OauthLoginStatus; -import lombok.Builder; - -/* -* 카카오와 구글 로그인 시 사용하는 Response -* */ - -public class OauthLoginResponse { - - @Builder - public record oauthKakaoResponse( - Long userId, - Long kakaoId, - OauthLoginStatus status - ){} - - /* - * public record googleLoginResponse(){} - * */ - -} diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java index 703717bb..35701ad1 100644 --- a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java +++ b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java @@ -1,5 +1,8 @@ package com.gachtaxi.global.auth.kakao.dto; +import com.gachtaxi.global.auth.enums.OauthLoginStatus; +import lombok.Builder; + public class KaKaoDTO { public record KakaoAccessToken( @@ -28,4 +31,11 @@ public record Profile( Boolean is_default_nickname ) {} + @Builder + public record oauthKakaoResponse( + Long userId, + Long kakaoId, + OauthLoginStatus status + ){} + } diff --git a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java index 298490d1..130ac0a8 100644 --- a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java +++ b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java @@ -4,7 +4,6 @@ import static com.gachtaxi.global.auth.enums.OauthLoginStatus.*; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; -import static com.gachtaxi.global.auth.dto.OauthLoginResponse.*; @Component public class OauthMapper { diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index ff852595..5ce34594 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -41,7 +41,7 @@ public RedisConnectionFactory redisConnectionFactory() { redisStandaloneConfiguration.setHostName(host); redisStandaloneConfiguration.setPort(port); - redisStandaloneConfiguration.setPassword(password); +// redisStandaloneConfiguration.setPassword(password); return new LettuceConnectionFactory(redisStandaloneConfiguration); } From e3803ae0cdff5def2d088c7cbb25354189b362e9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 05:53:33 +0900 Subject: [PATCH 040/770] =?UTF-8?q?feat:=20JwtRedisUtil=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20refreshToken=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/JwtRedisUtil.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java new file mode 100644 index 00000000..e5c3aaca --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java @@ -0,0 +1,36 @@ +package com.gachtaxi.global.auth.jwt.util; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +@Component +@RequiredArgsConstructor +public class JwtRedisUtil { + + private final static String PREFIX = "refresh_"; + + private final RedisTemplate redisTemplate; + + @Value("${gachtaxi.auth.jwt.refreshTokenExpiration}") + private Long refreshTokenExpiration; + + public void set(Long key, String value) { + redisTemplate.opsForValue().set(PREFIX + key, value, refreshTokenExpiration, TimeUnit.MILLISECONDS); + } + + public Object get(Long key){ + return redisTemplate.opsForValue().get(PREFIX +key); + } + + public boolean hasKey(Long key){ + return Boolean.TRUE.equals(redisTemplate.hasKey(PREFIX + key)); + } + + public boolean delete(Long key){ + return Boolean.TRUE.equals(redisTemplate.delete(PREFIX + key)); + } +} From 9fa5b582ae9293a8b2ae4384a558abee5d9c895a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 05:54:30 +0900 Subject: [PATCH 041/770] =?UTF-8?q?feat:=20refreshToken=20Redis=EC=97=90?= =?UTF-8?q?=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/service/JwtService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index ed4441a2..724b93b9 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -5,6 +5,7 @@ import com.gachtaxi.global.auth.jwt.util.CookieUtil; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; import com.gachtaxi.global.auth.jwt.util.JwtProvider; +import com.gachtaxi.global.auth.jwt.util.JwtRedisUtil; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -19,6 +20,7 @@ public class JwtService { private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; private final CookieUtil cookieUtil; + private final JwtRedisUtil redisUtil; private final JwtProvider jwtProvider; private final JwtExtractor jwtExtractor; @@ -30,10 +32,12 @@ public void responseJwtToken(Long id, String email, Role role, HttpServletRespon log.info(jwtToken.toString()); } - // AccessToken과 RefreshToken 만들기 + // JwtToken 생성 + Redis 저장 private JwtTokenDto generateJwtToken(Long id, String email, Role role) { String accessToken = jwtProvider.generateAccessToken(id, email, role); String refreshToken = jwtProvider.generateRefreshToken(id); + + redisUtil.set(id, refreshToken); return JwtTokenDto.builder() .accessToken(accessToken) .refreshToken(refreshToken) From 315019bc165effe01f377e25cc1d8a6f18691861 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 3 Jan 2025 13:42:32 +0900 Subject: [PATCH 042/770] =?UTF-8?q?feat:=20=EB=AA=BD=EA=B3=A0db=20Auditing?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/GachtaxiApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/GachtaxiApplication.java b/src/main/java/com/gachtaxi/GachtaxiApplication.java index cbdd3f1f..6b14e6e2 100644 --- a/src/main/java/com/gachtaxi/GachtaxiApplication.java +++ b/src/main/java/com/gachtaxi/GachtaxiApplication.java @@ -2,8 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.mongodb.config.EnableMongoAuditing; @SpringBootApplication +@EnableMongoAuditing public class GachtaxiApplication { public static void main(String[] args) { From 17dd591a8c31236d212336340a14dfcc23fedb00 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 3 Jan 2025 13:42:55 +0900 Subject: [PATCH 043/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/entity/ChattingMessage.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java new file mode 100644 index 00000000..48d3d0c6 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java @@ -0,0 +1,32 @@ +package com.gachtaxi.domain.chat.entity; + +import jakarta.persistence.Id; +import lombok.*; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.mongodb.core.mapping.Document; + +import java.time.LocalDateTime; + +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Document(collection = "chatting_messages") +public class ChattingMessage { + + @Id + private String id; + + private Long senderId; + + private String nickName; + + private Long roomId; + + private String message; + + private LocalDateTime timeStamp; + + @LastModifiedDate + private LocalDateTime updatedAt; +} From 461a465763973c402082656563d2339fe209600b Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 3 Jan 2025 13:43:07 +0900 Subject: [PATCH 044/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/entity/ChattingRoom.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java new file mode 100644 index 00000000..31615089 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java @@ -0,0 +1,17 @@ +package com.gachtaxi.domain.chat.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Getter +@Builder +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class ChattingRoom { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "chatting_room_id") + private Long id; +} From fe8ffed2f97e87392603ba3def9b967e1121d57c Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 3 Jan 2025 13:43:26 +0900 Subject: [PATCH 045/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC=EC=9E=90=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/entity/ChattingParticipant.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java new file mode 100644 index 00000000..23362734 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -0,0 +1,24 @@ +package com.gachtaxi.domain.chat.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Getter +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class ChattingParticipant { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "chatting_participant_id") + private Long id; + + @ManyToOne + @JoinColumn(name = "chatting_room_id") + private ChattingRoom chattingRoom; + +// @ManyToOne +// @JoinColumn(name = "member_id") +// private Members members; +} From cedd6b1bab0b89de12b625e46880a9deef6ebd25 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 3 Jan 2025 13:43:43 +0900 Subject: [PATCH 046/770] =?UTF-8?q?refactor:=20=EB=B9=8C=EB=8D=94=20?= =?UTF-8?q?=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java index 31615089..42d0f811 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java @@ -4,7 +4,6 @@ import lombok.*; @Getter -@Builder @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor From 39ed36eb75ef4b2367fb260960b997fe678596a7 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 3 Jan 2025 13:43:56 +0900 Subject: [PATCH 047/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=A0=80=EC=9E=A5=EC=86=8C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/repository/ChattingMessageRepository.java | 7 +++++++ .../chat/repository/ChattingParticipantRepository.java | 7 +++++++ .../domain/chat/repository/ChattingRoomRepository.java | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageRepository.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/repository/ChattingRoomRepository.java diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageRepository.java new file mode 100644 index 00000000..ffb78c3a --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageRepository.java @@ -0,0 +1,7 @@ +package com.gachtaxi.domain.chat.repository; + +import com.gachtaxi.domain.chat.entity.ChattingMessage; +import org.springframework.data.mongodb.repository.MongoRepository; + +public interface ChattingMessageRepository extends MongoRepository { +} diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java new file mode 100644 index 00000000..cdde5955 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java @@ -0,0 +1,7 @@ +package com.gachtaxi.domain.chat.repository; + +import com.gachtaxi.domain.chat.entity.ChattingParticipant; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ChattingParticipantRepository extends JpaRepository { +} diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingRoomRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingRoomRepository.java new file mode 100644 index 00000000..3e1baa94 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingRoomRepository.java @@ -0,0 +1,8 @@ +package com.gachtaxi.domain.chat.repository; + +import com.gachtaxi.domain.chat.entity.ChattingRoom; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ChattingRoomRepository extends JpaRepository { + +} From d1722eb373c0cd394a4190cbff404eec3393588b Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 3 Jan 2025 13:44:22 +0900 Subject: [PATCH 048/770] =?UTF-8?q?feat:=20=EB=8B=89=EB=84=A4=EC=9E=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=A0=95=EC=A0=81=20=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/dto/request/ChatMessage.java | 18 ++++++++++++++---- .../chat/dto/request/ChatMessageRequest.java | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index 4d63b7d1..fd75a994 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -1,14 +1,24 @@ package com.gachtaxi.domain.chat.dto.request; +import lombok.Builder; + import java.time.LocalDateTime; +@Builder public record ChatMessage( - long roomId, - long senderId, + Long roomId, + Long senderId, + String nickName, String message, LocalDateTime timeStamp ) { - public static ChatMessage of(long roomId, long senderId, String message, LocalDateTime timeStamp) { - return new ChatMessage(roomId, senderId, message, timeStamp); + public static ChatMessage of(ChatMessageRequest request, long senderId, LocalDateTime timeStamp) { + return ChatMessage.builder() + .roomId(request.roomId()) + .senderId(senderId) + .nickName(request.nickName()) + .message(request.message()) + .timeStamp(timeStamp) + .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java index 2552ac13..e9b76653 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java @@ -2,6 +2,7 @@ public record ChatMessageRequest( Long roomId, + String nickName, String message ) { } From e83cb3f4ea213bb8d34e512176284bcc269e02be Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 3 Jan 2025 13:44:50 +0900 Subject: [PATCH 049/770] =?UTF-8?q?feat:=20=EB=AA=BD=EA=B3=A0=20=EB=94=94?= =?UTF-8?q?=EB=B9=84=20=EA=B4=80=EB=A0=A8=20=ED=99=98=EA=B2=BD=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 14 +++++++------- src/main/resources/application-local.yml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index a264e0fb..4fcbcd9a 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -11,13 +11,13 @@ spring: dialect: org.hibernate.dialect.MySQLDialect hibernate: ddl-auto: update -# data: -# redis: -# host: ${REDIS_HOST} -# port: ${REDIS_PORT} -# password: ${REDIS_PASSWORD} -# mongodb: -# uri: ${MONGODB_URI} + data: + redis: + host: ${REDIS_HOST} + port: ${REDIS_PORT} + password: ${REDIS_PASSWORD} + mongodb: + uri: ${MONGODB_URI} logging: level: diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 1fd1bdc7..4fcbcd9a 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -16,8 +16,8 @@ spring: host: ${REDIS_HOST} port: ${REDIS_PORT} password: ${REDIS_PASSWORD} -# mongodb: -# uri: ${MONGODB_URI} + mongodb: + uri: ${MONGODB_URI} logging: level: From ab14134ef5d8bef5d916a10a67517a1dda2a6ee3 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 17:41:23 +0900 Subject: [PATCH 050/770] =?UTF-8?q?chore:=20=EB=8F=84=EC=BB=A4=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-dev | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Dockerfile-dev diff --git a/Dockerfile-dev b/Dockerfile-dev new file mode 100644 index 00000000..bd5597a4 --- /dev/null +++ b/Dockerfile-dev @@ -0,0 +1,7 @@ +FROM arm64v8/openjdk:17-alpine + +ARG JAR_FILE=build/libs/*.jar + +COPY ${JAR_FILE} docker-springboot.jar + +ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/docker-springboot.jar"] \ No newline at end of file From e6999333a3f6f941b2dacae031511b0309ea2baa Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 18:07:04 +0900 Subject: [PATCH 051/770] =?UTF-8?q?refactor:=20OpenJDK=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile-dev b/Dockerfile-dev index bd5597a4..2b9fb75e 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,4 +1,4 @@ -FROM arm64v8/openjdk:17-alpine +FROM openjdk:17-alpine ARG JAR_FILE=build/libs/*.jar From 7fe71523315e95640c769dddb84ba9a1fada5edb Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 18:30:52 +0900 Subject: [PATCH 052/770] =?UTF-8?q?chore:=20dev.yml=20cicd=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 98 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/dev.yml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 00000000..f7f37e9b --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,98 @@ +name: GachTaxi-BE dev CI/CD + +on: + push: + branches: [ "develop" ] # develop 브랜치에 push 시 트리거 + pull_request: + branches: [ "develop" ] # develop 브랜치에 대한 PR 시 트리거 + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Gradle 캐시 설정 + - name: Gradle Caching + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build with Gradle Wrapper + run: ./gradlew build + + # 빌드된 JAR 파일 확인 + - name: List JAR files + run: ls build/libs + + # Docker 이미지 빌드 및 푸시 + - name: Docker build & push + run: | + docker login -u ${{ secrets.DEV_DOCKER_USER_NAME }} -p ${{ secrets.DEV_DOCKER_USER_TOKEN }} + docker buildx create --name builder --use + docker buildx build --platform linux/arm64 -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi . + docker push ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi + + deploy: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' + + steps: + # SSH를 사용하여 원격 서버에 배포 + - name: Deploy to server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.DEV_SSH_SECRET_HOST }} + username: ${{ secrets.DEV_SSH_SECRET_USER }} + port: 30922 + key: ${{ secrets.DEV_SSH_SECRET_PRIVATE_KEY }} + script: | + # Blue-Green Deployment 포트 및 컨테이너 이름 설정 + BLUE_PORT=8080 + GREEN_PORT=8081 + BLUE_NAME="blue" + GREEN_NAME="green" + + # 현재 실행 중인 컨테이너 확인 + IS_BLUE_ON=$(sudo docker ps --filter "name=$BLUE_NAME" --filter "status=running" -q) + + if [ -n "$IS_BLUE_ON" ]; then + echo "** ${GREEN_PORT} 포트에서 GREEN 컨테이너 실행" + sudo docker run --name $GREEN_NAME -d -p $GREEN_PORT:$GREEN_PORT \ + --env-file ./gachtaxi-dev.env -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi + BEFORE_NAME=$BLUE_NAME + AFTER_NAME=$GREEN_NAME + BEFORE_PORT=$BLUE_PORT + AFTER_PORT=$GREEN_PORT + else + echo "** ${BLUE_PORT} 포트에서 BLUE 컨테이너 실행" + sudo docker run --name $BLUE_NAME -d -p $BLUE_PORT:$BLUE_PORT \ + --env-file ./gachtaxi-dev.env -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi + BEFORE_NAME=$GREEN_NAME + AFTER_NAME=$BLUE_NAME + BEFORE_PORT=$GREEN_PORT + AFTER_PORT=$BLUE_PORT + fi + + echo "** ${AFTER_NAME} 컨테이너 실행 완료 (포트: ${AFTER_PORT})" + + # 이전 컨테이너 중지 및 삭제 + echo "** 이전 컨테이너(${BEFORE_NAME}) 종료 및 삭제" + sudo docker stop $BEFORE_NAME || true + sudo docker rm $BEFORE_NAME || true \ No newline at end of file From a0b9e5336f015a5658a7934b0050ebf66f268af2 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 18:39:01 +0900 Subject: [PATCH 053/770] =?UTF-8?q?refactor:=20=ED=8A=B8=EB=A6=AC=EA=B1=B0?= =?UTF-8?q?=20=EC=A1=B0=EA=B1=B4=EC=9D=98=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index f7f37e9b..a4a4a33c 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -2,9 +2,9 @@ name: GachTaxi-BE dev CI/CD on: push: - branches: [ "develop" ] # develop 브랜치에 push 시 트리거 + branches: [ "dev" ] # develop 브랜치에 push 시 트리거 pull_request: - branches: [ "develop" ] # develop 브랜치에 대한 PR 시 트리거 + branches: [ "dev" ] # develop 브랜치에 대한 PR 시 트리거 types: [opened, synchronize, reopened] jobs: From 6a50103c6c72c04b3ed52d1971ef4f1884560ff8 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 18:49:46 +0900 Subject: [PATCH 054/770] =?UTF-8?q?fix:=20gradlew=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradlew | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 From f99aff399da2a49226b2ed30fcac293889b3c476 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 18:51:59 +0900 Subject: [PATCH 055/770] =?UTF-8?q?fix:=20cicd=20=EB=B9=8C=EB=93=9C?= =?UTF-8?q?=EC=8B=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index a4a4a33c..7d2b306a 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -34,7 +34,7 @@ jobs: ${{ runner.os }}-gradle- - name: Build with Gradle Wrapper - run: ./gradlew build + run: ./gradlew build -x test # 빌드된 JAR 파일 확인 - name: List JAR files From 36ecd228f2592c3cf297b963dfa053753585e06a Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 19:00:11 +0900 Subject: [PATCH 056/770] =?UTF-8?q?fix:=20docker=20build=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 7d2b306a..2f612606 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -44,8 +44,7 @@ jobs: - name: Docker build & push run: | docker login -u ${{ secrets.DEV_DOCKER_USER_NAME }} -p ${{ secrets.DEV_DOCKER_USER_TOKEN }} - docker buildx create --name builder --use - docker buildx build --platform linux/arm64 -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi . + docker build -t ${{ secrets.DOCKER_USER_NAME }}/gachtaxi . docker push ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi deploy: From cdc9713546004effedb1703d7df1b602cf0df5ff Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 19:07:21 +0900 Subject: [PATCH 057/770] =?UTF-8?q?fix:=20=EB=8F=84=EC=BB=A4=20=EB=B9=8C?= =?UTF-8?q?=EB=93=9C=EC=8B=9C,=20=EC=98=A4=ED=83=88=EC=9E=90=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 2f612606..ce54293c 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -44,7 +44,7 @@ jobs: - name: Docker build & push run: | docker login -u ${{ secrets.DEV_DOCKER_USER_NAME }} -p ${{ secrets.DEV_DOCKER_USER_TOKEN }} - docker build -t ${{ secrets.DOCKER_USER_NAME }}/gachtaxi . + docker build -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi . docker push ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi deploy: From ff6ef879b1e937515b3fa71deb9ac070b7ff0266 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 19:11:30 +0900 Subject: [PATCH 058/770] =?UTF-8?q?fix:=20=EB=8F=84=EC=BB=A4=20=EB=B9=8C?= =?UTF-8?q?=EB=93=9C=EC=8B=9C=20Dockerfile-dev=EB=A1=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index ce54293c..58dd7d30 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -44,7 +44,7 @@ jobs: - name: Docker build & push run: | docker login -u ${{ secrets.DEV_DOCKER_USER_NAME }} -p ${{ secrets.DEV_DOCKER_USER_TOKEN }} - docker build -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi . + docker build -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi . docker push ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi deploy: From 425ba820a3470cb189801465589d22b4f9ce936f Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 19:53:36 +0900 Subject: [PATCH 059/770] =?UTF-8?q?refactor:=20=EB=9D=BC=EC=A6=88=EB=B2=A0?= =?UTF-8?q?=EB=A6=AC=20=ED=8C=8C=EC=9D=B4=EC=97=90=EC=84=9C=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89=20=EA=B0=80=EB=8A=A5=ED=95=9C=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile-dev b/Dockerfile-dev index 2b9fb75e..bd5597a4 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,4 +1,4 @@ -FROM openjdk:17-alpine +FROM arm64v8/openjdk:17-alpine ARG JAR_FILE=build/libs/*.jar From 2d3ee7d2b5ce2f49de721358cafff02e6d367db5 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 19:57:56 +0900 Subject: [PATCH 060/770] =?UTF-8?q?refactor:=20=EB=B9=8C=EB=93=9C=EC=8B=9C?= =?UTF-8?q?=20=ED=94=8C=EB=9E=AB=ED=8F=BC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 58dd7d30..e8631f84 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -44,8 +44,8 @@ jobs: - name: Docker build & push run: | docker login -u ${{ secrets.DEV_DOCKER_USER_NAME }} -p ${{ secrets.DEV_DOCKER_USER_TOKEN }} - docker build -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi . - docker push ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi + docker buildx create --use + docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest --push . deploy: runs-on: ubuntu-latest From 8c285592c35b57ae56c5020ff53c6aaa3907b808 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 3 Jan 2025 20:00:23 +0900 Subject: [PATCH 061/770] =?UTF-8?q?fix:=20eclipse-temurin=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=EB=A5=BC=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile-dev b/Dockerfile-dev index bd5597a4..c5904f97 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,4 +1,4 @@ -FROM arm64v8/openjdk:17-alpine +FROM eclipse-temurin:17-jre-focal ARG JAR_FILE=build/libs/*.jar From 976fcf742b922b49be21a42f3459ab00d77886ba Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 20:01:34 +0900 Subject: [PATCH 062/770] =?UTF-8?q?fix:=20Members=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/entity/Members.java | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 71a0832e..0009622f 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -1,42 +1,68 @@ package com.gachtaxi.domain.members.entity; +import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; import lombok.Getter; +import org.hibernate.annotations.ColumnDefault; @Getter @Entity public class Members extends BaseEntity { + @Column(name = "email", nullable = false, unique = true) private String email; - private String real_name; + @Column(name = "profile_picture") + private String profilePicture; - private String nickName; + @Column(name = "nickname", nullable = false) + private String nickname; - private String gender; + @Column(name = "real_name", nullable = false) + private String realName; - private String phoneNumber; + @Column(name = "student_number", nullable = false, unique = true) + private String studentNumber; - private String profile_picture; + @Column(name = "phone_number", unique = true) // 피그마 참고하여 일단 null 허용 + private String phoneNumber; + @Column(name = "kakao_id", unique = true) private Long kakaoId; + @Column(name = "google_id", unique = true) private Long googleId; @Enumerated(EnumType.STRING) private Role role; - boolean marketing_agreement; - - boolean privacy_agreement; - - boolean terms_agreement; - - boolean two_factor_authentication; + @Enumerated(EnumType.STRING) + private Gender gender; + + // 이용 약관 동의 + @Column(name = "terms_agreement", nullable = false) + @ColumnDefault("true") + private Boolean termsAgreement; + + // 개인정보 수집 동의 + @Column(name = "privacy_agreement", nullable = false) + @ColumnDefault("true") + private Boolean privacyAgreement; + + // 광고성 정보 수신 동의 + @Column(name = "marketing_agreement", nullable = false) + @ColumnDefault("false") + private Boolean marketingAgreement; + + // 2차 인증 (전화번호) + @Column(name = "two_factor_authentication", nullable = false) + @ColumnDefault("false") + private Boolean twoFactorAuthentication; /* * 추가할 사항 From 36dabd7a76960789e4bce6ac91968e2cd0fbabf1 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:11:40 +0900 Subject: [PATCH 063/770] =?UTF-8?q?feat:=20REGISTER=5FSUCCESS=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/controller/SuccessMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java index 7967455a..b979d606 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java @@ -7,6 +7,7 @@ @AllArgsConstructor public enum SuccessMessage { // MemberController + REGISTER_SUCCESS("회원가입에 성공했습니다."), // AuthController LOGIN_SUCCESS("로그인 성공에 성공했습니다."), From 4aa5974dd9b64734dba2b1fb4f75bb61623c0e7c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:12:26 +0900 Subject: [PATCH 064/770] =?UTF-8?q?feat:=20Members=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=20=EC=83=9D=EC=84=B1=20=EC=BA=A1=EC=8A=90?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/entity/Members.java | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 0009622f..83451d57 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -1,17 +1,23 @@ package com.gachtaxi.domain.members.entity; +import com.gachtaxi.domain.members.dto.request.UserRequestDto; import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.common.entity.BaseEntity; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; import org.hibernate.annotations.ColumnDefault; @Getter @Entity +@SuperBuilder +@Table(name="members") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor public class Members extends BaseEntity { @Column(name = "email", nullable = false, unique = true) @@ -29,7 +35,7 @@ public class Members extends BaseEntity { @Column(name = "student_number", nullable = false, unique = true) private String studentNumber; - @Column(name = "phone_number", unique = true) // 피그마 참고하여 일단 null 허용 + @Column(name = "phone_number", unique = true) // 피그마 참고, 일단 null 허용 private String phoneNumber; @Column(name = "kakao_id", unique = true) @@ -71,4 +77,22 @@ public class Members extends BaseEntity { * friend_info * */ + public static Members of(UserRequestDto.registerDto dto){ + return Members.builder() + //.profilePicture(dto.profilePicture()) + .email(dto.email()) + .nickname(dto.nickName()) + .realName(dto.realName()) + .studentNumber(dto.studentNumber()) + //.phoneNumber(dto.phoneNumber()) + .kakaoId(dto.kakaoId()) + .googleId(dto.googleId()) + .role(Role.MEMBER) + .gender(dto.gender()) + .termsAgreement(dto.termsAgreement()) + .privacyAgreement(dto.privacyAgreement()) + .marketingAgreement(dto.marketingAgreement()) + .twoFactorAuthentication(dto.twoFactorAuthentication()) + .build(); + } } From 7bc18f26304bbf1a7d920033bdc8ddcb8c87e924 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:12:56 +0900 Subject: [PATCH 065/770] =?UTF-8?q?feat:=20Gender=20Enum=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/entity/enums/Gender.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/entity/enums/Gender.java diff --git a/src/main/java/com/gachtaxi/domain/members/entity/enums/Gender.java b/src/main/java/com/gachtaxi/domain/members/entity/enums/Gender.java new file mode 100644 index 00000000..ce48e9c6 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/entity/enums/Gender.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.members.entity.enums; + +public enum Gender { + MALE, FEMALE +} From 0f60cfd06e561083c256a7c5d1c96641baee6ee5 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:13:42 +0900 Subject: [PATCH 066/770] =?UTF-8?q?feat:=20DuplicatedStudentNumberExceptio?= =?UTF-8?q?n=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/DuplicatedStudentNumberException.java | 12 ++++++++++++ .../domain/members/exception/ErrorMessage.java | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/DuplicatedStudentNumberException.java create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedStudentNumberException.java b/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedStudentNumberException.java new file mode 100644 index 00000000..5b66e79d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedStudentNumberException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.members.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.DUPLICATED_STUDENT_NUMBER; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class DuplicatedStudentNumberException extends BaseException { + public DuplicatedStudentNumberException() { + super(BAD_REQUEST, DUPLICATED_STUDENT_NUMBER.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java new file mode 100644 index 00000000..7d6f825f --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.members.exception; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ErrorMessage { + + DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."); + + private final String message; +} From c951f78c3c80f900350468e1facefeb77da1280b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:14:58 +0900 Subject: [PATCH 067/770] =?UTF-8?q?feat:=20MemberService=20-=20saveMember(?= =?UTF-8?q?)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/MemberService.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 835b4707..a40f69f7 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,7 +1,11 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.members.dto.request.UserRequestDto; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; import com.gachtaxi.domain.members.repository.MemberRepository; +import com.gachtaxi.global.auth.jwt.service.JwtService; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -11,14 +15,28 @@ @RequiredArgsConstructor public class MemberService { + private final JwtService jwtService; private final MemberRepository memberRepository; - public Boolean checkByEmail(String email) { - return memberRepository.existsByEmail(email); + public void saveMember(UserRequestDto.registerDto dto, HttpServletResponse response) { + validStudentNumber(dto); + Members newMember = Members.of(dto); + jwtService.responseJwtToken(newMember.getId(), newMember.getEmail(), newMember.getRole(), response); + memberRepository.save(newMember); } - public Optional findByEmail(String email) { - return memberRepository.findByEmail(email); + public Optional findByKakaoId(Long kakaoId) { + return memberRepository.findByKakaoId(kakaoId); } + /* + * refactor + * */ + + private void validStudentNumber(UserRequestDto.registerDto dto) { + String studentNumber = dto.studentNumber(); + memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { + throw new DuplicatedStudentNumberException(); + }); + } } From cb81c68429e0cf6808e60132209282a7844bed53 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:15:32 +0900 Subject: [PATCH 068/770] =?UTF-8?q?feat:=20JwtService=20=EB=A7=A4=EA=B0=9C?= =?UTF-8?q?=EC=9D=B8=EC=9E=90=20userId=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/auth/jwt/service/JwtService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 724b93b9..c199dce6 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -24,8 +24,8 @@ public class JwtService { private final JwtProvider jwtProvider; private final JwtExtractor jwtExtractor; - public void responseJwtToken(Long id, String email, Role role, HttpServletResponse response) { - JwtTokenDto jwtToken = generateJwtToken(id, email, role); + public void responseJwtToken(Long userId, String email, Role role, HttpServletResponse response) { + JwtTokenDto jwtToken = generateJwtToken(userId, email, role); setHeader(jwtToken.accessToken(), response); setCookie(jwtToken.refreshToken(), response); @@ -33,11 +33,11 @@ public void responseJwtToken(Long id, String email, Role role, HttpServletRespon } // JwtToken 생성 + Redis 저장 - private JwtTokenDto generateJwtToken(Long id, String email, Role role) { - String accessToken = jwtProvider.generateAccessToken(id, email, role); - String refreshToken = jwtProvider.generateRefreshToken(id); + private JwtTokenDto generateJwtToken(Long userId, String email, Role role) { + String accessToken = jwtProvider.generateAccessToken(userId, email, role); + String refreshToken = jwtProvider.generateRefreshToken(userId); - redisUtil.set(id, refreshToken); + redisUtil.set(userId, refreshToken); return JwtTokenDto.builder() .accessToken(accessToken) .refreshToken(refreshToken) From c7f84f4a354a90c37d00749ad3064766a397924e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:17:25 +0900 Subject: [PATCH 069/770] =?UTF-8?q?feat:=20Jpa=20QueryMethod=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(StudentNumber,=20KakaoId)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/repository/MemberRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 0a54885d..86b56865 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -9,7 +9,7 @@ @Repository public interface MemberRepository extends JpaRepository { - Boolean existsByEmail(String email); + Optional findByStudentNumber(String studentNumber); - Optional findByEmail(String email); + Optional findByKakaoId(Long kakaoId); } From 502371326dd65ed7516b07bcfd2a38b3a7f90b07 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:18:02 +0900 Subject: [PATCH 070/770] =?UTF-8?q?fix:=20=EC=86=8C=EC=85=9C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EB=B6=84=EA=B8=B0=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=86=8C=EC=85=9CID=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/AuthService.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 92f41bb1..7d55ea20 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -31,16 +31,15 @@ public oauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); KakaoUserInfoResponse userInfo = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); - String email = userInfo.kakao_account().email(); - Optional optionalMember = memberService.findByEmail(email); + Long kakaoId = userInfo.id(); + Optional optionalMember = memberService.findByKakaoId(kakaoId); if(optionalMember.isEmpty()) { return oauthMapper.toKakaoUnRegisterResponse(userInfo); } Members member = optionalMember.get(); - jwtService.responseJwtToken(member.getId(), email, member.getRole(), response); - + jwtService.responseJwtToken(member.getId(), member.getEmail(), member.getRole(), response); return oauthMapper.toKakaoLoginResponse(userInfo, member.getId()); } } From b1bace33973fc5721cfe7e6aabf6653d63c9f04d Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:18:34 +0900 Subject: [PATCH 071/770] =?UTF-8?q?feat:=20MemberController=20-=20register?= =?UTF-8?q?()=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/MemberController.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/controller/MemberController.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java new file mode 100644 index 00000000..5f0dcab9 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -0,0 +1,30 @@ +package com.gachtaxi.domain.members.controller; + +import com.gachtaxi.domain.members.dto.request.UserRequestDto; +import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.global.common.response.ApiResponse; +import jakarta.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.gachtaxi.domain.members.controller.SuccessMessage.*; +import static org.springframework.http.HttpStatus.*; + +@Slf4j +@RequestMapping("/api/members") +@RestController +@RequiredArgsConstructor +public class MemberController { + + private final MemberService memberService; + + @PostMapping() + public ApiResponse register(@RequestBody UserRequestDto.registerDto registerDto, HttpServletResponse response) { + memberService.saveMember(registerDto, response); + return ApiResponse.response(OK, REGISTER_SUCCESS.getMessage()); + } +} From 3760104b23327d36d2c2f7ab1a837fef093b8399 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:18:52 +0900 Subject: [PATCH 072/770] =?UTF-8?q?feat:=20UserRequestDto=20-=20registerDt?= =?UTF-8?q?o=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/dto/request/UserRequestDto.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java new file mode 100644 index 00000000..27ec3029 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java @@ -0,0 +1,23 @@ +package com.gachtaxi.domain.members.dto.request; + + +import com.gachtaxi.domain.members.entity.enums.Gender; + +public class UserRequestDto { + + public record registerDto( + //String profilePicture, + String email, + String nickName, + String realName, + String studentNumber, + //String phoneNumber, + Gender gender, + Boolean termsAgreement, + Boolean privacyAgreement, + Boolean marketingAgreement, + Boolean twoFactorAuthentication, + Long kakaoId, + Long googleId + ){} +} From 65e398a83d09ae379e4a96d1959ddaf5a055ac5d Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:22:59 +0900 Subject: [PATCH 073/770] =?UTF-8?q?fix:=20redisConfig=20password=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/RedisConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index 5ce34594..ff852595 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -41,7 +41,7 @@ public RedisConnectionFactory redisConnectionFactory() { redisStandaloneConfiguration.setHostName(host); redisStandaloneConfiguration.setPort(port); -// redisStandaloneConfiguration.setPassword(password); + redisStandaloneConfiguration.setPassword(password); return new LettuceConnectionFactory(redisStandaloneConfiguration); } From f954edadaafcf695d7adbeb38f5e1f26c4534a10 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 3 Jan 2025 21:42:20 +0900 Subject: [PATCH 074/770] =?UTF-8?q?fix:=20SignUp=20=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/MemberController.java | 7 ++++--- .../domain/members/dto/request/UserRequestDto.java | 13 +++++++------ .../com/gachtaxi/domain/members/entity/Members.java | 2 +- .../domain/members/service/MemberService.java | 8 +++++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index 5f0dcab9..d4d6308a 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -1,9 +1,9 @@ package com.gachtaxi.domain.members.controller; -import com.gachtaxi.domain.members.dto.request.UserRequestDto; import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.common.response.ApiResponse; import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import static com.gachtaxi.domain.members.dto.request.UserRequestDto.*; import static com.gachtaxi.domain.members.controller.SuccessMessage.*; import static org.springframework.http.HttpStatus.*; @@ -23,8 +24,8 @@ public class MemberController { private final MemberService memberService; @PostMapping() - public ApiResponse register(@RequestBody UserRequestDto.registerDto registerDto, HttpServletResponse response) { - memberService.saveMember(registerDto, response); + public ApiResponse signUp(@RequestBody @Valid SignUpDto signUpDto, HttpServletResponse response) { + memberService.saveMember(signUpDto, response); return ApiResponse.response(OK, REGISTER_SUCCESS.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java index 27ec3029..d43065c7 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java @@ -2,17 +2,18 @@ import com.gachtaxi.domain.members.entity.enums.Gender; +import jakarta.validation.constraints.NotBlank; public class UserRequestDto { - public record registerDto( + public record SignUpDto( //String profilePicture, - String email, - String nickName, - String realName, - String studentNumber, + @NotBlank String email, + @NotBlank String nickName, + @NotBlank String realName, + @NotBlank String studentNumber, //String phoneNumber, - Gender gender, + @NotBlank Gender gender, Boolean termsAgreement, Boolean privacyAgreement, Boolean marketingAgreement, diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 83451d57..69185b2d 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -77,7 +77,7 @@ public class Members extends BaseEntity { * friend_info * */ - public static Members of(UserRequestDto.registerDto dto){ + public static Members of(UserRequestDto.SignUpDto dto){ return Members.builder() //.profilePicture(dto.profilePicture()) .email(dto.email()) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index a40f69f7..8b67a2a4 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,6 +1,5 @@ package com.gachtaxi.domain.members.service; -import com.gachtaxi.domain.members.dto.request.UserRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; import com.gachtaxi.domain.members.repository.MemberRepository; @@ -11,6 +10,9 @@ import java.util.Optional; +import static com.gachtaxi.domain.members.dto.request.UserRequestDto.*; + + @Service @RequiredArgsConstructor public class MemberService { @@ -18,7 +20,7 @@ public class MemberService { private final JwtService jwtService; private final MemberRepository memberRepository; - public void saveMember(UserRequestDto.registerDto dto, HttpServletResponse response) { + public void saveMember(SignUpDto dto, HttpServletResponse response) { validStudentNumber(dto); Members newMember = Members.of(dto); jwtService.responseJwtToken(newMember.getId(), newMember.getEmail(), newMember.getRole(), response); @@ -33,7 +35,7 @@ public Optional findByKakaoId(Long kakaoId) { * refactor * */ - private void validStudentNumber(UserRequestDto.registerDto dto) { + private void validStudentNumber(SignUpDto dto) { String studentNumber = dto.studentNumber(); memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { throw new DuplicatedStudentNumberException(); From 0120a71bf86d4adff48176f10b74f4924b1598e2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 03:43:21 +0900 Subject: [PATCH 075/770] =?UTF-8?q?fix:=20@Slf4j=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/controller/AuthController.java | 1 - .../gachtaxi/domain/members/controller/MemberController.java | 1 - .../java/com/gachtaxi/domain/members/service/AuthService.java | 2 +- .../java/com/gachtaxi/global/auth/jwt/service/JwtService.java | 3 --- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 1657f363..7c0efe32 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -12,7 +12,6 @@ import static com.gachtaxi.domain.members.controller.SuccessMessage.*; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; -@Slf4j @RequestMapping("/auth") @RestController @RequiredArgsConstructor diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index d4d6308a..7a26f775 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -15,7 +15,6 @@ import static com.gachtaxi.domain.members.controller.SuccessMessage.*; import static org.springframework.http.HttpStatus.*; -@Slf4j @RequestMapping("/api/members") @RestController @RequiredArgsConstructor diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 7d55ea20..4fd97c71 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -17,7 +17,7 @@ * AuthService는 인증 로직 책임을 가진다. * */ -@Slf4j + @Service @RequiredArgsConstructor public class AuthService { diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index c199dce6..f6f4c64b 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -@Slf4j @Service @RequiredArgsConstructor public class JwtService { @@ -28,8 +27,6 @@ public void responseJwtToken(Long userId, String email, Role role, HttpServletRe JwtTokenDto jwtToken = generateJwtToken(userId, email, role); setHeader(jwtToken.accessToken(), response); setCookie(jwtToken.refreshToken(), response); - - log.info(jwtToken.toString()); } // JwtToken 생성 + Redis 저장 From 227f8146c1d0bcfe0986e609959401b920b6ebc3 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 03:46:29 +0900 Subject: [PATCH 076/770] =?UTF-8?q?fix:=20SignUpDto=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=EC=84=B1=20=EA=B2=80=EC=A6=9D=20=EC=96=B4=EB=85=B8=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/request/UserRequestDto.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java index d43065c7..fa8b1ac5 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java @@ -3,21 +3,20 @@ import com.gachtaxi.domain.members.entity.enums.Gender; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; public class UserRequestDto { public record SignUpDto( - //String profilePicture, @NotBlank String email, @NotBlank String nickName, @NotBlank String realName, @NotBlank String studentNumber, - //String phoneNumber, @NotBlank Gender gender, - Boolean termsAgreement, - Boolean privacyAgreement, - Boolean marketingAgreement, - Boolean twoFactorAuthentication, + @NotNull Boolean termsAgreement, + @NotNull Boolean privacyAgreement, + @NotNull Boolean marketingAgreement, + @NotNull Boolean twoFactorAuthentication, Long kakaoId, Long googleId ){} From 94c632a9c4637056d4d7144bd5436c1f2fcfb8c8 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 03:47:54 +0900 Subject: [PATCH 077/770] =?UTF-8?q?fix:=20SuccessMesage=20->=20ResponseMes?= =?UTF-8?q?sage=20Enum=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/controller/AuthController.java | 5 ++--- .../gachtaxi/domain/members/controller/MemberController.java | 3 +-- .../controller/{SuccessMessage.java => ResponseMessage.java} | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) rename src/main/java/com/gachtaxi/domain/members/controller/{SuccessMessage.java => ResponseMessage.java} (92%) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 7c0efe32..433fa4bb 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -5,11 +5,10 @@ import com.gachtaxi.global.common.response.ApiResponse; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; -import static com.gachtaxi.domain.members.controller.SuccessMessage.*; +import static com.gachtaxi.domain.members.controller.ResponseMessage.*; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; @RequestMapping("/auth") @@ -22,7 +21,7 @@ public class AuthController { @GetMapping("/login/kakao") public ApiResponse kakaoLogin(@RequestParam("code") String authcode, HttpServletResponse response) { oauthKakaoResponse res = authService.kakaoLogin(authcode, response); - SuccessMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) + ResponseMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) ? LOGIN_SUCCESS : UN_REGISTER; return ApiResponse.response(HttpStatus.OK, OAUTH_STATUS.getMessage(), res); diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index 7a26f775..000c87fa 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -5,14 +5,13 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import static com.gachtaxi.domain.members.dto.request.UserRequestDto.*; -import static com.gachtaxi.domain.members.controller.SuccessMessage.*; +import static com.gachtaxi.domain.members.controller.ResponseMessage.*; import static org.springframework.http.HttpStatus.*; @RequestMapping("/api/members") diff --git a/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java similarity index 92% rename from src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java rename to src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index b979d606..04dd4772 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/SuccessMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -5,7 +5,7 @@ @Getter @AllArgsConstructor -public enum SuccessMessage { +public enum ResponseMessage { // MemberController REGISTER_SUCCESS("회원가입에 성공했습니다."), From 0fd90b03c3c650bb825dde32f80d0887d73332bb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 03:56:47 +0900 Subject: [PATCH 078/770] =?UTF-8?q?fix:=20JwtTokenDto=20=EA=B0=9D=EC=B2=B4?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=20=EC=BA=A1=EC=8A=90=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java | 5 +++++ .../com/gachtaxi/global/auth/jwt/service/JwtService.java | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java b/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java index 61108753..1e316fa6 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java @@ -7,4 +7,9 @@ public record JwtTokenDto( String accessToken, String refreshToken ){ + public static JwtTokenDto of(String accessToken, String refreshToken) { + return JwtTokenDto.builder() + .accessToken(accessToken) + .refreshToken(refreshToken).build(); + } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index f6f4c64b..3bfed391 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -35,10 +35,7 @@ private JwtTokenDto generateJwtToken(Long userId, String email, Role role) { String refreshToken = jwtProvider.generateRefreshToken(userId); redisUtil.set(userId, refreshToken); - return JwtTokenDto.builder() - .accessToken(accessToken) - .refreshToken(refreshToken) - .build(); + return JwtTokenDto.of(accessToken, refreshToken); } private void setHeader(String accessToken, HttpServletResponse response) { From ca166ce50ff719a1c641c8bbaaac8fe09f6efb73 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 04:03:13 +0900 Subject: [PATCH 079/770] fix: getIdFromToken - extract id to Long Type --- .../com/gachtaxi/global/auth/jwt/util/JwtExtractor.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java index 69ad20c3..108b80e0 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java @@ -26,8 +26,8 @@ public JwtExtractor(@Value("${gachtaxi.auth.jwt.key}") String secretKey) { this.key = Keys.hmacShaKeyFor(secretKey.getBytes()); // 키 변환 } - public String getId(String token){ - return getClaimFromToken(token, ID_CLAIM); + public Long getId(String token){ + return getIdFromToken(token, ID_CLAIM); } public String getEmail(String token){ @@ -48,6 +48,11 @@ private String getClaimFromToken(String token, String claimName) { return claims.get(claimName, String.class); } + private Long getIdFromToken(String token, String claimName) { + Claims claims = parseClaims(token); + return claims.get(claimName, Long.class); + } + private Claims parseClaims(String token) { try{ JwtParser parser = Jwts.parserBuilder() From 41d1ac99a0f16f613e3f7708785d096a04ee282f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 04:04:54 +0900 Subject: [PATCH 080/770] =?UTF-8?q?fix:=20OauthKakaoResponse=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AuthController.java | 4 ++-- .../com/gachtaxi/domain/members/service/AuthService.java | 3 +-- .../java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java | 2 +- .../java/com/gachtaxi/global/auth/mapper/OauthMapper.java | 8 ++++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 433fa4bb..d3507fba 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -19,8 +19,8 @@ public class AuthController { private final AuthService authService; @GetMapping("/login/kakao") - public ApiResponse kakaoLogin(@RequestParam("code") String authcode, HttpServletResponse response) { - oauthKakaoResponse res = authService.kakaoLogin(authcode, response); + public ApiResponse kakaoLogin(@RequestParam("code") String authcode, HttpServletResponse response) { + OauthKakaoResponse res = authService.kakaoLogin(authcode, response); ResponseMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) ? LOGIN_SUCCESS : UN_REGISTER; diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 4fd97c71..9c29c261 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -6,7 +6,6 @@ import com.gachtaxi.global.auth.mapper.OauthMapper; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.Optional; @@ -27,7 +26,7 @@ public class AuthService { private final JwtService jwtService; private final MemberService memberService; - public oauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse response) { + public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse response) { KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); KakaoUserInfoResponse userInfo = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java index 35701ad1..ea1d5916 100644 --- a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java +++ b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java @@ -32,7 +32,7 @@ public record Profile( ) {} @Builder - public record oauthKakaoResponse( + public record OauthKakaoResponse( Long userId, Long kakaoId, OauthLoginStatus status diff --git a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java index 130ac0a8..94597c3b 100644 --- a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java +++ b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java @@ -8,16 +8,16 @@ @Component public class OauthMapper { - public oauthKakaoResponse toKakaoUnRegisterResponse(KakaoUserInfoResponse userInfo) { - return oauthKakaoResponse.builder() + public OauthKakaoResponse toKakaoUnRegisterResponse(KakaoUserInfoResponse userInfo) { + return OauthKakaoResponse.builder() .kakaoId(userInfo.id()) .status(UN_REGISTER) .build(); } // jwt 토큰 추가 할 것. - public oauthKakaoResponse toKakaoLoginResponse(KakaoUserInfoResponse userInfo, Long userId) { - return oauthKakaoResponse.builder() + public OauthKakaoResponse toKakaoLoginResponse(KakaoUserInfoResponse userInfo, Long userId) { + return OauthKakaoResponse.builder() .userId(userId) .kakaoId(userInfo.id()) .status(LOGIN) From 304203d45e0ab19d3b9777d1d9fff4baebd4c609 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 04:26:49 +0900 Subject: [PATCH 081/770] =?UTF-8?q?fix:=20profile=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=B4=20secure=20=EC=98=B5=EC=85=98=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=20=EB=B3=80=EC=88=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java | 5 ++++- src/main/resources/application-local.yml | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java index c330055d..eafe6831 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java @@ -11,11 +11,14 @@ public class CookieUtil { @Value("${gachtaxi.auth.jwt.cookieMaxAge}") private Long cookieMaxAge; + @Value("${gachtaxi.auth.jwt.secureOption}") + private boolean secureOption; + public void setCookie( String name, String value, HttpServletResponse response) { ResponseCookie cookie = ResponseCookie.from(name, value) .maxAge(cookieMaxAge) .path("/") - .secure(false) //https 적용 시 true + .secure(secureOption) //https 적용 시 true .httpOnly(true) .sameSite("None") .build(); diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 547fdb38..f29206e2 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -35,4 +35,5 @@ gachtaxi: key: ${JWT_SECRET_KEY} accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} refreshTokenExpiration: ${JWT_REFRESH_TOKEN_EXPIRATION} - cookieMaxAge: ${JWT_COOKIE_MAX_AGE} \ No newline at end of file + cookieMaxAge: ${JWT_COOKIE_MAX_AGE} + secureOption: ${COOKIE_SECURE_OPTION} \ No newline at end of file From cee3fe0c9c950cf4f5a7b2c6e533e80a1de9d421 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 04:34:31 +0900 Subject: [PATCH 082/770] =?UTF-8?q?feat:=20@Transactional=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/MemberService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 8b67a2a4..f4f722ce 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -7,6 +7,7 @@ import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Optional; @@ -20,11 +21,12 @@ public class MemberService { private final JwtService jwtService; private final MemberRepository memberRepository; + @Transactional public void saveMember(SignUpDto dto, HttpServletResponse response) { validStudentNumber(dto); Members newMember = Members.of(dto); - jwtService.responseJwtToken(newMember.getId(), newMember.getEmail(), newMember.getRole(), response); memberRepository.save(newMember); + jwtService.responseJwtToken(newMember.getId(), newMember.getEmail(), newMember.getRole(), response); } public Optional findByKakaoId(Long kakaoId) { From 37934776528a2e773765b176a6ce27720cd11afb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 04:42:09 +0900 Subject: [PATCH 083/770] fix: StudentNumber field to Long type --- .../com/gachtaxi/domain/members/dto/request/UserRequestDto.java | 2 +- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 2 +- .../gachtaxi/domain/members/repository/MemberRepository.java | 2 +- .../java/com/gachtaxi/domain/members/service/MemberService.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java index fa8b1ac5..b325ad91 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java @@ -11,7 +11,7 @@ public record SignUpDto( @NotBlank String email, @NotBlank String nickName, @NotBlank String realName, - @NotBlank String studentNumber, + @NotBlank Long studentNumber, @NotBlank Gender gender, @NotNull Boolean termsAgreement, @NotNull Boolean privacyAgreement, diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 69185b2d..93775a34 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -33,7 +33,7 @@ public class Members extends BaseEntity { private String realName; @Column(name = "student_number", nullable = false, unique = true) - private String studentNumber; + private Long studentNumber; @Column(name = "phone_number", unique = true) // 피그마 참고, 일단 null 허용 private String phoneNumber; diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 86b56865..664eb3b3 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -9,7 +9,7 @@ @Repository public interface MemberRepository extends JpaRepository { - Optional findByStudentNumber(String studentNumber); + Optional findByStudentNumber(Long studentNumber); Optional findByKakaoId(Long kakaoId); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index f4f722ce..51e94191 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -38,7 +38,7 @@ public Optional findByKakaoId(Long kakaoId) { * */ private void validStudentNumber(SignUpDto dto) { - String studentNumber = dto.studentNumber(); + Long studentNumber = dto.studentNumber(); memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { throw new DuplicatedStudentNumberException(); }); From d16486187d2f02dcb27b8f02e77f4bfd45176552 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 04:44:22 +0900 Subject: [PATCH 084/770] =?UTF-8?q?fix:=20=EC=9D=B8=EC=A6=9D=20=ED=97=A4?= =?UTF-8?q?=EB=8D=94=EB=AA=85=20Authorization=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/jwt/service/JwtService.java | 2 +- .../java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 3bfed391..03c7fcdc 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -15,7 +15,7 @@ @RequiredArgsConstructor public class JwtService { - private static final String ACCESS_TOKEN_SUBJECT = "AccessToken"; + private static final String ACCESS_TOKEN_SUBJECT = "Authorization"; private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; private final CookieUtil cookieUtil; diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java index 807f2cde..0948b7c5 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java @@ -13,7 +13,7 @@ @Component public class JwtProvider { - private static final String ACCESS_TOKEN_SUBJECT = "AccessToken"; + private static final String ACCESS_TOKEN_SUBJECT = "Authorization"; private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; private static final String ID_CLAIM = "id"; private static final String EMAIL_CLAIM = "email"; From ed694a6737cad3072bf6521ad74b9915f37ea184 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 04:46:28 +0900 Subject: [PATCH 085/770] =?UTF-8?q?remove:=20AllArgsConstructor=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 93775a34..6f93ec19 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -17,7 +17,6 @@ @SuperBuilder @Table(name="members") @NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor public class Members extends BaseEntity { @Column(name = "email", nullable = false, unique = true) From c28938fc674e3910d1aeb81af22a6fe744fb38fb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 04:48:51 +0900 Subject: [PATCH 086/770] fix: rename checkDuplicatedStudenNumber() --- .../com/gachtaxi/domain/members/service/MemberService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 51e94191..b94801dc 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -23,7 +23,7 @@ public class MemberService { @Transactional public void saveMember(SignUpDto dto, HttpServletResponse response) { - validStudentNumber(dto); + checkDuplicatedStudentNumber(dto); Members newMember = Members.of(dto); memberRepository.save(newMember); jwtService.responseJwtToken(newMember.getId(), newMember.getEmail(), newMember.getRole(), response); @@ -37,7 +37,7 @@ public Optional findByKakaoId(Long kakaoId) { * refactor * */ - private void validStudentNumber(SignUpDto dto) { + private void checkDuplicatedStudentNumber(SignUpDto dto) { Long studentNumber = dto.studentNumber(); memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { throw new DuplicatedStudentNumberException(); From 01d4f24a49e829e0e458726ff59d6b15e838c5a7 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 4 Jan 2025 11:36:23 +0900 Subject: [PATCH 087/770] =?UTF-8?q?refactor:=20=EA=B0=9C=EB=B0=9C=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D=20=EB=8F=84=EC=BB=A4=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile-dev b/Dockerfile-dev index c5904f97..44e9a81b 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -4,4 +4,4 @@ ARG JAR_FILE=build/libs/*.jar COPY ${JAR_FILE} docker-springboot.jar -ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/docker-springboot.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=dev", "/docker-springboot.jar"] \ No newline at end of file From 7b1f26b043fd498c864ce5cb839dd3b0424da6ec Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 4 Jan 2025 11:40:15 +0900 Subject: [PATCH 088/770] =?UTF-8?q?refactor:=20deploy=20=EC=A1=B0=EA=B1=B4?= =?UTF-8?q?=EB=AC=B8=20=EC=9E=84=EC=8B=9C=EC=82=AD=EC=A0=9C=20=ED=9B=84=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index e8631f84..0bb7e503 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -50,7 +50,6 @@ jobs: deploy: runs-on: ubuntu-latest needs: build - if: github.event_name == 'push' steps: # SSH를 사용하여 원격 서버에 배포 From 1f324e1f04c224bd854ed09df049ce2b1cb0b45b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 4 Jan 2025 12:12:07 +0900 Subject: [PATCH 089/770] fix: UserSignUpRequestDto rename --- .../members/controller/MemberController.java | 4 ++-- .../members/dto/request/UserRequestDto.java | 23 ------------------- .../dto/request/UserSignUpRequestDto.java | 20 ++++++++++++++++ .../domain/members/entity/Members.java | 5 ++-- .../domain/members/service/MemberService.java | 8 +++---- 5 files changed, 27 insertions(+), 33 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index 000c87fa..a145934a 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.controller; +import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.common.response.ApiResponse; import jakarta.servlet.http.HttpServletResponse; @@ -10,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import static com.gachtaxi.domain.members.dto.request.UserRequestDto.*; import static com.gachtaxi.domain.members.controller.ResponseMessage.*; import static org.springframework.http.HttpStatus.*; @@ -22,7 +22,7 @@ public class MemberController { private final MemberService memberService; @PostMapping() - public ApiResponse signUp(@RequestBody @Valid SignUpDto signUpDto, HttpServletResponse response) { + public ApiResponse signUp(@RequestBody @Valid UserSignUpRequestDto signUpDto, HttpServletResponse response) { memberService.saveMember(signUpDto, response); return ApiResponse.response(OK, REGISTER_SUCCESS.getMessage()); } diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java deleted file mode 100644 index b325ad91..00000000 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/UserRequestDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gachtaxi.domain.members.dto.request; - - -import com.gachtaxi.domain.members.entity.enums.Gender; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -public class UserRequestDto { - - public record SignUpDto( - @NotBlank String email, - @NotBlank String nickName, - @NotBlank String realName, - @NotBlank Long studentNumber, - @NotBlank Gender gender, - @NotNull Boolean termsAgreement, - @NotNull Boolean privacyAgreement, - @NotNull Boolean marketingAgreement, - @NotNull Boolean twoFactorAuthentication, - Long kakaoId, - Long googleId - ){} -} diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java new file mode 100644 index 00000000..f9f79b2f --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java @@ -0,0 +1,20 @@ +package com.gachtaxi.domain.members.dto.request; + + +import com.gachtaxi.domain.members.entity.enums.Gender; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +public record UserSignUpRequestDto( + @NotBlank String email, + @NotBlank String nickName, + @NotBlank String realName, + @NotBlank Long studentNumber, + @NotBlank Gender gender, + @NotNull Boolean termsAgreement, + @NotNull Boolean privacyAgreement, + @NotNull Boolean marketingAgreement, + @NotNull Boolean twoFactorAuthentication, + Long kakaoId, + Long googleId +){} diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 6f93ec19..174e46e0 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -1,12 +1,11 @@ package com.gachtaxi.domain.members.entity; -import com.gachtaxi.domain.members.dto.request.UserRequestDto; +import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.*; import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -76,7 +75,7 @@ public class Members extends BaseEntity { * friend_info * */ - public static Members of(UserRequestDto.SignUpDto dto){ + public static Members of(UserSignUpRequestDto dto){ return Members.builder() //.profilePicture(dto.profilePicture()) .email(dto.email()) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index b94801dc..5de2958c 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; import com.gachtaxi.domain.members.repository.MemberRepository; @@ -11,9 +12,6 @@ import java.util.Optional; -import static com.gachtaxi.domain.members.dto.request.UserRequestDto.*; - - @Service @RequiredArgsConstructor public class MemberService { @@ -22,7 +20,7 @@ public class MemberService { private final MemberRepository memberRepository; @Transactional - public void saveMember(SignUpDto dto, HttpServletResponse response) { + public void saveMember(UserSignUpRequestDto dto, HttpServletResponse response) { checkDuplicatedStudentNumber(dto); Members newMember = Members.of(dto); memberRepository.save(newMember); @@ -37,7 +35,7 @@ public Optional findByKakaoId(Long kakaoId) { * refactor * */ - private void checkDuplicatedStudentNumber(SignUpDto dto) { + private void checkDuplicatedStudentNumber(UserSignUpRequestDto dto) { Long studentNumber = dto.studentNumber(); memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { throw new DuplicatedStudentNumberException(); From 62a32ce137200559d5ec6e7c5200a2d1d9f6e327 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 4 Jan 2025 13:51:51 +0900 Subject: [PATCH 090/770] =?UTF-8?q?refactor:=20=EB=8F=84=EC=BB=A4=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=ED=9B=84=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 0bb7e503..2fa75af5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -93,4 +93,8 @@ jobs: # 이전 컨테이너 중지 및 삭제 echo "** 이전 컨테이너(${BEFORE_NAME}) 종료 및 삭제" sudo docker stop $BEFORE_NAME || true - sudo docker rm $BEFORE_NAME || true \ No newline at end of file + sudo docker rm $BEFORE_NAME || true + + # 사용하지 않는 이미지 정리 + echo "** 사용하지 않는 Docker 이미지 정리" + sudo docker image prune -a -f \ No newline at end of file From 3101797048f11ebbd89b3baacf037915b0cdd557 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 4 Jan 2025 13:56:50 +0900 Subject: [PATCH 091/770] =?UTF-8?q?refactor:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=ED=9B=84=20deploy=20=EC=A1=B0=EA=B1=B4=EB=AC=B8=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 2fa75af5..16f686b1 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -50,6 +50,7 @@ jobs: deploy: runs-on: ubuntu-latest needs: build + if: github.event_name == 'push' steps: # SSH를 사용하여 원격 서버에 배포 From d6574062b578a35b5453f2f18d407cba60a31a4c Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 19:44:15 +0900 Subject: [PATCH 092/770] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/dto/request/ChatMessage.java | 4 ++-- .../gachtaxi/domain/chat/dto/request/ChatMessageRequest.java | 2 +- .../java/com/gachtaxi/domain/chat/entity/ChattingMessage.java | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index fd75a994..2023f71d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -8,7 +8,7 @@ public record ChatMessage( Long roomId, Long senderId, - String nickName, + String nickname, String message, LocalDateTime timeStamp ) { @@ -16,7 +16,7 @@ public static ChatMessage of(ChatMessageRequest request, long senderId, LocalDat return ChatMessage.builder() .roomId(request.roomId()) .senderId(senderId) - .nickName(request.nickName()) + .nickname(request.nickname()) .message(request.message()) .timeStamp(timeStamp) .build(); diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java index e9b76653..5815f763 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java @@ -2,7 +2,7 @@ public record ChatMessageRequest( Long roomId, - String nickName, + String nickname, String message ) { } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java index 48d3d0c6..d1c737bb 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java @@ -8,9 +8,7 @@ import java.time.LocalDateTime; @Getter -@Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor @Document(collection = "chatting_messages") public class ChattingMessage { @@ -19,7 +17,7 @@ public class ChattingMessage { private Long senderId; - private String nickName; + private String nickname; private Long roomId; From 9d88161760f04e311ea510d5e3aabc620b8e2577 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 19:44:28 +0900 Subject: [PATCH 093/770] =?UTF-8?q?refactor:=20BaseEntity=20=EC=83=81?= =?UTF-8?q?=EC=86=8D=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/entity/ChattingParticipant.java | 25 ++++++++++--------- .../domain/chat/entity/ChattingRoom.java | 17 ++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 23362734..13f4b62b 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -1,24 +1,25 @@ package com.gachtaxi.domain.chat.entity; -import jakarta.persistence.*; -import lombok.*; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; @Getter @Entity +@SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -public class ChattingParticipant { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "chatting_participant_id") - private Long id; +public class ChattingParticipant extends BaseEntity { @ManyToOne @JoinColumn(name = "chatting_room_id") private ChattingRoom chattingRoom; -// @ManyToOne -// @JoinColumn(name = "member_id") -// private Members members; + @ManyToOne + private Members members; } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java index 42d0f811..0458bd56 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java @@ -1,16 +1,15 @@ package com.gachtaxi.domain.chat.entity; -import jakarta.persistence.*; -import lombok.*; +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Entity; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; @Getter @Entity +@SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -public class ChattingRoom { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "chatting_room_id") - private Long id; +public class ChattingRoom extends BaseEntity { } From 6ef0ae0628271dd255135c2b86aa9813fe975fd5 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:10:12 +0900 Subject: [PATCH 094/770] =?UTF-8?q?refactor:=20=EC=A1=B0=EC=9D=B8=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/entity/ChattingParticipant.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 13f4b62b..f19e3cc9 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -21,5 +21,6 @@ public class ChattingParticipant extends BaseEntity { private ChattingRoom chattingRoom; @ManyToOne + @JoinColumn(name = "members_id") private Members members; } From c1f814c481985636677b63b4e27485cc68995a41 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:10:38 +0900 Subject: [PATCH 095/770] =?UTF-8?q?feat:=20STOMP=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EC=9D=B8=ED=84=B0=EC=85=89=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interceptor/CustomChannelInterceptor.java | 23 +++++++++++++++++++ .../global/config/WebSocketConfig.java | 13 ++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java new file mode 100644 index 00000000..a6a7c0d5 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java @@ -0,0 +1,23 @@ +package com.gachtaxi.domain.chat.interceptor; + +import com.gachtaxi.domain.chat.interceptor.strategy.ChatStrategyHandler; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; +import org.springframework.messaging.support.ChannelInterceptor; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +@RequiredArgsConstructor +public class CustomChannelInterceptor implements ChannelInterceptor { + private final ChatStrategyHandler chatStrategyHandler; + @Override + public Message preSend(Message message, MessageChannel channel) { + StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); + + return chatStrategyHandler.handle(message, accessor, channel); + } +} \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index 09f70d49..c3afafd1 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -1,6 +1,9 @@ package com.gachtaxi.global.config; +import com.gachtaxi.domain.chat.interceptor.CustomChannelInterceptor; +import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.simp.config.ChannelRegistration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.web.socket.config.annotation.EnableWebSocket; import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; @@ -10,13 +13,16 @@ @Configuration @EnableWebSocket @EnableWebSocketMessageBroker +@RequiredArgsConstructor public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { + private final CustomChannelInterceptor customChannelInterceptor; + @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3000"); + .setAllowedOriginPatterns("http://localhost:3001"); } @Override @@ -24,4 +30,9 @@ public void configureMessageBroker(MessageBrokerRegistry registry) { registry.enableSimpleBroker("/sub"); registry.setApplicationDestinationPrefixes("/pub"); } + + @Override + public void configureClientInboundChannel(ChannelRegistration registration) { + registration.interceptors(customChannelInterceptor); + } } From e17dc0a24baf20c1dd24e1af0a86a342ce93f73d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:14:01 +0900 Subject: [PATCH 096/770] =?UTF-8?q?feat:=20stomp=20=EC=BB=A4=EB=A7=A8?= =?UTF-8?q?=EB=93=9C=EB=B3=84=20=EC=A0=84=EB=9E=B5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../strategy/DefaultCommandStrategy.java | 23 ++++++++++ .../strategy/StompCommandStrategy.java | 13 ++++++ .../strategy/StompConnectStrategy.java | 45 +++++++++++++++++++ .../strategy/StompSubscribeStrategy.java | 31 +++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/DefaultCommandStrategy.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompCommandStrategy.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompSubscribeStrategy.java diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/DefaultCommandStrategy.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/DefaultCommandStrategy.java new file mode 100644 index 00000000..b221d98c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/DefaultCommandStrategy.java @@ -0,0 +1,23 @@ +package com.gachtaxi.domain.chat.interceptor.strategy; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +public class DefaultCommandStrategy implements StompCommandStrategy{ + + @Override + public boolean supports(StompCommand command) { + return false; + } + + @Override + public Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel) { + return message; + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompCommandStrategy.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompCommandStrategy.java new file mode 100644 index 00000000..bb0eb88e --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompCommandStrategy.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.chat.interceptor.strategy; + +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; + +public interface StompCommandStrategy { + + boolean supports(StompCommand command); + + Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel); +} diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java new file mode 100644 index 00000000..2f0e5cb2 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java @@ -0,0 +1,45 @@ +package com.gachtaxi.domain.chat.interceptor.strategy; + +import com.gachtaxi.global.auth.jwt.exception.TokenNotExistException; +import com.gachtaxi.global.auth.jwt.util.JwtExtractor; +import lombok.RequiredArgsConstructor; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; +import org.springframework.stereotype.Component; + +import static com.gachtaxi.global.auth.jwt.util.JwtProvider.ACCESS_TOKEN_SUBJECT; + +@Component +@RequiredArgsConstructor +public class StompConnectStrategy implements StompCommandStrategy{ + + private static final String TOKEN_PREFIX = "Bearer "; + private static final String USER_ID_KEY = "USER_ID"; + + private final JwtExtractor jwtExtractor; + + @Override + public boolean supports(StompCommand command) { + return StompCommand.CONNECT.equals(command); + } + + @Override + public Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel) { + String jwtToken = accessor.getFirstNativeHeader(ACCESS_TOKEN_SUBJECT); + + if(jwtToken == null || !jwtToken.startsWith(TOKEN_PREFIX)) { + throw new TokenNotExistException(); + } + + /* + todo 인증 객체 생성 후 설정하기 + */ + + Long userId = jwtExtractor.getId(jwtToken); + accessor.getSessionAttributes().put(USER_ID_KEY, userId); + + return message; + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompSubscribeStrategy.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompSubscribeStrategy.java new file mode 100644 index 00000000..b009d2dd --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompSubscribeStrategy.java @@ -0,0 +1,31 @@ +package com.gachtaxi.domain.chat.interceptor.strategy; + +import com.gachtaxi.domain.chat.exception.ChatSubscribeException; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; +import org.springframework.stereotype.Component; + +@Component +public class StompSubscribeStrategy implements StompCommandStrategy{ + + private static final String SUB_END_POINT = "/sub/chat/room/"; + + @Override + public boolean supports(StompCommand command) { + return StompCommand.SUBSCRIBE.equals(command); + } + + @Override + public Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel) { + String destination = accessor.getDestination(); + + if (!destination.startsWith(SUB_END_POINT)) { + throw new ChatSubscribeException(); + } + + return message; + } +} + From 79ffd31140521cf8865bfc45f8392b9a312393cd Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:15:52 +0900 Subject: [PATCH 097/770] =?UTF-8?q?feat:=20=EC=A0=84=EB=9E=B5=20=ED=95=B8?= =?UTF-8?q?=EB=93=A4=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../strategy/ChatStrategyHandler.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java new file mode 100644 index 00000000..f8ad71b9 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java @@ -0,0 +1,27 @@ +package com.gachtaxi.domain.chat.interceptor.strategy; + +import lombok.RequiredArgsConstructor; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +@RequiredArgsConstructor +public class ChatStrategyHandler { + + private final List stompCommandStrategies; + + public Message handle(Message message, StompHeaderAccessor accessor, MessageChannel channel) { + StompCommand command = accessor.getCommand(); + + return stompCommandStrategies.stream() + .filter(strategy -> strategy.supports(command)) + .findFirst() + .orElse(new DefaultCommandStrategy()) + .preSend(message, accessor, channel); + } +} From 1126ff200a49c7aa8b00fd680b96d484eed30c56 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:16:18 +0900 Subject: [PATCH 098/770] =?UTF-8?q?feat:=20=EA=B5=AC=EB=8F=85=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=EA=B0=80=20=EC=98=AC=EB=B0=94=EB=A5=B4=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EC=9D=84=20=EB=95=8C=20=EC=98=88=EC=99=B8=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/exception/ChatSubscribeException.java | 12 ++++++++++++ .../gachtaxi/domain/chat/exception/ErrorMessage.java | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/exception/ChatSubscribeException.java diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ChatSubscribeException.java b/src/main/java/com/gachtaxi/domain/chat/exception/ChatSubscribeException.java new file mode 100644 index 00000000..1c981f58 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ChatSubscribeException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.chat.exception.ErrorMessage.CHAT_SUBSCRIBE_ERROR; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class ChatSubscribeException extends BaseException { + public ChatSubscribeException() { + super(BAD_REQUEST, CHAT_SUBSCRIBE_ERROR.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java index 923884cb..86910efe 100644 --- a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java @@ -10,7 +10,7 @@ public enum ErrorMessage { SERIALIZATION_ERROR("[Redis] 데이터 직렬화에 실패했습니다"), MESSAGING_ERROR("STOMP 메시지 전송에 실패했습니다"), JSON_PROCESSING_ERROR("Json 직렬화에 실패했습니다."), - REDIS_SUB_ERROR("[Redis] 메시지 전송에 실패했습니다."); - + REDIS_SUB_ERROR("[Redis] 메시지 전송에 실패했습니다."), + CHAT_SUBSCRIBE_ERROR("올바르지 않은 채팅 구독 경로입니다."); private final String message; } From addd823bb041679954d3a00b1921fdc9fdb24625 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:16:31 +0900 Subject: [PATCH 099/770] =?UTF-8?q?feat:=20=ED=86=A0=ED=81=B0=EC=9D=B4=20?= =?UTF-8?q?=ED=97=A4=EB=8D=94=EC=97=90=20=EC=A1=B4=EC=9E=AC=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=84=20=EB=95=8C=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/exception/JwtErrorMessage.java | 3 ++- .../auth/jwt/exception/TokenNotExistException.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotExistException.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java index e25d79cf..36bb3bd4 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java @@ -7,7 +7,8 @@ @AllArgsConstructor public enum JwtErrorMessage { - JWT_TOKEN_UN_VALID("유효하지 않은 토큰 입니다."); + JWT_TOKEN_UN_VALID("유효하지 않은 토큰 입니다."), + JWT_TOKEN_NOT_EXIST("헤더에 인증 토큰이 존재하지 않습니다"); private final String message; } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotExistException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotExistException.java new file mode 100644 index 00000000..0957c5d6 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotExistException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_NOT_EXIST; +import static org.springframework.http.HttpStatus.UNAUTHORIZED; + +public class TokenNotExistException extends BaseException { + public TokenNotExistException () { + super(UNAUTHORIZED, JWT_TOKEN_NOT_EXIST.getMessage()); + } +} From 0cbfecf637f6125a9a4d22bf7d313cfb6ed4ab5f Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:16:43 +0900 Subject: [PATCH 100/770] =?UTF-8?q?refactor:=20=EC=83=81=EC=88=98=20?= =?UTF-8?q?=EC=A0=91=EA=B7=BC=20=EC=A0=9C=EC=96=B4=EC=9E=90=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java index 0948b7c5..2e59174f 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java @@ -13,7 +13,7 @@ @Component public class JwtProvider { - private static final String ACCESS_TOKEN_SUBJECT = "Authorization"; + public static final String ACCESS_TOKEN_SUBJECT = "Authorization"; private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; private static final String ID_CLAIM = "id"; private static final String EMAIL_CLAIM = "email"; From 3c00d6d681a461cd651f7526029f9c62a0098c20 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:19:24 +0900 Subject: [PATCH 101/770] =?UTF-8?q?refactor:=20=EC=9B=B9=EC=86=8C=EC=BC=93?= =?UTF-8?q?=20cors=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index c3afafd1..1829b59a 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -22,7 +22,7 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { public void registerStompEndpoints(StompEndpointRegistry registry) { registry .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3001"); + .setAllowedOriginPatterns("http://localhost:3000"); } @Override From 792a41b2bd90a9c3d82654141fba19cafc3f43d5 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:24:51 +0900 Subject: [PATCH 102/770] =?UTF-8?q?refactor:=20=EA=B0=9C=ED=96=89=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/interceptor/CustomChannelInterceptor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java index a6a7c0d5..22fb2356 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java @@ -14,10 +14,11 @@ @RequiredArgsConstructor public class CustomChannelInterceptor implements ChannelInterceptor { private final ChatStrategyHandler chatStrategyHandler; + @Override public Message preSend(Message message, MessageChannel channel) { StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); return chatStrategyHandler.handle(message, accessor, channel); } -} \ No newline at end of file +} From 198616012a15abfc78aeb30cfc55103049d81283 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:25:02 +0900 Subject: [PATCH 103/770] =?UTF-8?q?Revert=20"refactor:=20=EA=B0=9C?= =?UTF-8?q?=ED=96=89=20=EC=B6=94=EA=B0=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 792a41b2bd90a9c3d82654141fba19cafc3f43d5. --- .../domain/chat/interceptor/CustomChannelInterceptor.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java index 22fb2356..a6a7c0d5 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java @@ -14,11 +14,10 @@ @RequiredArgsConstructor public class CustomChannelInterceptor implements ChannelInterceptor { private final ChatStrategyHandler chatStrategyHandler; - @Override public Message preSend(Message message, MessageChannel channel) { StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); return chatStrategyHandler.handle(message, accessor, channel); } -} +} \ No newline at end of file From 7a80806931f3f75498fc3b135a651663ffc5f72e Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 5 Jan 2025 22:25:15 +0900 Subject: [PATCH 104/770] =?UTF-8?q?refactor:=20=EA=B0=9C=ED=96=89=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EB=A1=9C=EA=B1=B0=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/interceptor/CustomChannelInterceptor.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java index a6a7c0d5..b0be4fa9 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java @@ -2,22 +2,21 @@ import com.gachtaxi.domain.chat.interceptor.strategy.ChatStrategyHandler; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.simp.stomp.StompHeaderAccessor; import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.stereotype.Component; -@Slf4j @Component @RequiredArgsConstructor public class CustomChannelInterceptor implements ChannelInterceptor { private final ChatStrategyHandler chatStrategyHandler; + @Override public Message preSend(Message message, MessageChannel channel) { StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); return chatStrategyHandler.handle(message, accessor, channel); } -} \ No newline at end of file +} From 0e2c1e5be36395bff13b61f79cb67e70d5f67372 Mon Sep 17 00:00:00 2001 From: senna Date: Sun, 5 Jan 2025 23:58:07 +0900 Subject: [PATCH 105/770] =?UTF-8?q?chore:=20spring=20kafka=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle b/build.gradle index 88d352c6..1f078db9 100644 --- a/build.gradle +++ b/build.gradle @@ -49,6 +49,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-redis' runtimeOnly 'com.mysql:mysql-connector-j' + // Kafka + implementation 'org.springframework.kafka:spring-kafka' + // Test testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' From bf23d5ebf08eddc9636f3db0f31f6dd93ebff56b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 02:25:15 +0900 Subject: [PATCH 106/770] feat: Spring Security Dependency --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 88d352c6..5b9f408f 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ dependencies { // Spring implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' -// implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-websocket' developmentOnly 'org.springframework.boot:spring-boot-devtools' implementation 'org.springframework.boot:spring-boot-starter-validation' From 566f85a51095a91bed4e51d22f086f6855c06df2 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 6 Jan 2025 13:28:30 +0900 Subject: [PATCH 107/770] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/dto/request/ChatMessage.java | 4 ++-- .../gachtaxi/domain/chat/dto/request/ChatMessageRequest.java | 2 +- .../java/com/gachtaxi/domain/chat/entity/ChattingMessage.java | 2 +- src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index 2023f71d..08a9dc6f 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -8,7 +8,7 @@ public record ChatMessage( Long roomId, Long senderId, - String nickname, + String senderName, String message, LocalDateTime timeStamp ) { @@ -16,7 +16,7 @@ public static ChatMessage of(ChatMessageRequest request, long senderId, LocalDat return ChatMessage.builder() .roomId(request.roomId()) .senderId(senderId) - .nickname(request.nickname()) + .senderName(request.senderName()) .message(request.message()) .timeStamp(timeStamp) .build(); diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java index 5815f763..18743b72 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java @@ -2,7 +2,7 @@ public record ChatMessageRequest( Long roomId, - String nickname, + String senderName, String message ) { } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java index d1c737bb..774292e9 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java @@ -17,7 +17,7 @@ public class ChattingMessage { private Long senderId; - private String nickname; + private String senderName; private Long roomId; diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index 1829b59a..c3afafd1 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -22,7 +22,7 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { public void registerStompEndpoints(StompEndpointRegistry registry) { registry .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3000"); + .setAllowedOriginPatterns("http://localhost:3001"); } @Override From 5101c463464a710d679088713eec964a2bb59623 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 16:19:30 +0900 Subject: [PATCH 108/770] feat: CustomJwtException --- .../global/auth/jwt/exception/JwtErrorMessage.java | 6 +++++- .../auth/jwt/exception/TokenExpiredException.java | 12 ++++++++++++ .../auth/jwt/exception/TokenInvalidException.java | 7 ++++--- .../auth/jwt/exception/TokenNotFoundException.java | 13 +++++++++++++ .../jwt/exception/UserEmailNotFoundException.java | 12 ++++++++++++ 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotFoundException.java create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/UserEmailNotFoundException.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java index e25d79cf..1d696802 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java @@ -7,7 +7,11 @@ @AllArgsConstructor public enum JwtErrorMessage { - JWT_TOKEN_UN_VALID("유효하지 않은 토큰 입니다."); + JWT_TOKEN_FORBIDDEN("권한이 없습니다."), + USER_NOT_FOUND_EMAIL("해당 이메일의 유저를 찾을 수 없습니다"), + JWT_TOKEN_NOT_FOUND("토큰을 찾을 수 없습니다"), + JWT_TOKEN_EXPIRED("만료된 토큰입니다."), + JWT_TOKEN_INVALID("유효하지 않은 토큰 입니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java new file mode 100644 index 00000000..b42ee585 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_EXPIRED; + +public class TokenExpiredException extends BaseException { + public TokenExpiredException() { + super(HttpStatus.UNAUTHORIZED, JWT_TOKEN_EXPIRED.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java index ce697d26..551f9905 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java @@ -1,11 +1,12 @@ package com.gachtaxi.global.auth.jwt.exception; import com.gachtaxi.global.common.exception.BaseException; -import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_UN_VALID; -import static org.springframework.http.HttpStatus.BAD_REQUEST; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_INVALID; public class TokenInvalidException extends BaseException { public TokenInvalidException() { - super(BAD_REQUEST, JWT_TOKEN_UN_VALID.getMessage()); + super(HttpStatus.UNAUTHORIZED, JWT_TOKEN_INVALID.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotFoundException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotFoundException.java new file mode 100644 index 00000000..7e6464d0 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotFoundException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_NOT_FOUND; + +public class TokenNotFoundException extends BaseException { + + public TokenNotFoundException() { + super(HttpStatus.UNAUTHORIZED, JWT_TOKEN_NOT_FOUND.getMessage()); + } +} \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/UserEmailNotFoundException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/UserEmailNotFoundException.java new file mode 100644 index 00000000..57b20f4f --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/UserEmailNotFoundException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.USER_NOT_FOUND_EMAIL; + +public class UserEmailNotFoundException extends BaseException { + public UserEmailNotFoundException() { + super(HttpStatus.UNAUTHORIZED, USER_NOT_FOUND_EMAIL.getMessage()); + } +} From e45674418e80bd2b93272b492b534305756dc24c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:01:11 +0900 Subject: [PATCH 109/770] =?UTF-8?q?feat:=20CustomAuthenticationEntryPoint?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomAuthenticationEntryPoint.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/authentication/CustomAuthenticationEntryPoint.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/authentication/CustomAuthenticationEntryPoint.java b/src/main/java/com/gachtaxi/global/auth/jwt/authentication/CustomAuthenticationEntryPoint.java new file mode 100644 index 00000000..92218e51 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/authentication/CustomAuthenticationEntryPoint.java @@ -0,0 +1,47 @@ +package com.gachtaxi.global.auth.jwt.authentication; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage; +import com.gachtaxi.global.common.response.ApiResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +@Slf4j +@Component +public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { + + private final static String LOG_FORMAT = "ExceptionClass: {}, Message: {}"; + private final static String JWT_ERROR = "jwtError"; + private final static String CONTENT_TYPE = "application/json"; + private final static String CHAR_ENCODING = "UTF-8"; + + @Override + public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { + JwtErrorMessage jwtError = (JwtErrorMessage) request.getAttribute(JWT_ERROR); + + if (jwtError != null) { + setResponse(response, jwtError.getMessage()); + log.error(LOG_FORMAT, jwtError, jwtError.getMessage()); + } else { + setResponse(response, authException.getMessage()); + log.error(LOG_FORMAT, authException.getClass().getSimpleName(), authException.getMessage()); + } + } + + private void setResponse(HttpServletResponse response, String message) throws IOException { + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + response.setContentType(CONTENT_TYPE); + response.setCharacterEncoding(CHAR_ENCODING); + + String body = new ObjectMapper().writeValueAsString(ApiResponse.response(HttpStatus.UNAUTHORIZED, message)); + response.getWriter().write(body); + } +} \ No newline at end of file From 1faf269dff699dda2443fc26b96e832cbe04d949 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:01:20 +0900 Subject: [PATCH 110/770] =?UTF-8?q?feat:=20CustomAccessDeniedHandler=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomAccessDeniedHandler.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/authentication/CustomAccessDeniedHandler.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/authentication/CustomAccessDeniedHandler.java b/src/main/java/com/gachtaxi/global/auth/jwt/authentication/CustomAccessDeniedHandler.java new file mode 100644 index 00000000..88fe671a --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/authentication/CustomAccessDeniedHandler.java @@ -0,0 +1,39 @@ +package com.gachtaxi.global.auth.jwt.authentication; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gachtaxi.global.common.response.ApiResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.security.web.access.AccessDeniedHandler; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_FORBIDDEN; + +@Slf4j +@Component +public class CustomAccessDeniedHandler implements AccessDeniedHandler { + + private final static String LOG_FORMAT = "ExceptionClass: {}, Message: {}"; + private final static String CONTENT_TYPE = "application/json"; + private final static String CHAR_ENCODING = "UTF-8"; + + @Override + public void handle(HttpServletRequest request, HttpServletResponse response, org.springframework.security.access.AccessDeniedException accessDeniedException) throws IOException, ServletException { + setResponse(response); + log.error(LOG_FORMAT, accessDeniedException.getClass().getSimpleName(), accessDeniedException.getMessage()); + } + + private void setResponse(HttpServletResponse response) throws IOException { + response.setStatus(HttpServletResponse.SC_FORBIDDEN); + response.setContentType(CONTENT_TYPE); + response.setCharacterEncoding(CHAR_ENCODING); + + String body = new ObjectMapper().writeValueAsString(ApiResponse.response(HttpStatus.FORBIDDEN, JWT_TOKEN_FORBIDDEN.getMessage())); + response.getWriter().write(body); + } +} From 23dc33b1feb28bcd40ef1c397d95f8318eccc84e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:02:32 +0900 Subject: [PATCH 111/770] =?UTF-8?q?feat:=20JwtAuthenticationFilter=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?(=EB=AF=B8=EC=99=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jwt/filter/JwtAuthenticationFilter.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java new file mode 100644 index 00000000..0356d28f --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -0,0 +1,46 @@ +package com.gachtaxi.global.auth.jwt.filter; + +import com.gachtaxi.global.auth.jwt.user.JwtUserDetailsService; +import com.gachtaxi.global.auth.jwt.util.JwtExtractor; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.web.filter.OncePerRequestFilter; + +import java.io.IOException; +import java.util.Optional; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.*; + +@Slf4j +@RequiredArgsConstructor +public class JwtAuthenticationFilter extends OncePerRequestFilter { + + private final JwtExtractor jwtExtractor; + + private final static String JWT_ERROR = "jwtError"; + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + Optional token = jwtExtractor.extractJwtToken(request); + if (token.isEmpty()) { + request.setAttribute(JWT_ERROR, JWT_TOKEN_NOT_FOUND); + filterChain.doFilter(request, response); + return; + } + String accessToken = token.get(); + + if (jwtExtractor.isExpired(accessToken)) { + request.setAttribute(JWT_ERROR, JWT_TOKEN_EXPIRED); + filterChain.doFilter(request, response); + return; + } + } +} From afb8b27cd2c91fa4e37de5f6224187d485d597c0 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:05:40 +0900 Subject: [PATCH 112/770] =?UTF-8?q?feat:=20JwtUserDetails=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/user/JwtUserDetails.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java new file mode 100644 index 00000000..ca55d941 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java @@ -0,0 +1,29 @@ +package com.gachtaxi.global.auth.jwt.user; + +import com.gachtaxi.domain.members.entity.Members; +import lombok.Getter; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.User; + +import java.util.Collections; +import java.util.List; + +@Getter +public class JwtUserDetails extends User { + + private final Members member; + private final Long id; + private final String email; + + public JwtUserDetails(Members member, Long id, String email, List authorities) { + super(email, "", authorities); + this.member = member; + this.id = id; + this.email = email; + } + + public static JwtUserDetails of(Members member) { + return new JwtUserDetails(member, member.getId(), member.getEmail(), Collections.singletonList(new SimpleGrantedAuthority(member.getRole().toString()))); + } +} \ No newline at end of file From 4e7f5e2cbaee8e15ff3e68db98b70f2f31510590 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:05:56 +0900 Subject: [PATCH 113/770] =?UTF-8?q?feat:=20JwtUserDetailsService=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/jwt/user/JwtUserDetailsService.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetailsService.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetailsService.java b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetailsService.java new file mode 100644 index 00000000..5ee3fb6f --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetailsService.java @@ -0,0 +1,25 @@ +package com.gachtaxi.global.auth.jwt.user; + +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.repository.MemberRepository; +import com.gachtaxi.global.auth.jwt.exception.UserEmailNotFoundException; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class JwtUserDetailsService implements UserDetailsService { + + private final MemberRepository memberRepository; + + @Override + public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { + Members member = memberRepository.findByEmail(email) + .orElseThrow(UserEmailNotFoundException::new); + + return JwtUserDetails.of(member); + } +} From b54c418ebe8eba6379d02b8519935a32691f1467 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:06:40 +0900 Subject: [PATCH 114/770] =?UTF-8?q?feat:=20JwtAuthenticationFilter=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EA=B0=9D=EC=B2=B4=20=EC=84=B8=EC=85=98=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=EA=B3=BC=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/jwt/filter/JwtAuthenticationFilter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index 0356d28f..7d6ddf99 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -24,6 +24,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { private final JwtExtractor jwtExtractor; + private final JwtUserDetailsService jwtUserDetailsService; private final static String JWT_ERROR = "jwtError"; @@ -37,10 +38,21 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse } String accessToken = token.get(); - if (jwtExtractor.isExpired(accessToken)) { + if(jwtExtractor.isExpired(accessToken)){ request.setAttribute(JWT_ERROR, JWT_TOKEN_EXPIRED); filterChain.doFilter(request, response); return; } + + saveAuthentcation(accessToken); + filterChain.doFilter(request, response); + } + + private void saveAuthentcation(String token) { + String email = jwtExtractor.getEmail(token); + + UserDetails userDetails = jwtUserDetailsService.loadUserByUsername(email); + Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); + SecurityContextHolder.getContext().setAuthentication(authentication); } } From 6fd82fce0544d73951396bda81389e85af051e22 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:07:06 +0900 Subject: [PATCH 115/770] =?UTF-8?q?feat:=20JwtExtractor=20-=20extractJwtTo?= =?UTF-8?q?ken()=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/auth/jwt/util/JwtExtractor.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java index 108b80e0..6b4c52ca 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java @@ -6,16 +6,20 @@ import io.jsonwebtoken.JwtParser; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.security.Keys; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.security.Key; import java.util.Date; +import java.util.Optional; // 토큰 추출 및 검증 @Component public class JwtExtractor { + private static final String ACCESS_TOKEN_SUBJECT = "Authorization"; + private static final String BEARER = "Bearer"; private static final String ID_CLAIM = "id"; private static final String EMAIL_CLAIM = "email"; private static final String ROLE_CLAIM = "role"; @@ -26,6 +30,12 @@ public JwtExtractor(@Value("${gachtaxi.auth.jwt.key}") String secretKey) { this.key = Keys.hmacShaKeyFor(secretKey.getBytes()); // 키 변환 } + public Optional extractJwtToken(HttpServletRequest request) { + return Optional.ofNullable(request.getHeader(ACCESS_TOKEN_SUBJECT)) + .filter(refreshToken -> refreshToken.startsWith(BEARER)) + .map(refreshToken -> refreshToken.replace(BEARER, "")); + } + public Long getId(String token){ return getIdFromToken(token, ID_CLAIM); } @@ -63,5 +73,4 @@ private Claims parseClaims(String token) { throw new TokenInvalidException(); } } - } From 0bb72a3a1b1bc5f156e3c3145e89c86e36bbd275 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:07:34 +0900 Subject: [PATCH 116/770] =?UTF-8?q?feat:=20MemberRepository=20-=20findByEm?= =?UTF-8?q?ail()=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/repository/MemberRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 664eb3b3..2ac1fa52 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -9,6 +9,8 @@ @Repository public interface MemberRepository extends JpaRepository { + Optional findByEmail(String email); + Optional findByStudentNumber(Long studentNumber); Optional findByKakaoId(Long kakaoId); From 5f1469d1924ddcd2ae59ce89d8a03bc1f2c151fb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:08:57 +0900 Subject: [PATCH 117/770] =?UTF-8?q?feat:=20SecurityConfig=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/config/PermitUrlConfig.java | 34 ++++++++ .../global/config/SecurityConfig.java | 82 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java create mode 100644 src/main/java/com/gachtaxi/global/config/SecurityConfig.java diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java new file mode 100644 index 00000000..5b4f2715 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -0,0 +1,34 @@ +package com.gachtaxi.global.config; + +import org.springframework.stereotype.Component; + +@Component +public class PermitUrlConfig { + + public String[] getPublicUrl(){ + String[] publicUrls = { + "/auth/login/kakao", + "/login", + "/uri/test", + "/swagger-ui/**", + "/v3/api-docs/**" + }; + return publicUrls; + } + + public String[] getMemberUrl(){ + String[] memberUrls = { + + }; + return memberUrls; + } + + public String[] getAdminUrl(){ + String[] adminUrls = { + + }; + return adminUrls; + } + + +} diff --git a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java new file mode 100644 index 00000000..34e7a312 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java @@ -0,0 +1,82 @@ +package com.gachtaxi.global.config; + + +import com.gachtaxi.domain.members.entity.enums.Role; +import com.gachtaxi.global.auth.jwt.authentication.CustomAccessDeniedHandler; +import com.gachtaxi.global.auth.jwt.authentication.CustomAuthenticationEntryPoint; +import com.gachtaxi.global.auth.jwt.filter.JwtAuthenticationFilter; +import com.gachtaxi.global.auth.jwt.user.JwtUserDetailsService; +import com.gachtaxi.global.auth.jwt.util.JwtExtractor; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.CorsConfigurationSource; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; + +import java.util.Arrays; + +@Configuration +@EnableWebSecurity +@RequiredArgsConstructor +@EnableMethodSecurity(prePostEnabled = true) +public class SecurityConfig { + + private final PermitUrlConfig permitUrlConfig; + private final CustomAuthenticationEntryPoint customAuthenticationEntryPoint; + private final CustomAccessDeniedHandler customAccessDeniedHandler; + private final JwtExtractor jwtExtractor; + private final JwtUserDetailsService jwtUserDetailsService; + + @Bean + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + http + .formLogin(AbstractHttpConfigurer::disable) + .httpBasic(AbstractHttpConfigurer::disable) + .cors(cors -> cors.configurationSource(corsConfigurationSource())) + .csrf(AbstractHttpConfigurer::disable) + .sessionManagement(AbstractHttpConfigurer::disable); + + http.authorizeHttpRequests((auth) -> auth + .requestMatchers(permitUrlConfig.getPublicUrl()).permitAll() + .requestMatchers(permitUrlConfig.getMemberUrl()).hasRole(Role.MEMBER.name()) + .requestMatchers(permitUrlConfig.getAdminUrl()).hasRole(Role.ADMIN.name()) + .anyRequest().authenticated()); + + http.exceptionHandling(e -> e + .authenticationEntryPoint(customAuthenticationEntryPoint) + .accessDeniedHandler(customAccessDeniedHandler)); + http.addFilterBefore(new JwtAuthenticationFilter(jwtExtractor, jwtUserDetailsService), UsernamePasswordAuthenticationFilter.class); + + return http.build(); + } + + @Bean + public AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception { + return configuration.getAuthenticationManager(); + } + + @Bean + public CorsConfigurationSource corsConfigurationSource() { + CorsConfiguration configuration = new CorsConfiguration(); + configuration.setAllowedOriginPatterns(Arrays.asList("http://localhost:3000")); + configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PATCH", "DELETE", "OPTIONS")); + configuration.setAllowedHeaders(Arrays.asList("*")); + configuration.setExposedHeaders(Arrays.asList("Authorization")); + configuration.setAllowCredentials(true); + + // /** 들어오는 모든 유형의 URL 패턴을 허용. + UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); + urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", configuration); + return urlBasedCorsConfigurationSource; + } + +} From 9eaddf7f581b6dd7ffc31d346819c363b18b1970 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:09:58 +0900 Subject: [PATCH 118/770] feat: CustomAnnotaion -CurrentMemberId --- .../auth/jwt/annotation/CurrentMemberId.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMemberId.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMemberId.java b/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMemberId.java new file mode 100644 index 00000000..43f4330e --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMemberId.java @@ -0,0 +1,19 @@ +package com.gachtaxi.global.auth.jwt.annotation; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : id") +public @interface CurrentMemberId { + /* + * AuthenticationPrincipal의 id 필드를 반환 + * 즉, JwtUserDetails의 id 필드를 반환 + * JwtUserDetails의 id는 Userid + * */ +} From 1511b6292402ff95025066be58b27251c5d75f20 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 17:10:15 +0900 Subject: [PATCH 119/770] feat: CustomAnnotaion -CurrentMember --- .../auth/jwt/annotation/CurrentMember.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMember.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMember.java b/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMember.java new file mode 100644 index 00000000..043d1669 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMember.java @@ -0,0 +1,18 @@ +package com.gachtaxi.global.auth.jwt.annotation; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") +public @interface CurrentMember { + /* + * AuthenticationPrincipal의 member 필드를 반환 + * 즉, JwtUserDetilas의 member 필드를 반환 + * */ +} From 089b940da62454377cbd7910291adf4460a8f8cf Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 18:03:53 +0900 Subject: [PATCH 120/770] =?UTF-8?q?remove:=20=EC=9D=BC=EB=B6=80=20CustomJw?= =?UTF-8?q?tException=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/jwt/exception/TokenExpiredException.java | 12 ------------ .../auth/jwt/exception/TokenNotFoundException.java | 13 ------------- 2 files changed, 25 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java delete mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotFoundException.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java deleted file mode 100644 index b42ee585..00000000 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.gachtaxi.global.auth.jwt.exception; - -import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; - -import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_EXPIRED; - -public class TokenExpiredException extends BaseException { - public TokenExpiredException() { - super(HttpStatus.UNAUTHORIZED, JWT_TOKEN_EXPIRED.getMessage()); - } -} diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotFoundException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotFoundException.java deleted file mode 100644 index 7e6464d0..00000000 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenNotFoundException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gachtaxi.global.auth.jwt.exception; - -import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; - -import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_NOT_FOUND; - -public class TokenNotFoundException extends BaseException { - - public TokenNotFoundException() { - super(HttpStatus.UNAUTHORIZED, JWT_TOKEN_NOT_FOUND.getMessage()); - } -} \ No newline at end of file From 8f631dbe27f9e2a49aaa3786bee4308f42b2b909 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:02:11 +0900 Subject: [PATCH 121/770] =?UTF-8?q?feat:=20=ED=86=A0=ED=81=B0=20=EC=9E=AC?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20=EC=84=B1=EA=B3=B5=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/controller/ResponseMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 04dd4772..5f550565 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -10,6 +10,7 @@ public enum ResponseMessage { REGISTER_SUCCESS("회원가입에 성공했습니다."), // AuthController + REFRESH_TOKEN_REISSUE("토큰 재발급에 성공했습니다."), LOGIN_SUCCESS("로그인 성공에 성공했습니다."), UN_REGISTER("회원가입을 진행해주세요"); From 80e23828bc07ef7aba801f8d6f448e890eebe980 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:02:46 +0900 Subject: [PATCH 122/770] =?UTF-8?q?feat:=20redisUtil.get()=20Null=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java index e5c3aaca..740ab572 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java @@ -1,5 +1,6 @@ package com.gachtaxi.global.auth.jwt.util; +import com.gachtaxi.global.auth.jwt.exception.RefreshTokenNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; @@ -23,7 +24,11 @@ public void set(Long key, String value) { } public Object get(Long key){ - return redisTemplate.opsForValue().get(PREFIX +key); + Object getObjecet = redisTemplate.opsForValue().get(PREFIX +key); + if(getObjecet == null){ + throw new RefreshTokenNotFoundException(); + } + return getObjecet; } public boolean hasKey(Long key){ From 23baab20da137730261b0a7d85380fea7c97a14f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:06:57 +0900 Subject: [PATCH 123/770] =?UTF-8?q?feat:=20JwtService=20request=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=BF=A0=ED=82=A4=20=EC=B6=94=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/service/JwtService.java | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 03c7fcdc..71d48564 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -2,15 +2,21 @@ import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; +import com.gachtaxi.global.auth.jwt.exception.CookieNotFoundException; +import com.gachtaxi.global.auth.jwt.exception.TokenInvalidException; import com.gachtaxi.global.auth.jwt.util.CookieUtil; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; import com.gachtaxi.global.auth.jwt.util.JwtProvider; import com.gachtaxi.global.auth.jwt.util.JwtRedisUtil; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.Arrays; + + @Service @RequiredArgsConstructor public class JwtService { @@ -24,25 +30,44 @@ public class JwtService { private final JwtExtractor jwtExtractor; public void responseJwtToken(Long userId, String email, Role role, HttpServletResponse response) { - JwtTokenDto jwtToken = generateJwtToken(userId, email, role); + JwtTokenDto jwtToken = generateJwtToken(userId, email, role.name()); setHeader(jwtToken.accessToken(), response); setCookie(jwtToken.refreshToken(), response); } + + /* + * refactoring + * */ + + private String extractRefreshToken(HttpServletRequest request){ + Cookie[] cookies = request.getCookies(); + + if (cookies == null) { + throw new CookieNotFoundException(); + } + + return Arrays.stream(cookies) + .filter(cookie -> REFRESH_TOKEN_SUBJECT.equals(cookie.getName())) + .findFirst() + .map(Cookie::getValue) + .orElseThrow(TokenInvalidException::new); + } + // JwtToken 생성 + Redis 저장 - private JwtTokenDto generateJwtToken(Long userId, String email, Role role) { + private JwtTokenDto generateJwtToken(Long userId, String email, String role) { String accessToken = jwtProvider.generateAccessToken(userId, email, role); - String refreshToken = jwtProvider.generateRefreshToken(userId); + String refreshToken = jwtProvider.generateRefreshToken(userId, email, role); redisUtil.set(userId, refreshToken); return JwtTokenDto.of(accessToken, refreshToken); } - private void setHeader(String accessToken, HttpServletResponse response) { + public void setHeader(String accessToken, HttpServletResponse response) { response.setHeader(ACCESS_TOKEN_SUBJECT, accessToken); } - private void setCookie(String refreshToken, HttpServletResponse response) { + public void setCookie(String refreshToken, HttpServletResponse response) { cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, refreshToken, response); } } From e3cf22ce18eeae36f9c8386bb8734c5253f5dd43 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:07:40 +0900 Subject: [PATCH 124/770] =?UTF-8?q?fix:=20=ED=86=A0=ED=81=B0=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=9D=B8=EC=9E=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/util/JwtProvider.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java index 0948b7c5..30bfc806 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java @@ -1,7 +1,7 @@ package com.gachtaxi.global.auth.jwt.util; -import com.gachtaxi.domain.members.entity.enums.Role; -import io.jsonwebtoken.*; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; import io.jsonwebtoken.security.Keys; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -30,7 +30,7 @@ public JwtProvider(@Value("${gachtaxi.auth.jwt.key}") String secretKey) { @Value("${gachtaxi.auth.jwt.refreshTokenExpiration}") private Long refreshTokenExpiration; - public String generateAccessToken(Long id, String email, Role role) { + public String generateAccessToken(Long id, String email, String role) { return Jwts.builder() .claim(ID_CLAIM, id) .claim(EMAIL_CLAIM, email) @@ -42,9 +42,11 @@ public String generateAccessToken(Long id, String email, Role role) { .compact(); // 최종 문자열 생성 } - public String generateRefreshToken(Long id) { + public String generateRefreshToken(Long id, String email, String role) { return Jwts.builder() .claim(ID_CLAIM, id) + .claim(EMAIL_CLAIM, email) + .claim(ROLE_CLAIM, role) .setSubject(REFRESH_TOKEN_SUBJECT) // 사용자 정보(고유 식별자) .setIssuedAt(new Date()) // 발행 시간 .setExpiration(new Date(System.currentTimeMillis() + refreshTokenExpiration)) // 만료 시간 From 9171f96178e71eea676020ec85c83f4f67e6fe77 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:08:03 +0900 Subject: [PATCH 125/770] =?UTF-8?q?fix:=20=EC=9E=AC=EB=B0=9C=EA=B8=89=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=97=90=EB=9F=AC=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java index 1d696802..8cb03546 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java @@ -6,6 +6,8 @@ @Getter @AllArgsConstructor public enum JwtErrorMessage { + COOKIE_NOT_FOUND("헤더에 쿠키가 없습니다."), + REDIS_NOT_FOUND("Redis 에서 찾을 수 없습니다."), JWT_TOKEN_FORBIDDEN("권한이 없습니다."), USER_NOT_FOUND_EMAIL("해당 이메일의 유저를 찾을 수 없습니다"), From c25c25626eba9d5ae0a7fe2791c54f4d6aa0cc1b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:08:34 +0900 Subject: [PATCH 126/770] =?UTF-8?q?fix:=20JwtService=20-=20=ED=86=A0?= =?UTF-8?q?=ED=81=B0=20=EC=9E=AC=EB=B0=9C=EA=B8=89=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/service/JwtService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 71d48564..e75bf85e 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -35,6 +35,19 @@ public void responseJwtToken(Long userId, String email, Role role, HttpServletRe setCookie(jwtToken.refreshToken(), response); } + public JwtTokenDto reissueJwtToken(HttpServletRequest request) { + String refreshToken = extractRefreshToken(request); + Long userId = jwtExtractor.getId(refreshToken); + + String redisToken = (String) redisUtil.get(userId); + if(!redisToken.equals(refreshToken)) { + throw new TokenInvalidException(); + } + + String email = jwtExtractor.getEmail(refreshToken); + String role = jwtExtractor.getRole(refreshToken); + return generateJwtToken(userId, email, role); + } /* * refactoring From 43fa66b888e65b0ae4698bbec74879b8db17039b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:09:37 +0900 Subject: [PATCH 127/770] =?UTF-8?q?fix:=20JwtService=20-=20=ED=86=A0?= =?UTF-8?q?=ED=81=B0=20=EC=9E=AC=EB=B0=9C=EA=B8=89=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AuthController.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index d3507fba..c4c2fe21 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -2,14 +2,17 @@ import com.gachtaxi.domain.members.service.AuthService; import com.gachtaxi.global.auth.enums.OauthLoginStatus; +import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; +import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.common.response.ApiResponse; +import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.members.controller.ResponseMessage.*; -import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; +import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.OauthKakaoResponse; @RequestMapping("/auth") @RestController @@ -17,6 +20,7 @@ public class AuthController { private final AuthService authService; + private final JwtService jwtService; @GetMapping("/login/kakao") public ApiResponse kakaoLogin(@RequestParam("code") String authcode, HttpServletResponse response) { @@ -26,4 +30,13 @@ public ApiResponse kakaoLogin(@RequestParam("code") String a : UN_REGISTER; return ApiResponse.response(HttpStatus.OK, OAUTH_STATUS.getMessage(), res); } + + @PostMapping("/refresh") + public ApiResponse reissueRefreshToken(HttpServletRequest request, HttpServletResponse response) { + JwtTokenDto jwtTokenDto = jwtService.reissueJwtToken(request); + + jwtService.setCookie(jwtTokenDto.refreshToken(), response); + jwtService.setHeader(jwtTokenDto.accessToken(), response); + return ApiResponse.response(HttpStatus.OK, REFRESH_TOKEN_REISSUE.getMessage()); + } } From e9a9bd6a82764a97ebd5fd28925c370779d8d89c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:17:21 +0900 Subject: [PATCH 128/770] =?UTF-8?q?chore:=20application-dev.yml=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index a264e0fb..6e51ab5c 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -22,4 +22,18 @@ spring: logging: level: org.springframework.messaging: debug - org.springframework.web.socket: debug \ No newline at end of file + org.springframework.web.socket: debug + +gachtaxi: + auth: + kakao: + client: ${KAKAO_CLIENT_API_KEY} + redirect: ${KAKAO_REDIRECT_URL} + token_uri: ${KAKAO_TOKEN_URI} + user_profile: ${KAKAO_USER_PROFILE} + jwt: + key: ${JWT_SECRET_KEY} + accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} + refreshTokenExpiration: ${JWT_REFRESH_TOKEN_EXPIRATION} + cookieMaxAge: ${JWT_COOKIE_MAX_AGE} + secureOption: ${COOKIE_SECURE_OPTION} From 4870d6e3ac511310bc56e1f119c6ffc74ac8eda0 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:20:00 +0900 Subject: [PATCH 129/770] =?UTF-8?q?fix:=20application-local.yml=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-local.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index f29206e2..c30e75ab 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -36,4 +36,5 @@ gachtaxi: accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} refreshTokenExpiration: ${JWT_REFRESH_TOKEN_EXPIRATION} cookieMaxAge: ${JWT_COOKIE_MAX_AGE} - secureOption: ${COOKIE_SECURE_OPTION} \ No newline at end of file + secureOption: ${COOKIE_SECURE_OPTION} + cookiePathOption: ${COOKIE_PATH_OPTION} \ No newline at end of file From 9d043c746aea13ef108ce7539a194561da0fd834 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:20:48 +0900 Subject: [PATCH 130/770] =?UTF-8?q?fix:=20=EC=BF=A0=ED=82=A4=20path=20?= =?UTF-8?q?=EC=98=B5=EC=85=98=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java index eafe6831..000fa269 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/CookieUtil.java @@ -14,10 +14,13 @@ public class CookieUtil { @Value("${gachtaxi.auth.jwt.secureOption}") private boolean secureOption; + @Value("${gachtaxi.auth.jwt.cookiePathOption}") + private String cookiePathOption; + public void setCookie( String name, String value, HttpServletResponse response) { ResponseCookie cookie = ResponseCookie.from(name, value) .maxAge(cookieMaxAge) - .path("/") + .path(cookiePathOption) .secure(secureOption) //https 적용 시 true .httpOnly(true) .sameSite("None") From 28f02ee3a3fa167e946447272bd69d774af52ecb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:21:17 +0900 Subject: [PATCH 131/770] =?UTF-8?q?fix:=20PermitUrlConfig=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/config/PermitUrlConfig.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index 5b4f2715..08e24120 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -6,28 +6,25 @@ public class PermitUrlConfig { public String[] getPublicUrl(){ - String[] publicUrls = { + return new String[]{ "/auth/login/kakao", "/login", "/uri/test", "/swagger-ui/**", "/v3/api-docs/**" }; - return publicUrls; } public String[] getMemberUrl(){ - String[] memberUrls = { + return new String[]{ }; - return memberUrls; } public String[] getAdminUrl(){ - String[] adminUrls = { + return new String[]{ }; - return adminUrls; } From 12fe0423ed88c3fa9aac48ee13e701efde5f9a4f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:21:37 +0900 Subject: [PATCH 132/770] =?UTF-8?q?feat:=20=EC=9E=AC=EB=B0=9C=EA=B8=89=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/jwt/exception/CookieNotFoundException.java | 12 ++++++++++++ .../jwt/exception/RefreshTokenNotFoundException.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/CookieNotFoundException.java create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/RefreshTokenNotFoundException.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/CookieNotFoundException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/CookieNotFoundException.java new file mode 100644 index 00000000..aff3bd3c --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/CookieNotFoundException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.COOKIE_NOT_FOUND; + +public class CookieNotFoundException extends BaseException { + public CookieNotFoundException() { + super(HttpStatus.BAD_REQUEST, COOKIE_NOT_FOUND.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/RefreshTokenNotFoundException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/RefreshTokenNotFoundException.java new file mode 100644 index 00000000..7f602524 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/RefreshTokenNotFoundException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.REDIS_NOT_FOUND; + +public class RefreshTokenNotFoundException extends BaseException { + public RefreshTokenNotFoundException() { + super(HttpStatus.UNAUTHORIZED, REDIS_NOT_FOUND.getMessage()); + } +} From 3acbfd5453ae94745c98c4da07f2de8fa084053f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 21:47:33 +0900 Subject: [PATCH 133/770] =?UTF-8?q?feat:=20=ED=86=A0=ED=81=B0=20=EB=A7=8C?= =?UTF-8?q?=EB=A3=8C=EC=8B=9C=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/jwt/exception/TokenExpiredException.java | 13 +++++++++++++ .../global/auth/jwt/service/JwtService.java | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java new file mode 100644 index 00000000..386c1030 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.global.auth.jwt.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_EXPIRED; + +public class TokenExpiredException extends BaseException { + public TokenExpiredException() { + super(HttpStatus.UNAUTHORIZED, JWT_TOKEN_EXPIRED.getMessage()); + } +} + diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index e75bf85e..c20e1c49 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.exception.CookieNotFoundException; +import com.gachtaxi.global.auth.jwt.exception.TokenExpiredException; import com.gachtaxi.global.auth.jwt.exception.TokenInvalidException; import com.gachtaxi.global.auth.jwt.util.CookieUtil; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; @@ -37,6 +38,9 @@ public void responseJwtToken(Long userId, String email, Role role, HttpServletRe public JwtTokenDto reissueJwtToken(HttpServletRequest request) { String refreshToken = extractRefreshToken(request); + if(jwtExtractor.isExpired(refreshToken)){ + throw new TokenExpiredException(); + } Long userId = jwtExtractor.getId(refreshToken); String redisToken = (String) redisUtil.get(userId); From d3882520ca3b71fe11921d0b8dd83bb341f1d2ab Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 22:09:47 +0900 Subject: [PATCH 134/770] fix: enum type check @NotNull --- .../domain/members/dto/request/UserSignUpRequestDto.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java index f9f79b2f..9ef227a6 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java @@ -10,7 +10,7 @@ public record UserSignUpRequestDto( @NotBlank String nickName, @NotBlank String realName, @NotBlank Long studentNumber, - @NotBlank Gender gender, + @NotNull Gender gender, @NotNull Boolean termsAgreement, @NotNull Boolean privacyAgreement, @NotNull Boolean marketingAgreement, From 9359012a2e02e6c45b91635f7e0a37e29c244562 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 22:10:52 +0900 Subject: [PATCH 135/770] fix: Long type check @NotNull --- .../domain/members/dto/request/UserSignUpRequestDto.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java index 9ef227a6..22cb6d8d 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java @@ -9,7 +9,7 @@ public record UserSignUpRequestDto( @NotBlank String email, @NotBlank String nickName, @NotBlank String realName, - @NotBlank Long studentNumber, + @NotNull Long studentNumber, @NotNull Gender gender, @NotNull Boolean termsAgreement, @NotNull Boolean privacyAgreement, From df5e40a3741b9d43625a7d1a545b788303370677 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 22:18:11 +0900 Subject: [PATCH 136/770] HOTFIX: Long, Enum Type check@NotNull --- .../domain/members/dto/request/UserSignUpRequestDto.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java index f9f79b2f..b7eb9da4 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/UserSignUpRequestDto.java @@ -9,8 +9,8 @@ public record UserSignUpRequestDto( @NotBlank String email, @NotBlank String nickName, @NotBlank String realName, - @NotBlank Long studentNumber, - @NotBlank Gender gender, + @NotNull Long studentNumber, + @NotNull Gender gender, @NotNull Boolean termsAgreement, @NotNull Boolean privacyAgreement, @NotNull Boolean marketingAgreement, From 64bcea18a62a2f9a6f1c154121f7d281b108aa3c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 22:49:26 +0900 Subject: [PATCH 137/770] =?UTF-8?q?fix:=20BEARER=20=EC=83=81=EC=88=98=20?= =?UTF-8?q?=EB=9D=84=EC=96=B4=EC=93=B0=EA=B8=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java index 6b4c52ca..46b4df9d 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java @@ -19,7 +19,7 @@ public class JwtExtractor { private static final String ACCESS_TOKEN_SUBJECT = "Authorization"; - private static final String BEARER = "Bearer"; + private static final String BEARER = "Bearer "; private static final String ID_CLAIM = "id"; private static final String EMAIL_CLAIM = "email"; private static final String ROLE_CLAIM = "role"; From 4e580c5d370f729d42b22145c1d87b2b95913b7c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 22:52:55 +0900 Subject: [PATCH 138/770] =?UTF-8?q?remove:=20Slf4j=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/filter/JwtAuthenticationFilter.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index 7d6ddf99..dd61e97d 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -7,7 +7,6 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; @@ -17,9 +16,9 @@ import java.io.IOException; import java.util.Optional; -import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.*; +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_EXPIRED; +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_NOT_FOUND; -@Slf4j @RequiredArgsConstructor public class JwtAuthenticationFilter extends OncePerRequestFilter { From 8bd4515e210c6f85f2e48e2cae6a4fe629c3cbb4 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 22:54:07 +0900 Subject: [PATCH 139/770] fix: import static HttpStatus --- .../global/auth/jwt/exception/CookieNotFoundException.java | 4 ++-- .../auth/jwt/exception/RefreshTokenNotFoundException.java | 4 ++-- .../global/auth/jwt/exception/TokenExpiredException.java | 4 ++-- .../global/auth/jwt/exception/TokenInvalidException.java | 4 ++-- .../global/auth/jwt/exception/UserEmailNotFoundException.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/CookieNotFoundException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/CookieNotFoundException.java index aff3bd3c..1f5525cb 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/CookieNotFoundException.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/CookieNotFoundException.java @@ -1,12 +1,12 @@ package com.gachtaxi.global.auth.jwt.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.COOKIE_NOT_FOUND; +import static org.springframework.http.HttpStatus.BAD_REQUEST; public class CookieNotFoundException extends BaseException { public CookieNotFoundException() { - super(HttpStatus.BAD_REQUEST, COOKIE_NOT_FOUND.getMessage()); + super(BAD_REQUEST, COOKIE_NOT_FOUND.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/RefreshTokenNotFoundException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/RefreshTokenNotFoundException.java index 7f602524..252b1c9a 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/RefreshTokenNotFoundException.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/RefreshTokenNotFoundException.java @@ -1,12 +1,12 @@ package com.gachtaxi.global.auth.jwt.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.REDIS_NOT_FOUND; +import static org.springframework.http.HttpStatus.UNAUTHORIZED; public class RefreshTokenNotFoundException extends BaseException { public RefreshTokenNotFoundException() { - super(HttpStatus.UNAUTHORIZED, REDIS_NOT_FOUND.getMessage()); + super(UNAUTHORIZED, REDIS_NOT_FOUND.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java index 386c1030..82dfcdf7 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenExpiredException.java @@ -1,13 +1,13 @@ package com.gachtaxi.global.auth.jwt.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_EXPIRED; +import static org.springframework.http.HttpStatus.UNAUTHORIZED; public class TokenExpiredException extends BaseException { public TokenExpiredException() { - super(HttpStatus.UNAUTHORIZED, JWT_TOKEN_EXPIRED.getMessage()); + super(UNAUTHORIZED, JWT_TOKEN_EXPIRED.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java index 551f9905..d0ae23bd 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/TokenInvalidException.java @@ -1,12 +1,12 @@ package com.gachtaxi.global.auth.jwt.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_INVALID; +import static org.springframework.http.HttpStatus.UNAUTHORIZED; public class TokenInvalidException extends BaseException { public TokenInvalidException() { - super(HttpStatus.UNAUTHORIZED, JWT_TOKEN_INVALID.getMessage()); + super(UNAUTHORIZED, JWT_TOKEN_INVALID.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/UserEmailNotFoundException.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/UserEmailNotFoundException.java index 57b20f4f..a90ff0fe 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/UserEmailNotFoundException.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/UserEmailNotFoundException.java @@ -1,12 +1,12 @@ package com.gachtaxi.global.auth.jwt.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.USER_NOT_FOUND_EMAIL; +import static org.springframework.http.HttpStatus.UNAUTHORIZED; public class UserEmailNotFoundException extends BaseException { public UserEmailNotFoundException() { - super(HttpStatus.UNAUTHORIZED, USER_NOT_FOUND_EMAIL.getMessage()); + super(UNAUTHORIZED, USER_NOT_FOUND_EMAIL.getMessage()); } } From a6972446977916f0af2ca14802feecec0d829f0e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 23:03:43 +0900 Subject: [PATCH 140/770] =?UTF-8?q?fix:=20=EA=B0=9C=ED=96=89=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/filter/JwtAuthenticationFilter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index dd61e97d..2e84d9cf 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -30,11 +30,13 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { Optional token = jwtExtractor.extractJwtToken(request); + if (token.isEmpty()) { request.setAttribute(JWT_ERROR, JWT_TOKEN_NOT_FOUND); filterChain.doFilter(request, response); return; } + String accessToken = token.get(); if(jwtExtractor.isExpired(accessToken)){ From bc9fd01722458b869f18abe58e7f99f309da5782 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 23:05:09 +0900 Subject: [PATCH 141/770] =?UTF-8?q?feat:=20CORS=20=EC=BF=A0=ED=82=A4=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=ED=97=A4=EB=8D=94=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java index 34e7a312..7fe1f5da 100644 --- a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java @@ -70,7 +70,7 @@ public CorsConfigurationSource corsConfigurationSource() { configuration.setAllowedOriginPatterns(Arrays.asList("http://localhost:3000")); configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PATCH", "DELETE", "OPTIONS")); configuration.setAllowedHeaders(Arrays.asList("*")); - configuration.setExposedHeaders(Arrays.asList("Authorization")); + configuration.setExposedHeaders(Arrays.asList("Authorization", "Set-Cookie")); configuration.setAllowCredentials(true); // /** 들어오는 모든 유형의 URL 패턴을 허용. From f503fb5055381dae3c34ccc0bce26263584f9028 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:15:36 +0900 Subject: [PATCH 142/770] =?UTF-8?q?chore:=20=EC=84=A4=EC=A0=95=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EC=97=90=20kafka=20=EA=B4=80=EB=A0=A8=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-local.yml | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index f29206e2..ff622e0c 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -18,6 +18,22 @@ spring: password: ${REDIS_PASSWORD} # mongodb: # uri: ${MONGODB_URI} + kafka: + bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS} + producer: + retries: ${KAFKA_PRODUCER_RETRIES} + acks: ${KAFKA_PRODUCER_ACKS} + properties: + enable.idempotence: ${KAFKA_PRODUCER_ENABLE_IDEMPOTENCE} + max.in.flight.requests.per.connection: ${KAFKA_PRODUCER_MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION} + consumer: + group-id: ${KAFKA_CONSUMER_GROUP_ID} + auto-offset-reset: ${KAFKA_CONSUMER_AUTO_OFFSET_RESET} + enable-auto-commit: ${KAFKA_CONSUMER_ENABLE_AUTO_COMMIT} + admin: + properties: + client.id: ${KAFKA_ADMIN_CLIENT_ID} + logging: level: @@ -36,4 +52,11 @@ gachtaxi: accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} refreshTokenExpiration: ${JWT_REFRESH_TOKEN_EXPIRATION} cookieMaxAge: ${JWT_COOKIE_MAX_AGE} - secureOption: ${COOKIE_SECURE_OPTION} \ No newline at end of file + secureOption: ${COOKIE_SECURE_OPTION} + kafka: + topics: + match-room-created: ${KAFKA_TOPIC_MATCH_ROOM_CREATED} + match-member-joined: ${KAFKA_TOPIC_MATCH_MEMBER_JOINED} + match-room-cancelled: ${KAFKA_TOPIC_MATCH_ROOM_CANCELLED} + partition-count: ${KAFKA_PARTITION_COUNT} + replication-factor: ${KAFKA_REPLICATION_FACTOR} \ No newline at end of file From 2877483fd3cb115b2940c1a973740d9f2cc92c6c Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:15:50 +0900 Subject: [PATCH 143/770] =?UTF-8?q?feat:=20kafka=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/kafka/KafkaConsumerConfig.java | 75 +++++++++++++++++++ .../config/kafka/KafkaProducerConfig.java | 65 ++++++++++++++++ .../config/kafka/KafkaTopicsConfig.java | 40 ++++++++++ 3 files changed, 180 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java create mode 100644 src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java create mode 100644 src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java new file mode 100644 index 00000000..4cfb0cc9 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java @@ -0,0 +1,75 @@ +package com.gachtaxi.global.config.kafka; + +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import java.util.HashMap; +import java.util.Map; +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.common.serialization.StringDeserializer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; +import org.springframework.kafka.core.ConsumerFactory; +import org.springframework.kafka.core.DefaultKafkaConsumerFactory; +import org.springframework.kafka.listener.ContainerProperties; +import org.springframework.kafka.support.serializer.JsonDeserializer; + +@Configuration +public class KafkaConsumerConfig { + + @Value("${spring.kafka.bootstrap-servers}") + private String bootstrapServers; + @Value("${spring.kafka.consumer.group-id}") + private String groupId; + + // MatchRoomCreatedEvent + @Bean + public ConsumerFactory matchRoomCreatedEventConsumerFactory() { + Map configs = new HashMap<>(); + configs.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); + configs.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); + + JsonDeserializer jsonDeserializer = + new JsonDeserializer<>(MatchRoomCreatedEvent.class); + jsonDeserializer.addTrustedPackages("com.gachtaxi.domain.matching.event.dto"); + + return new DefaultKafkaConsumerFactory<>(configs, new StringDeserializer(), jsonDeserializer); + } + + @Bean + public ConcurrentKafkaListenerContainerFactory matchRoomCreatedEventListenerFactory() { + ConcurrentKafkaListenerContainerFactory factory + = new ConcurrentKafkaListenerContainerFactory<>(); + factory.setConsumerFactory(matchRoomCreatedEventConsumerFactory()); + factory.setConcurrency(3); + factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); + return factory; + } + + // MatchMemberJoinedEvent + @Bean + public ConsumerFactory matchMemberJoinedEventConsumerFactory() { + Map configs = new HashMap<>(); + configs.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); + configs.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); + + JsonDeserializer jsonDeserializer = + new JsonDeserializer<>(MatchMemberJoinedEvent.class); + jsonDeserializer.addTrustedPackages("com.gachtaxi.domain.matching.event.dto"); + + return new DefaultKafkaConsumerFactory<>(configs, new StringDeserializer(), jsonDeserializer); + } + + @Bean + public ConcurrentKafkaListenerContainerFactory matchMemberJoinedEventListenerFactory() { + ConcurrentKafkaListenerContainerFactory factory + = new ConcurrentKafkaListenerContainerFactory<>(); + factory.setConsumerFactory(matchMemberJoinedEventConsumerFactory()); + factory.setConcurrency(3); + factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); + return factory; + } +} \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java new file mode 100644 index 00000000..651f676d --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java @@ -0,0 +1,65 @@ +package com.gachtaxi.global.config.kafka; + +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import java.util.HashMap; +import java.util.Map; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.common.serialization.StringSerializer; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.kafka.core.DefaultKafkaProducerFactory; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.core.ProducerFactory; +import org.springframework.kafka.support.serializer.JsonSerializer; + +@Configuration +public class KafkaProducerConfig { + + @Value("${spring.kafka.bootstrap-servers}") + private String bootstrapServers; + + @Bean + @Qualifier("matchRoomCreatedEventProducerFactory") + public ProducerFactory matchRoomCreatedEventProducerFactory() { + Map configs = new HashMap<>(); + configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + + configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); + configs.put(ProducerConfig.ACKS_CONFIG, "all"); + configs.put(ProducerConfig.RETRIES_CONFIG, 3); + + return new DefaultKafkaProducerFactory<>(configs); + } + + @Bean + @Qualifier("matchMemberJoinedEventProducerFactory") + public ProducerFactory matchMemberJoinedEventProducerFactory() { + Map configs = new HashMap<>(); + configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + + configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); + configs.put(ProducerConfig.ACKS_CONFIG, "all"); + configs.put(ProducerConfig.RETRIES_CONFIG, 3); + + return new DefaultKafkaProducerFactory<>(configs); + } + + @Bean + @Qualifier("matchMemberJoinedEventKafkaTemplate") + public KafkaTemplate matchMemberJoinedEventKafkaTemplate() { + return new KafkaTemplate<>(matchMemberJoinedEventProducerFactory()); + } + + @Bean + @Qualifier("matchRoomCreatedEventKafkaTemplate") + public KafkaTemplate matchRoomCreatedEventKafkaTemplate() { + return new KafkaTemplate<>(matchRoomCreatedEventProducerFactory()); + } +} \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java new file mode 100644 index 00000000..4ecda46e --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java @@ -0,0 +1,40 @@ +package com.gachtaxi.global.config.kafka; + +import org.apache.kafka.clients.admin.NewTopic; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class KafkaTopicsConfig { + + @Value("${gachtaxi.kafka.topics.match-room-created}") + private String matchRoomCreatedTopic; + + @Value("${gachtaxi.kafka.topics.match-member-joined}") + private String matchMemberJoinedTopic; + + @Value("${gachtaxi.kafka.topics.match-room-cancelled}") + private String matchRoomCancelledTopic; + + @Value("${gachtaxi.kafka.partition-count}") + private short partitionCount; + + @Value("${gachtaxi.kafka.replication-factor}") + private short replicationFactor; + + @Bean + public NewTopic matchRoomCreatedTopic() { + return new NewTopic(matchRoomCreatedTopic, partitionCount, replicationFactor); + } + + @Bean + public NewTopic matchMemberJoinedTopic() { + return new NewTopic(matchMemberJoinedTopic, partitionCount, replicationFactor); + } + + @Bean + public NewTopic matchRoomCancelledTopic() { + return new NewTopic(matchRoomCancelledTopic, partitionCount, replicationFactor); + } +} \ No newline at end of file From d7ad054f0624c799e85b2d2e4323e1de9baaa1f7 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:16:16 +0900 Subject: [PATCH 144/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=95=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EC=9D=B8=ED=84=B0=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/dto/FindRoomResult.java | 13 ++++++++ .../service/MatchingAlgorithmService.java | 32 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java new file mode 100644 index 00000000..6d61fd2d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.matching.algorithm.dto; + +import lombok.Builder; + +@Builder +public record FindRoomResult( + Long roomId, +// String roomType, + Integer currentMembers, + Integer maxCapacity +) { + +} diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java new file mode 100644 index 00000000..611a1a4f --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java @@ -0,0 +1,32 @@ +package com.gachtaxi.domain.matching.algorithm.service; + +import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; +import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import java.util.List; +import java.util.Optional; + +public interface MatchingAlgorithmService { + + /** + * 방을 찾는 메서드 + * @param userId 방에 들어가려는 사용자 ID + * @param criteria 방 검색에 필요한 기타 조건 (ex. 위치, 키워드 등) + * @return Optional - 매칭 가능한 방 정보가 있으면 값이 있고, 없으면 empty + */ + Optional findRoom(Long userId, List criteria); + + /** + * 방 생성 처리 (DB에 실제 insert 등) + * @param userId 방을 만들 사용자(방장) + * @param criteria 조건(위치, 키워드 등) + * @return 생성된 방의 ID + */ + Long createRoom(Long userId, List criteria); + + /** + * 방에 참가 처리 + * @param roomId 참가할 방 ID + * @param userId 참가하는 사용자 + */ + void joinRoom(Long roomId, Long userId); +} From 428ccdb24e85f8fb8d77272eac86480a47ca7f05 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:16:27 +0900 Subject: [PATCH 145/770] =?UTF-8?q?feat:=20=EC=9E=84=EC=8B=9C=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=EC=B2=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MockMatchingAlgorithmService.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java new file mode 100644 index 00000000..b243844b --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -0,0 +1,34 @@ +package com.gachtaxi.domain.matching.algorithm.service; + +import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; +import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import java.util.List; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class MockMatchingAlgorithmService implements MatchingAlgorithmService { + + + @Override + public Optional findRoom(Long userId, List criteria) { + if (userId == 1L) { + return Optional.of(FindRoomResult.builder() + .roomId(1L) + .build()); + } + return Optional.empty(); + } + + @Override + public Long createRoom(Long userId, List criteria) { + return 1L; + } + + @Override + public void joinRoom(Long roomId, Long userId) { + + } +} From 95944f1d108fa31730b774f5d5b2a93efb62045f Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:17:17 +0900 Subject: [PATCH 146/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=9A=94=EC=B2=AD,=20=EC=9D=91=EB=8B=B5=20DTO=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/AutoMatchingPostRequest.java | 17 +++++++++++++++++ .../dto/response/AutoMatchingPostResponse.java | 13 +++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/response/AutoMatchingPostResponse.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java new file mode 100644 index 00000000..0dd343b3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java @@ -0,0 +1,17 @@ +package com.gachtaxi.domain.matching.common.dto.request; + +import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import java.util.List; + +public record AutoMatchingPostRequest( + String startPoint, + String destinationPoint, + List criteria +) { + + public List getCriteria() { + return this.criteria.stream() + .map(Tags::valueOf) + .toList(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/AutoMatchingPostResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/AutoMatchingPostResponse.java new file mode 100644 index 00000000..f35d99b8 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/AutoMatchingPostResponse.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.matching.common.dto.response; + +import com.gachtaxi.domain.matching.common.dto.enums.AutoMatchingStatus; + +public record AutoMatchingPostResponse( + String autoMatchingStatus + +) { + + public static AutoMatchingPostResponse of(AutoMatchingStatus autoMatchingStatus) { + return new AutoMatchingPostResponse(autoMatchingStatus.getValue()); + } +} From 1def20fc4a31ed8483becaef81f67434391a905b Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:17:37 +0900 Subject: [PATCH 147/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EC=97=90=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=ED=83=9C=EA=B7=B8=20enum=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/enums/Tags.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/enums/Tags.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/Tags.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/Tags.java new file mode 100644 index 00000000..93812d5d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/Tags.java @@ -0,0 +1,6 @@ +package com.gachtaxi.domain.matching.common.entity.enums; + +public enum Tags { + NO_SMOKE, + SAME_GENDER +} From 96587e04039834066b2e66b2aae93f38fd7e01ba Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:17:56 +0900 Subject: [PATCH 148/770] =?UTF-8?q?feat:=20=EC=9D=91=EB=8B=B5=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20enum=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/ResponseMessage.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java new file mode 100644 index 00000000..63dcff16 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java @@ -0,0 +1,18 @@ +package com.gachtaxi.domain.matching.common.controller; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum ResponseMessage { + + // sse + SUBSCRIBE_SUCCESS("SSE 구독에 성공했습니다."), + + // auto matching + AUTO_MATCHING_REQUEST_ACCEPTED("자동 매칭 요청 전송에 성공했습니다."), + NOT_SUBSCRIBED_SSE("SSE 구독 후 자동 매칭을 요청할 수 있습니다."); + + private final String message; +} From f82ac02814308b28d305dd28996253bdb3f72d31 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:18:14 +0900 Subject: [PATCH 149/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=84=B1=EA=B3=B5=20=EC=97=AC=EB=B6=80=20enum=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dto/enums/AutoMatchingStatus.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/enums/AutoMatchingStatus.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/enums/AutoMatchingStatus.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/enums/AutoMatchingStatus.java new file mode 100644 index 00000000..c1dee135 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/enums/AutoMatchingStatus.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.matching.common.dto.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum AutoMatchingStatus { + REQUESTED("REQUESTED"), + REJECTED("REJECTED"); + + private final String value; +} From df9d08079d3c6d4aaa41a88749ce57bec079714a Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:18:25 +0900 Subject: [PATCH 150/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AutoMatchingController.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java new file mode 100644 index 00000000..8f5f443a --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java @@ -0,0 +1,56 @@ +package com.gachtaxi.domain.matching.common.controller; + +import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; +import com.gachtaxi.domain.matching.common.dto.response.AutoMatchingPostResponse; +import com.gachtaxi.domain.matching.common.service.MatchingService; +import com.gachtaxi.global.common.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/matching/auto") +public class AutoMatchingController { + + private final MatchingService matchingService; + + @GetMapping("/subscribe") + public ApiResponse subscribeSse(@RequestParam Long memberId) { + // TODO: 인가 로직 완성되면 해당 멤버의 아이디를 가져오도록 변경 +// Long memberId = 1L; + return ApiResponse.response( + HttpStatus.OK, + ResponseMessage.SUBSCRIBE_SUCCESS.getMessage(), + this.matchingService.handleSubscribe(memberId) + ); + } + + @PostMapping("/request") + public ApiResponse requestMatching( + @RequestParam Long memberId, + @RequestBody AutoMatchingPostRequest autoMatchingPostRequest + ) { + // TODO: 인가 로직 완성되면 해당 멤버의 아이디를 가져오도록 변경 +// Long memberId = 1L; + if (!this.matchingService.isSseSubscribed(memberId)) { + return ApiResponse.response( + HttpStatus.BAD_REQUEST, + ResponseMessage.NOT_SUBSCRIBED_SSE.getMessage() + ); + } + + return ApiResponse.response( + HttpStatus.OK, + ResponseMessage.AUTO_MATCHING_REQUEST_ACCEPTED.getMessage(), + this.matchingService.handlerAutoRequestMatching(memberId, autoMatchingPostRequest) + ); + } +} \ No newline at end of file From 689770854fb1adb66dc0ad4844c1cce4d45a22b8 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:18:37 +0900 Subject: [PATCH 151/770] =?UTF-8?q?feat:=20SSE=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/service/sse/SseService.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/service/sse/SseService.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/sse/SseService.java b/src/main/java/com/gachtaxi/domain/matching/event/service/sse/SseService.java new file mode 100644 index 00000000..d76e0fb3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/sse/SseService.java @@ -0,0 +1,64 @@ +package com.gachtaxi.domain.matching.event.service.sse; + +import org.springframework.stereotype.Service; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 사용자별 SSE Emitter 관리 + */ +@Service +public class SseService { + + private final Map emitterMap = new ConcurrentHashMap<>(); + + /** + * SSE 구독 + */ + public SseEmitter subscribe(Long memberId) { + SseEmitter emitter = new SseEmitter(10 * 60 * 1000L); // 10분 + emitter.onCompletion(() -> emitterMap.remove(memberId)); + emitter.onTimeout(() -> emitterMap.remove(memberId)); + this.emitterMap.put(memberId, emitter); + return emitter; + } + + /** + * userId가 현재 SSE를 구독 중인지 확인 + */ + public boolean isSubscribed(Long memberId) { + return this.emitterMap.containsKey(memberId); + } + + /** + * 특정 사용자에게 이벤트 전송 + */ + public void sendToClient(Long memberId, String eventName, Object data) { + SseEmitter emitter = this.emitterMap.get(memberId); + if (emitter != null) { + try { + emitter.send(SseEmitter.event() + .name(eventName) + .data(data)); + } catch (IOException e) { + this.emitterMap.remove(memberId); + } + } + } + + /** + * 모든 사용자에게 브로드캐스트 + */ + public void broadcast(String eventName, Object data) { + for (Map.Entry entry : emitterMap.entrySet()) { + try { + entry.getValue().send(SseEmitter.event().name(eventName).data(data)); + } catch (IOException e) { + this.emitterMap.remove(entry.getKey()); + } + } + } +} \ No newline at end of file From 49185c1dc6a3b52a039cf27b8f7177797a275ec6 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:19:11 +0900 Subject: [PATCH 152/770] =?UTF-8?q?feat:=20kafka=20producer=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/service/kafka/ProducerService.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ProducerService.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ProducerService.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ProducerService.java new file mode 100644 index 00000000..53ce3539 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ProducerService.java @@ -0,0 +1,70 @@ +package com.gachtaxi.domain.matching.event.service.kafka; + +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import java.util.concurrent.CompletableFuture; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.kafka.clients.producer.RecordMetadata; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ProducerService { + + private final KafkaTemplate matchRoomCreatedEventKafkaTemplate; + private final KafkaTemplate matchMemberJoinedEventKafkaTemplate; + + @Value("${kafka.topic.match-room-created}") + private String matchRoomCreatedTopic; + + @Value("${kafka.topic.match-member-joined}") + private String matchMemberJoinedTopic; + + /** + * 방 생성 이벤트를 발행 + */ + public void sendMatchRoomCreatedEvent(MatchRoomCreatedEvent matchRoomCreatedEvent) { + String key = String.valueOf(matchRoomCreatedEvent.roomId()); + + CompletableFuture future = this.matchRoomCreatedEventKafkaTemplate.send(matchRoomCreatedTopic, key, matchRoomCreatedEvent); + + future.thenAccept(result -> { + if (result instanceof RecordMetadata metadata) { + log.info("[KAFKA PRODUCER] Success sending MatchRoomCreatedEvent: " + + "topic={}, partition={}, offset={}, key={}", + metadata.topic(), metadata.partition(), metadata.offset(), key + ); + } + } + ).exceptionally(ex -> { + log.error("[KAFKA PRODUCER] Failed to send MatchRoomCreatedEvent key={}", key, ex); + return null; + }); + } + + /** + * 방 멤버 참가 이벤트를 발행 + */ + public void sendMatchMemberJoinedEvent(MatchMemberJoinedEvent matchMemberJoinedEvent) { + String key = String.valueOf(matchMemberJoinedEvent.roomId()); + + CompletableFuture future = this.matchMemberJoinedEventKafkaTemplate.send(matchMemberJoinedTopic, key, matchMemberJoinedEvent); + + future.thenAccept(result -> { + if (result instanceof RecordMetadata metadata) { + log.info("[KAFKA PRODUCER] Success sending MatchMemberJoinedEvent: " + + "topic={}, partition={}, offset={}, key={}", + metadata.topic(), metadata.partition(), metadata.offset(), key + ); + } + } + ).exceptionally(ex -> { + log.error("[KAFKA PRODUCER] Failed to send MatchMemberJoinedEvent key={}", key, ex); + return null; + }); + } +} \ No newline at end of file From a972b5aa2fbcaa82312e6299ccb6ea502cface59 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:19:19 +0900 Subject: [PATCH 153/770] =?UTF-8?q?feat:=20kafka=20consumer=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/service/kafka/ConsumerListener.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ConsumerListener.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ConsumerListener.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ConsumerListener.java new file mode 100644 index 00000000..799b0c1d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ConsumerListener.java @@ -0,0 +1,61 @@ +package com.gachtaxi.domain.matching.event.service.kafka; + +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import com.gachtaxi.domain.matching.event.service.sse.SseService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.kafka.support.Acknowledgment; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ConsumerListener { + + private final SseService sseService; + + /** + * 방 생성 이벤트 구독 + */ + @KafkaListener( + topics = "${gachtaxi.kafka.topics.match-room-created}", + containerFactory = "matchRoomCreatedEventListenerFactory" + ) + public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) { + try { + log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event); + + // TODO: 매칭 방 생성 후 save + + this.sseService.sendToClient(event.hostMemberId(), "MATCH_ROOM_CREATED", event); + + ack.acknowledge(); + } catch (Exception e) { + log.error("[KAFKA CONSUMER] Error processing MatchRoomCreatedEvent", e); + } + } + + /** + * 방 멤버 참가 이벤트 구독 + */ + @KafkaListener( + topics = "${gachtaxi.kafka.topics.match-member-joined}", + containerFactory = "matchMemberJoinedEventListenerFactory" + ) + public void onMatchMemberJoined(MatchMemberJoinedEvent event, Acknowledgment ack) { + try { + log.info("[KAFKA CONSUMER] Received MatchMemberJoinedEvent: {}", event); + + // TODO: 매칭 방 멤버 참가 후 DB 상태 업데이트 + + this.sseService.sendToClient(event.memberId(), "MATCH_MEMBER_JOINED", event); + this.sseService.broadcast("MATCH_MEMBER_JOINED", event); + + ack.acknowledge(); + } catch (Exception e) { + log.error("[KAFKA CONSUMER] Error processing MatchMemberJoinedEvent", e); + } + } +} \ No newline at end of file From 4d8e73052e66c66c6d5becfb16965c0929706192 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:19:35 +0900 Subject: [PATCH 154/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20DTO=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kafka_topic/MatchMemberJoinedEvent.java | 19 +++++++++++++++++++ .../kafka_topic/MatchRoomCreatedEvent.java | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java new file mode 100644 index 00000000..a1a313b8 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java @@ -0,0 +1,19 @@ +package com.gachtaxi.domain.matching.event.dto.kafka_topic; + +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; +import lombok.Builder; + +@Builder +public record MatchMemberJoinedEvent( + Long roomId, + Long memberId, + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + LocalDateTime joinedAt +) { + + public static MatchMemberJoinedEvent of(Long roomId, Long memberId) { + return new MatchMemberJoinedEvent(roomId, memberId, LocalDateTime.now()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java new file mode 100644 index 00000000..dd701967 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java @@ -0,0 +1,19 @@ +package com.gachtaxi.domain.matching.event.dto.kafka_topic; + +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; +import lombok.Builder; + +@Builder +public record MatchRoomCreatedEvent( + Long roomId, + Long hostMemberId, + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + LocalDateTime createdAt +) { + + public static MatchRoomCreatedEvent of(Long roomId, Long memberId) { + return new MatchRoomCreatedEvent(roomId, memberId, LocalDateTime.now()); + } +} From 739b8d56413a5d53d8612f48056acb7532e6242f Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:19:48 +0900 Subject: [PATCH 155/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingService.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/service/MatchingService.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingService.java new file mode 100644 index 00000000..4224ec27 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingService.java @@ -0,0 +1,81 @@ +package com.gachtaxi.domain.matching.common.service; + +import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; +import com.gachtaxi.domain.matching.algorithm.service.MatchingAlgorithmService; +import com.gachtaxi.domain.matching.common.dto.enums.AutoMatchingStatus; +import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; +import com.gachtaxi.domain.matching.common.dto.response.AutoMatchingPostResponse; +import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import com.gachtaxi.domain.matching.event.service.kafka.ProducerService; +import com.gachtaxi.domain.matching.event.service.sse.SseService; +import jakarta.transaction.Transactional; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; + +@Service +@RequiredArgsConstructor +public class MatchingService { + + private final SseService sseService; + private final ProducerService producerService; + private final MatchingAlgorithmService matchingAlgorithmService; + + public SseEmitter handleSubscribe(Long userId) { + return this.sseService.subscribe(userId); + } + + public boolean isSseSubscribed(Long memberId) { + return this.sseService.isSubscribed(memberId); + } + + public AutoMatchingPostResponse handlerAutoRequestMatching( + Long memberId, + AutoMatchingPostRequest autoMatchingPostRequest + ) { + List criteria = autoMatchingPostRequest.getCriteria(); + Optional optionalRoom = + this.matchingAlgorithmService.findRoom(memberId, criteria); + + optionalRoom + .ifPresentOrElse( + roomResult -> this.sendMatchMemberJoinedEvent(memberId, roomResult), + () -> this.sendMatchRoomCreatedEvent(memberId, autoMatchingPostRequest) + ); + + return AutoMatchingPostResponse.of(AutoMatchingStatus.REQUESTED); + } + + private void sendMatchRoomCreatedEvent(Long memberId, + AutoMatchingPostRequest autoMatchingPostRequest) { + Long newRoomId = this.matchingAlgorithmService.createRoom(memberId, + autoMatchingPostRequest.getCriteria()); + + MatchRoomCreatedEvent createdEvent = MatchRoomCreatedEvent.builder() + .roomId(newRoomId) + .hostMemberId(memberId) + .createdAt(LocalDateTime.now()) + .build(); + + this.producerService.sendMatchRoomCreatedEvent(createdEvent); + } + + private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult) { + Long roomId = roomResult.roomId(); + + this.matchingAlgorithmService.joinRoom(roomId, memberId); + + MatchMemberJoinedEvent joinedEvent = MatchMemberJoinedEvent.builder() + .roomId(roomId) + .memberId(memberId) + .joinedAt(LocalDateTime.now()) + .build(); + + this.producerService.sendMatchMemberJoinedEvent(joinedEvent); + } +} From 99b8df4c84f8a11e0f11e3a01912fae79ca6c649 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:20:02 +0900 Subject: [PATCH 156/770] =?UTF-8?q?chore:=20.env=20=ED=8C=8C=EC=9D=BC=20.g?= =?UTF-8?q?itignore=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c2065bc2..3420b922 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ out/ ### VS Code ### .vscode/ + +src/main/resources/.env From bba74ade8c9ad667803cda1d30c24776417d156c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 23:30:23 +0900 Subject: [PATCH 157/770] =?UTF-8?q?remove:=20CurrentMember,=20JwtUserDetai?= =?UTF-8?q?lsService.java=20=EC=82=AD=EC=A0=9C=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/jwt/annotation/CurrentMember.java | 18 ------- .../jwt/filter/JwtAuthenticationFilter.java | 7 +-- .../global/auth/jwt/user/JwtUserDetails.java | 9 ++-- .../auth/jwt/user/JwtUserDetailsService.java | 50 +++++++++---------- .../gachtaxi/global/config/RedisConfig.java | 2 +- .../global/config/SecurityConfig.java | 4 +- 6 files changed, 34 insertions(+), 56 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMember.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMember.java b/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMember.java deleted file mode 100644 index 043d1669..00000000 --- a/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMember.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.gachtaxi.global.auth.jwt.annotation; - -import org.springframework.security.core.annotation.AuthenticationPrincipal; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") -public @interface CurrentMember { - /* - * AuthenticationPrincipal의 member 필드를 반환 - * 즉, JwtUserDetilas의 member 필드를 반환 - * */ -} diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index 2e84d9cf..60d3cd2b 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -1,6 +1,6 @@ package com.gachtaxi.global.auth.jwt.filter; -import com.gachtaxi.global.auth.jwt.user.JwtUserDetailsService; +import com.gachtaxi.global.auth.jwt.user.JwtUserDetails; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; @@ -23,7 +23,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { private final JwtExtractor jwtExtractor; - private final JwtUserDetailsService jwtUserDetailsService; private final static String JWT_ERROR = "jwtError"; @@ -50,9 +49,11 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse } private void saveAuthentcation(String token) { + Long id = jwtExtractor.getId(token); String email = jwtExtractor.getEmail(token); + String role = jwtExtractor.getRole(token); - UserDetails userDetails = jwtUserDetailsService.loadUserByUsername(email); + UserDetails userDetails = JwtUserDetails.of(id, email, role); Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java index ca55d941..6a733596 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java @@ -1,6 +1,5 @@ package com.gachtaxi.global.auth.jwt.user; -import com.gachtaxi.domain.members.entity.Members; import lombok.Getter; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; @@ -12,18 +11,16 @@ @Getter public class JwtUserDetails extends User { - private final Members member; private final Long id; private final String email; - public JwtUserDetails(Members member, Long id, String email, List authorities) { + public JwtUserDetails(Long id, String email, List authorities) { super(email, "", authorities); - this.member = member; this.id = id; this.email = email; } - public static JwtUserDetails of(Members member) { - return new JwtUserDetails(member, member.getId(), member.getEmail(), Collections.singletonList(new SimpleGrantedAuthority(member.getRole().toString()))); + public static JwtUserDetails of(Long id, String email, String role) { + return new JwtUserDetails(id, email, Collections.singletonList(new SimpleGrantedAuthority(role))); } } \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetailsService.java b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetailsService.java index 5ee3fb6f..6f986de1 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetailsService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetailsService.java @@ -1,25 +1,25 @@ -package com.gachtaxi.global.auth.jwt.user; - -import com.gachtaxi.domain.members.entity.Members; -import com.gachtaxi.domain.members.repository.MemberRepository; -import com.gachtaxi.global.auth.jwt.exception.UserEmailNotFoundException; -import lombok.RequiredArgsConstructor; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class JwtUserDetailsService implements UserDetailsService { - - private final MemberRepository memberRepository; - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - Members member = memberRepository.findByEmail(email) - .orElseThrow(UserEmailNotFoundException::new); - - return JwtUserDetails.of(member); - } -} +//package com.gachtaxi.global.auth.jwt.user; +// +//import com.gachtaxi.domain.members.entity.Members; +//import com.gachtaxi.domain.members.repository.MemberRepository; +//import com.gachtaxi.global.auth.jwt.exception.UserEmailNotFoundException; +//import lombok.RequiredArgsConstructor; +//import org.springframework.security.core.userdetails.UserDetails; +//import org.springframework.security.core.userdetails.UserDetailsService; +//import org.springframework.security.core.userdetails.UsernameNotFoundException; +//import org.springframework.stereotype.Service; +// +//@Service +//@RequiredArgsConstructor +//public class JwtUserDetailsService implements UserDetailsService { +// +// private final MemberRepository memberRepository; +// +// @Override +// public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { +// Members member = memberRepository.findByEmail(email) +// .orElseThrow(UserEmailNotFoundException::new); +// +// return JwtUserDetails.of(member); +// } +//} diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index ff852595..5ce34594 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -41,7 +41,7 @@ public RedisConnectionFactory redisConnectionFactory() { redisStandaloneConfiguration.setHostName(host); redisStandaloneConfiguration.setPort(port); - redisStandaloneConfiguration.setPassword(password); +// redisStandaloneConfiguration.setPassword(password); return new LettuceConnectionFactory(redisStandaloneConfiguration); } diff --git a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java index 7fe1f5da..8f80e1c9 100644 --- a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java @@ -5,7 +5,6 @@ import com.gachtaxi.global.auth.jwt.authentication.CustomAccessDeniedHandler; import com.gachtaxi.global.auth.jwt.authentication.CustomAuthenticationEntryPoint; import com.gachtaxi.global.auth.jwt.filter.JwtAuthenticationFilter; -import com.gachtaxi.global.auth.jwt.user.JwtUserDetailsService; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; @@ -34,7 +33,6 @@ public class SecurityConfig { private final CustomAuthenticationEntryPoint customAuthenticationEntryPoint; private final CustomAccessDeniedHandler customAccessDeniedHandler; private final JwtExtractor jwtExtractor; - private final JwtUserDetailsService jwtUserDetailsService; @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { @@ -54,7 +52,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti http.exceptionHandling(e -> e .authenticationEntryPoint(customAuthenticationEntryPoint) .accessDeniedHandler(customAccessDeniedHandler)); - http.addFilterBefore(new JwtAuthenticationFilter(jwtExtractor, jwtUserDetailsService), UsernamePasswordAuthenticationFilter.class); + http.addFilterBefore(new JwtAuthenticationFilter(jwtExtractor), UsernamePasswordAuthenticationFilter.class); return http.build(); } From 5df37e0fd4b507cb4e59850b64f449fdb46d3b29 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 6 Jan 2025 23:35:38 +0900 Subject: [PATCH 158/770] =?UTF-8?q?feat:=20=ED=86=A0=ED=81=B0=20=EC=9E=AC?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20publicUrl=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index b993ff7e..45ddfc07 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -8,11 +8,11 @@ public class PermitUrlConfig { public String[] getPublicUrl(){ return new String[]{ "/auth/login/kakao", + "/auth/refersh", "/api/members", - "/login", + "/swagger-ui/**", "/v3/api-docs/**", - "/test/login/kakao" }; } From 176b8b2ff20be84cbad6b1145bdee284c070ea72 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 6 Jan 2025 23:47:48 +0900 Subject: [PATCH 159/770] =?UTF-8?q?rename:=20MatchingService,=20Consumer,?= =?UTF-8?q?=20Producer=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EB=AA=85=ED=99=95=ED=95=98=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/AutoMatchingController.java | 11 +++++------ ...{MatchingService.java => AutoMatchingService.java} | 11 +++++------ ...onsumerListener.java => AutoMatchingConsumer.java} | 2 +- ...ProducerService.java => AutoMatchingProducer.java} | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) rename src/main/java/com/gachtaxi/domain/matching/common/service/{MatchingService.java => AutoMatchingService.java} (89%) rename src/main/java/com/gachtaxi/domain/matching/event/service/kafka/{ConsumerListener.java => AutoMatchingConsumer.java} (98%) rename src/main/java/com/gachtaxi/domain/matching/event/service/kafka/{ProducerService.java => AutoMatchingProducer.java} (98%) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java index 8f5f443a..58e57c54 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java @@ -2,12 +2,11 @@ import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; import com.gachtaxi.domain.matching.common.dto.response.AutoMatchingPostResponse; -import com.gachtaxi.domain.matching.common.service.MatchingService; +import com.gachtaxi.domain.matching.common.service.AutoMatchingService; import com.gachtaxi.global.common.response.ApiResponse; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -20,7 +19,7 @@ @RequestMapping("/api/matching/auto") public class AutoMatchingController { - private final MatchingService matchingService; + private final AutoMatchingService autoMatchingService; @GetMapping("/subscribe") public ApiResponse subscribeSse(@RequestParam Long memberId) { @@ -29,7 +28,7 @@ public ApiResponse subscribeSse(@RequestParam Long memberId) { return ApiResponse.response( HttpStatus.OK, ResponseMessage.SUBSCRIBE_SUCCESS.getMessage(), - this.matchingService.handleSubscribe(memberId) + this.autoMatchingService.handleSubscribe(memberId) ); } @@ -40,7 +39,7 @@ public ApiResponse requestMatching( ) { // TODO: 인가 로직 완성되면 해당 멤버의 아이디를 가져오도록 변경 // Long memberId = 1L; - if (!this.matchingService.isSseSubscribed(memberId)) { + if (!this.autoMatchingService.isSseSubscribed(memberId)) { return ApiResponse.response( HttpStatus.BAD_REQUEST, ResponseMessage.NOT_SUBSCRIBED_SSE.getMessage() @@ -50,7 +49,7 @@ public ApiResponse requestMatching( return ApiResponse.response( HttpStatus.OK, ResponseMessage.AUTO_MATCHING_REQUEST_ACCEPTED.getMessage(), - this.matchingService.handlerAutoRequestMatching(memberId, autoMatchingPostRequest) + this.autoMatchingService.handlerAutoRequestMatching(memberId, autoMatchingPostRequest) ); } } \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java similarity index 89% rename from src/main/java/com/gachtaxi/domain/matching/common/service/MatchingService.java rename to src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 4224ec27..856b5c40 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -8,9 +8,8 @@ import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; -import com.gachtaxi.domain.matching.event.service.kafka.ProducerService; +import com.gachtaxi.domain.matching.event.service.kafka.AutoMatchingProducer; import com.gachtaxi.domain.matching.event.service.sse.SseService; -import jakarta.transaction.Transactional; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -20,10 +19,10 @@ @Service @RequiredArgsConstructor -public class MatchingService { +public class AutoMatchingService { private final SseService sseService; - private final ProducerService producerService; + private final AutoMatchingProducer autoMatchingProducer; private final MatchingAlgorithmService matchingAlgorithmService; public SseEmitter handleSubscribe(Long userId) { @@ -62,7 +61,7 @@ private void sendMatchRoomCreatedEvent(Long memberId, .createdAt(LocalDateTime.now()) .build(); - this.producerService.sendMatchRoomCreatedEvent(createdEvent); + this.autoMatchingProducer.sendMatchRoomCreatedEvent(createdEvent); } private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult) { @@ -76,6 +75,6 @@ private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult .joinedAt(LocalDateTime.now()) .build(); - this.producerService.sendMatchMemberJoinedEvent(joinedEvent); + this.autoMatchingProducer.sendMatchMemberJoinedEvent(joinedEvent); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ConsumerListener.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java similarity index 98% rename from src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ConsumerListener.java rename to src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index 799b0c1d..6f82deaa 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ConsumerListener.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -12,7 +12,7 @@ @Slf4j @Service @RequiredArgsConstructor -public class ConsumerListener { +public class AutoMatchingConsumer { private final SseService sseService; diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ProducerService.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java similarity index 98% rename from src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ProducerService.java rename to src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java index 53ce3539..a612cd74 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/ProducerService.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java @@ -13,7 +13,7 @@ @Slf4j @Service @RequiredArgsConstructor -public class ProducerService { +public class AutoMatchingProducer { private final KafkaTemplate matchRoomCreatedEventKafkaTemplate; private final KafkaTemplate matchMemberJoinedEventKafkaTemplate; From 24d0cc36374a89a9b02a14e4da08db04a1dd455d Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:00:34 +0900 Subject: [PATCH 160/770] =?UTF-8?q?refactor:=20MatchingAlgorithmService=20?= =?UTF-8?q?=EB=8A=94=20findRoom=EB=A7=8C=20=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingAlgorithmService.java | 15 --------------- .../service/MockMatchingAlgorithmService.java | 10 ---------- 2 files changed, 25 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java index 611a1a4f..499c78bf 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java @@ -14,19 +14,4 @@ public interface MatchingAlgorithmService { * @return Optional - 매칭 가능한 방 정보가 있으면 값이 있고, 없으면 empty */ Optional findRoom(Long userId, List criteria); - - /** - * 방 생성 처리 (DB에 실제 insert 등) - * @param userId 방을 만들 사용자(방장) - * @param criteria 조건(위치, 키워드 등) - * @return 생성된 방의 ID - */ - Long createRoom(Long userId, List criteria); - - /** - * 방에 참가 처리 - * @param roomId 참가할 방 ID - * @param userId 참가하는 사용자 - */ - void joinRoom(Long roomId, Long userId); } diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index b243844b..b7802961 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -21,14 +21,4 @@ public Optional findRoom(Long userId, List criteria) { } return Optional.empty(); } - - @Override - public Long createRoom(Long userId, List criteria) { - return 1L; - } - - @Override - public void joinRoom(Long roomId, Long userId) { - - } } From 8eca7fb25f3a4931041b10e2ebceeb28604dab5b Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:48:32 +0900 Subject: [PATCH 161/770] =?UTF-8?q?feat:=20MatchingRoomRepository=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/repository/MatchingRoomRepository.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java new file mode 100644 index 00000000..a95e57f1 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.matching.common.repository; + +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MatchingRoomRepository extends JpaRepository { + +} From 991b9b165713295dead9277d196f4599e0ff24dc Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:48:48 +0900 Subject: [PATCH 162/770] =?UTF-8?q?feat:=20MatchingRoomTagInfoRepository?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MatchingRoomTagInfoRepository.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomTagInfoRepository.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomTagInfoRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomTagInfoRepository.java new file mode 100644 index 00000000..12fc4830 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomTagInfoRepository.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.matching.common.repository; + +import com.gachtaxi.domain.matching.common.entity.MatchingRoomTagInfo; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MatchingRoomTagInfoRepository extends JpaRepository { + +} From e335e4420ce2cfd132880a718d0b4f1d7a659704 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:49:28 +0900 Subject: [PATCH 163/770] =?UTF-8?q?feat:=20MemberMatchingRoomChargingInfoR?= =?UTF-8?q?epository=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MemberMatchingRoomChargingInfoRepository.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java new file mode 100644 index 00000000..96fb453b --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.matching.common.repository; + +import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MemberMatchingRoomChargingInfoRepository extends JpaRepository { + +} From 4b5a027ddba7130ece587ddd03e873ceaa68117c Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:49:42 +0900 Subject: [PATCH 164/770] =?UTF-8?q?feat:=20RouteRepository=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/repository/RouteRepository.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java new file mode 100644 index 00000000..617e4e75 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.matching.common.repository; + +import com.gachtaxi.domain.matching.common.entity.Route; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface RouteRepository extends JpaRepository { + +} From 01f47755bfcf734a0344a759f3751a7271d489cb Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:50:14 +0900 Subject: [PATCH 165/770] =?UTF-8?q?feat:=20=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20=EB=B0=8F=20enum=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/entity/MatchingRoom.java | 55 +++++++++++++++++++ .../common/entity/MatchingRoomTagInfo.java | 27 +++++++++ .../MemberMatchingRoomChargingInfo.java | 40 ++++++++++++++ .../domain/matching/common/entity/Route.java | 23 ++++++++ .../entity/enums/MatchingRoomStatus.java | 5 ++ .../common/entity/enums/PaymentStatus.java | 5 ++ 6 files changed, 155 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/enums/PaymentStatus.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java new file mode 100644 index 00000000..6111e51c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -0,0 +1,55 @@ +package com.gachtaxi.domain.matching.common.entity; + +import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "matching_room") +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class MatchingRoom extends BaseEntity { + + @OneToMany(mappedBy = "matchingRoom") + private List matchingRoomTagInfo; + + @Column(name = "capacity", nullable = false, columnDefinition = "INT CHECK (capacity BETWEEN 1 AND 4)") + private Integer capacity; + + // 팀원들 정보 + @OneToMany(mappedBy = "matchingRoom", fetch = FetchType.LAZY) + private List memberMatchingRoomChargingInfo; + + @ManyToOne(cascade = CascadeType.PERSIST, optional = false) + private Members roomMaster; + + @Column(name = "title", nullable = false) + private String title; + + @Column(name = "description", nullable = false) + private String description; + + @ManyToOne(fetch = FetchType.LAZY) + private Route route; + + @Column(name = "total_charge") + private Integer totalCharge; + + @Enumerated(EnumType.STRING) + private MatchingRoomStatus matchingRoomStatus; +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java new file mode 100644 index 00000000..bd21d37e --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java @@ -0,0 +1,27 @@ +package com.gachtaxi.domain.matching.common.entity; + +import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "matching_room_tag_info") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@Builder +public class MatchingRoomTagInfo extends BaseEntity { + + @ManyToOne + private MatchingRoom matchingRoom; + + @Enumerated(EnumType.STRING) + private Tags tags; +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java new file mode 100644 index 00000000..3c2a8a0e --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java @@ -0,0 +1,40 @@ +package com.gachtaxi.domain.matching.common.entity; + +import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +@Entity +@Table( + name = "member_matching_room_charging_info", + uniqueConstraints = { + @UniqueConstraint(columnNames = {"members_id", "matching_room_id"}) + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class MemberMatchingRoomChargingInfo extends BaseEntity { + + @ManyToOne(fetch = FetchType.LAZY) + private Members members; + + @ManyToOne(fetch = FetchType.LAZY) + private MatchingRoom matchingRoom; + + @Column(name = "charge") + private Integer charge; + + @Enumerated(EnumType.STRING) + private PaymentStatus paymentStatus = PaymentStatus.NOT_PAYED; +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java new file mode 100644 index 00000000..bb148948 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java @@ -0,0 +1,23 @@ +package com.gachtaxi.domain.matching.common.entity; + +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "route") +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class Route extends BaseEntity { + + private String startLocationCoordinate; + private String startLocationName; + + private String endLocationCoordinate; + private String endLocationName; +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java new file mode 100644 index 00000000..ddfcd386 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.matching.common.entity.enums; + +public enum MatchingRoomStatus { + PROCESS, COMPLETE, CANCELED, ACTIVE +} \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/PaymentStatus.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/PaymentStatus.java new file mode 100644 index 00000000..c754bfb3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/PaymentStatus.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.matching.common.entity.enums; + +public enum PaymentStatus { + PAYED, NOT_PAYED, FAILED +} From c5e44c7a5e0b54585ae13b95640ec135a0e8d132 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:50:31 +0900 Subject: [PATCH 166/770] =?UTF-8?q?feat:=20NoSuchMemberException=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/exception/ErrorMessage.java | 4 +++- .../members/exception/NoSuchMemberException.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/NoSuchMemberException.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index 7d6f825f..66e979c4 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -7,7 +7,9 @@ @AllArgsConstructor public enum ErrorMessage { - DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."); + DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), + + NO_SUCH_MEMBER("해당 멤버가 존재하지 않습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/exception/NoSuchMemberException.java b/src/main/java/com/gachtaxi/domain/members/exception/NoSuchMemberException.java new file mode 100644 index 00000000..e40e034a --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/NoSuchMemberException.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.members.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +public class NoSuchMemberException extends BaseException { + + public NoSuchMemberException() { + super(HttpStatus.NOT_FOUND, ErrorMessage.NO_SUCH_MEMBER.getMessage()); + } +} From 0919e22563989555162a7406ef7337b9b022f3b2 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:50:57 +0900 Subject: [PATCH 167/770] =?UTF-8?q?refactor:=20=EC=9E=90=EB=8F=99=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=9A=94=EC=B2=AD=20DTO=EC=97=90=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=ED=95=84=EB=93=9C=EB=93=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dto/request/AutoMatchingPostRequest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java index 0dd343b3..df12b641 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java @@ -5,8 +5,14 @@ public record AutoMatchingPostRequest( String startPoint, + String startName, String destinationPoint, - List criteria + String destinationName, + List criteria, + Integer maxCapacity, + String title, + String description, + Integer totalCharge ) { public List getCriteria() { From a21fbe1d2fa23e06beb7a7a9c2b6a309aa43bffe Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:51:11 +0900 Subject: [PATCH 168/770] =?UTF-8?q?refactor:=20=EB=B0=A9=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20DTO=EC=97=90=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=ED=95=84=EB=93=9C=EB=93=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/kafka_topic/MatchRoomCreatedEvent.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java index dd701967..b66ba08e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java @@ -1,19 +1,26 @@ package com.gachtaxi.domain.matching.event.dto.kafka_topic; import com.fasterxml.jackson.annotation.JsonFormat; +import com.gachtaxi.domain.matching.common.entity.enums.Tags; import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; @Builder public record MatchRoomCreatedEvent( - Long roomId, Long hostMemberId, + Integer maxCapacity, + String title, + String description, + Integer totalCharge, + String startPoint, + String startName, + String destinationPoint, + String destinationName, + List criteria, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime createdAt ) { - public static MatchRoomCreatedEvent of(Long roomId, Long memberId) { - return new MatchRoomCreatedEvent(roomId, memberId, LocalDateTime.now()); - } } From 23dd6b4941cb8c1bb6bcfffd9c92fc766cd68d55 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:52:27 +0900 Subject: [PATCH 169/770] =?UTF-8?q?feat:=20MatchingRoomService=20=EC=97=90?= =?UTF-8?q?=20MatchingRoom=20=EC=A0=80=EC=9E=A5=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java new file mode 100644 index 00000000..3bb1a59f --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -0,0 +1,76 @@ +package com.gachtaxi.domain.matching.common.service; + +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; +import com.gachtaxi.domain.matching.common.entity.MatchingRoomTagInfo; +import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import com.gachtaxi.domain.matching.common.entity.Route; +import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; +import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; +import com.gachtaxi.domain.matching.common.repository.MatchingRoomTagInfoRepository; +import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; +import com.gachtaxi.domain.matching.common.repository.RouteRepository; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.service.MemberService; +import jakarta.transaction.Transactional; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +@Transactional +public class MatchingRoomService { + + // service + private final MemberService memberService; + + // repository + private final MatchingRoomRepository matchingRoomRepository; + private final MatchingRoomTagInfoRepository matchingRoomTagInfoRepository; + private final RouteRepository routeRepository; + private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; + + public MatchingRoom save(MatchRoomCreatedEvent matchRoomCreatedEvent) { + Members members = this.memberService.findById(matchRoomCreatedEvent.hostMemberId()); + + Route route = this.saveRoute(matchRoomCreatedEvent); + + MatchingRoom matchingRoom = MatchingRoom.builder() + .capacity(matchRoomCreatedEvent.maxCapacity()) + .roomMaster(members) + .title(matchRoomCreatedEvent.title()) + .description(matchRoomCreatedEvent.description()) + .route(route) + .totalCharge(matchRoomCreatedEvent.totalCharge()) + .matchingRoomStatus(MatchingRoomStatus.ACTIVE) + .build(); + + this.saveMatchingRoomTagInfo(matchingRoom, matchRoomCreatedEvent.criteria()); + + return this.matchingRoomRepository.save(matchingRoom); + } + + public Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { + Route route = Route.builder() + .startLocationCoordinate(matchRoomCreatedEvent.startPoint()) + .startLocationName(matchRoomCreatedEvent.startName()) + .endLocationCoordinate(matchRoomCreatedEvent.destinationPoint()) + .endLocationName(matchRoomCreatedEvent.destinationName()) + .build(); + + return this.routeRepository.save(route); + } + + private void saveMatchingRoomTagInfo(MatchingRoom matchingRoom, List tags) { + for (Tags tag : tags) { + MatchingRoomTagInfo matchingRoomTagInfo = MatchingRoomTagInfo.builder() + .matchingRoom(matchingRoom) + .tags(tag) + .build(); + + this.matchingRoomTagInfoRepository.save(matchingRoomTagInfo); + } + } +} From b27c9ce742c2908f8395c0edb3dc5cea50858676 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:52:45 +0900 Subject: [PATCH 170/770] =?UTF-8?q?feat:=20MemberService=EC=97=90=20findBy?= =?UTF-8?q?Id=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/MemberService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 5de2958c..9c2c7f0a 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; +import com.gachtaxi.domain.members.exception.NoSuchMemberException; import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.global.auth.jwt.service.JwtService; import jakarta.servlet.http.HttpServletResponse; @@ -41,4 +42,8 @@ private void checkDuplicatedStudentNumber(UserSignUpRequestDto dto) { throw new DuplicatedStudentNumberException(); }); } + + public Members findById(Long id) { + return memberRepository.findById(id).orElseThrow(NoSuchMemberException::new); + } } From c4d9f3bab92c2142bda578ba4572bcf82966580e Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 00:53:09 +0900 Subject: [PATCH 171/770] =?UTF-8?q?feat:=20AutoMatchingService=EC=97=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=EB=90=9C=20DTO=20=ED=95=84=EB=93=9C=EB=93=A4?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/AutoMatchingService.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 856b5c40..8cfe55e1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -52,12 +52,16 @@ public AutoMatchingPostResponse handlerAutoRequestMatching( private void sendMatchRoomCreatedEvent(Long memberId, AutoMatchingPostRequest autoMatchingPostRequest) { - Long newRoomId = this.matchingAlgorithmService.createRoom(memberId, - autoMatchingPostRequest.getCriteria()); - MatchRoomCreatedEvent createdEvent = MatchRoomCreatedEvent.builder() - .roomId(newRoomId) .hostMemberId(memberId) + .startPoint(autoMatchingPostRequest.startPoint()) + .startName(autoMatchingPostRequest.startName()) + .destinationPoint(autoMatchingPostRequest.destinationPoint()) + .destinationName(autoMatchingPostRequest.destinationName()) + .maxCapacity(autoMatchingPostRequest.maxCapacity()) + .title(autoMatchingPostRequest.title()) + .description(autoMatchingPostRequest.description()) + .totalCharge(autoMatchingPostRequest.totalCharge()) .createdAt(LocalDateTime.now()) .build(); @@ -67,8 +71,6 @@ private void sendMatchRoomCreatedEvent(Long memberId, private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult) { Long roomId = roomResult.roomId(); - this.matchingAlgorithmService.joinRoom(roomId, memberId); - MatchMemberJoinedEvent joinedEvent = MatchMemberJoinedEvent.builder() .roomId(roomId) .memberId(memberId) From 9fe9b44d1f9746247b63c7b9a3ec499ea4df36d4 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 7 Jan 2025 01:25:41 +0900 Subject: [PATCH 172/770] =?UTF-8?q?hotfix:=20=EB=8F=84=EC=BB=A4=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=20=EC=8B=A4=ED=96=89?= =?UTF-8?q?=EC=8B=9C=20=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 16f686b1..17d5cfc1 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -74,7 +74,7 @@ jobs: if [ -n "$IS_BLUE_ON" ]; then echo "** ${GREEN_PORT} 포트에서 GREEN 컨테이너 실행" sudo docker run --name $GREEN_NAME -d -p $GREEN_PORT:$GREEN_PORT \ - --env-file ./gachtaxi-dev.env -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi + --env-file ./gachtaxi-dev.env --network gachtaxi -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi BEFORE_NAME=$BLUE_NAME AFTER_NAME=$GREEN_NAME BEFORE_PORT=$BLUE_PORT @@ -82,7 +82,7 @@ jobs: else echo "** ${BLUE_PORT} 포트에서 BLUE 컨테이너 실행" sudo docker run --name $BLUE_NAME -d -p $BLUE_PORT:$BLUE_PORT \ - --env-file ./gachtaxi-dev.env -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi + --env-file ./gachtaxi-dev.env --network gachtaxi -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi BEFORE_NAME=$GREEN_NAME AFTER_NAME=$BLUE_NAME BEFORE_PORT=$GREEN_PORT @@ -98,4 +98,4 @@ jobs: # 사용하지 않는 이미지 정리 echo "** 사용하지 않는 Docker 이미지 정리" - sudo docker image prune -a -f \ No newline at end of file + sudo docker image prune -f \ No newline at end of file From 3c013a8e9b8570d89856feedfe5aa8ffad168644 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 01:37:35 +0900 Subject: [PATCH 173/770] =?UTF-8?q?feat:=20NotActiveMatchingRoom,=20NoSuch?= =?UTF-8?q?MatchingRoom=20=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/exception/ErrorMessage.java | 14 ++++++++++++++ .../exception/NoSuchMatchingRoomException.java | 11 +++++++++++ .../exception/NotActiveMatchingRoomException.java | 11 +++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchMatchingRoomException.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java new file mode 100644 index 00000000..f7569666 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -0,0 +1,14 @@ +package com.gachtaxi.domain.matching.common.exception; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum ErrorMessage { + + NO_SUCH_MATCHING_ROOM("해당 매칭 방이 존재하지 않습니다."), + NOT_ACTIVE_MATCHING_ROOM("열린 매칭 방이 아닙니다."); + + private final String message; +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchMatchingRoomException.java new file mode 100644 index 00000000..997d6d41 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchMatchingRoomException.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.matching.common.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +public class NoSuchMatchingRoomException extends BaseException { + + public NoSuchMatchingRoomException() { + super(HttpStatus.NOT_FOUND, ErrorMessage.NO_SUCH_MATCHING_ROOM.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java new file mode 100644 index 00000000..88ded883 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.matching.common.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +public class NotActiveMatchingRoomException extends BaseException { + + public NotActiveMatchingRoomException() { + super(HttpStatus.BAD_REQUEST, ErrorMessage.NOT_ACTIVE_MATCHING_ROOM.getMessage()); + } +} From a76f562fc67ec296f0b3a61b5b75f427c9ce371d Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 01:38:33 +0900 Subject: [PATCH 174/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=83=9D=EC=84=B1=20=EC=9A=94=EC=B2=AD=20DTO?= =?UTF-8?q?=EC=97=90=20=EC=98=88=EC=83=81=20=EC=B4=9D=20=EA=B8=88=EC=95=A1?= =?UTF-8?q?=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/AutoMatchingPostRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java index df12b641..f8323f5d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java @@ -12,7 +12,7 @@ public record AutoMatchingPostRequest( Integer maxCapacity, String title, String description, - Integer totalCharge + Integer expectedTotalCharge ) { public List getCriteria() { From d504eb55744260d81aa2da023901ccceb74023b1 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 7 Jan 2025 01:58:06 +0900 Subject: [PATCH 175/770] =?UTF-8?q?hotfix:=20=EB=8F=84=EC=BB=A4=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=EC=8B=9C=20dev=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 17d5cfc1..8d1845de 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -73,16 +73,16 @@ jobs: if [ -n "$IS_BLUE_ON" ]; then echo "** ${GREEN_PORT} 포트에서 GREEN 컨테이너 실행" - sudo docker run --name $GREEN_NAME -d -p $GREEN_PORT:$GREEN_PORT \ - --env-file ./gachtaxi-dev.env --network gachtaxi -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi + sudo docker run --platform linux/arm64 --name $GREEN_NAME -d -p $GREEN_PORT:$GREEN_PORT \ + --env-file ./gachtaxi-dev.env --network gachtaxi -e SPRING_PROFILES_ACTIVE=dev -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi BEFORE_NAME=$BLUE_NAME AFTER_NAME=$GREEN_NAME BEFORE_PORT=$BLUE_PORT AFTER_PORT=$GREEN_PORT else echo "** ${BLUE_PORT} 포트에서 BLUE 컨테이너 실행" - sudo docker run --name $BLUE_NAME -d -p $BLUE_PORT:$BLUE_PORT \ - --env-file ./gachtaxi-dev.env --network gachtaxi -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi + sudo docker run --platform linux/arm64 --name $BLUE_NAME -d -p $BLUE_PORT:$BLUE_PORT \ + --env-file ./gachtaxi-dev.env --network gachtaxi -e SPRING_PROFILES_ACTIVE=dev -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi BEFORE_NAME=$GREEN_NAME AFTER_NAME=$BLUE_NAME BEFORE_PORT=$GREEN_PORT From 45a39a491466d8c1463d6bb39eaf16699fce0eaa Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 7 Jan 2025 02:11:43 +0900 Subject: [PATCH 176/770] =?UTF-8?q?hotfix:=20=EB=A0=88=EB=94=94=EC=8A=A4?= =?UTF-8?q?=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=A3=BC=EC=84=9D?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 6e51ab5c..4e1f926c 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -11,13 +11,13 @@ spring: dialect: org.hibernate.dialect.MySQLDialect hibernate: ddl-auto: update -# data: -# redis: -# host: ${REDIS_HOST} -# port: ${REDIS_PORT} -# password: ${REDIS_PASSWORD} -# mongodb: -# uri: ${MONGODB_URI} + data: + redis: + host: ${REDIS_HOST} + port: ${REDIS_PORT} + password: ${REDIS_PASSWORD} + mongodb: + uri: ${MONGODB_URI} logging: level: From 80041766858db69d328c2864cb1e2b6596f91106 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 7 Jan 2025 02:50:03 +0900 Subject: [PATCH 177/770] =?UTF-8?q?fix:=20JwtUserDetails=20-=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=20=EC=A4=91=EB=B3=B5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java index 6a733596..9fe10a04 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/user/JwtUserDetails.java @@ -12,12 +12,10 @@ public class JwtUserDetails extends User { private final Long id; - private final String email; public JwtUserDetails(Long id, String email, List authorities) { super(email, "", authorities); this.id = id; - this.email = email; } public static JwtUserDetails of(Long id, String email, String role) { From e5ebaf39b50f143409188e422208a84fa5b04aab Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 7 Jan 2025 03:28:04 +0900 Subject: [PATCH 178/770] =?UTF-8?q?fix:=20getCookie()=EB=A1=9C=20=EC=B1=85?= =?UTF-8?q?=EC=9E=84=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/service/JwtService.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index c20e1c49..2eab7b20 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -58,11 +58,7 @@ public JwtTokenDto reissueJwtToken(HttpServletRequest request) { * */ private String extractRefreshToken(HttpServletRequest request){ - Cookie[] cookies = request.getCookies(); - - if (cookies == null) { - throw new CookieNotFoundException(); - } + Cookie[] cookies = getCookie(request); return Arrays.stream(cookies) .filter(cookie -> REFRESH_TOKEN_SUBJECT.equals(cookie.getName())) @@ -71,6 +67,15 @@ private String extractRefreshToken(HttpServletRequest request){ .orElseThrow(TokenInvalidException::new); } + private static Cookie[] getCookie(HttpServletRequest request) { + Cookie[] cookies = request.getCookies(); + + if (cookies == null) { + throw new CookieNotFoundException(); + } + return cookies; + } + // JwtToken 생성 + Redis 저장 private JwtTokenDto generateJwtToken(Long userId, String email, String role) { String accessToken = jwtProvider.generateAccessToken(userId, email, role); From b637fb73030926370c0e9cf8cf3868fde8bfee4d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 7 Jan 2025 10:18:24 +0900 Subject: [PATCH 179/770] =?UTF-8?q?refactor:=20=EC=88=98=EC=A0=95=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/interceptor/strategy/ChatStrategyHandler.java | 3 ++- .../chat/interceptor/strategy/StompConnectStrategy.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java index f8ad71b9..d0f0cd98 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java @@ -14,6 +14,7 @@ public class ChatStrategyHandler { private final List stompCommandStrategies; + private final DefaultCommandStrategy defaultCommandStrategy; public Message handle(Message message, StompHeaderAccessor accessor, MessageChannel channel) { StompCommand command = accessor.getCommand(); @@ -21,7 +22,7 @@ public Message handle(Message message, StompHeaderAccessor accessor, Messa return stompCommandStrategies.stream() .filter(strategy -> strategy.supports(command)) .findFirst() - .orElse(new DefaultCommandStrategy()) + .orElse(defaultCommandStrategy) .preSend(message, accessor, channel); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java index 2f0e5cb2..e63da8d8 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java @@ -16,7 +16,7 @@ public class StompConnectStrategy implements StompCommandStrategy{ private static final String TOKEN_PREFIX = "Bearer "; - private static final String USER_ID_KEY = "USER_ID"; + private static final String CHAT_USER_ID = "CHAT_USER_ID"; private final JwtExtractor jwtExtractor; @@ -38,7 +38,7 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess */ Long userId = jwtExtractor.getId(jwtToken); - accessor.getSessionAttributes().put(USER_ID_KEY, userId); + accessor.getSessionAttributes().put(CHAT_USER_ID, userId); return message; } From 1961fb6c0f4b88fc6131af2c2ddfe70b4f3ebb88 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:15:07 +0900 Subject: [PATCH 180/770] =?UTF-8?q?docs:=20=EB=A7=A4=EC=B9=AD=20=EC=95=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=EC=A6=98=EC=97=90=EC=84=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=B4=EC=95=BC=ED=95=A0=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/algorithm/service/MatchingAlgorithmService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java index 499c78bf..a6ccd586 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java @@ -9,6 +9,7 @@ public interface MatchingAlgorithmService { /** * 방을 찾는 메서드 + * 이미 방에 들어가있는 멤버가 다시 요청했을 때 Optional.empty()를 반환하도록 로직을 구성해야함 * @param userId 방에 들어가려는 사용자 ID * @param criteria 방 검색에 필요한 기타 조건 (ex. 위치, 키워드 등) * @return Optional - 매칭 가능한 방 정보가 있으면 값이 있고, 없으면 empty From b6375d7c8b6b3e9f81bc650f6b2052603e81e79a Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:15:22 +0900 Subject: [PATCH 181/770] =?UTF-8?q?refactor:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=B4=20mock=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MockMatchingAlgorithmService.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index b7802961..6e2c5896 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -1,7 +1,9 @@ package com.gachtaxi.domain.matching.algorithm.service; import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; @@ -11,13 +13,18 @@ @RequiredArgsConstructor public class MockMatchingAlgorithmService implements MatchingAlgorithmService { + private final MatchingRoomRepository matchingRoomRepository; @Override public Optional findRoom(Long userId, List criteria) { - if (userId == 1L) { - return Optional.of(FindRoomResult.builder() - .roomId(1L) - .build()); + List matchingRoomList = this.matchingRoomRepository.findAll(); + if (!matchingRoomList.isEmpty()) { + MatchingRoom matchingRoom = matchingRoomList.get(0); + return Optional.of( + FindRoomResult.builder() + .roomId(matchingRoom.getId()) + .maxCapacity(matchingRoom.getCapacity()) + .build()); } return Optional.empty(); } From 305cf2cccfd991ad5947509c8f098a0dce73b750 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:15:47 +0900 Subject: [PATCH 182/770] =?UTF-8?q?fix:=20SSE=20=EB=A5=BC=20=EC=A0=95?= =?UTF-8?q?=EC=83=81=20=EC=9E=91=EB=8F=99=ED=95=98=EA=B2=8C=20=ED=95=98?= =?UTF-8?q?=EA=B8=B0=EC=9C=84=ED=95=B4=EC=84=9C=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=ED=98=95=EC=8B=9D=20=EB=B0=8F=20=EB=A6=AC=ED=84=B4=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/AutoMatchingController.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java index 58e57c54..cd32b3cd 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java @@ -6,6 +6,7 @@ import com.gachtaxi.global.common.response.ApiResponse; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -21,15 +22,12 @@ public class AutoMatchingController { private final AutoMatchingService autoMatchingService; - @GetMapping("/subscribe") - public ApiResponse subscribeSse(@RequestParam Long memberId) { + @GetMapping(value = "/subscribe", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public SseEmitter subscribeSse(@RequestParam Long memberId) { // TODO: 인가 로직 완성되면 해당 멤버의 아이디를 가져오도록 변경 // Long memberId = 1L; - return ApiResponse.response( - HttpStatus.OK, - ResponseMessage.SUBSCRIBE_SUCCESS.getMessage(), - this.autoMatchingService.handleSubscribe(memberId) - ); + + return this.autoMatchingService.handleSubscribe(memberId); } @PostMapping("/request") From 617fda192bc87ad3837e4293d9f8b1b6d45b01fc Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:16:48 +0900 Subject: [PATCH 183/770] =?UTF-8?q?feat:=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=EB=93=A4=EC=97=90=20Getter,=20Setter,=20=ED=8E=B8=EC=9D=98=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoom.java | 7 +++++++ .../common/entity/MemberMatchingRoomChargingInfo.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 6111e51c..2f51ceb6 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -16,6 +16,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Getter; import lombok.NoArgsConstructor; @Entity @@ -29,6 +30,7 @@ public class MatchingRoom extends BaseEntity { private List matchingRoomTagInfo; @Column(name = "capacity", nullable = false, columnDefinition = "INT CHECK (capacity BETWEEN 1 AND 4)") + @Getter private Integer capacity; // 팀원들 정보 @@ -48,8 +50,13 @@ public class MatchingRoom extends BaseEntity { private Route route; @Column(name = "total_charge") + @Getter private Integer totalCharge; @Enumerated(EnumType.STRING) private MatchingRoomStatus matchingRoomStatus; + + public boolean isActiveMatchingRoom() { + return this.matchingRoomStatus == MatchingRoomStatus.ACTIVE; + } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java index 3c2a8a0e..aa4e11b3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java @@ -13,7 +13,9 @@ import jakarta.persistence.UniqueConstraint; import lombok.AccessLevel; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.NoArgsConstructor; +import lombok.Setter; @Entity @Table( @@ -24,6 +26,7 @@ ) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) +@Builder public class MemberMatchingRoomChargingInfo extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) @@ -33,6 +36,7 @@ public class MemberMatchingRoomChargingInfo extends BaseEntity { private MatchingRoom matchingRoom; @Column(name = "charge") + @Setter private Integer charge; @Enumerated(EnumType.STRING) From 8a78ac6fc7339bf5b8532a7cef64ec2e6b475493 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:17:13 +0900 Subject: [PATCH 184/770] =?UTF-8?q?refactor:=20=EC=9E=90=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20DTO=EC=97=90=EC=84=9C=20title,=20capacity,=20descri?= =?UTF-8?q?ption=20=EC=82=AD=EC=A0=9C=20->=20=EC=84=9C=EB=B9=84=EC=8A=A4?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=EC=97=90=EC=84=9C=20=EC=95=8C=EC=95=84?= =?UTF-8?q?=EC=84=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/AutoMatchingPostRequest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java index f8323f5d..505ad488 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java @@ -9,9 +9,6 @@ public record AutoMatchingPostRequest( String destinationPoint, String destinationName, List criteria, - Integer maxCapacity, - String title, - String description, Integer expectedTotalCharge ) { From eaff7d787e72122adbe9e8585dfa9027c02ef607 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:17:40 +0900 Subject: [PATCH 185/770] =?UTF-8?q?feat:=20MemberMatchingRoomChargingInfoR?= =?UTF-8?q?epository.findbyMatchingRoom(MatchingRoom)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MemberMatchingRoomChargingInfoRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java index 96fb453b..d447c308 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java @@ -1,10 +1,13 @@ package com.gachtaxi.domain.matching.common.repository; +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface MemberMatchingRoomChargingInfoRepository extends JpaRepository { + List findByMatchingRoom(MatchingRoom matchingRoom); } From e32b84bc60b67a34d4acd9813c73bfea8afdb836 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:18:15 +0900 Subject: [PATCH 186/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=9A=94=EC=B2=AD=20DTO=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EB=A7=A4=EC=B9=AD=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20DTO=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/AutoMatchingService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 8cfe55e1..5a18d81c 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -13,6 +13,7 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Optional; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; @@ -21,6 +22,9 @@ @RequiredArgsConstructor public class AutoMatchingService { + private static final int AUTO_MAX_CAPACITY = 4; + private static final String AUTO_DESCRIPTION = "AUTO_MATCHING"; + private final SseService sseService; private final AutoMatchingProducer autoMatchingProducer; private final MatchingAlgorithmService matchingAlgorithmService; @@ -58,11 +62,11 @@ private void sendMatchRoomCreatedEvent(Long memberId, .startName(autoMatchingPostRequest.startName()) .destinationPoint(autoMatchingPostRequest.destinationPoint()) .destinationName(autoMatchingPostRequest.destinationName()) - .maxCapacity(autoMatchingPostRequest.maxCapacity()) - .title(autoMatchingPostRequest.title()) - .description(autoMatchingPostRequest.description()) - .totalCharge(autoMatchingPostRequest.totalCharge()) - .createdAt(LocalDateTime.now()) + .maxCapacity(AUTO_MAX_CAPACITY) + .title(UUID.randomUUID().toString()) + .description(AUTO_DESCRIPTION) + .expectedTotalCharge(autoMatchingPostRequest.expectedTotalCharge()) + .criteria(autoMatchingPostRequest.getCriteria()) .build(); this.autoMatchingProducer.sendMatchRoomCreatedEvent(createdEvent); From 124a65c8e9e295eed89cbd69447a2ba788750f62 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:18:40 +0900 Subject: [PATCH 187/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=EC=97=90=20=EC=B6=94=EA=B0=80=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=EA=B0=80=20=EB=93=A4=EC=96=B4=EC=98=AC=EB=95=8C=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89=ED=95=A0=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 3bb1a59f..1eab6c64 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -6,10 +6,13 @@ import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.NotActiveMatchingRoomException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.matching.common.repository.MatchingRoomTagInfoRepository; import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; import com.gachtaxi.domain.matching.common.repository.RouteRepository; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; @@ -43,16 +46,17 @@ public MatchingRoom save(MatchRoomCreatedEvent matchRoomCreatedEvent) { .title(matchRoomCreatedEvent.title()) .description(matchRoomCreatedEvent.description()) .route(route) - .totalCharge(matchRoomCreatedEvent.totalCharge()) + .totalCharge(matchRoomCreatedEvent.expectedTotalCharge()) .matchingRoomStatus(MatchingRoomStatus.ACTIVE) .build(); this.saveMatchingRoomTagInfo(matchingRoom, matchRoomCreatedEvent.criteria()); + this.saveHostMemberChargingInfo(matchingRoom, members); return this.matchingRoomRepository.save(matchingRoom); } - public Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { + private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { Route route = Route.builder() .startLocationCoordinate(matchRoomCreatedEvent.startPoint()) .startLocationName(matchRoomCreatedEvent.startName()) @@ -73,4 +77,48 @@ private void saveMatchingRoomTagInfo(MatchingRoom matchingRoom, List tags) this.matchingRoomTagInfoRepository.save(matchingRoomTagInfo); } } + + private void saveHostMemberChargingInfo(MatchingRoom matchingRoom, Members members) { + MemberMatchingRoomChargingInfo matchingRoomChargingInfo = MemberMatchingRoomChargingInfo.builder() + .matchingRoom(matchingRoom) + .members(members) + .charge(matchingRoom.getTotalCharge()) + .build(); + + this.memberMatchingRoomChargingInfoRepository.save(matchingRoomChargingInfo); + } + + public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEvent) { + Members members = this.memberService.findById(matchMemberJoinedEvent.memberId()); + MatchingRoom matchingRoom = this.matchingRoomRepository.findById( + matchMemberJoinedEvent.roomId()).orElseThrow( + NoSuchMatchingRoomException::new); + + if (!matchingRoom.isActiveMatchingRoom()) { + throw new NotActiveMatchingRoomException(); + } + + List existMembers = this.memberMatchingRoomChargingInfoRepository.findByMatchingRoom( + matchingRoom); + + // TODO: 딱 떨어지지 않는 금액은 어떻게 해야할지? + int distributedCharge = matchingRoom.getTotalCharge() / (existMembers.size() + 1); + + this.memberMatchingRoomChargingInfoRepository.save( + MemberMatchingRoomChargingInfo.builder() + .matchingRoom(matchingRoom) + .members(members) + .charge(distributedCharge) + .build() + ); + + this.updateExistMembersCharge(existMembers, distributedCharge); + } + + private void updateExistMembersCharge(List existMembers, int charge) { + for (MemberMatchingRoomChargingInfo memberMatchingRoomChargingInfo : existMembers) { + memberMatchingRoomChargingInfo.setCharge(charge); + } + this.memberMatchingRoomChargingInfoRepository.saveAll(existMembers); + } } From 2f7e9a8d2cbcc5043ddb9e7d085b9d82a958e611 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:19:01 +0900 Subject: [PATCH 188/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EB=B0=A9=20=EC=83=9D=EC=84=B1=20=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=EC=9D=98=20charge=20->=20expectedCharge=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java index b66ba08e..e1ca21c8 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java @@ -12,12 +12,12 @@ public record MatchRoomCreatedEvent( Integer maxCapacity, String title, String description, - Integer totalCharge, String startPoint, String startName, String destinationPoint, String destinationName, List criteria, + Integer expectedTotalCharge, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime createdAt From d3bda624f32eae2369dacc63b0cac34394add69c Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:19:26 +0900 Subject: [PATCH 189/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=83=9D=EC=84=B1=EC=9D=80=20=EB=B0=A9=20id?= =?UTF-8?q?=EB=A5=BC=20=EB=B0=9B=EC=A7=80=20=EC=95=8A=EC=9C=BC=EB=AF=80?= =?UTF-8?q?=EB=A1=9C=20event=20key=EB=A1=9C=20title=EC=9D=84=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/event/service/kafka/AutoMatchingProducer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java index a612cd74..406b9d37 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java @@ -28,7 +28,7 @@ public class AutoMatchingProducer { * 방 생성 이벤트를 발행 */ public void sendMatchRoomCreatedEvent(MatchRoomCreatedEvent matchRoomCreatedEvent) { - String key = String.valueOf(matchRoomCreatedEvent.roomId()); + String key = matchRoomCreatedEvent.title(); CompletableFuture future = this.matchRoomCreatedEventKafkaTemplate.send(matchRoomCreatedTopic, key, matchRoomCreatedEvent); From e903bf0d121477b2c017deb14b16b87912829308 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:19:54 +0900 Subject: [PATCH 190/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EB=B0=A9=20=EC=83=9D=EC=84=B1,=20=EB=B0=A9?= =?UTF-8?q?=EC=97=90=20=EB=A9=A4=EB=B2=84=20=EC=B6=94=EA=B0=80=20consumer?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/event/service/kafka/AutoMatchingConsumer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index 6f82deaa..9f041594 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.matching.event.service.kafka; +import com.gachtaxi.domain.matching.common.service.MatchingRoomService; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.matching.event.service.sse.SseService; @@ -15,6 +16,7 @@ public class AutoMatchingConsumer { private final SseService sseService; + private final MatchingRoomService matchingRoomService; /** * 방 생성 이벤트 구독 @@ -27,7 +29,7 @@ public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) try { log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event); - // TODO: 매칭 방 생성 후 save + this.matchingRoomService.save(event); this.sseService.sendToClient(event.hostMemberId(), "MATCH_ROOM_CREATED", event); @@ -48,7 +50,7 @@ public void onMatchMemberJoined(MatchMemberJoinedEvent event, Acknowledgment ack try { log.info("[KAFKA CONSUMER] Received MatchMemberJoinedEvent: {}", event); - // TODO: 매칭 방 멤버 참가 후 DB 상태 업데이트 + this.matchingRoomService.joinMemberToMatchingRoom(event); this.sseService.sendToClient(event.memberId(), "MATCH_MEMBER_JOINED", event); this.sseService.broadcast("MATCH_MEMBER_JOINED", event); From 94e5a6047c28f1fdb2b7953a314c1c01dbc479e7 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 14:46:26 +0900 Subject: [PATCH 191/770] =?UTF-8?q?refactor:=20=EC=9E=90=EB=8F=99=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20?= =?UTF-8?q?=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91,=20=EB=AA=A9=EC=A0=81=EC=A7=80=20=EC=A2=8C=ED=91=9C?= =?UTF-8?q?=EB=A5=BC=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/algorithm/dto/FindRoomResult.java | 1 - .../algorithm/service/MatchingAlgorithmService.java | 6 ++++-- .../algorithm/service/MockMatchingAlgorithmService.java | 2 +- .../domain/matching/common/service/AutoMatchingService.java | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java index 6d61fd2d..3d059f14 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java @@ -5,7 +5,6 @@ @Builder public record FindRoomResult( Long roomId, -// String roomType, Integer currentMembers, Integer maxCapacity ) { diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java index a6ccd586..778256e6 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java @@ -11,8 +11,10 @@ public interface MatchingAlgorithmService { * 방을 찾는 메서드 * 이미 방에 들어가있는 멤버가 다시 요청했을 때 Optional.empty()를 반환하도록 로직을 구성해야함 * @param userId 방에 들어가려는 사용자 ID - * @param criteria 방 검색에 필요한 기타 조건 (ex. 위치, 키워드 등) + * @param startPoint 매칭 시작 지점 좌표 + * @param destinationPoint 도착지 좌표 + * @param criteria 방 검색에 필요한 기타 조건 (태그 등) * @return Optional - 매칭 가능한 방 정보가 있으면 값이 있고, 없으면 empty */ - Optional findRoom(Long userId, List criteria); + Optional findRoom(Long userId, String startPoint, String destinationPoint, List criteria); } diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 6e2c5896..655d629d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -16,7 +16,7 @@ public class MockMatchingAlgorithmService implements MatchingAlgorithmService { private final MatchingRoomRepository matchingRoomRepository; @Override - public Optional findRoom(Long userId, List criteria) { + public Optional findRoom(Long userId, String startPoint, String destinationPoint, List criteria) { List matchingRoomList = this.matchingRoomRepository.findAll(); if (!matchingRoomList.isEmpty()) { MatchingRoom matchingRoom = matchingRoomList.get(0); diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 5a18d81c..2428f12f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -43,7 +43,8 @@ public AutoMatchingPostResponse handlerAutoRequestMatching( ) { List criteria = autoMatchingPostRequest.getCriteria(); Optional optionalRoom = - this.matchingAlgorithmService.findRoom(memberId, criteria); + this.matchingAlgorithmService.findRoom(memberId, autoMatchingPostRequest.startPoint(), + autoMatchingPostRequest.destinationPoint(), criteria); optionalRoom .ifPresentOrElse( From e19b6cf656cc8ef51d11fbc87568ea9e2798cdd9 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 7 Jan 2025 18:10:21 +0900 Subject: [PATCH 192/770] =?UTF-8?q?HOTFIX:=20=EB=A0=88=EB=94=94=EC=8A=A4?= =?UTF-8?q?=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/config/RedisConfig.java | 6 +++--- src/main/resources/application-dev.yml | 9 +++++---- src/main/resources/application-local.yml | 9 +++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index ff852595..c7692cd0 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -23,13 +23,13 @@ public class RedisConfig { public static final String WILD_CARD = "*"; - @Value("${spring.data.redis.host}") + @Value("${redis.host}") private String host; - @Value("${spring.data.redis.port}") + @Value("${redis.port}") private int port; - @Value("${spring.data.redis.password}") + @Value("${redis.password}") private String password; @Value("${chat.topic}") diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 4e1f926c..74275956 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -12,13 +12,14 @@ spring: hibernate: ddl-auto: update data: - redis: - host: ${REDIS_HOST} - port: ${REDIS_PORT} - password: ${REDIS_PASSWORD} mongodb: uri: ${MONGODB_URI} +redis: + host: ${REDIS_HOST} + port: ${REDIS_PORT} + password: ${REDIS_PASSWORD} + logging: level: org.springframework.messaging: debug diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 195b4039..d8cc3f6a 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -12,13 +12,14 @@ spring: hibernate: ddl-auto: update data: - redis: - host: ${REDIS_HOST} - port: ${REDIS_PORT} - password: ${REDIS_PASSWORD} mongodb: uri: ${MONGODB_URI} +redis: + host: ${REDIS_HOST} + port: ${REDIS_PORT} + password: ${REDIS_PASSWORD} + logging: level: org.springframework.messaging: debug From 105d4f232402b84667db166cfc418712538733d0 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 7 Jan 2025 18:23:48 +0900 Subject: [PATCH 193/770] =?UTF-8?q?HOTFIX:=20=EB=A0=88=EB=94=94=EC=8A=A4?= =?UTF-8?q?=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/config/RedisConfig.java | 6 +++--- src/main/resources/application-dev.yml | 9 ++++----- src/main/resources/application-local.yml | 9 ++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index c7692cd0..bced1c59 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -23,13 +23,13 @@ public class RedisConfig { public static final String WILD_CARD = "*"; - @Value("${redis.host}") + @Value("${redis.host:localhost}") private String host; - @Value("${redis.port}") + @Value("${redis.port:6379}") private int port; - @Value("${redis.password}") + @Value("${redis.password:}") private String password; @Value("${chat.topic}") diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 74275956..4e1f926c 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -12,14 +12,13 @@ spring: hibernate: ddl-auto: update data: + redis: + host: ${REDIS_HOST} + port: ${REDIS_PORT} + password: ${REDIS_PASSWORD} mongodb: uri: ${MONGODB_URI} -redis: - host: ${REDIS_HOST} - port: ${REDIS_PORT} - password: ${REDIS_PASSWORD} - logging: level: org.springframework.messaging: debug diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index d8cc3f6a..195b4039 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -12,14 +12,13 @@ spring: hibernate: ddl-auto: update data: + redis: + host: ${REDIS_HOST} + port: ${REDIS_PORT} + password: ${REDIS_PASSWORD} mongodb: uri: ${MONGODB_URI} -redis: - host: ${REDIS_HOST} - port: ${REDIS_PORT} - password: ${REDIS_PASSWORD} - logging: level: org.springframework.messaging: debug From f8382e2eb1fcdfc2c637575ca31eadc8b69e1fca Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 7 Jan 2025 18:29:38 +0900 Subject: [PATCH 194/770] =?UTF-8?q?HOTFIX:=20=EB=A0=88=EB=94=94=EC=8A=A4?= =?UTF-8?q?=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/RedisConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index bced1c59..92a37e27 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -23,13 +23,13 @@ public class RedisConfig { public static final String WILD_CARD = "*"; - @Value("${redis.host:localhost}") + @Value("${spring.data.redis.host:localhost}") private String host; - @Value("${redis.port:6379}") + @Value("${spring.data.redis.port:6379}") private int port; - @Value("${redis.password:}") + @Value("${spring.data.redis.password:}") private String password; @Value("${chat.topic}") From 5e4f2c7c65625cc0383e4333afd7376a2046219b Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 7 Jan 2025 18:56:12 +0900 Subject: [PATCH 195/770] =?UTF-8?q?HOTFIX:=20=EB=A0=88=EB=94=94=EC=8A=A4?= =?UTF-8?q?=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/RedisConfig.java | 6 +++--- src/main/resources/application-dev.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index 92a37e27..ff852595 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -23,13 +23,13 @@ public class RedisConfig { public static final String WILD_CARD = "*"; - @Value("${spring.data.redis.host:localhost}") + @Value("${spring.data.redis.host}") private String host; - @Value("${spring.data.redis.port:6379}") + @Value("${spring.data.redis.port}") private int port; - @Value("${spring.data.redis.password:}") + @Value("${spring.data.redis.password}") private String password; @Value("${chat.topic}") diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 4e1f926c..ac868db7 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -13,8 +13,8 @@ spring: ddl-auto: update data: redis: - host: ${REDIS_HOST} - port: ${REDIS_PORT} + host: ${REDIS_HOST:localhost} + port: ${REDIS_PORT:6379} password: ${REDIS_PASSWORD} mongodb: uri: ${MONGODB_URI} From 35fb9ed5df11b170d020cedf8cb927e6a3534112 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 19:06:42 +0900 Subject: [PATCH 196/770] =?UTF-8?q?hotfix:=20spring=20profile=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b7efa8b7..aa0595ac 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,7 +3,7 @@ server: spring: profiles: - active: local + active: dev springdoc: swagger-ui: From 1bdb5a11e84e83abbcb1651a3cc2ebf33b071b68 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 19:20:39 +0900 Subject: [PATCH 197/770] =?UTF-8?q?hotfix:=20jwtRedisTemplate=20bean=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/auth/jwt/util/JwtRedisUtil.java | 10 +++++----- .../com/gachtaxi/global/config/RedisConfig.java | 13 +++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java index e5c3aaca..a9147d70 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java @@ -13,24 +13,24 @@ public class JwtRedisUtil { private final static String PREFIX = "refresh_"; - private final RedisTemplate redisTemplate; + private final RedisTemplate jwtRedisTemplate; @Value("${gachtaxi.auth.jwt.refreshTokenExpiration}") private Long refreshTokenExpiration; public void set(Long key, String value) { - redisTemplate.opsForValue().set(PREFIX + key, value, refreshTokenExpiration, TimeUnit.MILLISECONDS); + jwtRedisTemplate.opsForValue().set(PREFIX + key, value, refreshTokenExpiration, TimeUnit.MILLISECONDS); } public Object get(Long key){ - return redisTemplate.opsForValue().get(PREFIX +key); + return jwtRedisTemplate.opsForValue().get(PREFIX +key); } public boolean hasKey(Long key){ - return Boolean.TRUE.equals(redisTemplate.hasKey(PREFIX + key)); + return Boolean.TRUE.equals(jwtRedisTemplate.hasKey(PREFIX + key)); } public boolean delete(Long key){ - return Boolean.TRUE.equals(redisTemplate.delete(PREFIX + key)); + return Boolean.TRUE.equals(jwtRedisTemplate.delete(PREFIX + key)); } } diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index ff852595..c00febdd 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.gachtaxi.domain.chat.dto.request.ChatMessage; import com.gachtaxi.domain.chat.redis.RedisChatSubscriber; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -47,6 +48,7 @@ public RedisConnectionFactory redisConnectionFactory() { } @Bean + @Qualifier("chatRedisTemplate") public RedisTemplate chatRedisTemplate(RedisConnectionFactory redisConnectionFactory) { RedisTemplate redisTemplate = new RedisTemplate<>(); @@ -73,4 +75,15 @@ public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnecti return container; } + + @Bean + @Qualifier("jwtRedisTemplate") + public RedisTemplate jwtRedisTemplate(RedisConnectionFactory factory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(factory); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new StringRedisSerializer()); + // 필요한 경우, 다른 Serializer 설정 + return redisTemplate; + } } From a3bc17a54fd3134bd86b75fa0f785218a7043daf Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 19:43:00 +0900 Subject: [PATCH 198/770] =?UTF-8?q?hotfix:=20CD=EC=97=90=20docker=20pull?= =?UTF-8?q?=20=EB=AA=85=EB=A0=B9=EC=96=B4=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 ++ src/main/java/com/gachtaxi/global/config/RedisConfig.java | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 8d1845de..dca4e33b 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -62,6 +62,8 @@ jobs: port: 30922 key: ${{ secrets.DEV_SSH_SECRET_PRIVATE_KEY }} script: | + docker pull ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest + # Blue-Green Deployment 포트 및 컨테이너 이름 설정 BLUE_PORT=8080 GREEN_PORT=8081 diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index c00febdd..7a7f16bf 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -83,7 +83,6 @@ public RedisTemplate jwtRedisTemplate(RedisConnectionFactory fac redisTemplate.setConnectionFactory(factory); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new StringRedisSerializer()); - // 필요한 경우, 다른 Serializer 설정 return redisTemplate; } } From 4055a3fbd627564984f4e9c565fa6bfb58fd6a51 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 7 Jan 2025 21:16:35 +0900 Subject: [PATCH 199/770] =?UTF-8?q?HOTFIX:=20=EB=A0=88=EB=94=94=EC=8A=A4?= =?UTF-8?q?=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index ac868db7..4e1f926c 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -13,8 +13,8 @@ spring: ddl-auto: update data: redis: - host: ${REDIS_HOST:localhost} - port: ${REDIS_PORT:6379} + host: ${REDIS_HOST} + port: ${REDIS_PORT} password: ${REDIS_PASSWORD} mongodb: uri: ${MONGODB_URI} From fb59c772b6c6a3603417cee31cb138723f382a66 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 7 Jan 2025 21:23:13 +0900 Subject: [PATCH 200/770] feat: Merge --- .../gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java index 8cb03546..6cc65caf 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java @@ -13,7 +13,9 @@ public enum JwtErrorMessage { USER_NOT_FOUND_EMAIL("해당 이메일의 유저를 찾을 수 없습니다"), JWT_TOKEN_NOT_FOUND("토큰을 찾을 수 없습니다"), JWT_TOKEN_EXPIRED("만료된 토큰입니다."), - JWT_TOKEN_INVALID("유효하지 않은 토큰 입니다."); + JWT_TOKEN_INVALID("유효하지 않은 토큰 입니다."), + JWT_TOKEN_UN_VALID("유효하지 않은 토큰 입니다."), + JWT_TOKEN_NOT_EXIST("헤더에 인증 토큰이 존재하지 않습니다"); private final String message; } From a5245b8cc068a0ba427a380b0b4f9a49ffd3e14a Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 7 Jan 2025 21:33:24 +0900 Subject: [PATCH 201/770] =?UTF-8?q?chore:=20dev=20CD=20pipeline=20docker?= =?UTF-8?q?=20compose=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index dca4e33b..479719a5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -64,39 +64,7 @@ jobs: script: | docker pull ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest - # Blue-Green Deployment 포트 및 컨테이너 이름 설정 - BLUE_PORT=8080 - GREEN_PORT=8081 - BLUE_NAME="blue" - GREEN_NAME="green" - - # 현재 실행 중인 컨테이너 확인 - IS_BLUE_ON=$(sudo docker ps --filter "name=$BLUE_NAME" --filter "status=running" -q) - - if [ -n "$IS_BLUE_ON" ]; then - echo "** ${GREEN_PORT} 포트에서 GREEN 컨테이너 실행" - sudo docker run --platform linux/arm64 --name $GREEN_NAME -d -p $GREEN_PORT:$GREEN_PORT \ - --env-file ./gachtaxi-dev.env --network gachtaxi -e SPRING_PROFILES_ACTIVE=dev -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi - BEFORE_NAME=$BLUE_NAME - AFTER_NAME=$GREEN_NAME - BEFORE_PORT=$BLUE_PORT - AFTER_PORT=$GREEN_PORT - else - echo "** ${BLUE_PORT} 포트에서 BLUE 컨테이너 실행" - sudo docker run --platform linux/arm64 --name $BLUE_NAME -d -p $BLUE_PORT:$BLUE_PORT \ - --env-file ./gachtaxi-dev.env --network gachtaxi -e SPRING_PROFILES_ACTIVE=dev -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi - BEFORE_NAME=$GREEN_NAME - AFTER_NAME=$BLUE_NAME - BEFORE_PORT=$GREEN_PORT - AFTER_PORT=$BLUE_PORT - fi - - echo "** ${AFTER_NAME} 컨테이너 실행 완료 (포트: ${AFTER_PORT})" - - # 이전 컨테이너 중지 및 삭제 - echo "** 이전 컨테이너(${BEFORE_NAME}) 종료 및 삭제" - sudo docker stop $BEFORE_NAME || true - sudo docker rm $BEFORE_NAME || true + docker compose up -d --no-deps gachtaxi # 사용하지 않는 이미지 정리 echo "** 사용하지 않는 Docker 이미지 정리" From df8cf906b30a3843fc20b1c57b0a063323582a92 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 7 Jan 2025 22:25:32 +0900 Subject: [PATCH 202/770] =?UTF-8?q?HOTFIX:=20COOKIE=5FPATH=5FOPTION=20-=20?= =?UTF-8?q?dev=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 4e1f926c..5ed8a053 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -37,3 +37,4 @@ gachtaxi: refreshTokenExpiration: ${JWT_REFRESH_TOKEN_EXPIRATION} cookieMaxAge: ${JWT_COOKIE_MAX_AGE} secureOption: ${COOKIE_SECURE_OPTION} + cookiePathOption: ${COOKIE_PATH_OPTION} From 52444c7cd9b3c0ff199202231513452dbb6086a7 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 7 Jan 2025 22:41:08 +0900 Subject: [PATCH 203/770] =?UTF-8?q?HOTFIX:=20RedisTemplate=20Duplicated=20?= =?UTF-8?q?Bean=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/config/RedisConfig.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index 7a7f16bf..1de0f55c 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -76,13 +76,13 @@ public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnecti return container; } - @Bean - @Qualifier("jwtRedisTemplate") - public RedisTemplate jwtRedisTemplate(RedisConnectionFactory factory) { - RedisTemplate redisTemplate = new RedisTemplate<>(); - redisTemplate.setConnectionFactory(factory); - redisTemplate.setKeySerializer(new StringRedisSerializer()); - redisTemplate.setValueSerializer(new StringRedisSerializer()); - return redisTemplate; - } + // @Bean + // @Qualifier("jwtRedisTemplate") + // public RedisTemplate jwtRedisTemplate(RedisConnectionFactory factory) { + // RedisTemplate redisTemplate = new RedisTemplate<>(); + // redisTemplate.setConnectionFactory(factory); + // redisTemplate.setKeySerializer(new StringRedisSerializer()); + // redisTemplate.setValueSerializer(new StringRedisSerializer()); + // return redisTemplate; + // } } From fdb9f7c0a03b0a879f387143f4b3e90010146df6 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 7 Jan 2025 23:27:07 +0900 Subject: [PATCH 204/770] =?UTF-8?q?HOTFIX:=20CORS=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/SecurityConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java index 8f80e1c9..18e627f8 100644 --- a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java @@ -65,7 +65,8 @@ public AuthenticationManager authenticationManager(AuthenticationConfiguration c @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); - configuration.setAllowedOriginPatterns(Arrays.asList("http://localhost:3000")); + // configuration.setAllowedOriginPatterns(Arrays.asList("http://localhost:3000")); + corsConfiguration.setAllowedOriginPatterns(List.of("*")); configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PATCH", "DELETE", "OPTIONS")); configuration.setAllowedHeaders(Arrays.asList("*")); configuration.setExposedHeaders(Arrays.asList("Authorization", "Set-Cookie")); From 8a60cb6d434270dd5c490edcd19f47a5fad8f636 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 7 Jan 2025 23:29:39 +0900 Subject: [PATCH 205/770] =?UTF-8?q?HOTFIX:=20CORS=20=EC=84=A4=EC=A0=95=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java index 18e627f8..bd1d98c1 100644 --- a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java @@ -66,7 +66,7 @@ public AuthenticationManager authenticationManager(AuthenticationConfiguration c public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); // configuration.setAllowedOriginPatterns(Arrays.asList("http://localhost:3000")); - corsConfiguration.setAllowedOriginPatterns(List.of("*")); + configuration.setAllowedOriginPatterns(List.of("*")); configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PATCH", "DELETE", "OPTIONS")); configuration.setAllowedHeaders(Arrays.asList("*")); configuration.setExposedHeaders(Arrays.asList("Authorization", "Set-Cookie")); From 3ffcd99518e6fadc4d7ba7e7a451bbeb086a5036 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 7 Jan 2025 23:33:10 +0900 Subject: [PATCH 206/770] =?UTF-8?q?HOTFIX:=20CORS=20=EC=84=A4=EC=A0=95=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/SecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java index bd1d98c1..cd5404a8 100644 --- a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java @@ -22,6 +22,7 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import java.util.Arrays; +import java.util.List; @Configuration @EnableWebSecurity From 980fdac7cc04ce4e53beac4838d4cf3d1f98f856 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 8 Jan 2025 03:52:15 +0900 Subject: [PATCH 207/770] =?UTF-8?q?hotfix:=20sudo=20=EB=AA=85=EB=A0=B9?= =?UTF-8?q?=EC=96=B4=20=EC=82=AC=EC=9A=A9=EC=8B=9C=20=ED=8C=A8=EC=8A=A4?= =?UTF-8?q?=EC=9B=8C=EB=93=9C=20=EC=9E=85=EB=A0=A5=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 479719a5..5d884105 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -68,4 +68,4 @@ jobs: # 사용하지 않는 이미지 정리 echo "** 사용하지 않는 Docker 이미지 정리" - sudo docker image prune -f \ No newline at end of file + echo "${{ secrets.DEV_SSH_SECRET_PASSWORD }}" | sudo docker image prune -f \ No newline at end of file From 288dd3d6eec5bd2dde49aeac1cf72c22c21e5fd3 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 12:56:56 +0900 Subject: [PATCH 208/770] =?UTF-8?q?feat:=20=EC=9E=84=EC=8B=9C=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/members/entity/enums/Role.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java b/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java index 671beb79..724243c7 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.members.entity.enums; public enum Role { - MEMBER, ADMIN + TEMPORARY, MEMBER, ADMIN } From 781514348aba8ff2b808d174aee02492e8da882e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 12:58:19 +0900 Subject: [PATCH 209/770] =?UTF-8?q?feat:=20=EC=9E=84=EC=8B=9C=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=9D=B8=EA=B0=80=20=EA=B2=BD=EB=A1=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/config/PermitUrlConfig.java | 6 ++++++ .../java/com/gachtaxi/global/config/SecurityConfig.java | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index 45ddfc07..f08823f3 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -16,6 +16,12 @@ public String[] getPublicUrl(){ }; } + public String[] getTmpMemberUrl(){ + return new String[]{ + "/api/tmp-members/**" + }; + } + public String[] getMemberUrl(){ return new String[]{ diff --git a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java index cd5404a8..e7710684 100644 --- a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java @@ -1,7 +1,6 @@ package com.gachtaxi.global.config; -import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.auth.jwt.authentication.CustomAccessDeniedHandler; import com.gachtaxi.global.auth.jwt.authentication.CustomAuthenticationEntryPoint; import com.gachtaxi.global.auth.jwt.filter.JwtAuthenticationFilter; @@ -24,6 +23,8 @@ import java.util.Arrays; import java.util.List; +import static com.gachtaxi.domain.members.entity.enums.Role.*; + @Configuration @EnableWebSecurity @RequiredArgsConstructor @@ -46,8 +47,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti http.authorizeHttpRequests((auth) -> auth .requestMatchers(permitUrlConfig.getPublicUrl()).permitAll() - .requestMatchers(permitUrlConfig.getMemberUrl()).hasRole(Role.MEMBER.name()) - .requestMatchers(permitUrlConfig.getAdminUrl()).hasRole(Role.ADMIN.name()) + .requestMatchers(permitUrlConfig.getTmpMemberUrl()).hasRole(TEMPORARY.name()) + .requestMatchers(permitUrlConfig.getMemberUrl()).hasAnyRole(MEMBER.name(), ADMIN.name()) + .requestMatchers(permitUrlConfig.getAdminUrl()).hasRole(ADMIN.name()) .anyRequest().authenticated()); http.exceptionHandling(e -> e From 93aead611dafde3f53b5b8feb66b2e895c5d39f8 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:33:45 +0900 Subject: [PATCH 210/770] =?UTF-8?q?feat:=20=EC=9E=84=EC=8B=9C=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20tmpEmail=20?= =?UTF-8?q?=EC=A3=BC=EC=9E=85=20(UserDetails=20=EB=95=8C=EB=AC=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/entity/Members.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 174e46e0..47f30164 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -18,19 +18,19 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Members extends BaseEntity { - @Column(name = "email", nullable = false, unique = true) + @Column(name = "email", unique = true) private String email; @Column(name = "profile_picture") private String profilePicture; - @Column(name = "nickname", nullable = false) + @Column(name = "nickname") private String nickname; - @Column(name = "real_name", nullable = false) + @Column(name = "real_name") private String realName; - @Column(name = "student_number", nullable = false, unique = true) + @Column(name = "student_number", unique = true) private Long studentNumber; @Column(name = "phone_number", unique = true) // 피그마 참고, 일단 null 허용 @@ -49,22 +49,22 @@ public class Members extends BaseEntity { private Gender gender; // 이용 약관 동의 - @Column(name = "terms_agreement", nullable = false) + @Column(name = "terms_agreement") @ColumnDefault("true") private Boolean termsAgreement; // 개인정보 수집 동의 - @Column(name = "privacy_agreement", nullable = false) + @Column(name = "privacy_agreement") @ColumnDefault("true") private Boolean privacyAgreement; // 광고성 정보 수신 동의 - @Column(name = "marketing_agreement", nullable = false) + @Column(name = "marketing_agreement") @ColumnDefault("false") private Boolean marketingAgreement; // 2차 인증 (전화번호) - @Column(name = "two_factor_authentication", nullable = false) + @Column(name = "two_factor_authentication") @ColumnDefault("false") private Boolean twoFactorAuthentication; @@ -76,7 +76,7 @@ public class Members extends BaseEntity { * */ public static Members of(UserSignUpRequestDto dto){ - return Members.builder() + return com.gachtaxi.domain.members.entity.Members.builder() //.profilePicture(dto.profilePicture()) .email(dto.email()) .nickname(dto.nickName()) @@ -93,4 +93,12 @@ public static Members of(UserSignUpRequestDto dto){ .twoFactorAuthentication(dto.twoFactorAuthentication()) .build(); } + + public static Members ofKakaoId(Long kakaoId, String tmpEmail){ + return Members.builder() + .kakaoId(kakaoId) + .email(tmpEmail) + .role(Role.TEMPORARY) + .build(); + } } From 36c78066d679e0c966713abd96a37a5f77db5b97 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:35:07 +0900 Subject: [PATCH 211/770] =?UTF-8?q?fix:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B5=AC=ED=98=84=20=EB=B0=A9?= =?UTF-8?q?=EC=8B=9D=20=EB=B3=80=EA=B2=BD=20(=ED=94=84=EB=A1=A0=ED=8A=B8?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9D=B8=EA=B0=80=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/controller/AuthController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index c4c2fe21..2b4eecb0 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.members.controller.ResponseMessage.*; +import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.KakaoAuthCode; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.OauthKakaoResponse; @RequestMapping("/auth") @@ -22,9 +23,9 @@ public class AuthController { private final AuthService authService; private final JwtService jwtService; - @GetMapping("/login/kakao") - public ApiResponse kakaoLogin(@RequestParam("code") String authcode, HttpServletResponse response) { - OauthKakaoResponse res = authService.kakaoLogin(authcode, response); + @PostMapping("/login/kakao") + public ApiResponse kakaoLogin(@RequestBody KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { + OauthKakaoResponse res = authService.kakaoLogin(kakaoAuthCode.authCode(), response); ResponseMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) ? LOGIN_SUCCESS : UN_REGISTER; From ce5ede4fe7f321dee5d6d3e1754c42482b25a12a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:35:42 +0900 Subject: [PATCH 212/770] =?UTF-8?q?feat:=20JwtProvider=20=EC=9E=84?= =?UTF-8?q?=EC=8B=9C=20=ED=86=A0=ED=81=B0=20=EC=83=9D=EC=84=B1=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/JwtProvider.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java index de78d4ef..89817fbd 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java @@ -18,6 +18,7 @@ public class JwtProvider { private static final String ID_CLAIM = "id"; private static final String EMAIL_CLAIM = "email"; private static final String ROLE_CLAIM = "role"; + private static final String TMP_EMAIL_CLAIM = "tmpEmail"; private final Key key; public JwtProvider(@Value("${gachtaxi.auth.jwt.key}") String secretKey) { @@ -27,6 +28,9 @@ public JwtProvider(@Value("${gachtaxi.auth.jwt.key}") String secretKey) { @Value("${gachtaxi.auth.jwt.accessTokenExpiration}") private Long accessTokenExpiration; + @Value("${gachtaxi.auth.jwt.tmpAccessTokenExpiration}") + private Long tmpAccessTokenExpiration; + @Value("${gachtaxi.auth.jwt.refreshTokenExpiration}") private Long refreshTokenExpiration; @@ -42,6 +46,19 @@ public String generateAccessToken(Long id, String email, String role) { .compact(); // 최종 문자열 생성 } + public String generateTmpAccessToken(Long id, String email, String role) { + return Jwts.builder() + .claim(ID_CLAIM, id) + .claim(EMAIL_CLAIM, email) + .claim(EMAIL_CLAIM, TMP_EMAIL_CLAIM) + .claim(ROLE_CLAIM, role) + .setSubject(ACCESS_TOKEN_SUBJECT) // 사용자 정보(고유 식별자) + .setIssuedAt(new Date()) // 발행 시간 + .setExpiration(new Date(System.currentTimeMillis() + tmpAccessTokenExpiration)) // 만료 시간 + .signWith(key, SignatureAlgorithm.HS256) // 서명 알고리즘 + .compact(); // 최종 문자열 생성 + } + public String generateRefreshToken(Long id, String email, String role) { return Jwts.builder() .claim(ID_CLAIM, id) From 197fcf5435838831ecded5fa19c5c78612ca723c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:36:20 +0900 Subject: [PATCH 213/770] =?UTF-8?q?feat:=20JwtService=20=EC=9E=84=EC=8B=9C?= =?UTF-8?q?=20=ED=86=A0=ED=81=B0=20=EC=9D=91=EB=8B=B5=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/service/JwtService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 2eab7b20..f7953430 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -1,5 +1,6 @@ package com.gachtaxi.global.auth.jwt.service; +import com.gachtaxi.domain.members.dto.request.TmpMemberDto; import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.exception.CookieNotFoundException; @@ -36,6 +37,11 @@ public void responseJwtToken(Long userId, String email, Role role, HttpServletRe setCookie(jwtToken.refreshToken(), response); } + public void responseTmpAccessToken(TmpMemberDto tmpMemberDto, HttpServletResponse response) { + String tmpAccessToken = jwtProvider.generateTmpAccessToken(tmpMemberDto.userId(), tmpMemberDto.email(), tmpMemberDto.role().name()); + setHeader(tmpAccessToken, response); + } + public JwtTokenDto reissueJwtToken(HttpServletRequest request) { String refreshToken = extractRefreshToken(request); if(jwtExtractor.isExpired(refreshToken)){ From 5c1a8a1671136cf3aa0d000e5b5f0a065498a81f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:36:40 +0900 Subject: [PATCH 214/770] =?UTF-8?q?feat:=20KakaoAuthCode=20Dto=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java index ea1d5916..38efd09b 100644 --- a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java +++ b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java @@ -1,10 +1,15 @@ package com.gachtaxi.global.auth.kakao.dto; import com.gachtaxi.global.auth.enums.OauthLoginStatus; +import jakarta.validation.constraints.NotBlank; import lombok.Builder; public class KaKaoDTO { + public record KakaoAuthCode( + @NotBlank String authCode + ){} + public record KakaoAccessToken( String access_token, String token_type, @@ -34,7 +39,6 @@ public record Profile( @Builder public record OauthKakaoResponse( Long userId, - Long kakaoId, OauthLoginStatus status ){} From 0e5d6a64525f47e4440a8d2c266ba78aacba64f0 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:37:38 +0900 Subject: [PATCH 215/770] =?UTF-8?q?feat:=20application-local,=20dev=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C=ED=86=A0=ED=81=B0=20=EB=A7=8C=EB=A3=8C?= =?UTF-8?q?=EA=B8=B0=EA=B0=84=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 1 + src/main/resources/application-local.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 5ed8a053..05c01230 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -35,6 +35,7 @@ gachtaxi: key: ${JWT_SECRET_KEY} accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} refreshTokenExpiration: ${JWT_REFRESH_TOKEN_EXPIRATION} + tmpAccessTokenExpiration: ${JWT_TMP_ACCESS_TOKEN_EXPIRATION} cookieMaxAge: ${JWT_COOKIE_MAX_AGE} secureOption: ${COOKIE_SECURE_OPTION} cookiePathOption: ${COOKIE_PATH_OPTION} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 02f0f136..d8889e93 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -35,6 +35,7 @@ gachtaxi: key: ${JWT_SECRET_KEY} accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} refreshTokenExpiration: ${JWT_REFRESH_TOKEN_EXPIRATION} + tmpAccessTokenExpiration: ${JWT_TMP_ACCESS_TOKEN_EXPIRATION} cookieMaxAge: ${JWT_COOKIE_MAX_AGE} secureOption: ${COOKIE_SECURE_OPTION} cookiePathOption: ${COOKIE_PATH_OPTION} \ No newline at end of file From b6b2ea39fc9bb63a554aa25ddc0898d8db0b8da2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:44:04 +0900 Subject: [PATCH 216/770] =?UTF-8?q?feat:=20=EC=9E=84=EC=8B=9C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/entity/Members.java | 8 ++++++-- .../gachtaxi/domain/members/service/MemberService.java | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 47f30164..1449caa7 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -18,6 +18,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Members extends BaseEntity { + // UserDetails를 만드는 과정에서 null 방지를 위해 임시로 저장하는 이메일 + // 추후 로직 개선하겠습니다. + private final static String TMP_EMAIL = "tmpEmail@gmail.com"; + @Column(name = "email", unique = true) private String email; @@ -94,10 +98,10 @@ public static Members of(UserSignUpRequestDto dto){ .build(); } - public static Members ofKakaoId(Long kakaoId, String tmpEmail){ + public static Members ofKakaoId(Long kakaoId){ return Members.builder() .kakaoId(kakaoId) - .email(tmpEmail) + .email(TMP_EMAIL) .role(Role.TEMPORARY) .build(); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 5de2958c..87b48606 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.members.dto.request.TmpMemberDto; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; @@ -19,6 +20,7 @@ public class MemberService { private final JwtService jwtService; private final MemberRepository memberRepository; + //TODO 최종 회원가입 절차에서 사용 @Transactional public void saveMember(UserSignUpRequestDto dto, HttpServletResponse response) { checkDuplicatedStudentNumber(dto); @@ -27,6 +29,14 @@ public void saveMember(UserSignUpRequestDto dto, HttpServletResponse response) { jwtService.responseJwtToken(newMember.getId(), newMember.getEmail(), newMember.getRole(), response); } + // 임시 유저 저장 + @Transactional + public TmpMemberDto saveTmpMember(Long kakaoId){ + Members tmpMember = Members.ofKakaoId(kakaoId); + memberRepository.save(tmpMember); + return TmpMemberDto.of(tmpMember); + } + public Optional findByKakaoId(Long kakaoId) { return memberRepository.findByKakaoId(kakaoId); } From 7dc49bfbef2aa74ef79973f223ff93d41636a3df Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:45:00 +0900 Subject: [PATCH 217/770] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=A0=88=EC=B0=A8=20=EC=A4=91=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EB=B0=9C=EC=83=9D=EC=8B=9C=20=EC=9E=84=EC=8B=9C=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EB=8A=94=20=EC=83=9D=EA=B2=A8=EB=82=98=EB=AF=80?= =?UTF-8?q?=EB=A1=9C=20=EC=A1=B0=EA=B1=B4=EC=97=90=20TEMPORARY=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/service/AuthService.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 9c29c261..501ac7d1 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.members.dto.request.TmpMemberDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; @@ -7,8 +8,10 @@ import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; + import java.util.Optional; +import static com.gachtaxi.domain.members.entity.enums.Role.TEMPORARY; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; @@ -33,12 +36,15 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon Long kakaoId = userInfo.id(); Optional optionalMember = memberService.findByKakaoId(kakaoId); - if(optionalMember.isEmpty()) { - return oauthMapper.toKakaoUnRegisterResponse(userInfo); + if(optionalMember.isEmpty() || optionalMember.get().getRole() == TEMPORARY) { + TmpMemberDto tmpDto = memberService.saveTmpMember(kakaoId); + + jwtService.responseTmpAccessToken(tmpDto, response); + return oauthMapper.toKakaoUnRegisterResponse(tmpDto.userId()); } Members member = optionalMember.get(); jwtService.responseJwtToken(member.getId(), member.getEmail(), member.getRole(), response); - return oauthMapper.toKakaoLoginResponse(userInfo, member.getId()); + return oauthMapper.toKakaoLoginResponse(member.getId()); } } From 5816cdbb8badcecbd8a1ef2045688b6ca1b82692 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:46:43 +0900 Subject: [PATCH 218/770] =?UTF-8?q?feat:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=B5=9C=EC=A2=85=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20-=20userId=EC=99=80=20=ED=97=A4=EB=8D=94=EC=97=90?= =?UTF-8?q?=20Token=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/mapper/OauthMapper.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java index 94597c3b..73c8cd4a 100644 --- a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java +++ b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java @@ -8,18 +8,17 @@ @Component public class OauthMapper { - public OauthKakaoResponse toKakaoUnRegisterResponse(KakaoUserInfoResponse userInfo) { + public OauthKakaoResponse toKakaoUnRegisterResponse(Long userId) { return OauthKakaoResponse.builder() - .kakaoId(userInfo.id()) + .userId(userId) .status(UN_REGISTER) .build(); } // jwt 토큰 추가 할 것. - public OauthKakaoResponse toKakaoLoginResponse(KakaoUserInfoResponse userInfo, Long userId) { + public OauthKakaoResponse toKakaoLoginResponse(Long userId) { return OauthKakaoResponse.builder() .userId(userId) - .kakaoId(userInfo.id()) .status(LOGIN) .build(); } From 983b10cda3a0b87beed3041d127d71112e9a278f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 13:54:33 +0900 Subject: [PATCH 219/770] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=A7=84=ED=96=89=EC=9D=B4=20=EC=A4=91=EB=8B=A8?= =?UTF-8?q?=EB=90=9C=20=EC=9C=A0=EC=A0=80=20=EC=97=A3=EC=A7=80=20=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/service/AuthService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 501ac7d1..76daa3cc 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -35,14 +35,22 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon Long kakaoId = userInfo.id(); Optional optionalMember = memberService.findByKakaoId(kakaoId); +// System.out.println(optionalMember.get().getKakaoId()); - if(optionalMember.isEmpty() || optionalMember.get().getRole() == TEMPORARY) { + if(optionalMember.isEmpty()) { TmpMemberDto tmpDto = memberService.saveTmpMember(kakaoId); jwtService.responseTmpAccessToken(tmpDto, response); return oauthMapper.toKakaoUnRegisterResponse(tmpDto.userId()); } + // 회원 가입 진행 중 중단된 유저 또한 다시 임시 토큰을 재발급해준다. + if(optionalMember.get().getRole() == TEMPORARY){ + TmpMemberDto tmpDto = TmpMemberDto.of(optionalMember.get()); + jwtService.responseTmpAccessToken(tmpDto, response); + return oauthMapper.toKakaoUnRegisterResponse(tmpDto.userId()); + } + Members member = optionalMember.get(); jwtService.responseJwtToken(member.getId(), member.getEmail(), member.getRole(), response); return oauthMapper.toKakaoLoginResponse(member.getId()); From 16b51a46f7bd249b4628054c76688f8d36b0df56 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 8 Jan 2025 14:08:18 +0900 Subject: [PATCH 220/770] =?UTF-8?q?feat:=20=EA=B8=B0=EB=B3=B8=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20=EB=94=94?= =?UTF-8?q?=EB=A0=89=ED=86=A0=EB=A6=AC=20=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/chat/service/ChatRoomService.java | 9 +++++++++ .../com/gachtaxi/domain/chat/service/ChatService.java | 9 +++++++++ .../{interceptor => stomp}/CustomChannelInterceptor.java | 4 ++-- .../gachtaxi/domain/chat/stomp/StompErrorHandler.java | 8 ++++++++ .../strategy/ChatStrategyHandler.java | 2 +- .../strategy/DefaultCommandStrategy.java | 2 +- .../strategy/StompCommandStrategy.java | 2 +- .../strategy/StompConnectStrategy.java | 2 +- .../strategy/StompSubscribeStrategy.java | 2 +- .../java/com/gachtaxi/global/config/WebSocketConfig.java | 2 +- 10 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/service/ChatRoomService.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/service/ChatService.java rename src/main/java/com/gachtaxi/domain/chat/{interceptor => stomp}/CustomChannelInterceptor.java (85%) create mode 100644 src/main/java/com/gachtaxi/domain/chat/stomp/StompErrorHandler.java rename src/main/java/com/gachtaxi/domain/chat/{interceptor => stomp}/strategy/ChatStrategyHandler.java (94%) rename src/main/java/com/gachtaxi/domain/chat/{interceptor => stomp}/strategy/DefaultCommandStrategy.java (92%) rename src/main/java/com/gachtaxi/domain/chat/{interceptor => stomp}/strategy/StompCommandStrategy.java (88%) rename src/main/java/com/gachtaxi/domain/chat/{interceptor => stomp}/strategy/StompConnectStrategy.java (96%) rename src/main/java/com/gachtaxi/domain/chat/{interceptor => stomp}/strategy/StompSubscribeStrategy.java (94%) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChatRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChatRoomService.java new file mode 100644 index 00000000..7cfc47bd --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChatRoomService.java @@ -0,0 +1,9 @@ +package com.gachtaxi.domain.chat.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ChatRoomService { +} diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChatService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChatService.java new file mode 100644 index 00000000..f87785b0 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChatService.java @@ -0,0 +1,9 @@ +package com.gachtaxi.domain.chat.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ChatService { +} diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java b/src/main/java/com/gachtaxi/domain/chat/stomp/CustomChannelInterceptor.java similarity index 85% rename from src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java rename to src/main/java/com/gachtaxi/domain/chat/stomp/CustomChannelInterceptor.java index b0be4fa9..7d5a5680 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/CustomChannelInterceptor.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/CustomChannelInterceptor.java @@ -1,6 +1,6 @@ -package com.gachtaxi.domain.chat.interceptor; +package com.gachtaxi.domain.chat.stomp; -import com.gachtaxi.domain.chat.interceptor.strategy.ChatStrategyHandler; +import com.gachtaxi.domain.chat.stomp.strategy.ChatStrategyHandler; import lombok.RequiredArgsConstructor; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/StompErrorHandler.java b/src/main/java/com/gachtaxi/domain/chat/stomp/StompErrorHandler.java new file mode 100644 index 00000000..dc9712e4 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/StompErrorHandler.java @@ -0,0 +1,8 @@ +package com.gachtaxi.domain.chat.stomp; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.messaging.StompSubProtocolErrorHandler; + +@Configuration +public class StompErrorHandler extends StompSubProtocolErrorHandler { +} diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/ChatStrategyHandler.java similarity index 94% rename from src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java rename to src/main/java/com/gachtaxi/domain/chat/stomp/strategy/ChatStrategyHandler.java index d0f0cd98..f93f593a 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/ChatStrategyHandler.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/ChatStrategyHandler.java @@ -1,4 +1,4 @@ -package com.gachtaxi.domain.chat.interceptor.strategy; +package com.gachtaxi.domain.chat.stomp.strategy; import lombok.RequiredArgsConstructor; import org.springframework.messaging.Message; diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/DefaultCommandStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java similarity index 92% rename from src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/DefaultCommandStrategy.java rename to src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java index b221d98c..5b9b2f72 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/DefaultCommandStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java @@ -1,4 +1,4 @@ -package com.gachtaxi.domain.chat.interceptor.strategy; +package com.gachtaxi.domain.chat.stomp.strategy; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompCommandStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java similarity index 88% rename from src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompCommandStrategy.java rename to src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java index bb0eb88e..2093bb4b 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompCommandStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java @@ -1,4 +1,4 @@ -package com.gachtaxi.domain.chat.interceptor.strategy; +package com.gachtaxi.domain.chat.stomp.strategy; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java similarity index 96% rename from src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java rename to src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java index e63da8d8..97e6fd25 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompConnectStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java @@ -1,4 +1,4 @@ -package com.gachtaxi.domain.chat.interceptor.strategy; +package com.gachtaxi.domain.chat.stomp.strategy; import com.gachtaxi.global.auth.jwt.exception.TokenNotExistException; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; diff --git a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompSubscribeStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java similarity index 94% rename from src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompSubscribeStrategy.java rename to src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java index b009d2dd..c06eaba9 100644 --- a/src/main/java/com/gachtaxi/domain/chat/interceptor/strategy/StompSubscribeStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java @@ -1,4 +1,4 @@ -package com.gachtaxi.domain.chat.interceptor.strategy; +package com.gachtaxi.domain.chat.stomp.strategy; import com.gachtaxi.domain.chat.exception.ChatSubscribeException; import org.springframework.messaging.Message; diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index c3afafd1..2d81616c 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -1,6 +1,6 @@ package com.gachtaxi.global.config; -import com.gachtaxi.domain.chat.interceptor.CustomChannelInterceptor; +import com.gachtaxi.domain.chat.stomp.CustomChannelInterceptor; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.ChannelRegistration; From 2038155aebba8da8b1fb18e6529e60690cef2f6b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 14:10:33 +0900 Subject: [PATCH 221/770] =?UTF-8?q?feat:=20TmpMemberDto=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/dto/request/TmpMemberDto.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/TmpMemberDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/TmpMemberDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/TmpMemberDto.java new file mode 100644 index 00000000..4b4436c4 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/TmpMemberDto.java @@ -0,0 +1,20 @@ +package com.gachtaxi.domain.members.dto.request; + +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.entity.enums.Role; +import lombok.Builder; + +@Builder +public record TmpMemberDto( + Long userId, + String email, + Role role +) { + public static TmpMemberDto of(Members tmpMember) { + return TmpMemberDto.builder() + .userId(tmpMember.getId()) + .email(tmpMember.getEmail()) + .role(tmpMember.getRole()) + .build(); + } +} From a3d2e44c840bda6f87328b0539d751bd03178fba Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 14:51:59 +0900 Subject: [PATCH 222/770] =?UTF-8?q?feat:=20@Valid=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/controller/AuthController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 2b4eecb0..76763de6 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -7,6 +7,7 @@ import com.gachtaxi.global.common.response.ApiResponse; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -24,7 +25,7 @@ public class AuthController { private final JwtService jwtService; @PostMapping("/login/kakao") - public ApiResponse kakaoLogin(@RequestBody KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { + public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { OauthKakaoResponse res = authService.kakaoLogin(kakaoAuthCode.authCode(), response); ResponseMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) ? LOGIN_SUCCESS From c168c7aa51c479b66b0603e5cc80941ef4ef0e23 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 14:52:54 +0900 Subject: [PATCH 223/770] =?UTF-8?q?feat:=20Members=20=EA=B2=BD=EB=A1=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 1449caa7..6accb5a2 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -80,7 +80,7 @@ public class Members extends BaseEntity { * */ public static Members of(UserSignUpRequestDto dto){ - return com.gachtaxi.domain.members.entity.Members.builder() + return Members.builder() //.profilePicture(dto.profilePicture()) .email(dto.email()) .nickname(dto.nickName()) From 3818a468a80a16e16a2f0879cdee46e1e3c8c72e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 14:58:12 +0900 Subject: [PATCH 224/770] =?UTF-8?q?remove:=20=EC=B6=9C=EB=A0=A5=EB=AC=B8?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/members/service/AuthService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 76daa3cc..042fdbda 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -35,7 +35,6 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon Long kakaoId = userInfo.id(); Optional optionalMember = memberService.findByKakaoId(kakaoId); -// System.out.println(optionalMember.get().getKakaoId()); if(optionalMember.isEmpty()) { TmpMemberDto tmpDto = memberService.saveTmpMember(kakaoId); From 9deb9f9cafbf99d317592f6ac3ff2bd63ca3bfe5 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 15:55:04 +0900 Subject: [PATCH 225/770] =?UTF-8?q?fix:=20=EC=9E=84=EC=8B=9C=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EA=B6=8C=ED=95=9C=20=EA=B2=BD=EB=A1=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/SecurityConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java index e7710684..ddaf21c4 100644 --- a/src/main/java/com/gachtaxi/global/config/SecurityConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SecurityConfig.java @@ -47,7 +47,6 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti http.authorizeHttpRequests((auth) -> auth .requestMatchers(permitUrlConfig.getPublicUrl()).permitAll() - .requestMatchers(permitUrlConfig.getTmpMemberUrl()).hasRole(TEMPORARY.name()) .requestMatchers(permitUrlConfig.getMemberUrl()).hasAnyRole(MEMBER.name(), ADMIN.name()) .requestMatchers(permitUrlConfig.getAdminUrl()).hasRole(ADMIN.name()) .anyRequest().authenticated()); From 0fdc43dc4365dc9343801de1554643cd2f6266a2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 16:10:17 +0900 Subject: [PATCH 226/770] =?UTF-8?q?fix:=20=ED=86=A0=ED=81=B0=20email=20Cla?= =?UTF-8?q?ims=EC=97=90=EB=8A=94=20=EB=8D=94=EB=AF=B8=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/service/JwtService.java | 2 +- .../gachtaxi/global/auth/jwt/util/JwtProvider.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index f7953430..cf9c221d 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -38,7 +38,7 @@ public void responseJwtToken(Long userId, String email, Role role, HttpServletRe } public void responseTmpAccessToken(TmpMemberDto tmpMemberDto, HttpServletResponse response) { - String tmpAccessToken = jwtProvider.generateTmpAccessToken(tmpMemberDto.userId(), tmpMemberDto.email(), tmpMemberDto.role().name()); + String tmpAccessToken = jwtProvider.generateTmpAccessToken(tmpMemberDto.userId(), tmpMemberDto.role().name()); setHeader(tmpAccessToken, response); } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java index 89817fbd..a31756e6 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java @@ -18,7 +18,8 @@ public class JwtProvider { private static final String ID_CLAIM = "id"; private static final String EMAIL_CLAIM = "email"; private static final String ROLE_CLAIM = "role"; - private static final String TMP_EMAIL_CLAIM = "tmpEmail"; + private static final String ROLE_PREFIX = "ROLE_"; + private static final String DUMMY_EMAIL = "dummy_email"; private final Key key; public JwtProvider(@Value("${gachtaxi.auth.jwt.key}") String secretKey) { @@ -38,7 +39,7 @@ public String generateAccessToken(Long id, String email, String role) { return Jwts.builder() .claim(ID_CLAIM, id) .claim(EMAIL_CLAIM, email) - .claim(ROLE_CLAIM, role) + .claim(ROLE_CLAIM, ROLE_PREFIX+role) .setSubject(ACCESS_TOKEN_SUBJECT) // 사용자 정보(고유 식별자) .setIssuedAt(new Date()) // 발행 시간 .setExpiration(new Date(System.currentTimeMillis() + accessTokenExpiration)) // 만료 시간 @@ -46,12 +47,11 @@ public String generateAccessToken(Long id, String email, String role) { .compact(); // 최종 문자열 생성 } - public String generateTmpAccessToken(Long id, String email, String role) { + public String generateTmpAccessToken(Long id, String role) { return Jwts.builder() .claim(ID_CLAIM, id) - .claim(EMAIL_CLAIM, email) - .claim(EMAIL_CLAIM, TMP_EMAIL_CLAIM) - .claim(ROLE_CLAIM, role) + .claim(EMAIL_CLAIM, DUMMY_EMAIL) + .claim(ROLE_CLAIM, ROLE_PREFIX+role) .setSubject(ACCESS_TOKEN_SUBJECT) // 사용자 정보(고유 식별자) .setIssuedAt(new Date()) // 발행 시간 .setExpiration(new Date(System.currentTimeMillis() + tmpAccessTokenExpiration)) // 만료 시간 @@ -63,7 +63,7 @@ public String generateRefreshToken(Long id, String email, String role) { return Jwts.builder() .claim(ID_CLAIM, id) .claim(EMAIL_CLAIM, email) - .claim(ROLE_CLAIM, role) + .claim(ROLE_CLAIM, ROLE_PREFIX+role) .setSubject(REFRESH_TOKEN_SUBJECT) // 사용자 정보(고유 식별자) .setIssuedAt(new Date()) // 발행 시간 .setExpiration(new Date(System.currentTimeMillis() + refreshTokenExpiration)) // 만료 시간 From dbaa479bf24aa3d38d27a6071bb88ebdfcd42c82 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 16:10:52 +0900 Subject: [PATCH 227/770] =?UTF-8?q?fix:=20=EC=9E=84=EC=8B=9C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20email=20DB=EC=97=90=EB=8A=94=20null=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 6accb5a2..09434d99 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -101,7 +101,6 @@ public static Members of(UserSignUpRequestDto dto){ public static Members ofKakaoId(Long kakaoId){ return Members.builder() .kakaoId(kakaoId) - .email(TMP_EMAIL) .role(Role.TEMPORARY) .build(); } From 863cd2af422ea4adae77af0a79547c2fd6802142 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 16:17:28 +0900 Subject: [PATCH 228/770] =?UTF-8?q?feat:=20UserStatus=20-=20ACTIVE,=20INAC?= =?UTF-8?q?TIVE=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/members/entity/Members.java | 8 +++++++- .../com/gachtaxi/domain/members/entity/enums/Role.java | 2 +- .../com/gachtaxi/domain/members/service/AuthService.java | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 09434d99..486e5008 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; +import com.gachtaxi.domain.members.entity.enums.UserStatus; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.*; import lombok.AccessLevel; @@ -52,6 +53,9 @@ public class Members extends BaseEntity { @Enumerated(EnumType.STRING) private Gender gender; + @Enumerated(EnumType.STRING) + private UserStatus status; + // 이용 약관 동의 @Column(name = "terms_agreement") @ColumnDefault("true") @@ -90,6 +94,7 @@ public static Members of(UserSignUpRequestDto dto){ .kakaoId(dto.kakaoId()) .googleId(dto.googleId()) .role(Role.MEMBER) + .status(UserStatus.ACTIVE) .gender(dto.gender()) .termsAgreement(dto.termsAgreement()) .privacyAgreement(dto.privacyAgreement()) @@ -101,7 +106,8 @@ public static Members of(UserSignUpRequestDto dto){ public static Members ofKakaoId(Long kakaoId){ return Members.builder() .kakaoId(kakaoId) - .role(Role.TEMPORARY) + .status(UserStatus.INACTIVE) + .role(Role.MEMBER) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java b/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java index 724243c7..671beb79 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/enums/Role.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.members.entity.enums; public enum Role { - TEMPORARY, MEMBER, ADMIN + MEMBER, ADMIN } diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 042fdbda..83989dee 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -11,7 +11,7 @@ import java.util.Optional; -import static com.gachtaxi.domain.members.entity.enums.Role.TEMPORARY; +import static com.gachtaxi.domain.members.entity.enums.UserStatus.INACTIVE; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; @@ -44,7 +44,7 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon } // 회원 가입 진행 중 중단된 유저 또한 다시 임시 토큰을 재발급해준다. - if(optionalMember.get().getRole() == TEMPORARY){ + if(optionalMember.get().getStatus() == INACTIVE){ TmpMemberDto tmpDto = TmpMemberDto.of(optionalMember.get()); jwtService.responseTmpAccessToken(tmpDto, response); return oauthMapper.toKakaoUnRegisterResponse(tmpDto.userId()); From d6f4cad3caed63ee33619addaf635e30120b1471 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 16:24:28 +0900 Subject: [PATCH 229/770] =?UTF-8?q?remove:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=83=81=EC=88=98=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 486e5008..a64e8db2 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -19,10 +19,6 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Members extends BaseEntity { - // UserDetails를 만드는 과정에서 null 방지를 위해 임시로 저장하는 이메일 - // 추후 로직 개선하겠습니다. - private final static String TMP_EMAIL = "tmpEmail@gmail.com"; - @Column(name = "email", unique = true) private String email; From feca89dc2f2eeae95c12f0dacad252590d65ad7c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 16:28:24 +0900 Subject: [PATCH 230/770] =?UTF-8?q?feat:=20UserStatus=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/entity/enums/UserStatus.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/entity/enums/UserStatus.java diff --git a/src/main/java/com/gachtaxi/domain/members/entity/enums/UserStatus.java b/src/main/java/com/gachtaxi/domain/members/entity/enums/UserStatus.java new file mode 100644 index 00000000..306e5999 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/entity/enums/UserStatus.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.members.entity.enums; + +public enum UserStatus { + ACTIVE, INACTIVE +} From 650522cea07efa4f0615b080c58d39d0ec0a96d2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 16:48:55 +0900 Subject: [PATCH 231/770] =?UTF-8?q?remove:=20=EC=9E=84=EC=8B=9C=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EA=B6=8C=ED=95=9C=20=EA=B2=BD=EB=A1=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/config/PermitUrlConfig.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index f08823f3..45ddfc07 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -16,12 +16,6 @@ public String[] getPublicUrl(){ }; } - public String[] getTmpMemberUrl(){ - return new String[]{ - "/api/tmp-members/**" - }; - } - public String[] getMemberUrl(){ return new String[]{ From ce46c4515a3d8aa708e4c19bf8357fed2b398245 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 21:31:13 +0900 Subject: [PATCH 232/770] =?UTF-8?q?feat:=20SesClinetConfig=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/config/SesClinetConfig.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/config/SesClinetConfig.java diff --git a/src/main/java/com/gachtaxi/global/config/SesClinetConfig.java b/src/main/java/com/gachtaxi/global/config/SesClinetConfig.java new file mode 100644 index 00000000..de60f62c --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/SesClinetConfig.java @@ -0,0 +1,32 @@ +package com.gachtaxi.global.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.ses.SesClient; + +@Configuration +public class SesClinetConfig { + + @Value("${aws.ses.accessKey}") + private String accessKey; + + @Value("${aws.ses.secretKey}") + private String secretKey; + + @Bean + public SesClient sesClient() { + AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create( + AwsBasicCredentials.create(accessKey, secretKey)); + + return SesClient.builder() + .region(Region.AP_SOUTHEAST_2) + .credentialsProvider(credentialsProvider) + .build(); + } + +} From 783f9a042c77bd95f1218a2b65cd07e9ea6ff6a8 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:20:12 +0900 Subject: [PATCH 233/770] =?UTF-8?q?fix:=20=EC=9E=84=EC=8B=9C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/{TmpMemberDto.java => InactiveMemberDto.java} | 6 +++--- .../com/gachtaxi/domain/members/service/AuthService.java | 6 +++--- .../com/gachtaxi/domain/members/service/MemberService.java | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) rename src/main/java/com/gachtaxi/domain/members/dto/request/{TmpMemberDto.java => InactiveMemberDto.java} (74%) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/TmpMemberDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberDto.java similarity index 74% rename from src/main/java/com/gachtaxi/domain/members/dto/request/TmpMemberDto.java rename to src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberDto.java index 4b4436c4..c1aa1137 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/TmpMemberDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberDto.java @@ -5,13 +5,13 @@ import lombok.Builder; @Builder -public record TmpMemberDto( +public record InactiveMemberDto( Long userId, String email, Role role ) { - public static TmpMemberDto of(Members tmpMember) { - return TmpMemberDto.builder() + public static InactiveMemberDto of(Members tmpMember) { + return InactiveMemberDto.builder() .userId(tmpMember.getId()) .email(tmpMember.getEmail()) .role(tmpMember.getRole()) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 83989dee..9c0184c9 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -1,6 +1,6 @@ package com.gachtaxi.domain.members.service; -import com.gachtaxi.domain.members.dto.request.TmpMemberDto; +import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; @@ -37,7 +37,7 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon Optional optionalMember = memberService.findByKakaoId(kakaoId); if(optionalMember.isEmpty()) { - TmpMemberDto tmpDto = memberService.saveTmpMember(kakaoId); + InactiveMemberDto tmpDto = memberService.saveTmpMember(kakaoId); jwtService.responseTmpAccessToken(tmpDto, response); return oauthMapper.toKakaoUnRegisterResponse(tmpDto.userId()); @@ -45,7 +45,7 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon // 회원 가입 진행 중 중단된 유저 또한 다시 임시 토큰을 재발급해준다. if(optionalMember.get().getStatus() == INACTIVE){ - TmpMemberDto tmpDto = TmpMemberDto.of(optionalMember.get()); + InactiveMemberDto tmpDto = InactiveMemberDto.of(optionalMember.get()); jwtService.responseTmpAccessToken(tmpDto, response); return oauthMapper.toKakaoUnRegisterResponse(tmpDto.userId()); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 87b48606..e430a6dc 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,6 +1,6 @@ package com.gachtaxi.domain.members.service; -import com.gachtaxi.domain.members.dto.request.TmpMemberDto; +import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; @@ -31,10 +31,10 @@ public void saveMember(UserSignUpRequestDto dto, HttpServletResponse response) { // 임시 유저 저장 @Transactional - public TmpMemberDto saveTmpMember(Long kakaoId){ + public InactiveMemberDto saveTmpMember(Long kakaoId){ Members tmpMember = Members.ofKakaoId(kakaoId); memberRepository.save(tmpMember); - return TmpMemberDto.of(tmpMember); + return InactiveMemberDto.of(tmpMember); } public Optional findByKakaoId(Long kakaoId) { From a8d1ec8db8e91971d2ee2866631bf5621f0843d9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:20:37 +0900 Subject: [PATCH 234/770] =?UTF-8?q?feat:=20ses=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 5b9f408f..3b7d04d3 100644 --- a/build.gradle +++ b/build.gradle @@ -38,8 +38,8 @@ dependencies { // Swagger implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0' - // Java Mail Sender - implementation 'org.springframework.boot:spring-boot-starter-mail' + // AWS SES + implementation 'software.amazon.awssdk:ses:2.20.7' // S3 Client implementation 'software.amazon.awssdk:s3:2.20.126' From 237704ff3711e46ca41caf10e62207be8126ab8a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:21:18 +0900 Subject: [PATCH 235/770] =?UTF-8?q?feat:=20JwtRedisUtil=EC=9D=84=20RedisUt?= =?UTF-8?q?il=EB=A1=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20=EB=B0=8F=20=ED=8C=A8=ED=82=A4=EC=A7=80=20=EA=B5=AC=EC=A1=B0?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/JwtRedisUtil.java | 41 ------------- .../global/common/redis/RedisUtil.java | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 41 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java create mode 100644 src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java deleted file mode 100644 index 740ab572..00000000 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtRedisUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.gachtaxi.global.auth.jwt.util; - -import com.gachtaxi.global.auth.jwt.exception.RefreshTokenNotFoundException; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; - -import java.util.concurrent.TimeUnit; - -@Component -@RequiredArgsConstructor -public class JwtRedisUtil { - - private final static String PREFIX = "refresh_"; - - private final RedisTemplate redisTemplate; - - @Value("${gachtaxi.auth.jwt.refreshTokenExpiration}") - private Long refreshTokenExpiration; - - public void set(Long key, String value) { - redisTemplate.opsForValue().set(PREFIX + key, value, refreshTokenExpiration, TimeUnit.MILLISECONDS); - } - - public Object get(Long key){ - Object getObjecet = redisTemplate.opsForValue().get(PREFIX +key); - if(getObjecet == null){ - throw new RefreshTokenNotFoundException(); - } - return getObjecet; - } - - public boolean hasKey(Long key){ - return Boolean.TRUE.equals(redisTemplate.hasKey(PREFIX + key)); - } - - public boolean delete(Long key){ - return Boolean.TRUE.equals(redisTemplate.delete(PREFIX + key)); - } -} diff --git a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java new file mode 100644 index 00000000..c1ddd21b --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java @@ -0,0 +1,58 @@ +package com.gachtaxi.global.common.redis; + +import com.gachtaxi.global.auth.jwt.exception.RefreshTokenNotFoundException; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +@Component +@RequiredArgsConstructor +public class RedisUtil { + + private final static String PREFIX_TOKEN = "refresh_"; + private final static String PREFIX_EMAIL_CODE = "email_"; + + private final RedisTemplate redisTemplate; + + @Value("${gachtaxi.auth.jwt.refreshTokenExpiration}") + private Long refreshTokenExpiration; + + @Value("${gachtaxi.auth.redis.emailAuthCodeExpiration}") + private Long emailAuthCodeExpiration; + + public void setRefreshToken(Long key, String value) { + redisTemplate.opsForValue().set(PREFIX_TOKEN + key, value, refreshTokenExpiration, TimeUnit.MILLISECONDS); + } + + public void setEmailAuthCode(String key, String value) { + redisTemplate.opsForValue().set(PREFIX_EMAIL_CODE+key, value, emailAuthCodeExpiration, TimeUnit.MILLISECONDS); + } + + public Object getRefreshToken(Long key){ + Object getObjecet = redisTemplate.opsForValue().get(PREFIX_TOKEN +key); + if(getObjecet == null){ + throw new RefreshTokenNotFoundException(); + } + return getObjecet; + } + + public Object getEmailAuthCode(Long key){ + Object getObjecet = redisTemplate.opsForValue().get(PREFIX_EMAIL_CODE+key); + if(getObjecet == null){ + // EmailAuthCode 만료됨 + throw new RefreshTokenNotFoundException(); + } + return getObjecet; + } + + public boolean hasKey(Long key){ + return Boolean.TRUE.equals(redisTemplate.hasKey(PREFIX_TOKEN + key)); + } + + public boolean delete(Long key){ + return Boolean.TRUE.equals(redisTemplate.delete(PREFIX_TOKEN + key)); + } +} From 0916d291588a9154ff34a23dbbfce24f578ac448 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:22:57 +0900 Subject: [PATCH 236/770] =?UTF-8?q?feat:=20SesTemplate=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SesClientTemplateService.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java b/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java new file mode 100644 index 00000000..776d3d1a --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java @@ -0,0 +1,31 @@ +package com.gachtaxi.global.common.mail.service; + +import org.springframework.stereotype.Service; +import software.amazon.awssdk.services.ses.SesClient; +import software.amazon.awssdk.services.ses.model.CreateTemplateRequest; +import software.amazon.awssdk.services.ses.model.Template; + +@Service +public class SesClientTemplateService { + + private final SesClient sesClient; + + public SesClientTemplateService(SesClient sesClient) { + this.sesClient = sesClient; + } + + public void createTemplate(String templateName, String subject, String htmlBody, String textBody) { + Template template = Template.builder() + .templateName(templateName) + .subjectPart(subject) + .htmlPart(htmlBody) + .textPart(textBody) + .build(); + + CreateTemplateRequest request = CreateTemplateRequest.builder() + .template(template) + .build(); + + sesClient.createTemplate(request); + } +} From 585687bc4f563606b5ac8321f3f268c3668f9b6f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:24:41 +0900 Subject: [PATCH 237/770] =?UTF-8?q?feat:=20EmailService=20=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=EC=BD=94=EB=93=9C=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/mail/service/EmailService.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java new file mode 100644 index 00000000..f313c9bf --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -0,0 +1,63 @@ +package com.gachtaxi.global.common.mail.service; + +import com.gachtaxi.global.common.redis.RedisUtil; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import software.amazon.awssdk.services.ses.SesClient; +import software.amazon.awssdk.services.ses.model.Destination; +import software.amazon.awssdk.services.ses.model.SendTemplatedEmailRequest; + +import java.security.SecureRandom; + +@Service +@RequiredArgsConstructor +public class EmailService { + + private static final String CODE_LENGTH = "%06d"; + private static final String CODE_FORMAT = "{\"code\":\"%s\"}"; + private static final int BOUND = 888888; + private static final int OFFSET = 111111; + + private final SesClient sesClient; + private final RedisUtil redisUtil; + private final SecureRandom secureRandom = new SecureRandom(); + + @Value("${aws.ses.templateName}") + private String emailTemplateName; + @Value("${aws.ses.from}") + private String senderEmail; + + public void sendEmail(String recipientEmail) { + String code = generateCode(); + redisUtil.setEmailAuthCode(recipientEmail, code); + + sendAuthCodeEmail(recipientEmail, code); + } + + // 인증 코드 검증 + + /* + * refactoring + * */ + + private String generateCode() { + return String.format(CODE_LENGTH, secureRandom.nextInt(BOUND) + OFFSET); + } + + // @Async 비동기 처리?? + private void sendAuthCodeEmail(String recipientEmail, String code) { + String templateData = String.format(CODE_FORMAT, code); + + SendTemplatedEmailRequest request = SendTemplatedEmailRequest.builder() + .destination(Destination.builder().toAddresses(recipientEmail).build()) + .template(emailTemplateName) + .templateData(templateData) + .source(senderEmail) + .build(); + + sesClient.sendTemplatedEmail(request); + } + + +} From f1e09e2e3c78d570db540fdb2b2c3f0085cc2e69 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:27:19 +0900 Subject: [PATCH 238/770] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/common/mail/service/EmailService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index f313c9bf..4859d809 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -2,6 +2,7 @@ import com.gachtaxi.global.common.redis.RedisUtil; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import software.amazon.awssdk.services.ses.SesClient; @@ -10,6 +11,7 @@ import java.security.SecureRandom; +@Slf4j @Service @RequiredArgsConstructor public class EmailService { @@ -33,6 +35,7 @@ public void sendEmail(String recipientEmail) { redisUtil.setEmailAuthCode(recipientEmail, code); sendAuthCodeEmail(recipientEmail, code); + log.info(" Email: " + recipientEmail + "\n Code: " + code + "\n 전달"); } // 인증 코드 검증 From f1fdc11d999a7f9d30253ea90b67f5bdf029ce06 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:27:42 +0900 Subject: [PATCH 239/770] =?UTF-8?q?feat:=20EmailAddressDto=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/mail/dto/request/EmailAddressDto.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java diff --git a/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java b/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java new file mode 100644 index 00000000..0efe5313 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java @@ -0,0 +1,6 @@ +package com.gachtaxi.global.common.mail.dto.request; + +public record EmailAddressDto( + String email +) { +} From 831c7f3a69126494f508e37833251044eb8f7012 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:28:33 +0900 Subject: [PATCH 240/770] =?UTF-8?q?feat:=20=EC=9D=B8=EC=A6=9D=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=A0=84=EC=86=A1=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InactiveMemberController.java | 32 +++++++++++++++++++ .../members/controller/ResponseMessage.java | 5 ++- .../response/InactiveMemberResponseDto.java | 15 +++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/InactiveMemberResponseDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java new file mode 100644 index 00000000..055e84eb --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java @@ -0,0 +1,32 @@ +package com.gachtaxi.domain.members.controller; + +import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; +import com.gachtaxi.global.common.mail.service.EmailService; +import com.gachtaxi.global.common.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.gachtaxi.domain.members.controller.ResponseMessage.EMAIL_SEND_SUCCESS; +import static org.springframework.http.HttpStatus.OK; + +@RequestMapping("/api") +@RestController +@RequiredArgsConstructor +public class InactiveMemberController { + + private final EmailService emailService; + + @PostMapping("/tmp-members/mail-authcode") + public ApiResponse sendEmail( + @RequestBody EmailAddressDto emailDto, + @CurrentMemberId Long userId + ) { + emailService.sendEmail(emailDto.email()); + return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 5f550565..9fe0a893 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -12,7 +12,10 @@ public enum ResponseMessage { // AuthController REFRESH_TOKEN_REISSUE("토큰 재발급에 성공했습니다."), LOGIN_SUCCESS("로그인 성공에 성공했습니다."), - UN_REGISTER("회원가입을 진행해주세요"); + UN_REGISTER("회원가입을 진행해주세요"), + + //InactiveMemberController + EMAIL_SEND_SUCCESS("이메일을 성공적으로 전송했습니다"); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/InactiveMemberResponseDto.java b/src/main/java/com/gachtaxi/domain/members/dto/response/InactiveMemberResponseDto.java new file mode 100644 index 00000000..f0ffa988 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/InactiveMemberResponseDto.java @@ -0,0 +1,15 @@ +package com.gachtaxi.domain.members.dto.response; + +import lombok.Builder; + +@Builder +public record InactiveMemberResponseDto( + Long userId +) { + public static InactiveMemberResponseDto from(Long userId) { + return InactiveMemberResponseDto.builder() + .userId(userId) + .build(); + } + +} From a1eac7cf81e9764e1929bab83087e5c5019bc2fb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:29:48 +0900 Subject: [PATCH 241/770] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 2 ++ src/main/resources/application-local.yml | 4 +++- src/main/resources/application.yml | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 05c01230..6be8f1a0 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -39,3 +39,5 @@ gachtaxi: cookieMaxAge: ${JWT_COOKIE_MAX_AGE} secureOption: ${COOKIE_SECURE_OPTION} cookiePathOption: ${COOKIE_PATH_OPTION} + redis: + emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} \ No newline at end of file diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index d8889e93..6be8f1a0 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -38,4 +38,6 @@ gachtaxi: tmpAccessTokenExpiration: ${JWT_TMP_ACCESS_TOKEN_EXPIRATION} cookieMaxAge: ${JWT_COOKIE_MAX_AGE} secureOption: ${COOKIE_SECURE_OPTION} - cookiePathOption: ${COOKIE_PATH_OPTION} \ No newline at end of file + cookiePathOption: ${COOKIE_PATH_OPTION} + redis: + emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b7efa8b7..f6c2621d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -11,4 +11,11 @@ springdoc: tags-sorter: alpha chat: - topic: ${CHAT_TOPIC} \ No newline at end of file + topic: ${CHAT_TOPIC} + +aws: + ses: + accessKey: ${AWS_SES_ACCESS_KEY} + secretKey: ${AWS_SES_SECRET_KEY} + from: ${AWS_SES_FROM} + templateName: ${AWS_SES_TEMPLATE_NAME} \ No newline at end of file From cc755575b138cc09b1ab83906966bba3e12353df Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:30:30 +0900 Subject: [PATCH 242/770] =?UTF-8?q?fix:=20=ED=95=84=EB=93=9C=20=EB=B0=8F?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=AA=85=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/service/JwtService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index cf9c221d..dc1d2cb8 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -1,6 +1,6 @@ package com.gachtaxi.global.auth.jwt.service; -import com.gachtaxi.domain.members.dto.request.TmpMemberDto; +import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.exception.CookieNotFoundException; @@ -9,7 +9,7 @@ import com.gachtaxi.global.auth.jwt.util.CookieUtil; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; import com.gachtaxi.global.auth.jwt.util.JwtProvider; -import com.gachtaxi.global.auth.jwt.util.JwtRedisUtil; +import com.gachtaxi.global.common.redis.RedisUtil; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -27,7 +27,7 @@ public class JwtService { private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; private final CookieUtil cookieUtil; - private final JwtRedisUtil redisUtil; + private final RedisUtil redisUtil; private final JwtProvider jwtProvider; private final JwtExtractor jwtExtractor; @@ -37,8 +37,8 @@ public void responseJwtToken(Long userId, String email, Role role, HttpServletRe setCookie(jwtToken.refreshToken(), response); } - public void responseTmpAccessToken(TmpMemberDto tmpMemberDto, HttpServletResponse response) { - String tmpAccessToken = jwtProvider.generateTmpAccessToken(tmpMemberDto.userId(), tmpMemberDto.role().name()); + public void responseTmpAccessToken(InactiveMemberDto inactiveMemberDto, HttpServletResponse response) { + String tmpAccessToken = jwtProvider.generateTmpAccessToken(inactiveMemberDto.userId(), inactiveMemberDto.role().name()); setHeader(tmpAccessToken, response); } @@ -49,7 +49,7 @@ public JwtTokenDto reissueJwtToken(HttpServletRequest request) { } Long userId = jwtExtractor.getId(refreshToken); - String redisToken = (String) redisUtil.get(userId); + String redisToken = (String) redisUtil.getRefreshToken(userId); if(!redisToken.equals(refreshToken)) { throw new TokenInvalidException(); } @@ -87,7 +87,7 @@ private JwtTokenDto generateJwtToken(Long userId, String email, String role) { String accessToken = jwtProvider.generateAccessToken(userId, email, role); String refreshToken = jwtProvider.generateRefreshToken(userId, email, role); - redisUtil.set(userId, refreshToken); + redisUtil.setRefreshToken(userId, refreshToken); return JwtTokenDto.of(accessToken, refreshToken); } From da7527e11e9a31e84b8ac4df602e1cca2ff8a92e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:31:23 +0900 Subject: [PATCH 243/770] =?UTF-8?q?fix:=20=EB=A9=A4=EB=B2=84=20=EC=9D=B8?= =?UTF-8?q?=EA=B0=80=20=EA=B2=BD=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index 45ddfc07..48dab710 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -18,7 +18,7 @@ public String[] getPublicUrl(){ public String[] getMemberUrl(){ return new String[]{ - + "/api/tmp-members/**", }; } From 5645130978dadbca3e5255d57178640a90fc1b5a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 22:34:24 +0900 Subject: [PATCH 244/770] =?UTF-8?q?feat:=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/InactiveMemberController.java | 3 ++- .../global/common/mail/dto/request/EmailAddressDto.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java index 055e84eb..32594be0 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java @@ -5,6 +5,7 @@ import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; import com.gachtaxi.global.common.mail.service.EmailService; import com.gachtaxi.global.common.response.ApiResponse; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -23,7 +24,7 @@ public class InactiveMemberController { @PostMapping("/tmp-members/mail-authcode") public ApiResponse sendEmail( - @RequestBody EmailAddressDto emailDto, + @RequestBody @Valid EmailAddressDto emailDto, @CurrentMemberId Long userId ) { emailService.sendEmail(emailDto.email()); diff --git a/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java b/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java index 0efe5313..c26fb94d 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java +++ b/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java @@ -1,6 +1,8 @@ package com.gachtaxi.global.common.mail.dto.request; +import jakarta.validation.constraints.NotBlank; + public record EmailAddressDto( - String email + @NotBlank String email ) { } From f2faa8a0836e733d1ff65e53841985242784aa62 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 8 Jan 2025 22:46:54 +0900 Subject: [PATCH 245/770] =?UTF-8?q?feat:=20s3=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b7efa8b7..dbd057b5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -11,4 +11,17 @@ springdoc: tags-sorter: alpha chat: - topic: ${CHAT_TOPIC} \ No newline at end of file + topic: ${CHAT_TOPIC} + +cloud: + aws: + s3: + bucket: ${S3_BUCKET} + credentials: + access-key: ${S3_ACCESS_KEY} + secret-key: ${S3_SECRET_KEY} + region: + static: ap-northeast-2 + auto: false + stack: + auto: false \ No newline at end of file From 11a1d09acbc17e4d3e1de8110fcb9bf122d6e437 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 8 Jan 2025 22:47:06 +0900 Subject: [PATCH 246/770] =?UTF-8?q?feat:=20s3=20config=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/config/AwsS3Config.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/config/AwsS3Config.java diff --git a/src/main/java/com/gachtaxi/global/config/AwsS3Config.java b/src/main/java/com/gachtaxi/global/config/AwsS3Config.java new file mode 100644 index 00000000..701f2c37 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/AwsS3Config.java @@ -0,0 +1,32 @@ +package com.gachtaxi.global.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.s3.presigner.S3Presigner; + +@Configuration +public class AwsS3Config { + + @Value("${cloud.aws.credentials.access-key}") + private String accessKey; + + @Value("${cloud.aws.credentials.secret-key}") + private String secreteKey; + + @Value("${cloud.aws.region.static}") + private String region; + + @Bean + public S3Presigner s3Presigner() { + AwsBasicCredentials credentials = AwsBasicCredentials.create(accessKey, secreteKey); + + return S3Presigner.builder() + .region(Region.of(region)) + .credentialsProvider(StaticCredentialsProvider.create(credentials)) + .build(); + } +} From 7d704ff36ac8a057b65d7f85bed605f1dd37c5a4 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 8 Jan 2025 22:47:37 +0900 Subject: [PATCH 247/770] =?UTF-8?q?feat:=20Presigned=20Url=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/image/ImageUtil.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/common/image/ImageUtil.java diff --git a/src/main/java/com/gachtaxi/global/common/image/ImageUtil.java b/src/main/java/com/gachtaxi/global/common/image/ImageUtil.java new file mode 100644 index 00000000..5a17cb8e --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/image/ImageUtil.java @@ -0,0 +1,40 @@ +package com.gachtaxi.global.common.image; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import software.amazon.awssdk.services.s3.model.PutObjectRequest; +import software.amazon.awssdk.services.s3.presigner.S3Presigner; +import software.amazon.awssdk.services.s3.presigner.model.PresignedPutObjectRequest; +import software.amazon.awssdk.services.s3.presigner.model.PutObjectPresignRequest; + +import java.time.Duration; +import java.util.UUID; + +@Component +@RequiredArgsConstructor +public class ImageUtil { + + private final S3Presigner s3Presigner; + + @Value("${cloud.aws.s3.bucket}") + private String bucket; + + public String generateUrl() { + String key = UUID.randomUUID().toString(); + + PutObjectRequest putObjectRequest = PutObjectRequest.builder() + .bucket(bucket) + .key(key) + .build(); + + PutObjectPresignRequest request = PutObjectPresignRequest.builder() + .signatureDuration(Duration.ofMinutes(5)) + .putObjectRequest(putObjectRequest) + .build(); + + PresignedPutObjectRequest presignedUrlRequest = s3Presigner.presignPutObject(request); + + return presignedUrlRequest.url().toString(); + } +} From 0bde6a9354fef9f9dcaa425d5cd611277f296a4c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:02:59 +0900 Subject: [PATCH 248/770] =?UTF-8?q?feat:=20=EC=9D=91=EB=8B=B5=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/ResponseMessage.java | 4 +++- .../members/exception/AuthCodeNotMatchException.java | 12 ++++++++++++ .../domain/members/exception/ErrorMessage.java | 3 ++- .../members/exception/MemberNotFoundException.java | 12 ++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/MemberNotFoundException.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 9fe0a893..1d01edb7 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -15,7 +15,9 @@ public enum ResponseMessage { UN_REGISTER("회원가입을 진행해주세요"), //InactiveMemberController - EMAIL_SEND_SUCCESS("이메일을 성공적으로 전송했습니다"); + EMAIL_SEND_SUCCESS("이메일을 성공적으로 전송했습니다"), + EMAIL_AUTHENTICATION_SUCESS("이메일 인증에 성공했습니다!"), + AUTH_CODE_NOT_MATCH("인증 코드가 일치하지 않습니다"); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java b/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java new file mode 100644 index 00000000..9bf9fdb7 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.members.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.domain.members.controller.ResponseMessage.AUTH_CODE_NOT_MATCH; + +public class AuthCodeNotMatchException extends BaseException { + public AuthCodeNotMatchException() { + super(HttpStatus.BAD_REQUEST, AUTH_CODE_NOT_MATCH.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index 7d6f825f..841127d8 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -7,7 +7,8 @@ @AllArgsConstructor public enum ErrorMessage { - DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."); + DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), + MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/exception/MemberNotFoundException.java b/src/main/java/com/gachtaxi/domain/members/exception/MemberNotFoundException.java new file mode 100644 index 00000000..dcee1eb3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/MemberNotFoundException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.members.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.MEMBER_NOT_FOUND; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class MemberNotFoundException extends BaseException { + public MemberNotFoundException() { + super(BAD_REQUEST, MEMBER_NOT_FOUND.getMessage()); + } +} From 171bec12ee17dbe8f303f975ca8378aff6a9e3eb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:03:55 +0900 Subject: [PATCH 249/770] =?UTF-8?q?feat:=20Member=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20(?= =?UTF-8?q?=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=B6=94=EA=B0=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index a64e8db2..ed4c5ef8 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -79,6 +79,10 @@ public class Members extends BaseEntity { * friend_info * */ + public void updateEmail(String email) { + this.email = email; + } + public static Members of(UserSignUpRequestDto dto){ return Members.builder() //.profilePicture(dto.profilePicture()) From 312fb166e6c02a55d62f8b607633558406e86c59 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:04:22 +0900 Subject: [PATCH 250/770] =?UTF-8?q?feat:=20Redis=20Key=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java index c1ddd21b..481bb51e 100644 --- a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java +++ b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java @@ -39,7 +39,7 @@ public Object getRefreshToken(Long key){ return getObjecet; } - public Object getEmailAuthCode(Long key){ + public Object getEmailAuthCode(String key){ Object getObjecet = redisTemplate.opsForValue().get(PREFIX_EMAIL_CODE+key); if(getObjecet == null){ // EmailAuthCode 만료됨 From 424069e9e963a59c8a4d2a42a1b5c858e9332345 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:05:02 +0900 Subject: [PATCH 251/770] =?UTF-8?q?feat:=20=EC=9D=B8=EC=A6=9D=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/mail/service/EmailService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index 4859d809..fbc61b93 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -1,5 +1,6 @@ package com.gachtaxi.global.common.mail.service; +import com.gachtaxi.domain.members.exception.AuthCodeNotMatchException; import com.gachtaxi.global.common.redis.RedisUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -38,6 +39,14 @@ public void sendEmail(String recipientEmail) { log.info(" Email: " + recipientEmail + "\n Code: " + code + "\n 전달"); } + public void checkEmailAuthCode(String recipientEmail, String inputCode) { + String redisAuthCode = (String) redisUtil.getEmailAuthCode(recipientEmail); + + if(!redisAuthCode.equals(inputCode)) { + throw new AuthCodeNotMatchException(); + } + } + // 인증 코드 검증 /* From bd562c8557f0ba45185425f216011cfdf6cd8f73 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:06:14 +0900 Subject: [PATCH 252/770] =?UTF-8?q?feat:=20=EC=9D=B8=EC=A6=9D=20email=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EB=A9=A4=EB=B2=84=EC=97=90=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/service/MemberService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index e430a6dc..f20fbab5 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -4,6 +4,7 @@ import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; +import com.gachtaxi.domain.members.exception.MemberNotFoundException; import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.global.auth.jwt.service.JwtService; import jakarta.servlet.http.HttpServletResponse; @@ -37,6 +38,14 @@ public InactiveMemberDto saveTmpMember(Long kakaoId){ return InactiveMemberDto.of(tmpMember); } + @Transactional + public void updateInactiveMemberOfEmail(String email, Long userId) { + Members members = memberRepository.findById(userId) + .orElseThrow(MemberNotFoundException::new); + + members.updateEmail(email); + } + public Optional findByKakaoId(Long kakaoId) { return memberRepository.findByKakaoId(kakaoId); } From 68c4a3fa061728f6d483c00a0ee4a8b1d240eff6 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:06:23 +0900 Subject: [PATCH 253/770] =?UTF-8?q?feat:=20InactiveMemberAuthCodeRequestDt?= =?UTF-8?q?o=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/InactiveMemberAuthCodeRequestDto.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberAuthCodeRequestDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberAuthCodeRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberAuthCodeRequestDto.java new file mode 100644 index 00000000..755496c6 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberAuthCodeRequestDto.java @@ -0,0 +1,8 @@ +package com.gachtaxi.domain.members.dto.request; + +import jakarta.validation.constraints.NotBlank; + +public record InactiveMemberAuthCodeRequestDto( + @NotBlank String email, + @NotBlank String authCode +) { } From 44f03d89f7fdfcaefb06f6d3558682e3a2446c29 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:06:53 +0900 Subject: [PATCH 254/770] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EB=B0=8F=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80=20API=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InactiveMemberController.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java index 32594be0..541c372f 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java @@ -1,17 +1,17 @@ package com.gachtaxi.domain.members.controller; +import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; +import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; import com.gachtaxi.global.common.mail.service.EmailService; import com.gachtaxi.global.common.response.ApiResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import static com.gachtaxi.domain.members.controller.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; import static com.gachtaxi.domain.members.controller.ResponseMessage.EMAIL_SEND_SUCCESS; import static org.springframework.http.HttpStatus.OK; @@ -21,6 +21,7 @@ public class InactiveMemberController { private final EmailService emailService; + private final MemberService memberService; @PostMapping("/tmp-members/mail-authcode") public ApiResponse sendEmail( @@ -30,4 +31,14 @@ public ApiResponse sendEmail( emailService.sendEmail(emailDto.email()); return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); } + + @PatchMapping("/tmp-members/mail-authcode") + public ApiResponse checkAuthCodeAndUpdateEmail( + @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, + @CurrentMemberId Long userId + ) { + emailService.checkEmailAuthCode(dto.email(), dto.authCode()); + memberService.updateInactiveMemberOfEmail(dto.email(), userId); + return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); + } } From 0383003f9ff8661b410c20bf03d64959cdfdd30f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:19:24 +0900 Subject: [PATCH 255/770] =?UTF-8?q?feat:=20@Email=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=EC=84=B1=20=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/InactiveMemberAuthCodeRequestDto.java | 7 +++++-- .../global/common/mail/dto/request/EmailAddressDto.java | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberAuthCodeRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberAuthCodeRequestDto.java index 755496c6..c024b74c 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberAuthCodeRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/InactiveMemberAuthCodeRequestDto.java @@ -1,8 +1,11 @@ package com.gachtaxi.domain.members.dto.request; +import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; public record InactiveMemberAuthCodeRequestDto( - @NotBlank String email, - @NotBlank String authCode + @NotBlank @Email(message = "이메일 형식이 올바르지 않습니다.") + String email, + @NotBlank + String authCode ) { } diff --git a/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java b/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java index c26fb94d..38ad3d54 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java +++ b/src/main/java/com/gachtaxi/global/common/mail/dto/request/EmailAddressDto.java @@ -1,8 +1,10 @@ package com.gachtaxi.global.common.mail.dto.request; +import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; public record EmailAddressDto( - @NotBlank String email + @NotBlank @Email(message = "이메일 형식이 올바르지 않습니다.") + String email ) { } From d9d38b9dbe35839f55b6182a76f2ce0f23a3aa63 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:19:52 +0900 Subject: [PATCH 256/770] =?UTF-8?q?feat:=20=EA=B0=80=EC=B2=9C=EB=8C=80=20?= =?UTF-8?q?=EC=9D=B4=EB=A9=94=EC=9D=BC=20=ED=98=95=EC=8B=9D=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/mail/service/EmailService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index fbc61b93..f61d996d 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -1,6 +1,7 @@ package com.gachtaxi.global.common.mail.service; import com.gachtaxi.domain.members.exception.AuthCodeNotMatchException; +import com.gachtaxi.domain.members.exception.EmailFormInvalidException; import com.gachtaxi.global.common.redis.RedisUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -32,11 +33,13 @@ public class EmailService { private String senderEmail; public void sendEmail(String recipientEmail) { + checkGachonEmail(recipientEmail); + String code = generateCode(); redisUtil.setEmailAuthCode(recipientEmail, code); sendAuthCodeEmail(recipientEmail, code); - log.info(" Email: " + recipientEmail + "\n Code: " + code + "\n 전달"); + log.info("\n Email: " + recipientEmail + "\n Code: " + code + "\n 전달"); } public void checkEmailAuthCode(String recipientEmail, String inputCode) { @@ -53,6 +56,12 @@ public void checkEmailAuthCode(String recipientEmail, String inputCode) { * refactoring * */ + private void checkGachonEmail(String email){ + if(!email.endsWith("@gachon.ac.kr")){ + throw new EmailFormInvalidException(); + } + } + private String generateCode() { return String.format(CODE_LENGTH, secureRandom.nextInt(BOUND) + OFFSET); } From 4b849cf5912ce4a417b2a8ebbade028c9fee0d86 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:20:07 +0900 Subject: [PATCH 257/770] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=ED=98=95=EC=8B=9D=20=EC=98=88=EC=99=B8=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/exception/ErrorMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index 841127d8..24739683 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -8,7 +8,8 @@ public enum ErrorMessage { DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), - MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."); + MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."), + EMAIL_FROM_INVALID("가천대 이메일 형식이 아닙니다."); private final String message; } From 9577df1247cb7b63af3a460a5f60dad294f86193 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 8 Jan 2025 23:25:02 +0900 Subject: [PATCH 258/770] =?UTF-8?q?feat:=20Presigned=20Url=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image/controller/ImageController.java | 30 +++++++++++++++++++ .../image/controller/ResponseMessage.java | 14 +++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/common/image/controller/ImageController.java create mode 100644 src/main/java/com/gachtaxi/global/common/image/controller/ResponseMessage.java diff --git a/src/main/java/com/gachtaxi/global/common/image/controller/ImageController.java b/src/main/java/com/gachtaxi/global/common/image/controller/ImageController.java new file mode 100644 index 00000000..fb1dca55 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/image/controller/ImageController.java @@ -0,0 +1,30 @@ +package com.gachtaxi.global.common.image.controller; + +import com.gachtaxi.global.common.image.ImageUtil; +import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.gachtaxi.global.common.image.controller.ResponseMessage.PRESIGNED_URL_GENERATE_SUCCESS; +import static org.springframework.http.HttpStatus.OK; + +@Tag(name = "IMAGE") +@RestController +@RequestMapping("/api/images") +@RequiredArgsConstructor +public class ImageController { + + private final ImageUtil imageUtil; + + @GetMapping() + @Operation(summary = "Presigned Url 반환을 위한 요청 API 입니다.") + public ApiResponse getPutUrl() { + String putUrl = imageUtil.generateUrl(); + + return ApiResponse.response(OK, PRESIGNED_URL_GENERATE_SUCCESS.getMessage(), putUrl); + } +} diff --git a/src/main/java/com/gachtaxi/global/common/image/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/global/common/image/controller/ResponseMessage.java new file mode 100644 index 00000000..460bf485 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/image/controller/ResponseMessage.java @@ -0,0 +1,14 @@ +package com.gachtaxi.global.common.image.controller; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ResponseMessage { + + PRESIGNED_URL_GENERATE_SUCCESS("Presigned url 발급에 성공했습니다."); + + private final String message; + +} From e5c5415be7cfcc5fcce1e58fe555bf6a0d8d2269 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 8 Jan 2025 23:25:15 +0900 Subject: [PATCH 259/770] =?UTF-8?q?feat:=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20J?= =?UTF-8?q?WT=20=ED=86=A0=ED=81=B0=20=EC=9E=85=EB=A0=A5=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/config/SwaggerConfig.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/SwaggerConfig.java b/src/main/java/com/gachtaxi/global/config/SwaggerConfig.java index 33cd786a..db0584cd 100644 --- a/src/main/java/com/gachtaxi/global/config/SwaggerConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SwaggerConfig.java @@ -1,25 +1,47 @@ package com.gachtaxi.global.config; import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import static com.gachtaxi.global.auth.jwt.util.JwtProvider.ACCESS_TOKEN_SUBJECT; + @Configuration public class SwaggerConfig { + private static final String SCHEMA_NAME = "bearerAuth"; + @Bean public OpenAPI openAPI() { + SecurityScheme accessSecurityScheme = getAccessSecurityScheme(); + SecurityRequirement securityRequirement = new SecurityRequirement().addList(SCHEMA_NAME); + return new OpenAPI() - .components(new Components()) + .addServersItem(new Server().url("/")) + .components(new Components() + .addSecuritySchemes(SCHEMA_NAME, accessSecurityScheme)) + .addSecurityItem(securityRequirement) .info(apiInfo()); } - private Info apiInfo(){ + private Info apiInfo() { return new Info() .title("GachTaxi API Specifications") .description("가치택시 REST API 스웨거 명세서") .version("1.0.0"); } + + private SecurityScheme getAccessSecurityScheme() { + return new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT") + .in(SecurityScheme.In.HEADER) + .name(ACCESS_TOKEN_SUBJECT); + } } From 67e9b95f8b9ecd3ba6213a10f35878e0ab44bdbb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:40:17 +0900 Subject: [PATCH 260/770] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=ED=98=95=EC=8B=9D=20=EC=98=88=EC=99=B8=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/exception/EmailFormInvalidException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/EmailFormInvalidException.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/EmailFormInvalidException.java b/src/main/java/com/gachtaxi/domain/members/exception/EmailFormInvalidException.java new file mode 100644 index 00000000..e79e02c0 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/EmailFormInvalidException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.members.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.EMAIL_FROM_INVALID; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class EmailFormInvalidException extends BaseException { + public EmailFormInvalidException() { + super(BAD_REQUEST, EMAIL_FROM_INVALID.getMessage()); + } +} From 7141853af1b16be73cd6a91e142c7e4328054d67 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:45:31 +0900 Subject: [PATCH 261/770] =?UTF-8?q?feat:=20=EB=A9=94=EC=9D=BC=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EB=A9=94=EC=84=B8=EC=A7=80=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InactiveMemberController.java | 4 ++-- .../members/controller/ResponseMessage.java | 7 +------ .../exception/AuthCodeNotMatchException.java | 3 ++- .../global/common/mail/message/ErrorMessage.java | 14 ++++++++++++++ .../common/mail/message/ResponseMessage.java | 15 +++++++++++++++ 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/gachtaxi/global/common/mail/message/ErrorMessage.java create mode 100644 src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java index 541c372f..f2330698 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java @@ -11,8 +11,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; -import static com.gachtaxi.domain.members.controller.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; -import static com.gachtaxi.domain.members.controller.ResponseMessage.EMAIL_SEND_SUCCESS; +import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; +import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_SEND_SUCCESS; import static org.springframework.http.HttpStatus.OK; @RequestMapping("/api") diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 1d01edb7..5f550565 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -12,12 +12,7 @@ public enum ResponseMessage { // AuthController REFRESH_TOKEN_REISSUE("토큰 재발급에 성공했습니다."), LOGIN_SUCCESS("로그인 성공에 성공했습니다."), - UN_REGISTER("회원가입을 진행해주세요"), - - //InactiveMemberController - EMAIL_SEND_SUCCESS("이메일을 성공적으로 전송했습니다"), - EMAIL_AUTHENTICATION_SUCESS("이메일 인증에 성공했습니다!"), - AUTH_CODE_NOT_MATCH("인증 코드가 일치하지 않습니다"); + UN_REGISTER("회원가입을 진행해주세요"); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java b/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java index 9bf9fdb7..156c5b60 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java @@ -3,7 +3,8 @@ import com.gachtaxi.global.common.exception.BaseException; import org.springframework.http.HttpStatus; -import static com.gachtaxi.domain.members.controller.ResponseMessage.AUTH_CODE_NOT_MATCH; +import static com.gachtaxi.global.common.mail.message.ErrorMessage.AUTH_CODE_NOT_MATCH; + public class AuthCodeNotMatchException extends BaseException { public AuthCodeNotMatchException() { diff --git a/src/main/java/com/gachtaxi/global/common/mail/message/ErrorMessage.java b/src/main/java/com/gachtaxi/global/common/mail/message/ErrorMessage.java new file mode 100644 index 00000000..643092d3 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/mail/message/ErrorMessage.java @@ -0,0 +1,14 @@ +package com.gachtaxi.global.common.mail.message; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ErrorMessage { + + AUTH_CODE_NOT_MATCH("인증 코드가 일치하지 않습니다"); + + private final String message; +} diff --git a/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java b/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java new file mode 100644 index 00000000..3853f022 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java @@ -0,0 +1,15 @@ +package com.gachtaxi.global.common.mail.message; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ResponseMessage { + + EMAIL_SEND_SUCCESS("이메일을 성공적으로 전송했습니다"), + EMAIL_AUTHENTICATION_SUCESS("이메일 인증에 성공했습니다!"), + EMAIL_TEMPLATE_CREATE_SUCCESS("이메일 템플릿을 생성했습니다."); + + private final String message; +} From 35e901231762af4be02766f2b2a0bfc4f529ed2f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 8 Jan 2025 23:46:33 +0900 Subject: [PATCH 262/770] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=ED=85=9C=ED=94=8C=EB=A6=BF=20=EC=83=9D=EC=84=B1=20API=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AdminMemberController.java | 28 +++++++++++++++++++ .../dto/request/NewTemplateRequestDto.java | 12 ++++++++ .../service/SesClientTemplateService.java | 11 ++++---- 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/controller/AdminMemberController.java create mode 100644 src/main/java/com/gachtaxi/global/common/mail/dto/request/NewTemplateRequestDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AdminMemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/AdminMemberController.java new file mode 100644 index 00000000..1191b2be --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/controller/AdminMemberController.java @@ -0,0 +1,28 @@ +package com.gachtaxi.domain.members.controller; + +import com.gachtaxi.global.common.mail.dto.request.NewTemplateRequestDto; +import com.gachtaxi.global.common.mail.service.SesClientTemplateService; +import com.gachtaxi.global.common.response.ApiResponse; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_TEMPLATE_CREATE_SUCCESS; + +@RestController +@RequestMapping("/api/admin") +@RequiredArgsConstructor +public class AdminMemberController { + + private final SesClientTemplateService sesClientTemplateService; + + @PostMapping("/email/template") + public ApiResponse createTemplate(@RequestBody @Valid NewTemplateRequestDto dto){ + sesClientTemplateService.createTemplate(dto); + return ApiResponse.response(HttpStatus.OK, EMAIL_TEMPLATE_CREATE_SUCCESS.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/global/common/mail/dto/request/NewTemplateRequestDto.java b/src/main/java/com/gachtaxi/global/common/mail/dto/request/NewTemplateRequestDto.java new file mode 100644 index 00000000..1dface9c --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/mail/dto/request/NewTemplateRequestDto.java @@ -0,0 +1,12 @@ +package com.gachtaxi.global.common.mail.dto.request; + +import jakarta.validation.constraints.NotBlank; + +public record NewTemplateRequestDto( + + @NotBlank String templateName, // 템플릿 제목 + @NotBlank String subject, // 메일 제목 + @NotBlank String htmlBody, // html 바디 + @NotBlank String textBody // html 전환 오류시 사용 + +) { } diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java b/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java index 776d3d1a..6860fbad 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java @@ -1,5 +1,6 @@ package com.gachtaxi.global.common.mail.service; +import com.gachtaxi.global.common.mail.dto.request.NewTemplateRequestDto; import org.springframework.stereotype.Service; import software.amazon.awssdk.services.ses.SesClient; import software.amazon.awssdk.services.ses.model.CreateTemplateRequest; @@ -14,12 +15,12 @@ public SesClientTemplateService(SesClient sesClient) { this.sesClient = sesClient; } - public void createTemplate(String templateName, String subject, String htmlBody, String textBody) { + public void createTemplate(NewTemplateRequestDto dto) { Template template = Template.builder() - .templateName(templateName) - .subjectPart(subject) - .htmlPart(htmlBody) - .textPart(textBody) + .templateName(dto.templateName()) + .subjectPart(dto.subject()) + .htmlPart(dto.htmlBody()) + .textPart(dto.textBody()) .build(); CreateTemplateRequest request = CreateTemplateRequest.builder() From 7707f340faaadd8dacdf67420775162ee2e1d866 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 00:41:21 +0900 Subject: [PATCH 263/770] =?UTF-8?q?feat:=20parser.parseClaimsJws=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=8D=98=EC=A0=B8=EC=A7=80=EB=8A=94=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EC=B2=98=EB=A6=AC=20=EC=97=A3=EC=A7=80=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/JwtExtractor.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java index 46b4df9d..6af88ed0 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java @@ -1,12 +1,12 @@ package com.gachtaxi.global.auth.jwt.util; -import com.gachtaxi.global.auth.jwt.exception.TokenInvalidException; import io.jsonwebtoken.Claims; import io.jsonwebtoken.JwtException; import io.jsonwebtoken.JwtParser; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.security.Keys; import jakarta.servlet.http.HttpServletRequest; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -15,6 +15,7 @@ import java.util.Optional; // 토큰 추출 및 검증 +@Slf4j @Component public class JwtExtractor { @@ -50,6 +51,7 @@ public String getRole(String token) { public Boolean isExpired(String token) { Claims claims = parseClaims(token); + if(claims == null) return true; return claims.getExpiration().before(new Date()); } @@ -64,13 +66,15 @@ private Long getIdFromToken(String token, String claimName) { } private Claims parseClaims(String token) { + JwtParser parser = Jwts.parserBuilder() + .setSigningKey(key) + .build(); + Claims claims = null; try{ - JwtParser parser = Jwts.parserBuilder() - .setSigningKey(key) - .build(); - return parser.parseClaimsJws(token).getBody(); + claims = parser.parseClaimsJws(token).getBody(); }catch (JwtException e){ - throw new TokenInvalidException(); + log.error(e.getMessage()); } + return claims; } } From 1b10adbafe691bf0fc1f410dd4dc93e2b67d4c1f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 00:43:03 +0900 Subject: [PATCH 264/770] =?UTF-8?q?feat:=20=EC=9D=B8=EA=B0=80=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index 48dab710..a74a7339 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -9,7 +9,7 @@ public String[] getPublicUrl(){ return new String[]{ "/auth/login/kakao", "/auth/refersh", - "/api/members", + "/api/members/signup", "/swagger-ui/**", "/v3/api-docs/**", @@ -19,6 +19,7 @@ public String[] getPublicUrl(){ public String[] getMemberUrl(){ return new String[]{ "/api/tmp-members/**", + "/api/admin/email/template", }; } From acbdb518d9182e401d1788b89ad07258b80fff28 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 01:16:51 +0900 Subject: [PATCH 265/770] =?UTF-8?q?feat:=20=EC=83=81=EC=88=98=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/common/mail/service/EmailService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index f61d996d..47e38737 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -20,6 +20,7 @@ public class EmailService { private static final String CODE_LENGTH = "%06d"; private static final String CODE_FORMAT = "{\"code\":\"%s\"}"; + private static final String GACHON_EMAIL_FORM = "@gachon.ac.kr"; private static final int BOUND = 888888; private static final int OFFSET = 111111; @@ -57,7 +58,7 @@ public void checkEmailAuthCode(String recipientEmail, String inputCode) { * */ private void checkGachonEmail(String email){ - if(!email.endsWith("@gachon.ac.kr")){ + if(!email.endsWith(GACHON_EMAIL_FORM)){ throw new EmailFormInvalidException(); } } From 946ddbcddc2836cbd9e1cf0ca715bdd56e50cc60 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 14:52:35 +0900 Subject: [PATCH 266/770] =?UTF-8?q?fix:=20=EC=9E=84=EC=8B=9C=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=EB=A5=BC=20=EB=94=B0=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InactiveMemberController.java | 88 +++++++++---------- .../members/controller/MemberController.java | 32 ++++++- 2 files changed, 72 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java index f2330698..f5ceee9d 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java @@ -1,44 +1,44 @@ -package com.gachtaxi.domain.members.controller; - -import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; -import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; -import com.gachtaxi.domain.members.service.MemberService; -import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; -import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; -import com.gachtaxi.global.common.mail.service.EmailService; -import com.gachtaxi.global.common.response.ApiResponse; -import jakarta.validation.Valid; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; -import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_SEND_SUCCESS; -import static org.springframework.http.HttpStatus.OK; - -@RequestMapping("/api") -@RestController -@RequiredArgsConstructor -public class InactiveMemberController { - - private final EmailService emailService; - private final MemberService memberService; - - @PostMapping("/tmp-members/mail-authcode") - public ApiResponse sendEmail( - @RequestBody @Valid EmailAddressDto emailDto, - @CurrentMemberId Long userId - ) { - emailService.sendEmail(emailDto.email()); - return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); - } - - @PatchMapping("/tmp-members/mail-authcode") - public ApiResponse checkAuthCodeAndUpdateEmail( - @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, - @CurrentMemberId Long userId - ) { - emailService.checkEmailAuthCode(dto.email(), dto.authCode()); - memberService.updateInactiveMemberOfEmail(dto.email(), userId); - return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); - } -} +//package com.gachtaxi.domain.members.controller; +// +//import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; +//import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; +//import com.gachtaxi.domain.members.service.MemberService; +//import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +//import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; +//import com.gachtaxi.global.common.mail.service.EmailService; +//import com.gachtaxi.global.common.response.ApiResponse; +//import jakarta.validation.Valid; +//import lombok.RequiredArgsConstructor; +//import org.springframework.web.bind.annotation.*; +// +//import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; +//import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_SEND_SUCCESS; +//import static org.springframework.http.HttpStatus.OK; +// +//@RequestMapping("/api") +//@RestController +//@RequiredArgsConstructor +//public class InactiveMemberController { +// +// private final EmailService emailService; +// private final MemberService memberService; +// +// @PostMapping("/tmp-members/mail-authcode") +// public ApiResponse sendEmail( +// @RequestBody @Valid EmailAddressDto emailDto, +// @CurrentMemberId Long userId +// ) { +// emailService.sendEmail(emailDto.email()); +// return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); +// } +// +// @PatchMapping("/tmp-members/mail-authcode") +// public ApiResponse checkAuthCodeAndUpdateEmail( +// @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, +// @CurrentMemberId Long userId +// ) { +// emailService.checkEmailAuthCode(dto.email(), dto.authCode()); +// memberService.updateInactiveMemberOfEmail(dto.email(), userId); +// return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); +// } +//} diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index a145934a..c936bbb9 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -1,17 +1,21 @@ package com.gachtaxi.domain.members.controller; +import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; +import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; +import com.gachtaxi.global.common.mail.service.EmailService; import com.gachtaxi.global.common.response.ApiResponse; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.members.controller.ResponseMessage.*; +import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; +import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_SEND_SUCCESS; import static org.springframework.http.HttpStatus.*; @RequestMapping("/api/members") @@ -20,10 +24,30 @@ public class MemberController { private final MemberService memberService; + private final EmailService emailService; @PostMapping() public ApiResponse signUp(@RequestBody @Valid UserSignUpRequestDto signUpDto, HttpServletResponse response) { memberService.saveMember(signUpDto, response); return ApiResponse.response(OK, REGISTER_SUCCESS.getMessage()); } + + @PostMapping("/mail-authcode") + public ApiResponse sendEmail( + @RequestBody @Valid EmailAddressDto emailDto, + @CurrentMemberId Long userId + ) { + emailService.sendEmail(emailDto.email()); + return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); + } + + @PatchMapping("/mail-authcode") + public ApiResponse checkAuthCodeAndUpdateEmail( + @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, + @CurrentMemberId Long userId + ) { + emailService.checkEmailAuthCode(dto.email(), dto.authCode()); + memberService.updateInactiveMemberOfEmail(dto.email(), userId); + return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); + } } From 5a369a4c4cfabcd1c84a6b2d584c68e51f06bdc0 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 14:54:31 +0900 Subject: [PATCH 267/770] =?UTF-8?q?fix:=20@RequiredArgsConstructor=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/mail/service/SesClientTemplateService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java b/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java index 6860fbad..c50338c0 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/SesClientTemplateService.java @@ -1,20 +1,18 @@ package com.gachtaxi.global.common.mail.service; import com.gachtaxi.global.common.mail.dto.request.NewTemplateRequestDto; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import software.amazon.awssdk.services.ses.SesClient; import software.amazon.awssdk.services.ses.model.CreateTemplateRequest; import software.amazon.awssdk.services.ses.model.Template; @Service +@RequiredArgsConstructor public class SesClientTemplateService { private final SesClient sesClient; - public SesClientTemplateService(SesClient sesClient) { - this.sesClient = sesClient; - } - public void createTemplate(NewTemplateRequestDto dto) { Template template = Template.builder() .templateName(dto.templateName()) From 87344b667a310bfeb95ef3dd0ec63aa84e248997 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 14:58:50 +0900 Subject: [PATCH 268/770] =?UTF-8?q?fix:=20=EC=98=88=EC=99=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mail/exception/AuthCodeExpirationException.java | 12 ++++++++++++ .../mail}/exception/AuthCodeNotMatchException.java | 6 +++--- .../global/common/mail/message/ErrorMessage.java | 1 + .../global/common/mail/service/EmailService.java | 3 +-- .../com/gachtaxi/global/common/redis/RedisUtil.java | 3 ++- 5 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/gachtaxi/global/common/mail/exception/AuthCodeExpirationException.java rename src/main/java/com/gachtaxi/{domain/members => global/common/mail}/exception/AuthCodeNotMatchException.java (59%) diff --git a/src/main/java/com/gachtaxi/global/common/mail/exception/AuthCodeExpirationException.java b/src/main/java/com/gachtaxi/global/common/mail/exception/AuthCodeExpirationException.java new file mode 100644 index 00000000..cfb802d8 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/mail/exception/AuthCodeExpirationException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.global.common.mail.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.global.common.mail.message.ErrorMessage.AUTH_CODE_EXPIRED; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class AuthCodeExpirationException extends BaseException { + public AuthCodeExpirationException() { + super(BAD_REQUEST, AUTH_CODE_EXPIRED.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java b/src/main/java/com/gachtaxi/global/common/mail/exception/AuthCodeNotMatchException.java similarity index 59% rename from src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java rename to src/main/java/com/gachtaxi/global/common/mail/exception/AuthCodeNotMatchException.java index 156c5b60..446a0ef1 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/AuthCodeNotMatchException.java +++ b/src/main/java/com/gachtaxi/global/common/mail/exception/AuthCodeNotMatchException.java @@ -1,13 +1,13 @@ -package com.gachtaxi.domain.members.exception; +package com.gachtaxi.global.common.mail.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; import static com.gachtaxi.global.common.mail.message.ErrorMessage.AUTH_CODE_NOT_MATCH; +import static org.springframework.http.HttpStatus.BAD_REQUEST; public class AuthCodeNotMatchException extends BaseException { public AuthCodeNotMatchException() { - super(HttpStatus.BAD_REQUEST, AUTH_CODE_NOT_MATCH.getMessage()); + super(BAD_REQUEST, AUTH_CODE_NOT_MATCH.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/global/common/mail/message/ErrorMessage.java b/src/main/java/com/gachtaxi/global/common/mail/message/ErrorMessage.java index 643092d3..a638f1b9 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/message/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/global/common/mail/message/ErrorMessage.java @@ -8,6 +8,7 @@ @AllArgsConstructor public enum ErrorMessage { + AUTH_CODE_EXPIRED("인증 코드가 만료됐습니다"), AUTH_CODE_NOT_MATCH("인증 코드가 일치하지 않습니다"); private final String message; diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index 47e38737..492ae3dd 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -1,6 +1,6 @@ package com.gachtaxi.global.common.mail.service; -import com.gachtaxi.domain.members.exception.AuthCodeNotMatchException; +import com.gachtaxi.global.common.mail.exception.AuthCodeNotMatchException; import com.gachtaxi.domain.members.exception.EmailFormInvalidException; import com.gachtaxi.global.common.redis.RedisUtil; import lombok.RequiredArgsConstructor; @@ -77,7 +77,6 @@ private void sendAuthCodeEmail(String recipientEmail, String code) { .templateData(templateData) .source(senderEmail) .build(); - sesClient.sendTemplatedEmail(request); } diff --git a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java index 481bb51e..d83c52c5 100644 --- a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java +++ b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java @@ -1,6 +1,7 @@ package com.gachtaxi.global.common.redis; import com.gachtaxi.global.auth.jwt.exception.RefreshTokenNotFoundException; +import com.gachtaxi.global.common.mail.exception.AuthCodeExpirationException; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; @@ -43,7 +44,7 @@ public Object getEmailAuthCode(String key){ Object getObjecet = redisTemplate.opsForValue().get(PREFIX_EMAIL_CODE+key); if(getObjecet == null){ // EmailAuthCode 만료됨 - throw new RefreshTokenNotFoundException(); + throw new AuthCodeExpirationException(); } return getObjecet; } From 125ee3e7e2febe6daa967c1dfabdaca14ace1861 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 14:59:57 +0900 Subject: [PATCH 269/770] =?UTF-8?q?fix:=20=EA=B0=9C=ED=96=89=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/common/redis/RedisUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java index d83c52c5..bfe3c5d8 100644 --- a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java +++ b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java @@ -34,18 +34,21 @@ public void setEmailAuthCode(String key, String value) { public Object getRefreshToken(Long key){ Object getObjecet = redisTemplate.opsForValue().get(PREFIX_TOKEN +key); + if(getObjecet == null){ throw new RefreshTokenNotFoundException(); } + return getObjecet; } public Object getEmailAuthCode(String key){ Object getObjecet = redisTemplate.opsForValue().get(PREFIX_EMAIL_CODE+key); + if(getObjecet == null){ - // EmailAuthCode 만료됨 throw new AuthCodeExpirationException(); } + return getObjecet; } From d522366d79d2feac567a7b9272a6dcca0e5f2964 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 15:23:46 +0900 Subject: [PATCH 270/770] =?UTF-8?q?feat:=20STOMP=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=ED=95=B8=EB=93=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/StompExceptionHandler.java | 55 +++++++++++++++++++ .../global/config/WebSocketConfig.java | 3 + 2 files changed, 58 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/common/exception/handler/StompExceptionHandler.java diff --git a/src/main/java/com/gachtaxi/global/common/exception/handler/StompExceptionHandler.java b/src/main/java/com/gachtaxi/global/common/exception/handler/StompExceptionHandler.java new file mode 100644 index 00000000..2db3f636 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/exception/handler/StompExceptionHandler.java @@ -0,0 +1,55 @@ +package com.gachtaxi.global.common.exception.handler; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gachtaxi.global.common.exception.BaseException; +import com.gachtaxi.global.common.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.messaging.Message; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; +import org.springframework.messaging.support.MessageBuilder; +import org.springframework.stereotype.Component; +import org.springframework.web.socket.messaging.StompSubProtocolErrorHandler; + +import java.nio.charset.StandardCharsets; + +@Component +@RequiredArgsConstructor +public class StompExceptionHandler extends StompSubProtocolErrorHandler { + + private final ObjectMapper objectMapper; + + @Override + public Message handleClientMessageProcessingError(Message clientMessage, Throwable ex) { + if (ex instanceof BaseException baseException) { + return sendErrorMessage(baseException); + } + + return super.handleClientMessageProcessingError(clientMessage, ex); + } + + private Message sendErrorMessage(BaseException ex) { + StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR); + + accessor.setHeader("content-type", "application/json"); + accessor.setMessage(ex.getMessage()); + accessor.setLeaveMutable(true); + + ApiResponse response = ApiResponse.response(ex.getStatus(), ex.getMessage()); + + String payload; + + try { + payload = objectMapper.writeValueAsString(response); + } catch (JsonProcessingException e) { + payload = "{\"error\": \"" + ex.getMessage() + "\"}"; + } + + return MessageBuilder.createMessage( + payload.getBytes(StandardCharsets.UTF_8), + accessor.getMessageHeaders() + ); + } +} diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index 2d81616c..bc0ad49b 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -1,6 +1,7 @@ package com.gachtaxi.global.config; import com.gachtaxi.domain.chat.stomp.CustomChannelInterceptor; +import com.gachtaxi.global.common.exception.handler.StompExceptionHandler; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.ChannelRegistration; @@ -17,10 +18,12 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { private final CustomChannelInterceptor customChannelInterceptor; + private final StompExceptionHandler stompExceptionHandler; @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry + .setErrorHandler(stompExceptionHandler) .addEndpoint("/ws") .setAllowedOriginPatterns("http://localhost:3001"); } From 9e00be55452efba7a87ae8c9ab114ea7c7c944c4 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 15:25:16 +0900 Subject: [PATCH 271/770] =?UTF-8?q?feat:=20STOMP=20send=20=EC=A0=84?= =?UTF-8?q?=EB=9E=B5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stomp/strategy/StompSendStrategy.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java new file mode 100644 index 00000000..dad9674d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java @@ -0,0 +1,31 @@ +package com.gachtaxi.domain.chat.stomp.strategy; + + +import com.gachtaxi.domain.chat.exception.ChatSendEndPointException; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; +import org.springframework.stereotype.Component; + +@Component +public class StompSendStrategy implements StompCommandStrategy { + + private static final String SEND_END_POINT = "/pub/chat/message"; + + @Override + public boolean supports(StompCommand command) { + return StompCommand.SEND.equals(command); + } + + @Override + public Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel) { + String destination = accessor.getDestination(); + + if (!destination.startsWith(SEND_END_POINT)) { + throw new ChatSendEndPointException(); + } + + return message; + } +} From ca6e7dc9a1124753f67b0fca3ac616709a665fa1 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 15:26:16 +0900 Subject: [PATCH 272/770] =?UTF-8?q?feat:=20STOMP=20sub=20=EC=A0=84?= =?UTF-8?q?=EB=9E=B5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../strategy/StompSubscribeStrategy.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java index c06eaba9..ef2bfc73 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java @@ -1,17 +1,28 @@ package com.gachtaxi.domain.chat.stomp.strategy; import com.gachtaxi.domain.chat.exception.ChatSubscribeException; +import com.gachtaxi.domain.chat.service.ChattingRoomService; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaderAccessor; import org.springframework.stereotype.Component; +import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; + @Component -public class StompSubscribeStrategy implements StompCommandStrategy{ +@RequiredArgsConstructor +public class StompSubscribeStrategy implements StompCommandStrategy { private static final String SUB_END_POINT = "/sub/chat/room/"; + private final ChattingRoomService chattingRoomService; + + @Value("${chat.topic}") + public String chatTopic; + @Override public boolean supports(StompCommand command) { return StompCommand.SUBSCRIBE.equals(command); @@ -25,6 +36,12 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess throw new ChatSubscribeException(); } + Long senderId = (Long) accessor.getSessionAttributes().get(CHAT_USER_ID); + Long roomId = Long.valueOf(destination.replace(SUB_END_POINT, "")); + String senderName = accessor.getFirstNativeHeader("senderName"); + + chattingRoomService.subscribeChatRoom(roomId, senderId, senderName); + return message; } } From 0a62629547082a583962d148a3073804c024bee9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 15:41:05 +0900 Subject: [PATCH 273/770] =?UTF-8?q?fix:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 30 ++++++++++++++++ .../members/controller/MemberController.java | 36 ++++--------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 76763de6..c9b8c704 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -1,9 +1,15 @@ package com.gachtaxi.domain.members.controller; +import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; +import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; import com.gachtaxi.domain.members.service.AuthService; +import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.auth.enums.OauthLoginStatus; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.service.JwtService; +import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; +import com.gachtaxi.global.common.mail.service.EmailService; import com.gachtaxi.global.common.response.ApiResponse; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -15,14 +21,19 @@ import static com.gachtaxi.domain.members.controller.ResponseMessage.*; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.KakaoAuthCode; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.OauthKakaoResponse; +import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; +import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_SEND_SUCCESS; +import static org.springframework.http.HttpStatus.OK; @RequestMapping("/auth") @RestController @RequiredArgsConstructor public class AuthController { + private final EmailService emailService; private final AuthService authService; private final JwtService jwtService; + private final MemberService memberService; @PostMapping("/login/kakao") public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { @@ -41,4 +52,23 @@ public ApiResponse reissueRefreshToken(HttpServletRequest request, HttpSer jwtService.setHeader(jwtTokenDto.accessToken(), response); return ApiResponse.response(HttpStatus.OK, REFRESH_TOKEN_REISSUE.getMessage()); } + + @PostMapping("/code/mail") + public ApiResponse sendEmail( + @RequestBody @Valid EmailAddressDto emailDto, + @CurrentMemberId Long userId + ) { + emailService.sendEmail(emailDto.email()); + return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); + } + + @PatchMapping("/code/mail") + public ApiResponse checkAuthCodeAndUpdateEmail( + @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, + @CurrentMemberId Long userId + ) { + emailService.checkEmailAuthCode(dto.email(), dto.authCode()); + memberService.updateInactiveMemberOfEmail(dto.email(), userId); + return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); + } } diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index c936bbb9..4f0dc35b 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -1,22 +1,18 @@ package com.gachtaxi.domain.members.controller; -import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; -import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; import com.gachtaxi.domain.members.service.MemberService; -import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; -import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; -import com.gachtaxi.global.common.mail.service.EmailService; import com.gachtaxi.global.common.response.ApiResponse; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -import static com.gachtaxi.domain.members.controller.ResponseMessage.*; -import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; -import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_SEND_SUCCESS; -import static org.springframework.http.HttpStatus.*; +import static com.gachtaxi.domain.members.controller.ResponseMessage.REGISTER_SUCCESS; +import static org.springframework.http.HttpStatus.OK; @RequestMapping("/api/members") @RestController @@ -24,30 +20,10 @@ public class MemberController { private final MemberService memberService; - private final EmailService emailService; @PostMapping() public ApiResponse signUp(@RequestBody @Valid UserSignUpRequestDto signUpDto, HttpServletResponse response) { memberService.saveMember(signUpDto, response); return ApiResponse.response(OK, REGISTER_SUCCESS.getMessage()); } - - @PostMapping("/mail-authcode") - public ApiResponse sendEmail( - @RequestBody @Valid EmailAddressDto emailDto, - @CurrentMemberId Long userId - ) { - emailService.sendEmail(emailDto.email()); - return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); - } - - @PatchMapping("/mail-authcode") - public ApiResponse checkAuthCodeAndUpdateEmail( - @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, - @CurrentMemberId Long userId - ) { - emailService.checkEmailAuthCode(dto.email(), dto.authCode()); - memberService.updateInactiveMemberOfEmail(dto.email(), userId); - return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); - } } From d17ad2b194e98d1f54b5827dd156c713ea057ab9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 16:42:49 +0900 Subject: [PATCH 274/770] =?UTF-8?q?fix:=20=ED=86=A0=ED=81=B0=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=EB=A1=9C=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jwt/filter/JwtAuthenticationFilter.java | 24 ++++++++++++++++--- .../global/auth/jwt/util/JwtExtractor.java | 18 +++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index 60d3cd2b..54b77216 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -7,6 +7,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; @@ -16,9 +17,9 @@ import java.io.IOException; import java.util.Optional; -import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_EXPIRED; -import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_NOT_FOUND; +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.*; +@Slf4j @RequiredArgsConstructor public class JwtAuthenticationFilter extends OncePerRequestFilter { @@ -38,7 +39,13 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse String accessToken = token.get(); - if(jwtExtractor.isExpired(accessToken)){ + if (!jwtExtractor.validateJwtToken(accessToken)) { + request.setAttribute(JWT_ERROR, JWT_TOKEN_INVALID); + filterChain.doFilter(request, response); + return; + } + + if (jwtExtractor.isExpired(accessToken)) { request.setAttribute(JWT_ERROR, JWT_TOKEN_EXPIRED); filterChain.doFilter(request, response); return; @@ -57,4 +64,15 @@ private void saveAuthentcation(String token) { Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); } + +// private boolean checkValidToken(String token) { +// try { +// JwtParser parser = jwtExtractor.getParser(); +// parser.parseClaimsJws(token).getBody(); +// }catch (JwtException e){ +// log.error(e.getMessage()); +// return false; +// } +// return true; +// } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java index 6af88ed0..30e79483 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java @@ -51,7 +51,6 @@ public String getRole(String token) { public Boolean isExpired(String token) { Claims claims = parseClaims(token); - if(claims == null) return true; return claims.getExpiration().before(new Date()); } @@ -69,12 +68,19 @@ private Claims parseClaims(String token) { JwtParser parser = Jwts.parserBuilder() .setSigningKey(key) .build(); - Claims claims = null; - try{ - claims = parser.parseClaimsJws(token).getBody(); + Claims claims = parser.parseClaimsJws(token).getBody(); + return claims; + } + + public boolean validateJwtToken(String token) { + try { + JwtParser parser = Jwts.parserBuilder() + .setSigningKey(key) + .build(); + parser.parseClaimsJws(token).getBody(); + return true; }catch (JwtException e){ - log.error(e.getMessage()); + return false; } - return claims; } } From cb03589d74e21d25ad21c12a8c07e32539b0b155 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 16:50:24 +0900 Subject: [PATCH 275/770] =?UTF-8?q?fix:=20=EC=9D=B8=EA=B0=80=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/config/PermitUrlConfig.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index a74a7339..c02e55a2 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -9,7 +9,7 @@ public String[] getPublicUrl(){ return new String[]{ "/auth/login/kakao", "/auth/refersh", - "/api/members/signup", + "/api/members", "/swagger-ui/**", "/v3/api-docs/**", @@ -18,14 +18,13 @@ public String[] getPublicUrl(){ public String[] getMemberUrl(){ return new String[]{ - "/api/tmp-members/**", - "/api/admin/email/template", + "/auth/code/**", }; } public String[] getAdminUrl(){ return new String[]{ - + "/api/admin/email/template", }; } From 8dba344768e4682fea877c0349632803577750f9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 17:03:27 +0900 Subject: [PATCH 276/770] =?UTF-8?q?fix:=20=EB=A0=88=EB=94=94=EC=8A=A4=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=ED=8F=AC=EB=A7=B7=20=ED=98=95=EC=8B=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/redis/RedisUtil.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java index bfe3c5d8..66a230f6 100644 --- a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java +++ b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java @@ -13,8 +13,8 @@ @RequiredArgsConstructor public class RedisUtil { - private final static String PREFIX_TOKEN = "refresh_"; - private final static String PREFIX_EMAIL_CODE = "email_"; + private final static String TOKEN_FORMAT = "refreshToken:%s"; + private final static String EMAIL_CODE_FORMAT = "emailAuthCode:%s"; private final RedisTemplate redisTemplate; @@ -24,16 +24,19 @@ public class RedisUtil { @Value("${gachtaxi.auth.redis.emailAuthCodeExpiration}") private Long emailAuthCodeExpiration; - public void setRefreshToken(Long key, String value) { - redisTemplate.opsForValue().set(PREFIX_TOKEN + key, value, refreshTokenExpiration, TimeUnit.MILLISECONDS); + public void setRefreshToken(Long id, String value) { + String key = String.format(TOKEN_FORMAT, id); + redisTemplate.opsForValue().set(key, value, refreshTokenExpiration, TimeUnit.MILLISECONDS); } - public void setEmailAuthCode(String key, String value) { - redisTemplate.opsForValue().set(PREFIX_EMAIL_CODE+key, value, emailAuthCodeExpiration, TimeUnit.MILLISECONDS); + public void setEmailAuthCode(String email, String value) { + String key = String.format(EMAIL_CODE_FORMAT, email); + redisTemplate.opsForValue().set(key, value, emailAuthCodeExpiration, TimeUnit.MILLISECONDS); } - public Object getRefreshToken(Long key){ - Object getObjecet = redisTemplate.opsForValue().get(PREFIX_TOKEN +key); + public Object getRefreshToken(Long id){ + String key = String.format(TOKEN_FORMAT, id); + Object getObjecet = redisTemplate.opsForValue().get(key); if(getObjecet == null){ throw new RefreshTokenNotFoundException(); @@ -42,8 +45,9 @@ public Object getRefreshToken(Long key){ return getObjecet; } - public Object getEmailAuthCode(String key){ - Object getObjecet = redisTemplate.opsForValue().get(PREFIX_EMAIL_CODE+key); + public Object getEmailAuthCode(String email){ + String key = String.format(EMAIL_CODE_FORMAT, email); + Object getObjecet = redisTemplate.opsForValue().get(key); if(getObjecet == null){ throw new AuthCodeExpirationException(); @@ -53,10 +57,10 @@ public Object getEmailAuthCode(String key){ } public boolean hasKey(Long key){ - return Boolean.TRUE.equals(redisTemplate.hasKey(PREFIX_TOKEN + key)); + return Boolean.TRUE.equals(redisTemplate.hasKey(TOKEN_FORMAT + key)); } public boolean delete(Long key){ - return Boolean.TRUE.equals(redisTemplate.delete(PREFIX_TOKEN + key)); + return Boolean.TRUE.equals(redisTemplate.delete(TOKEN_FORMAT + key)); } } From 309a1615015b372abca2a31a89f1329c17df6b9f Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:46:08 +0900 Subject: [PATCH 277/770] =?UTF-8?q?feat:=20STOMP=20connect=20=EC=A0=84?= =?UTF-8?q?=EB=9E=B5=20=ED=86=A0=ED=81=B0=20=EC=B6=94=EC=B6=9C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/stomp/strategy/StompConnectStrategy.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java index 97e6fd25..e997b079 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java @@ -16,7 +16,7 @@ public class StompConnectStrategy implements StompCommandStrategy{ private static final String TOKEN_PREFIX = "Bearer "; - private static final String CHAT_USER_ID = "CHAT_USER_ID"; + public static final String CHAT_USER_ID = "CHAT_USER_ID"; private final JwtExtractor jwtExtractor; @@ -33,11 +33,13 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess throw new TokenNotExistException(); } + String token = jwtToken.replace(TOKEN_PREFIX, "").trim(); + /* todo 인증 객체 생성 후 설정하기 */ - Long userId = jwtExtractor.getId(jwtToken); + Long userId = jwtExtractor.getId(token); accessor.getSessionAttributes().put(CHAT_USER_ID, userId); return message; From 3e19eabed3edf71027cecb11cbb1823cdea55c19 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:48:59 +0900 Subject: [PATCH 278/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EB=B0=8F=20=EC=B1=84=ED=8C=85=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/controller/ChattingController.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java new file mode 100644 index 00000000..32322e59 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -0,0 +1,43 @@ +package com.gachtaxi.domain.chat.controller; + +import com.gachtaxi.domain.chat.dto.request.ChatMessageRequest; +import com.gachtaxi.domain.chat.dto.request.ChattingRoomResponse; +import com.gachtaxi.domain.chat.service.ChattingRoomService; +import com.gachtaxi.domain.chat.service.ChattingService; +import com.gachtaxi.global.common.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.messaging.handler.annotation.MessageMapping; +import org.springframework.messaging.simp.SimpMessageHeaderAccessor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.gachtaxi.domain.chat.controller.ResponseMessage.CREATE_CHATTING_ROOM_SUCCESS; +import static org.springframework.http.HttpStatus.OK; + +@Slf4j +@RestController +@RequiredArgsConstructor +public class ChattingController { + + private final ChattingService chattingService; + private final ChattingRoomService chattingRoomService; + + /* + 채팅방 생성 + 채팅 구독 + 채팅 메시지 전달 + */ + + @GetMapping("/api/chat/room") + public ApiResponse createChattingRoom() { + ChattingRoomResponse response = chattingRoomService.save(); + + return ApiResponse.response(OK, CREATE_CHATTING_ROOM_SUCCESS.getMessage(), response); + } + + @MessageMapping("/chat/message") + public void message(ChatMessageRequest request, SimpMessageHeaderAccessor headerAccessor) { + chattingService.chat(request, headerAccessor); + } +} From def0fe0d554c5db0152d93638773f5da1e8ac74a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:49:20 +0900 Subject: [PATCH 279/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/ChattingRoomService.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java new file mode 100644 index 00000000..c72a796d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -0,0 +1,62 @@ +package com.gachtaxi.domain.chat.service; + +import com.gachtaxi.domain.chat.dto.request.ChatMessage; +import com.gachtaxi.domain.chat.dto.request.ChattingRoomResponse; +import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; +import com.gachtaxi.domain.chat.redis.RedisChatPublisher; +import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; +import com.gachtaxi.domain.chat.repository.ChattingRoomRepository; +import com.gachtaxi.domain.members.service.MemberService; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class ChattingRoomService { + + private final ChattingRoomRepository chattingRoomRepository; + private final ChattingParticipantRepository chattingParticipantRepository; + private final MemberService memberService; + private final RedisChatPublisher redisChatPublisher; + + @Value("${chat.topic}") + public String chatTopic; + + @Transactional + public ChattingRoomResponse save() { + ChattingRoom chattingRoom = ChattingRoom.builder().build(); + + chattingRoomRepository.save(chattingRoom); + return ChattingRoomResponse.from(chattingRoom); + } + + @Transactional + public void delete(long chattingRoomId) { + ChattingRoom chattingRoom = find(chattingRoomId); + + chattingRoom.delete(); + } + + @Transactional + public void subscribeChatRoom(long roomId, long senderId, String senderName) { + ChattingRoom chattingRoom = find(roomId); +// Members members = memberService.find(); + + ChannelTopic topic = new ChannelTopic(chatTopic + roomId); + ChatMessage chatMessage = ChatMessage.subscribe(roomId, senderId, senderName, senderName+" 님이 입장하셨습니다."); + +// ChattingParticipant chattingParticipant = ChattingParticipant.of(chattingRoom, members); +// chattingParticipantRepository.save(chattingParticipant); + + redisChatPublisher.publish(topic, chatMessage); + } + + public ChattingRoom find(long chattingRoomId) { + return chattingRoomRepository.findById(chattingRoomId) + .orElseThrow(ChattingRoomNotFoundException::new); + } +} From a205f83d4be1d2e3abea77886dbda49b1307c15e Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:49:24 +0900 Subject: [PATCH 280/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChattingService.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java new file mode 100644 index 00000000..03e97b4c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -0,0 +1,38 @@ +package com.gachtaxi.domain.chat.service; + +import com.gachtaxi.domain.chat.dto.request.ChatMessage; +import com.gachtaxi.domain.chat.dto.request.ChatMessageRequest; +import com.gachtaxi.domain.chat.entity.ChattingMessage; +import com.gachtaxi.domain.chat.redis.RedisChatPublisher; +import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.messaging.simp.SimpMessageHeaderAccessor; +import org.springframework.stereotype.Service; + +import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; + +@Service +@RequiredArgsConstructor +public class ChattingService { + + private final ChattingMessageRepository chattingMessageRepository; + private final RedisChatPublisher redisChatPublisher; + + @Value("${chat.topic}") + public String chatTopic; + + public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) { + Long userId = (Long) accessor.getSessionAttributes().get(CHAT_USER_ID); + + ChatMessage chatMessage = ChatMessage.of(request, userId); + ChattingMessage chattingMessage = ChattingMessage.of(chatMessage); + + chattingMessageRepository.save(chattingMessage); + + ChannelTopic topic = new ChannelTopic(chatTopic + chatMessage.roomId()); + + redisChatPublisher.publish(topic, chatMessage); + } +} From 47697312fb23fb8f4102bcf15ac25429044e4f87 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:49:41 +0900 Subject: [PATCH 281/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/entity/ChattingRoom.java | 16 +++++++++++++--- .../domain/chat/entity/enums/Status.java | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/entity/enums/Status.java diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java index 0458bd56..ccff29b8 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java @@ -1,15 +1,25 @@ package com.gachtaxi.domain.chat.entity; +import com.gachtaxi.domain.chat.entity.enums.Status; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.Entity; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.*; import lombok.experimental.SuperBuilder; @Getter @Entity @SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor public class ChattingRoom extends BaseEntity { + + @Builder.Default + @Enumerated(EnumType.STRING) + private Status status = Status.ACTIVE; + + public void delete() { + status = Status.INACTIVE; + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/enums/Status.java b/src/main/java/com/gachtaxi/domain/chat/entity/enums/Status.java new file mode 100644 index 00000000..94a11fb6 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/entity/enums/Status.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.chat.entity.enums; + +public enum Status { + ACTIVE, INACTIVE +} From 2f25275825139b4bd2038be6f1174680249cce0b Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:49:53 +0900 Subject: [PATCH 282/770] =?UTF-8?q?feat:=20=EC=A0=95=EC=A0=81=20=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/entity/ChattingMessage.java | 13 +++++++++++++ .../domain/chat/entity/ChattingParticipant.java | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java index 774292e9..dd3c32cc 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java @@ -1,13 +1,16 @@ package com.gachtaxi.domain.chat.entity; +import com.gachtaxi.domain.chat.dto.request.ChatMessage; import jakarta.persistence.Id; import lombok.*; +import lombok.experimental.SuperBuilder; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.mongodb.core.mapping.Document; import java.time.LocalDateTime; @Getter +@SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) @Document(collection = "chatting_messages") public class ChattingMessage { @@ -27,4 +30,14 @@ public class ChattingMessage { @LastModifiedDate private LocalDateTime updatedAt; + + public static ChattingMessage of(ChatMessage chatMessage) { + return ChattingMessage.builder() + .senderId(chatMessage.senderId()) + .senderName(chatMessage.senderName()) + .roomId(chatMessage.roomId()) + .message(chatMessage.message()) + .timeStamp(chatMessage.timeStamp()) + .build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index f19e3cc9..663e6853 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -23,4 +23,11 @@ public class ChattingParticipant extends BaseEntity { @ManyToOne @JoinColumn(name = "members_id") private Members members; + + public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) { + return ChattingParticipant.builder() + .chattingRoom(chattingRoom) + .members(members) + .build(); + } } From 46141c2a970226ac4d0dad2bc473440dfd6c95db Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:50:07 +0900 Subject: [PATCH 283/770] =?UTF-8?q?feat:=20=EC=98=88=EC=99=B8=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/exception/ChatSendEndPointException.java | 12 ++++++++++++ .../exception/ChattingRoomNotFoundException.java | 12 ++++++++++++ .../gachtaxi/domain/chat/exception/ErrorMessage.java | 4 +++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/exception/ChatSendEndPointException.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/exception/ChattingRoomNotFoundException.java diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ChatSendEndPointException.java b/src/main/java/com/gachtaxi/domain/chat/exception/ChatSendEndPointException.java new file mode 100644 index 00000000..235d01af --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ChatSendEndPointException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.chat.exception.ErrorMessage.CHAT_SEND_END_POINT_ERROR; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class ChatSendEndPointException extends BaseException { + public ChatSendEndPointException() { + super(BAD_REQUEST, CHAT_SEND_END_POINT_ERROR.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ChattingRoomNotFoundException.java b/src/main/java/com/gachtaxi/domain/chat/exception/ChattingRoomNotFoundException.java new file mode 100644 index 00000000..9ec77f6c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ChattingRoomNotFoundException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.chat.exception.ErrorMessage.CHATTING_ROOM_NOT_FOUND; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class ChattingRoomNotFoundException extends BaseException { + public ChattingRoomNotFoundException() { + super(BAD_REQUEST, CHATTING_ROOM_NOT_FOUND.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java index 86910efe..4986e3f3 100644 --- a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java @@ -11,6 +11,8 @@ public enum ErrorMessage { MESSAGING_ERROR("STOMP 메시지 전송에 실패했습니다"), JSON_PROCESSING_ERROR("Json 직렬화에 실패했습니다."), REDIS_SUB_ERROR("[Redis] 메시지 전송에 실패했습니다."), - CHAT_SUBSCRIBE_ERROR("올바르지 않은 채팅 구독 경로입니다."); + CHAT_SUBSCRIBE_ERROR("올바르지 않은 채팅 구독 경로입니다."), + CHATTING_ROOM_NOT_FOUND("존재하지 않는 채팅방입니다."), + CHAT_SEND_END_POINT_ERROR("올바르지 않은 채팅 메시지 경로입니다."); private final String message; } From a54e73a7510547094366859125cf26903fc83e1a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:50:31 +0900 Subject: [PATCH 284/770] =?UTF-8?q?feat:=20=EB=A9=94=EC=84=B8=EC=A7=80=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/dto/request/ChatMessage.java | 20 ++++++++++++++++--- .../domain/chat/entity/enums/MessageType.java | 5 +++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index 08a9dc6f..a9bcb912 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.chat.dto.request; +import com.gachtaxi.domain.chat.entity.enums.MessageType; import lombok.Builder; import java.time.LocalDateTime; @@ -10,15 +11,28 @@ public record ChatMessage( Long senderId, String senderName, String message, - LocalDateTime timeStamp + LocalDateTime timeStamp, + MessageType messageType ) { - public static ChatMessage of(ChatMessageRequest request, long senderId, LocalDateTime timeStamp) { + public static ChatMessage of(ChatMessageRequest request, long senderId) { return ChatMessage.builder() .roomId(request.roomId()) .senderId(senderId) .senderName(request.senderName()) .message(request.message()) - .timeStamp(timeStamp) + .timeStamp(LocalDateTime.now()) + .messageType(MessageType.MESSAGE) + .build(); + } + + public static ChatMessage subscribe(long roomId, Long senderId, String senderName, String message) { + return ChatMessage.builder() + .roomId(roomId) + .senderId(senderId) + .senderName(senderName) + .message(message) + .timeStamp(LocalDateTime.now()) + .messageType(MessageType.ENTER) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java b/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java new file mode 100644 index 00000000..81c07738 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.chat.entity.enums; + +public enum MessageType { + MESSAGE, ENTER +} From a35b4f70c676f0fc451abe050ba3dba90c502420 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:50:43 +0900 Subject: [PATCH 285/770] =?UTF-8?q?feat:=20=EC=9D=91=EB=8B=B5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/controller/ResponseMessage.java | 13 +++++++++++++ .../chat/dto/request/ChattingRoomResponse.java | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/dto/request/ChattingRoomResponse.java diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java new file mode 100644 index 00000000..b1245a0b --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.chat.controller; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ResponseMessage { + + CREATE_CHATTING_ROOM_SUCCESS("채팅방 생성에 성공했습니다."); + + private final String message; +} diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChattingRoomResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChattingRoomResponse.java new file mode 100644 index 00000000..97f6eb71 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChattingRoomResponse.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.chat.dto.request; + +import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.entity.enums.Status; + +public record ChattingRoomResponse( + Long roomId, + Status status +) { + public static ChattingRoomResponse from(ChattingRoom chattingRoom) { + return new ChattingRoomResponse(chattingRoom.getId(), chattingRoom.getStatus()); + } +} From 7a88c7991c4ce7871edb0c68e3f233767f983290 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:50:48 +0900 Subject: [PATCH 286/770] =?UTF-8?q?feat:=20=EC=9B=B9=EC=86=8C=EC=BC=93=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index 45ddfc07..266ca8ae 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -13,6 +13,8 @@ public String[] getPublicUrl(){ "/swagger-ui/**", "/v3/api-docs/**", + + "/ws" }; } From e86f155aa128c594b2cea793c478f032cca5369a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:50:55 +0900 Subject: [PATCH 287/770] =?UTF-8?q?feat:=20=ED=8C=8C=EC=9D=BC=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/service/ChatService.java | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/chat/service/ChatService.java diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChatService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChatService.java deleted file mode 100644 index f87785b0..00000000 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChatService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gachtaxi.domain.chat.service; - -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class ChatService { -} From 34641d31cf80a65bbe88c36723cfcf5c4f576f5c Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 17:51:40 +0900 Subject: [PATCH 288/770] =?UTF-8?q?refactor:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/chat/service/ChatRoomService.java | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/chat/service/ChatRoomService.java diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChatRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChatRoomService.java deleted file mode 100644 index 7cfc47bd..00000000 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChatRoomService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gachtaxi.domain.chat.service; - -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class ChatRoomService { -} From 59327437c67e4b29d2a1ef03efb8e65754b99f55 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 19:25:32 +0900 Subject: [PATCH 289/770] =?UTF-8?q?refactor:=20roomId=EB=8F=84=20=EC=84=B8?= =?UTF-8?q?=EC=85=98=EC=97=90=20=EC=A0=80=EC=9E=A5=ED=95=B4=EC=84=9C=20?= =?UTF-8?q?=ED=99=9C=EC=9A=A9=ED=95=98=EB=8A=94=20=EA=B2=83=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/dto/request/ChatMessage.java | 4 ++-- .../chat/dto/request/ChatMessageRequest.java | 1 - .../exception/WebSocketSessionException.java | 12 ++++++++++ .../domain/chat/service/ChattingService.java | 22 ++++++++++++++----- .../strategy/StompSubscribeStrategy.java | 3 +++ 5 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/exception/WebSocketSessionException.java diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index a9bcb912..6b5e56f4 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -14,9 +14,9 @@ public record ChatMessage( LocalDateTime timeStamp, MessageType messageType ) { - public static ChatMessage of(ChatMessageRequest request, long senderId) { + public static ChatMessage of(ChatMessageRequest request, long roomId, long senderId) { return ChatMessage.builder() - .roomId(request.roomId()) + .roomId(roomId) .senderId(senderId) .senderName(request.senderName()) .message(request.message()) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java index 18743b72..0bcccff1 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java @@ -1,7 +1,6 @@ package com.gachtaxi.domain.chat.dto.request; public record ChatMessageRequest( - Long roomId, String senderName, String message ) { diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/WebSocketSessionException.java b/src/main/java/com/gachtaxi/domain/chat/exception/WebSocketSessionException.java new file mode 100644 index 00000000..b74692a3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/exception/WebSocketSessionException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.chat.exception.ErrorMessage.*; +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; + +public class WebSocketSessionException extends BaseException { + public WebSocketSessionException(String keyword) { + super(INTERNAL_SERVER_ERROR, keyword + WEB_SOCKET_SESSION_ATTR_NOT_FOUND); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 03e97b4c..8fd4f7cf 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -3,16 +3,22 @@ import com.gachtaxi.domain.chat.dto.request.ChatMessage; import com.gachtaxi.domain.chat.dto.request.ChatMessageRequest; import com.gachtaxi.domain.chat.entity.ChattingMessage; +import com.gachtaxi.domain.chat.exception.WebSocketSessionException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.stereotype.Service; +import java.util.Optional; + import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; +import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_ROOM_ID; +@Slf4j @Service @RequiredArgsConstructor public class ChattingService { @@ -24,15 +30,21 @@ public class ChattingService { public String chatTopic; public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) { - Long userId = (Long) accessor.getSessionAttributes().get(CHAT_USER_ID); + long roomId = getSessionAttribute(accessor, CHAT_ROOM_ID, Long.class); + long userId = getSessionAttribute(accessor, CHAT_USER_ID, Long.class); - ChatMessage chatMessage = ChatMessage.of(request, userId); + ChatMessage chatMessage = ChatMessage.of(request, roomId, userId); ChattingMessage chattingMessage = ChattingMessage.of(chatMessage); - chattingMessageRepository.save(chattingMessage); - ChannelTopic topic = new ChannelTopic(chatTopic + chatMessage.roomId()); - redisChatPublisher.publish(topic, chatMessage); + + chattingMessageRepository.save(chattingMessage); + } + + private T getSessionAttribute(SimpMessageHeaderAccessor accessor, String attributeName, Class type) { + return Optional.ofNullable(accessor.getSessionAttributes()) + .map(attrs -> type.cast(attrs.get(attributeName))) + .orElseThrow(() -> new WebSocketSessionException(attributeName)); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java index ef2bfc73..95e0a5f1 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java @@ -17,6 +17,8 @@ public class StompSubscribeStrategy implements StompCommandStrategy { private static final String SUB_END_POINT = "/sub/chat/room/"; + public static final String CHAT_ROOM_ID = "CHAT_ROOM_ID"; + private final ChattingRoomService chattingRoomService; @@ -41,6 +43,7 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess String senderName = accessor.getFirstNativeHeader("senderName"); chattingRoomService.subscribeChatRoom(roomId, senderId, senderName); + accessor.getSessionAttributes().put(CHAT_ROOM_ID, roomId); return message; } From a3a765162e30fc1456db1167927170fda7113145 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 19:25:46 +0900 Subject: [PATCH 290/770] =?UTF-8?q?feat:=20=EC=9B=B9=EC=86=8C=EC=BC=93=20?= =?UTF-8?q?=EC=84=B8=EC=85=98=20=EC=97=90=EB=9F=AC=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/chat/exception/ErrorMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java index 4986e3f3..edf2fefa 100644 --- a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java @@ -13,6 +13,7 @@ public enum ErrorMessage { REDIS_SUB_ERROR("[Redis] 메시지 전송에 실패했습니다."), CHAT_SUBSCRIBE_ERROR("올바르지 않은 채팅 구독 경로입니다."), CHATTING_ROOM_NOT_FOUND("존재하지 않는 채팅방입니다."), - CHAT_SEND_END_POINT_ERROR("올바르지 않은 채팅 메시지 경로입니다."); + CHAT_SEND_END_POINT_ERROR("올바르지 않은 채팅 메시지 경로입니다."), + WEB_SOCKET_SESSION_ATTR_NOT_FOUND(" 가 웹소켓 세션에 존재하지 않습니다."); private final String message; } From 0151072fd1494b06de545ff1261f430bc35115d5 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 19:26:00 +0900 Subject: [PATCH 291/770] =?UTF-8?q?refactor:=20=EC=9E=85=EC=9E=A5=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=83=81=EC=88=98=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/service/ChattingRoomService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index c72a796d..197d2232 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -18,6 +18,8 @@ @RequiredArgsConstructor public class ChattingRoomService { + private static final String ENTER_MESSAGE =" 님이 입장하셨습니다."; + private final ChattingRoomRepository chattingRoomRepository; private final ChattingParticipantRepository chattingParticipantRepository; private final MemberService memberService; @@ -47,7 +49,7 @@ public void subscribeChatRoom(long roomId, long senderId, String senderName) { // Members members = memberService.find(); ChannelTopic topic = new ChannelTopic(chatTopic + roomId); - ChatMessage chatMessage = ChatMessage.subscribe(roomId, senderId, senderName, senderName+" 님이 입장하셨습니다."); + ChatMessage chatMessage = ChatMessage.subscribe(roomId, senderId, senderName, senderName + ENTER_MESSAGE); // ChattingParticipant chattingParticipant = ChattingParticipant.of(chattingRoom, members); // chattingParticipantRepository.save(chattingParticipant); From aaccd872b3e44933872b26961e8c86c2a36b5db7 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 19:31:25 +0900 Subject: [PATCH 292/770] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=96=B4=EB=85=B8=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/controller/ChattingController.java | 8 -------- .../com/gachtaxi/domain/chat/entity/ChattingRoom.java | 1 - .../com/gachtaxi/domain/chat/service/ChattingService.java | 2 -- .../com/gachtaxi/domain/chat/stomp/StompErrorHandler.java | 8 -------- 4 files changed, 19 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/chat/stomp/StompErrorHandler.java diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index 32322e59..1eb9809b 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -6,7 +6,6 @@ import com.gachtaxi.domain.chat.service.ChattingService; import com.gachtaxi.global.common.response.ApiResponse; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.web.bind.annotation.GetMapping; @@ -15,7 +14,6 @@ import static com.gachtaxi.domain.chat.controller.ResponseMessage.CREATE_CHATTING_ROOM_SUCCESS; import static org.springframework.http.HttpStatus.OK; -@Slf4j @RestController @RequiredArgsConstructor public class ChattingController { @@ -23,12 +21,6 @@ public class ChattingController { private final ChattingService chattingService; private final ChattingRoomService chattingRoomService; - /* - 채팅방 생성 - 채팅 구독 - 채팅 메시지 전달 - */ - @GetMapping("/api/chat/room") public ApiResponse createChattingRoom() { ChattingRoomResponse response = chattingRoomService.save(); diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java index ccff29b8..febc341a 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java @@ -12,7 +12,6 @@ @Entity @SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor public class ChattingRoom extends BaseEntity { @Builder.Default diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 8fd4f7cf..7a2abb6f 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -7,7 +7,6 @@ import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; @@ -18,7 +17,6 @@ import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_ROOM_ID; -@Slf4j @Service @RequiredArgsConstructor public class ChattingService { diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/StompErrorHandler.java b/src/main/java/com/gachtaxi/domain/chat/stomp/StompErrorHandler.java deleted file mode 100644 index dc9712e4..00000000 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/StompErrorHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.gachtaxi.domain.chat.stomp; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.messaging.StompSubProtocolErrorHandler; - -@Configuration -public class StompErrorHandler extends StompSubProtocolErrorHandler { -} From 117d147a5049c3d09a6b6b96195860fd66876de2 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 19:59:00 +0900 Subject: [PATCH 293/770] =?UTF-8?q?refactor:=20Throwable=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/handler/StompExceptionHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/exception/handler/StompExceptionHandler.java b/src/main/java/com/gachtaxi/global/common/exception/handler/StompExceptionHandler.java index 2db3f636..3ec06fe3 100644 --- a/src/main/java/com/gachtaxi/global/common/exception/handler/StompExceptionHandler.java +++ b/src/main/java/com/gachtaxi/global/common/exception/handler/StompExceptionHandler.java @@ -5,7 +5,6 @@ import com.gachtaxi.global.common.exception.BaseException; import com.gachtaxi.global.common.response.ApiResponse; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaderAccessor; @@ -23,7 +22,9 @@ public class StompExceptionHandler extends StompSubProtocolErrorHandler { @Override public Message handleClientMessageProcessingError(Message clientMessage, Throwable ex) { - if (ex instanceof BaseException baseException) { + Throwable cause = ex.getCause(); + + if (cause instanceof BaseException baseException) { return sendErrorMessage(baseException); } From 273b070bb0295c6eab9c61a0fef017a2f9d55195 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 21:10:26 +0900 Subject: [PATCH 294/770] =?UTF-8?q?feat:=20AWS=20SDK=20=EC=B5=9C=EC=8B=A0?= =?UTF-8?q?=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3b7d04d3..c493364f 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ dependencies { implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0' // AWS SES - implementation 'software.amazon.awssdk:ses:2.20.7' + implementation 'software.amazon.awssdk:ses:2.29.46' // S3 Client implementation 'software.amazon.awssdk:s3:2.20.126' From c9fc793b1ed915d8813c15fa4a1d77d90a06dc6a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 9 Jan 2025 21:36:03 +0900 Subject: [PATCH 295/770] =?UTF-8?q?refactor:=20=EC=A0=95=EC=A0=81=20?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/chat/entity/ChattingMessage.java | 2 +- .../java/com/gachtaxi/domain/chat/service/ChattingService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java index dd3c32cc..c329517f 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java @@ -31,7 +31,7 @@ public class ChattingMessage { @LastModifiedDate private LocalDateTime updatedAt; - public static ChattingMessage of(ChatMessage chatMessage) { + public static ChattingMessage from(ChatMessage chatMessage) { return ChattingMessage.builder() .senderId(chatMessage.senderId()) .senderName(chatMessage.senderName()) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 7a2abb6f..f0b3e933 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -32,7 +32,7 @@ public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) long userId = getSessionAttribute(accessor, CHAT_USER_ID, Long.class); ChatMessage chatMessage = ChatMessage.of(request, roomId, userId); - ChattingMessage chattingMessage = ChattingMessage.of(chatMessage); + ChattingMessage chattingMessage = ChattingMessage.from(chatMessage); ChannelTopic topic = new ChannelTopic(chatTopic + chatMessage.roomId()); redisChatPublisher.publish(topic, chatMessage); From 9504d166160f83227b25bc141a73f3d03f1d698d Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 21:44:22 +0900 Subject: [PATCH 296/770] =?UTF-8?q?remove:=20InactiveMemberController?= =?UTF-8?q?=EB=A5=BC=20AuthController=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InactiveMemberController.java | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java deleted file mode 100644 index f5ceee9d..00000000 --- a/src/main/java/com/gachtaxi/domain/members/controller/InactiveMemberController.java +++ /dev/null @@ -1,44 +0,0 @@ -//package com.gachtaxi.domain.members.controller; -// -//import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; -//import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; -//import com.gachtaxi.domain.members.service.MemberService; -//import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; -//import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; -//import com.gachtaxi.global.common.mail.service.EmailService; -//import com.gachtaxi.global.common.response.ApiResponse; -//import jakarta.validation.Valid; -//import lombok.RequiredArgsConstructor; -//import org.springframework.web.bind.annotation.*; -// -//import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; -//import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_SEND_SUCCESS; -//import static org.springframework.http.HttpStatus.OK; -// -//@RequestMapping("/api") -//@RestController -//@RequiredArgsConstructor -//public class InactiveMemberController { -// -// private final EmailService emailService; -// private final MemberService memberService; -// -// @PostMapping("/tmp-members/mail-authcode") -// public ApiResponse sendEmail( -// @RequestBody @Valid EmailAddressDto emailDto, -// @CurrentMemberId Long userId -// ) { -// emailService.sendEmail(emailDto.email()); -// return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); -// } -// -// @PatchMapping("/tmp-members/mail-authcode") -// public ApiResponse checkAuthCodeAndUpdateEmail( -// @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, -// @CurrentMemberId Long userId -// ) { -// emailService.checkEmailAuthCode(dto.email(), dto.authCode()); -// memberService.updateInactiveMemberOfEmail(dto.email(), userId); -// return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); -// } -//} From 0937c69be32e5cf6830f86c98ed729c65a795122 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 9 Jan 2025 23:13:25 +0900 Subject: [PATCH 297/770] =?UTF-8?q?feat:=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20?= =?UTF-8?q?=EB=AA=85=EC=84=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AdminMemberController.java | 2 ++ .../gachtaxi/domain/members/controller/AuthController.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AdminMemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/AdminMemberController.java index 1191b2be..82037081 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AdminMemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AdminMemberController.java @@ -3,6 +3,7 @@ import com.gachtaxi.global.common.mail.dto.request.NewTemplateRequestDto; import com.gachtaxi.global.common.mail.service.SesClientTemplateService; import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -21,6 +22,7 @@ public class AdminMemberController { private final SesClientTemplateService sesClientTemplateService; @PostMapping("/email/template") + @Operation(summary = "이메일 템플릿을 생성하는 API 입니다. 생성한 템플릿 명을 환경변수에 적용해주세요.") public ApiResponse createTemplate(@RequestBody @Valid NewTemplateRequestDto dto){ sesClientTemplateService.createTemplate(dto); return ApiResponse.response(HttpStatus.OK, EMAIL_TEMPLATE_CREATE_SUCCESS.getMessage()); diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index c9b8c704..5582f526 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -11,6 +11,7 @@ import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; import com.gachtaxi.global.common.mail.service.EmailService; import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; @@ -36,6 +37,7 @@ public class AuthController { private final MemberService memberService; @PostMapping("/login/kakao") + @Operation(summary = "인가 코드를 전달받아, 소셜 로그인을 진행합니다.") public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { OauthKakaoResponse res = authService.kakaoLogin(kakaoAuthCode.authCode(), response); ResponseMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) @@ -45,6 +47,7 @@ public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthC } @PostMapping("/refresh") + @Operation(summary = "RefreshToken으로 AccessToken과 RefreshToken을 재발급 하는 API 입니다.") public ApiResponse reissueRefreshToken(HttpServletRequest request, HttpServletResponse response) { JwtTokenDto jwtTokenDto = jwtService.reissueJwtToken(request); @@ -54,6 +57,7 @@ public ApiResponse reissueRefreshToken(HttpServletRequest request, HttpSer } @PostMapping("/code/mail") + @Operation(summary = "이메일 인증 코드를 보내는 API입니다.") public ApiResponse sendEmail( @RequestBody @Valid EmailAddressDto emailDto, @CurrentMemberId Long userId @@ -63,6 +67,7 @@ public ApiResponse sendEmail( } @PatchMapping("/code/mail") + @Operation(summary = "사용자가 입력한 인증 코드를 검증 후 이메일 정보를 업데이트하는 API 입니다.") public ApiResponse checkAuthCodeAndUpdateEmail( @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, @CurrentMemberId Long userId From 0d797f4711189c56e57feddb7a23a505bb11cb25 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 10 Jan 2025 05:25:02 +0900 Subject: [PATCH 298/770] =?UTF-8?q?feat:=20redisUtil=20-=20=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=EB=B3=84=20=EC=A1=B4=EC=9E=AC,=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/redis/RedisUtil.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java index 66a230f6..04ee401b 100644 --- a/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java +++ b/src/main/java/com/gachtaxi/global/common/redis/RedisUtil.java @@ -56,11 +56,23 @@ public Object getEmailAuthCode(String email){ return getObjecet; } - public boolean hasKey(Long key){ - return Boolean.TRUE.equals(redisTemplate.hasKey(TOKEN_FORMAT + key)); + public boolean hasRefreshTokenKey(Long id){ + String key = String.format(TOKEN_FORMAT, id); + return Boolean.TRUE.equals(redisTemplate.hasKey(key)); + } + + public boolean hasAuthCodeKey(Long email){ + String key = String.format(EMAIL_CODE_FORMAT, email); + return Boolean.TRUE.equals(redisTemplate.hasKey(key)); } - public boolean delete(Long key){ - return Boolean.TRUE.equals(redisTemplate.delete(TOKEN_FORMAT + key)); + public boolean deleteRefreshToken(Long id){ + String key = String.format(TOKEN_FORMAT, id); + return Boolean.TRUE.equals(redisTemplate.delete(key)); + } + + public boolean deleteAuthCode(Long email){ + String key = String.format(EMAIL_CODE_FORMAT, email); + return Boolean.TRUE.equals(redisTemplate.delete( key)); } } From 9a5cf356b62e34c66ece863ea99119125468e26a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 10 Jan 2025 10:10:08 +0900 Subject: [PATCH 299/770] =?UTF-8?q?refactor:=20=EC=88=98=EC=A0=95=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/chat/controller/ChattingController.java | 4 ++-- .../domain/chat/exception/WebSocketSessionException.java | 2 +- .../com/gachtaxi/domain/chat/service/ChattingRoomService.java | 2 ++ src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index 1eb9809b..e156d5e3 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -8,7 +8,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import static com.gachtaxi.domain.chat.controller.ResponseMessage.CREATE_CHATTING_ROOM_SUCCESS; @@ -21,7 +21,7 @@ public class ChattingController { private final ChattingService chattingService; private final ChattingRoomService chattingRoomService; - @GetMapping("/api/chat/room") + @PostMapping("/api/chat/room") public ApiResponse createChattingRoom() { ChattingRoomResponse response = chattingRoomService.save(); diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/WebSocketSessionException.java b/src/main/java/com/gachtaxi/domain/chat/exception/WebSocketSessionException.java index b74692a3..134f9295 100644 --- a/src/main/java/com/gachtaxi/domain/chat/exception/WebSocketSessionException.java +++ b/src/main/java/com/gachtaxi/domain/chat/exception/WebSocketSessionException.java @@ -7,6 +7,6 @@ public class WebSocketSessionException extends BaseException { public WebSocketSessionException(String keyword) { - super(INTERNAL_SERVER_ERROR, keyword + WEB_SOCKET_SESSION_ATTR_NOT_FOUND); + super(INTERNAL_SERVER_ERROR, keyword + WEB_SOCKET_SESSION_ATTR_NOT_FOUND.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 197d2232..afa5a53e 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.chat.dto.request.ChatMessage; import com.gachtaxi.domain.chat.dto.request.ChattingRoomResponse; import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.entity.enums.Status; import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; @@ -59,6 +60,7 @@ public void subscribeChatRoom(long roomId, long senderId, String senderName) { public ChattingRoom find(long chattingRoomId) { return chattingRoomRepository.findById(chattingRoomId) + .filter(chattingRoom -> chattingRoom.getStatus() == Status.ACTIVE) .orElseThrow(ChattingRoomNotFoundException::new); } } diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index bc0ad49b..fb9344a4 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -25,7 +25,7 @@ public void registerStompEndpoints(StompEndpointRegistry registry) { registry .setErrorHandler(stompExceptionHandler) .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3001"); + .setAllowedOriginPatterns("http://localhost:3000"); } @Override From 758d75923670b65a078a7609204fea2286604157 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 10 Jan 2025 10:19:39 +0900 Subject: [PATCH 300/770] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=20=EC=88=9C=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/service/ChattingService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index f0b3e933..27ae8f93 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -32,12 +32,11 @@ public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) long userId = getSessionAttribute(accessor, CHAT_USER_ID, Long.class); ChatMessage chatMessage = ChatMessage.of(request, roomId, userId); - ChattingMessage chattingMessage = ChattingMessage.from(chatMessage); - ChannelTopic topic = new ChannelTopic(chatTopic + chatMessage.roomId()); - redisChatPublisher.publish(topic, chatMessage); + ChattingMessage chattingMessage = ChattingMessage.from(chatMessage); chattingMessageRepository.save(chattingMessage); + redisChatPublisher.publish(topic, chatMessage); } private T getSessionAttribute(SimpMessageHeaderAccessor accessor, String attributeName, Class type) { From 6bde2bf6aa412ed4783316cff3d1d71b35a3b25a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 10 Jan 2025 16:46:44 +0900 Subject: [PATCH 301/770] =?UTF-8?q?remove:=20=ED=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/jwt/filter/JwtAuthenticationFilter.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index 54b77216..24ed0bc4 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -64,15 +64,4 @@ private void saveAuthentcation(String token) { Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); } - -// private boolean checkValidToken(String token) { -// try { -// JwtParser parser = jwtExtractor.getParser(); -// parser.parseClaimsJws(token).getBody(); -// }catch (JwtException e){ -// log.error(e.getMessage()); -// return false; -// } -// return true; -// } } From ea64db64ea37603ee76ae11799a0aa97336181a5 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 11 Jan 2025 23:46:13 +0900 Subject: [PATCH 302/770] =?UTF-8?q?feat:=20=EC=95=BD=EA=B4=80=20=EB=8F=99?= =?UTF-8?q?=EC=9D=98=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EB=B9=84?= =?UTF-8?q?=EC=A7=80=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/MemberAgreementRequestDto.java | 10 ++++++++++ .../com/gachtaxi/domain/members/entity/Members.java | 7 +++++++ .../gachtaxi/domain/members/service/AuthService.java | 5 +++++ .../domain/members/service/MemberService.java | 11 +++++++++++ 4 files changed, 33 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/MemberAgreementRequestDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberAgreementRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberAgreementRequestDto.java new file mode 100644 index 00000000..9e577b06 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberAgreementRequestDto.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.members.dto.request; + +import jakarta.validation.constraints.NotNull; + +public record MemberAgreementRequestDto( + @NotNull boolean termsAgreement, + @NotNull boolean privacyAgreement, + @NotNull boolean marketingAgreement +) { +} diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index ed4c5ef8..4b4a3143 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.entity; +import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; @@ -83,6 +84,12 @@ public void updateEmail(String email) { this.email = email; } + public void updateAgreement(MemberAgreementRequestDto dto) { + this.termsAgreement = dto.termsAgreement(); + this.privacyAgreement = dto.privacyAgreement(); + this.marketingAgreement = dto.marketingAgreement(); + } + public static Members of(UserSignUpRequestDto dto){ return Members.builder() //.profilePicture(dto.profilePicture()) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 9c0184c9..dca606a4 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.members.service; import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; +import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; @@ -54,4 +55,8 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon jwtService.responseJwtToken(member.getId(), member.getEmail(), member.getRole(), response); return oauthMapper.toKakaoLoginResponse(member.getId()); } + + public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId){ + memberService.updateInactiveMemberOfAgreement(dto, userId); + } } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index f20fbab5..cde96a86 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.members.service; import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; +import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; @@ -46,6 +47,16 @@ public void updateInactiveMemberOfEmail(String email, Long userId) { members.updateEmail(email); } + @Transactional + public void updateInactiveMemberOfAgreement(MemberAgreementRequestDto dto, Long userId) { + Members members = memberRepository.findById(userId) + .orElseThrow(MemberNotFoundException::new); + + members.updateAgreement(dto); + } + + + public Optional findByKakaoId(Long kakaoId) { return memberRepository.findByKakaoId(kakaoId); } From c74a8db40df0760fe7ebc206734445a3eeb83a17 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 11 Jan 2025 23:46:24 +0900 Subject: [PATCH 303/770] =?UTF-8?q?feat:=20=EC=95=BD=EA=B4=80=20=EB=8F=99?= =?UTF-8?q?=EC=9D=98=20=EC=A0=95=EB=B3=B4=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AuthController.java | 14 ++++++++++++-- .../common/mail/message/ResponseMessage.java | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 5582f526..8675bfa8 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.members.controller; import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; import com.gachtaxi.domain.members.service.AuthService; import com.gachtaxi.domain.members.service.MemberService; @@ -22,8 +23,7 @@ import static com.gachtaxi.domain.members.controller.ResponseMessage.*; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.KakaoAuthCode; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.OauthKakaoResponse; -import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_AUTHENTICATION_SUCESS; -import static com.gachtaxi.global.common.mail.message.ResponseMessage.EMAIL_SEND_SUCCESS; +import static com.gachtaxi.global.common.mail.message.ResponseMessage.*; import static org.springframework.http.HttpStatus.OK; @RequestMapping("/auth") @@ -76,4 +76,14 @@ public ApiResponse checkAuthCodeAndUpdateEmail( memberService.updateInactiveMemberOfEmail(dto.email(), userId); return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); } + + @PatchMapping("/agreement") + @Operation(summary = "약관 동의 정보를 업데이트하는 API 입니다.") + public ApiResponse updateUserAgreement( + @RequestBody MemberAgreementRequestDto dto, + @CurrentMemberId Long userId + ){ + authService.updateMemberAgreement(dto, userId); + return ApiResponse.response(OK, AGREEEMENT_UPDATE_SUCCESS.getMessage()); + } } diff --git a/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java b/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java index 3853f022..8778fcc1 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java @@ -9,6 +9,7 @@ public enum ResponseMessage { EMAIL_SEND_SUCCESS("이메일을 성공적으로 전송했습니다"), EMAIL_AUTHENTICATION_SUCESS("이메일 인증에 성공했습니다!"), + AGREEEMENT_UPDATE_SUCCESS("약관 동의 정보를 업데이트 했습니다!"), EMAIL_TEMPLATE_CREATE_SUCCESS("이메일 템플릿을 생성했습니다."); private final String message; From 2d617f9ab2808567871f63ae4f3f31935a87ddd2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 00:08:36 +0900 Subject: [PATCH 304/770] =?UTF-8?q?feat:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EC=A0=95=EB=B3=B4=20=EB=B9=84=EC=A7=80?= =?UTF-8?q?=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/MemberSupplmentRequestDto.java | 14 ++++++++++++++ .../gachtaxi/domain/members/entity/Members.java | 10 ++++++++++ .../domain/members/service/AuthService.java | 5 +++++ .../domain/members/service/MemberService.java | 7 +++++++ 4 files changed, 36 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/MemberSupplmentRequestDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberSupplmentRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberSupplmentRequestDto.java new file mode 100644 index 00000000..3d4736d3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberSupplmentRequestDto.java @@ -0,0 +1,14 @@ +package com.gachtaxi.domain.members.dto.request; + +import com.gachtaxi.domain.members.entity.enums.Gender; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +public record MemberSupplmentRequestDto( + String profilePicture, + @NotBlank String nickname, + @NotBlank String realName, + @NotNull Long studentNumber, + @NotNull Gender gender +) { +} diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 4b4a3143..eccecc8a 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.members.entity; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; @@ -90,6 +91,15 @@ public void updateAgreement(MemberAgreementRequestDto dto) { this.marketingAgreement = dto.marketingAgreement(); } + public void updateSupplment(MemberSupplmentRequestDto dto) { + this.profilePicture = dto.profilePicture(); + this.nickname = dto.nickname(); + this.realName = dto.realName(); + this.studentNumber = dto.studentNumber(); + this.gender = dto.gender(); + this.status = UserStatus.ACTIVE; + } + public static Members of(UserSignUpRequestDto dto){ return Members.builder() //.profilePicture(dto.profilePicture()) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index dca606a4..296cbe5b 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; @@ -59,4 +60,8 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId){ memberService.updateInactiveMemberOfAgreement(dto, userId); } + + public void updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { + memberService.updateInactiveMemberOfSupplment(dto, userId); + } } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index cde96a86..d1ffbe64 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; @@ -55,7 +56,13 @@ public void updateInactiveMemberOfAgreement(MemberAgreementRequestDto dto, Long members.updateAgreement(dto); } + @Transactional + public void updateInactiveMemberOfSupplment(MemberSupplmentRequestDto dto, Long userId) { + Members members = memberRepository.findById(userId) + .orElseThrow(MemberNotFoundException::new); + members.updateSupplment(dto); + } public Optional findByKakaoId(Long kakaoId) { return memberRepository.findByKakaoId(kakaoId); From f40e400523787a018a72e04befcfc62de41bfcf2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 00:08:44 +0900 Subject: [PATCH 305/770] =?UTF-8?q?feat:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EC=A0=95=EB=B3=B4=20Controller=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AuthController.java | 13 ++++++++++++- .../global/common/mail/message/ResponseMessage.java | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 8675bfa8..b97c010c 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; import com.gachtaxi.domain.members.service.AuthService; import com.gachtaxi.domain.members.service.MemberService; @@ -79,11 +80,21 @@ public ApiResponse checkAuthCodeAndUpdateEmail( @PatchMapping("/agreement") @Operation(summary = "약관 동의 정보를 업데이트하는 API 입니다.") - public ApiResponse updateUserAgreement( + public ApiResponse updateUserAgreement( @RequestBody MemberAgreementRequestDto dto, @CurrentMemberId Long userId ){ authService.updateMemberAgreement(dto, userId); return ApiResponse.response(OK, AGREEEMENT_UPDATE_SUCCESS.getMessage()); } + + @PatchMapping("/supplement") + @Operation(summary = "사용자 추가 정보 업데이트하는 API 입니다. (프로필, 닉네임, 실명, 학번, 성별,)") + public ApiResponse updateMemberSupplement( + @RequestBody MemberSupplmentRequestDto dto, + @CurrentMemberId Long userId + ){ + authService.updateMemberSupplement(dto, userId); + return ApiResponse.response(OK, SUPPLEMENT_UPDATE_SUCCESS.getMessage()); + } } diff --git a/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java b/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java index 8778fcc1..ca84e31d 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java @@ -10,6 +10,7 @@ public enum ResponseMessage { EMAIL_SEND_SUCCESS("이메일을 성공적으로 전송했습니다"), EMAIL_AUTHENTICATION_SUCESS("이메일 인증에 성공했습니다!"), AGREEEMENT_UPDATE_SUCCESS("약관 동의 정보를 업데이트 했습니다!"), + SUPPLEMENT_UPDATE_SUCCESS("사용자 추가 정보를 업데이트 했습니다!"), EMAIL_TEMPLATE_CREATE_SUCCESS("이메일 템플릿을 생성했습니다."); private final String message; From 3c43db1072eb134a6cb5b124eb1c687e94011764 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 00:11:18 +0900 Subject: [PATCH 306/770] =?UTF-8?q?feat:=20MemberService=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AuthController.java | 6 +++--- .../gachtaxi/domain/members/service/AuthService.java | 10 ---------- .../gachtaxi/domain/members/service/MemberService.java | 6 +++--- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index b97c010c..0736d6d3 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -74,7 +74,7 @@ public ApiResponse checkAuthCodeAndUpdateEmail( @CurrentMemberId Long userId ) { emailService.checkEmailAuthCode(dto.email(), dto.authCode()); - memberService.updateInactiveMemberOfEmail(dto.email(), userId); + memberService.updateMemberEmail(dto.email(), userId); return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); } @@ -84,7 +84,7 @@ public ApiResponse updateUserAgreement( @RequestBody MemberAgreementRequestDto dto, @CurrentMemberId Long userId ){ - authService.updateMemberAgreement(dto, userId); + memberService.updateMemberAgreement(dto, userId); return ApiResponse.response(OK, AGREEEMENT_UPDATE_SUCCESS.getMessage()); } @@ -94,7 +94,7 @@ public ApiResponse updateMemberSupplement( @RequestBody MemberSupplmentRequestDto dto, @CurrentMemberId Long userId ){ - authService.updateMemberSupplement(dto, userId); + memberService.updateMemberSupplement(dto, userId); return ApiResponse.response(OK, SUPPLEMENT_UPDATE_SUCCESS.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 296cbe5b..9c0184c9 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -1,8 +1,6 @@ package com.gachtaxi.domain.members.service; import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; -import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; -import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; @@ -56,12 +54,4 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon jwtService.responseJwtToken(member.getId(), member.getEmail(), member.getRole(), response); return oauthMapper.toKakaoLoginResponse(member.getId()); } - - public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId){ - memberService.updateInactiveMemberOfAgreement(dto, userId); - } - - public void updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { - memberService.updateInactiveMemberOfSupplment(dto, userId); - } } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index d1ffbe64..8c5d3d8a 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -41,7 +41,7 @@ public InactiveMemberDto saveTmpMember(Long kakaoId){ } @Transactional - public void updateInactiveMemberOfEmail(String email, Long userId) { + public void updateMemberEmail(String email, Long userId) { Members members = memberRepository.findById(userId) .orElseThrow(MemberNotFoundException::new); @@ -49,7 +49,7 @@ public void updateInactiveMemberOfEmail(String email, Long userId) { } @Transactional - public void updateInactiveMemberOfAgreement(MemberAgreementRequestDto dto, Long userId) { + public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId) { Members members = memberRepository.findById(userId) .orElseThrow(MemberNotFoundException::new); @@ -57,7 +57,7 @@ public void updateInactiveMemberOfAgreement(MemberAgreementRequestDto dto, Long } @Transactional - public void updateInactiveMemberOfSupplment(MemberSupplmentRequestDto dto, Long userId) { + public void updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { Members members = memberRepository.findById(userId) .orElseThrow(MemberNotFoundException::new); From 45a8dd947183da686b5fff75d74dfa55bfdaf9c8 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 00:29:54 +0900 Subject: [PATCH 307/770] =?UTF-8?q?fix:=20Members=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EC=95=BD=EA=B4=80=20?= =?UTF-8?q?=EB=8F=99=EC=9D=98=20false=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index eccecc8a..1c11b95b 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -125,6 +125,10 @@ public static Members ofKakaoId(Long kakaoId){ .kakaoId(kakaoId) .status(UserStatus.INACTIVE) .role(Role.MEMBER) + .termsAgreement(false) + .privacyAgreement(false) + .marketingAgreement(false) + .twoFactorAuthentication(false) .build(); } } From c388570cb998bfd1c0f2a9827bed54f7a164e7e6 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 00:35:54 +0900 Subject: [PATCH 308/770] =?UTF-8?q?fix:=20BaseEntity=20TimeStamp=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/GachtaxiApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/GachtaxiApplication.java b/src/main/java/com/gachtaxi/GachtaxiApplication.java index 6b14e6e2..bb667bc3 100644 --- a/src/main/java/com/gachtaxi/GachtaxiApplication.java +++ b/src/main/java/com/gachtaxi/GachtaxiApplication.java @@ -2,9 +2,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.mongodb.config.EnableMongoAuditing; @SpringBootApplication +@EnableJpaAuditing @EnableMongoAuditing public class GachtaxiApplication { From 596d3697073276f4841922b1b62a6663f7a6b61f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 01:28:45 +0900 Subject: [PATCH 309/770] =?UTF-8?q?remove:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/MemberController.java | 17 ------------ .../domain/members/service/MemberService.java | 16 +---------- .../global/auth/kakao/dto/KaKaoDTO.java | 9 ------- .../global/auth/mapper/OauthMapper.java | 27 ------------------- 4 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index 4f0dc35b..9c808b9e 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -1,29 +1,12 @@ package com.gachtaxi.domain.members.controller; -import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; -import com.gachtaxi.domain.members.service.MemberService; -import com.gachtaxi.global.common.response.ApiResponse; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import static com.gachtaxi.domain.members.controller.ResponseMessage.REGISTER_SUCCESS; -import static org.springframework.http.HttpStatus.OK; - @RequestMapping("/api/members") @RestController @RequiredArgsConstructor public class MemberController { - private final MemberService memberService; - - @PostMapping() - public ApiResponse signUp(@RequestBody @Valid UserSignUpRequestDto signUpDto, HttpServletResponse response) { - memberService.saveMember(signUpDto, response); - return ApiResponse.response(OK, REGISTER_SUCCESS.getMessage()); - } } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 8c5d3d8a..a76a3d9d 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -3,13 +3,10 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; -import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; import com.gachtaxi.domain.members.exception.MemberNotFoundException; import com.gachtaxi.domain.members.repository.MemberRepository; -import com.gachtaxi.global.auth.jwt.service.JwtService; -import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,18 +17,8 @@ @RequiredArgsConstructor public class MemberService { - private final JwtService jwtService; private final MemberRepository memberRepository; - //TODO 최종 회원가입 절차에서 사용 - @Transactional - public void saveMember(UserSignUpRequestDto dto, HttpServletResponse response) { - checkDuplicatedStudentNumber(dto); - Members newMember = Members.of(dto); - memberRepository.save(newMember); - jwtService.responseJwtToken(newMember.getId(), newMember.getEmail(), newMember.getRole(), response); - } - // 임시 유저 저장 @Transactional public InactiveMemberDto saveTmpMember(Long kakaoId){ @@ -72,8 +59,7 @@ public Optional findByKakaoId(Long kakaoId) { * refactor * */ - private void checkDuplicatedStudentNumber(UserSignUpRequestDto dto) { - Long studentNumber = dto.studentNumber(); + private void checkDuplicatedStudentNumber(Long studentNumber) { memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { throw new DuplicatedStudentNumberException(); }); diff --git a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java index 38efd09b..91e9b79c 100644 --- a/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java +++ b/src/main/java/com/gachtaxi/global/auth/kakao/dto/KaKaoDTO.java @@ -1,8 +1,6 @@ package com.gachtaxi.global.auth.kakao.dto; -import com.gachtaxi.global.auth.enums.OauthLoginStatus; import jakarta.validation.constraints.NotBlank; -import lombok.Builder; public class KaKaoDTO { @@ -35,11 +33,4 @@ public record Profile( String nickname, Boolean is_default_nickname ) {} - - @Builder - public record OauthKakaoResponse( - Long userId, - OauthLoginStatus status - ){} - } diff --git a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java b/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java deleted file mode 100644 index 73c8cd4a..00000000 --- a/src/main/java/com/gachtaxi/global/auth/mapper/OauthMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.gachtaxi.global.auth.mapper; - -import org.springframework.stereotype.Component; - -import static com.gachtaxi.global.auth.enums.OauthLoginStatus.*; -import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; - -@Component -public class OauthMapper { - - public OauthKakaoResponse toKakaoUnRegisterResponse(Long userId) { - return OauthKakaoResponse.builder() - .userId(userId) - .status(UN_REGISTER) - .build(); - } - - // jwt 토큰 추가 할 것. - public OauthKakaoResponse toKakaoLoginResponse(Long userId) { - return OauthKakaoResponse.builder() - .userId(userId) - .status(LOGIN) - .build(); - } - - -} From 1f8dd99b28403b51f9533ea34a47cca801325d22 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 01:29:01 +0900 Subject: [PATCH 310/770] =?UTF-8?q?fix:=20=EC=9E=AC=EB=B0=9C=EA=B8=89=20?= =?UTF-8?q?=ED=97=88=EC=9A=A9=20=EA=B2=BD=EB=A1=9C=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index e20fc30b..34c762ad 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -8,7 +8,7 @@ public class PermitUrlConfig { public String[] getPublicUrl(){ return new String[]{ "/auth/login/kakao", - "/auth/refersh", + "/auth/refresh", "/api/members", "/swagger-ui/**", From d355600d029551b81996df781df979c1fbd4a920 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 01:29:56 +0900 Subject: [PATCH 311/770] =?UTF-8?q?feat:=20=EC=A4=91=EB=B3=B5=20=ED=95=99?= =?UTF-8?q?=EB=B2=88=20=EA=B2=80=EC=82=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/members/service/MemberService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index a76a3d9d..de873760 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -45,6 +45,7 @@ public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId) { @Transactional public void updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { + checkDuplicatedStudentNumber(dto.studentNumber()); Members members = memberRepository.findById(userId) .orElseThrow(MemberNotFoundException::new); From 6bf39f8b04b59da24516042f1127a6cacbfa793b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 01:30:26 +0900 Subject: [PATCH 312/770] =?UTF-8?q?remove:=20=EC=A4=91=EB=B3=B5=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EC=83=81=EC=88=98=20=EC=82=AD=EC=A0=9C=20=EB=B0=8F?= =?UTF-8?q?=20=EC=9E=AC=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java | 3 ++- .../java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java index 30e79483..379c956a 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtExtractor.java @@ -14,12 +14,13 @@ import java.util.Date; import java.util.Optional; +import static com.gachtaxi.global.auth.jwt.util.JwtProvider.ACCESS_TOKEN_SUBJECT; + // 토큰 추출 및 검증 @Slf4j @Component public class JwtExtractor { - private static final String ACCESS_TOKEN_SUBJECT = "Authorization"; private static final String BEARER = "Bearer "; private static final String ID_CLAIM = "id"; private static final String EMAIL_CLAIM = "email"; diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java index a31756e6..db574708 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/JwtProvider.java @@ -14,7 +14,7 @@ public class JwtProvider { public static final String ACCESS_TOKEN_SUBJECT = "Authorization"; - private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; + public static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; private static final String ID_CLAIM = "id"; private static final String EMAIL_CLAIM = "email"; private static final String ROLE_CLAIM = "role"; From fdea5e2b947e0bb2e306589466284ce7277459ce Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 01:31:30 +0900 Subject: [PATCH 313/770] =?UTF-8?q?fix:=20=ED=86=A0=ED=81=B0=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=B1=85=EC=9E=84=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=EB=A1=9C=20=EA=B7=80=EC=86=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 31 +++++++++----- .../domain/members/service/AuthService.java | 21 ++++------ .../global/auth/jwt/dto/JwtTokenDto.java | 6 +++ .../global/auth/jwt/service/JwtService.java | 41 ++++++------------- 4 files changed, 47 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 0736d6d3..7f968b0c 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -6,10 +6,10 @@ import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; import com.gachtaxi.domain.members.service.AuthService; import com.gachtaxi.domain.members.service.MemberService; -import com.gachtaxi.global.auth.enums.OauthLoginStatus; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.service.JwtService; +import com.gachtaxi.global.auth.jwt.util.CookieUtil; import com.gachtaxi.global.common.mail.dto.request.EmailAddressDto; import com.gachtaxi.global.common.mail.service.EmailService; import com.gachtaxi.global.common.response.ApiResponse; @@ -22,8 +22,9 @@ import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.members.controller.ResponseMessage.*; +import static com.gachtaxi.global.auth.jwt.util.JwtProvider.ACCESS_TOKEN_SUBJECT; +import static com.gachtaxi.global.auth.jwt.util.JwtProvider.REFRESH_TOKEN_SUBJECT; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.KakaoAuthCode; -import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.OauthKakaoResponse; import static com.gachtaxi.global.common.mail.message.ResponseMessage.*; import static org.springframework.http.HttpStatus.OK; @@ -33,18 +34,23 @@ public class AuthController { private final EmailService emailService; + private final CookieUtil cookieUtil; private final AuthService authService; private final JwtService jwtService; private final MemberService memberService; @PostMapping("/login/kakao") @Operation(summary = "인가 코드를 전달받아, 소셜 로그인을 진행합니다.") - public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { - OauthKakaoResponse res = authService.kakaoLogin(kakaoAuthCode.authCode(), response); - ResponseMessage OAUTH_STATUS = (res.status() == OauthLoginStatus.LOGIN) - ? LOGIN_SUCCESS - : UN_REGISTER; - return ApiResponse.response(HttpStatus.OK, OAUTH_STATUS.getMessage(), res); + public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { + JwtTokenDto jwtTokenDto = authService.kakaoLogin(kakaoAuthCode.authCode()); + response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); + + if(jwtTokenDto.refreshToken()==null){ // 임시 유저 + return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage()); + } + + cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); + return ApiResponse.response(HttpStatus.OK, LOGIN_SUCCESS.getMessage()); } @PostMapping("/refresh") @@ -52,8 +58,9 @@ public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthC public ApiResponse reissueRefreshToken(HttpServletRequest request, HttpServletResponse response) { JwtTokenDto jwtTokenDto = jwtService.reissueJwtToken(request); - jwtService.setCookie(jwtTokenDto.refreshToken(), response); - jwtService.setHeader(jwtTokenDto.accessToken(), response); + response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); + cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); + return ApiResponse.response(HttpStatus.OK, REFRESH_TOKEN_REISSUE.getMessage()); } @@ -97,4 +104,8 @@ public ApiResponse updateMemberSupplement( memberService.updateMemberSupplement(dto, userId); return ApiResponse.response(OK, SUPPLEMENT_UPDATE_SUCCESS.getMessage()); } + + /* + * refactoring + * */ } diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 9c0184c9..a2280831 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -2,10 +2,10 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; -import com.gachtaxi.global.auth.mapper.OauthMapper; -import jakarta.servlet.http.HttpServletResponse; +//import com.gachtaxi.global.auth.mapper.OauthMapper; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -25,11 +25,10 @@ public class AuthService { private final KakaoUtil kakaoUtil; - private final OauthMapper oauthMapper; private final JwtService jwtService; private final MemberService memberService; - public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse response) { + public JwtTokenDto kakaoLogin(String authCode) { KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); KakaoUserInfoResponse userInfo = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); @@ -38,20 +37,16 @@ public OauthKakaoResponse kakaoLogin(String authCode, HttpServletResponse respon if(optionalMember.isEmpty()) { InactiveMemberDto tmpDto = memberService.saveTmpMember(kakaoId); - - jwtService.responseTmpAccessToken(tmpDto, response); - return oauthMapper.toKakaoUnRegisterResponse(tmpDto.userId()); + return jwtService.generateTmpAccessToken(tmpDto); } // 회원 가입 진행 중 중단된 유저 또한 다시 임시 토큰을 재발급해준다. - if(optionalMember.get().getStatus() == INACTIVE){ + Members member = optionalMember.get(); + if(member.getStatus() == INACTIVE){ InactiveMemberDto tmpDto = InactiveMemberDto.of(optionalMember.get()); - jwtService.responseTmpAccessToken(tmpDto, response); - return oauthMapper.toKakaoUnRegisterResponse(tmpDto.userId()); + return jwtService.generateTmpAccessToken(tmpDto); } - Members member = optionalMember.get(); - jwtService.responseJwtToken(member.getId(), member.getEmail(), member.getRole(), response); - return oauthMapper.toKakaoLoginResponse(member.getId()); + return jwtService.generateJwtToken(member.getId(), member.getEmail(), member.getRole().name()); } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java b/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java index 1e316fa6..520ead30 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java @@ -12,4 +12,10 @@ public static JwtTokenDto of(String accessToken, String refreshToken) { .accessToken(accessToken) .refreshToken(refreshToken).build(); } + + public static JwtTokenDto of(String accessToken) { + return JwtTokenDto.builder() + .accessToken(accessToken) + .build(); + } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index dc1d2cb8..16405087 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -1,7 +1,6 @@ package com.gachtaxi.global.auth.jwt.service; import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; -import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.exception.CookieNotFoundException; import com.gachtaxi.global.auth.jwt.exception.TokenExpiredException; @@ -12,34 +11,35 @@ import com.gachtaxi.global.common.redis.RedisUtil; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.Arrays; +import static com.gachtaxi.global.auth.jwt.util.JwtProvider.REFRESH_TOKEN_SUBJECT; + @Service @RequiredArgsConstructor public class JwtService { - private static final String ACCESS_TOKEN_SUBJECT = "Authorization"; - private static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; - private final CookieUtil cookieUtil; private final RedisUtil redisUtil; private final JwtProvider jwtProvider; private final JwtExtractor jwtExtractor; - public void responseJwtToken(Long userId, String email, Role role, HttpServletResponse response) { - JwtTokenDto jwtToken = generateJwtToken(userId, email, role.name()); - setHeader(jwtToken.accessToken(), response); - setCookie(jwtToken.refreshToken(), response); + // JwtToken 생성 + Redis 저장 + public JwtTokenDto generateJwtToken(Long userId, String email, String role) { + String accessToken = jwtProvider.generateAccessToken(userId, email, role); + String refreshToken = jwtProvider.generateRefreshToken(userId, email, role); + + redisUtil.setRefreshToken(userId, refreshToken); + return JwtTokenDto.of(accessToken, refreshToken); } - public void responseTmpAccessToken(InactiveMemberDto inactiveMemberDto, HttpServletResponse response) { + public JwtTokenDto generateTmpAccessToken(InactiveMemberDto inactiveMemberDto) { String tmpAccessToken = jwtProvider.generateTmpAccessToken(inactiveMemberDto.userId(), inactiveMemberDto.role().name()); - setHeader(tmpAccessToken, response); + return JwtTokenDto.of(tmpAccessToken); } public JwtTokenDto reissueJwtToken(HttpServletRequest request) { @@ -47,8 +47,8 @@ public JwtTokenDto reissueJwtToken(HttpServletRequest request) { if(jwtExtractor.isExpired(refreshToken)){ throw new TokenExpiredException(); } - Long userId = jwtExtractor.getId(refreshToken); + Long userId = jwtExtractor.getId(refreshToken); String redisToken = (String) redisUtil.getRefreshToken(userId); if(!redisToken.equals(refreshToken)) { throw new TokenInvalidException(); @@ -81,21 +81,4 @@ private static Cookie[] getCookie(HttpServletRequest request) { } return cookies; } - - // JwtToken 생성 + Redis 저장 - private JwtTokenDto generateJwtToken(Long userId, String email, String role) { - String accessToken = jwtProvider.generateAccessToken(userId, email, role); - String refreshToken = jwtProvider.generateRefreshToken(userId, email, role); - - redisUtil.setRefreshToken(userId, refreshToken); - return JwtTokenDto.of(accessToken, refreshToken); - } - - public void setHeader(String accessToken, HttpServletResponse response) { - response.setHeader(ACCESS_TOKEN_SUBJECT, accessToken); - } - - public void setCookie(String refreshToken, HttpServletResponse response) { - cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, refreshToken, response); - } } From 660a495f74709b3fbfdfde058a79336aea98a471 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 01:59:40 +0900 Subject: [PATCH 314/770] =?UTF-8?q?fix:=20@CookieValue=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 9 +++++---- .../domain/members/service/AuthService.java | 13 ++----------- .../auth/jwt/exception/JwtErrorMessage.java | 4 ++-- .../global/auth/jwt/service/JwtService.java | 19 +------------------ 4 files changed, 10 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 7f968b0c..0b44abac 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -14,7 +14,6 @@ import com.gachtaxi.global.common.mail.service.EmailService; import com.gachtaxi.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.Operation; -import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -55,9 +54,11 @@ public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthC @PostMapping("/refresh") @Operation(summary = "RefreshToken으로 AccessToken과 RefreshToken을 재발급 하는 API 입니다.") - public ApiResponse reissueRefreshToken(HttpServletRequest request, HttpServletResponse response) { - JwtTokenDto jwtTokenDto = jwtService.reissueJwtToken(request); - + public ApiResponse reissueRefreshToken( + @CookieValue(value = REFRESH_TOKEN_SUBJECT) String refreshToken, + HttpServletResponse response + ) { + JwtTokenDto jwtTokenDto = jwtService.reissueJwtToken(refreshToken); response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index a2280831..df4ab4eb 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -5,7 +5,6 @@ import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; -//import com.gachtaxi.global.auth.mapper.OauthMapper; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -14,12 +13,6 @@ import static com.gachtaxi.domain.members.entity.enums.UserStatus.INACTIVE; import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; - -/* -* AuthService는 인증 로직 책임을 가진다. -* */ - - @Service @RequiredArgsConstructor public class AuthService { @@ -36,15 +29,13 @@ public JwtTokenDto kakaoLogin(String authCode) { Optional optionalMember = memberService.findByKakaoId(kakaoId); if(optionalMember.isEmpty()) { - InactiveMemberDto tmpDto = memberService.saveTmpMember(kakaoId); - return jwtService.generateTmpAccessToken(tmpDto); + return jwtService.generateTmpAccessToken(memberService.saveTmpMember(kakaoId)); } // 회원 가입 진행 중 중단된 유저 또한 다시 임시 토큰을 재발급해준다. Members member = optionalMember.get(); if(member.getStatus() == INACTIVE){ - InactiveMemberDto tmpDto = InactiveMemberDto.of(optionalMember.get()); - return jwtService.generateTmpAccessToken(tmpDto); + return jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())); } return jwtService.generateJwtToken(member.getId(), member.getEmail(), member.getRole().name()); diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java index 6cc65caf..478e4491 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/exception/JwtErrorMessage.java @@ -6,11 +6,11 @@ @Getter @AllArgsConstructor public enum JwtErrorMessage { - COOKIE_NOT_FOUND("헤더에 쿠키가 없습니다."), + COOKIE_NOT_FOUND("헤더에 RefreshToken이 없습니다."), REDIS_NOT_FOUND("Redis 에서 찾을 수 없습니다."), - JWT_TOKEN_FORBIDDEN("권한이 없습니다."), USER_NOT_FOUND_EMAIL("해당 이메일의 유저를 찾을 수 없습니다"), + JWT_TOKEN_FORBIDDEN("권한이 없습니다."), JWT_TOKEN_NOT_FOUND("토큰을 찾을 수 없습니다"), JWT_TOKEN_EXPIRED("만료된 토큰입니다."), JWT_TOKEN_INVALID("유효하지 않은 토큰 입니다."), diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 16405087..0262cdc9 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -5,7 +5,6 @@ import com.gachtaxi.global.auth.jwt.exception.CookieNotFoundException; import com.gachtaxi.global.auth.jwt.exception.TokenExpiredException; import com.gachtaxi.global.auth.jwt.exception.TokenInvalidException; -import com.gachtaxi.global.auth.jwt.util.CookieUtil; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; import com.gachtaxi.global.auth.jwt.util.JwtProvider; import com.gachtaxi.global.common.redis.RedisUtil; @@ -14,16 +13,11 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import java.util.Arrays; - -import static com.gachtaxi.global.auth.jwt.util.JwtProvider.REFRESH_TOKEN_SUBJECT; - @Service @RequiredArgsConstructor public class JwtService { - private final CookieUtil cookieUtil; private final RedisUtil redisUtil; private final JwtProvider jwtProvider; private final JwtExtractor jwtExtractor; @@ -42,8 +36,7 @@ public JwtTokenDto generateTmpAccessToken(InactiveMemberDto inactiveMemberDto) { return JwtTokenDto.of(tmpAccessToken); } - public JwtTokenDto reissueJwtToken(HttpServletRequest request) { - String refreshToken = extractRefreshToken(request); + public JwtTokenDto reissueJwtToken(String refreshToken) { if(jwtExtractor.isExpired(refreshToken)){ throw new TokenExpiredException(); } @@ -63,16 +56,6 @@ public JwtTokenDto reissueJwtToken(HttpServletRequest request) { * refactoring * */ - private String extractRefreshToken(HttpServletRequest request){ - Cookie[] cookies = getCookie(request); - - return Arrays.stream(cookies) - .filter(cookie -> REFRESH_TOKEN_SUBJECT.equals(cookie.getName())) - .findFirst() - .map(Cookie::getValue) - .orElseThrow(TokenInvalidException::new); - } - private static Cookie[] getCookie(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); From c843952de9b18016e12ff1778eef6a671936e311 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 02:00:00 +0900 Subject: [PATCH 315/770] =?UTF-8?q?feat:=20MissingRequestCookieException?= =?UTF-8?q?=20=EA=B8=80=EB=A1=9C=EB=B2=8C=20=ED=95=B8=EB=93=A4=EB=9F=AC?= =?UTF-8?q?=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/handler/GlobalExceptionHandler.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java b/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java index 48fb8391..56a78b89 100644 --- a/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java @@ -8,12 +8,15 @@ import org.springframework.http.ResponseEntity; import org.springframework.validation.BindException; import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingRequestCookieException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import java.util.List; -import static org.springframework.http.HttpStatus.*; +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.COOKIE_NOT_FOUND; +import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; @Slf4j @RestControllerAdvice @@ -28,8 +31,13 @@ public ResponseEntity> handleException(BaseException e) { return exceptionResponse(e, e.getStatus(), e.getMessage(), null); } + @ExceptionHandler(MissingRequestCookieException.class) + public ResponseEntity> handleException(MissingRequestCookieException e) { + return exceptionResponse(e, BAD_REQUEST, COOKIE_NOT_FOUND.getMessage(), null); + } + // BindException 처리 - @ExceptionHandler(BindException.class) + @ExceptionHandler({BindException.class}) public ResponseEntity>> handleException(MethodArgumentNotValidException e) { List validErrorResponses = e.getBindingResult().getFieldErrors().stream() .map(fieldError -> ValidErrorResponse.builder() From 91fafe4c9f962621d1eb82eae5c545b02cc04100 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 02:01:42 +0900 Subject: [PATCH 316/770] =?UTF-8?q?chore:=20PR=20=EA=B3=B5=EB=B0=B1=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index bfaefd12..9785622f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,5 @@ ## 📌 관련 이슈 -관련 이슈 번호 # +관련 이슈 번호 # Close # From 14ee2284c2cfe6c3706e74cd91336ac81954187e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 02:19:47 +0900 Subject: [PATCH 317/770] =?UTF-8?q?remove:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20User=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/entity/Members.java | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 1c11b95b..1548b64f 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -2,7 +2,6 @@ import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; -import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.domain.members.entity.enums.UserStatus; @@ -100,26 +99,6 @@ public void updateSupplment(MemberSupplmentRequestDto dto) { this.status = UserStatus.ACTIVE; } - public static Members of(UserSignUpRequestDto dto){ - return Members.builder() - //.profilePicture(dto.profilePicture()) - .email(dto.email()) - .nickname(dto.nickName()) - .realName(dto.realName()) - .studentNumber(dto.studentNumber()) - //.phoneNumber(dto.phoneNumber()) - .kakaoId(dto.kakaoId()) - .googleId(dto.googleId()) - .role(Role.MEMBER) - .status(UserStatus.ACTIVE) - .gender(dto.gender()) - .termsAgreement(dto.termsAgreement()) - .privacyAgreement(dto.privacyAgreement()) - .marketingAgreement(dto.marketingAgreement()) - .twoFactorAuthentication(dto.twoFactorAuthentication()) - .build(); - } - public static Members ofKakaoId(Long kakaoId){ return Members.builder() .kakaoId(kakaoId) From 8c1c0ae5af2dd1e1bcd13039bd9b6abd0814e86c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 06:09:34 +0900 Subject: [PATCH 318/770] =?UTF-8?q?fix:=20JwtTokenDto=20=EC=9E=84=EC=8B=9C?= =?UTF-8?q?=20=EC=9C=A0=EC=A0=80=20=ED=8C=90=EB=8B=A8=20=EC=BA=A1=EC=8A=90?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/controller/AuthController.java | 2 +- .../java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 0b44abac..d27bda2f 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -44,7 +44,7 @@ public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthC JwtTokenDto jwtTokenDto = authService.kakaoLogin(kakaoAuthCode.authCode()); response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); - if(jwtTokenDto.refreshToken()==null){ // 임시 유저 + if(jwtTokenDto.isTemporaryUser()){ // 임시 유저 return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage()); } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java b/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java index 520ead30..703dfd25 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/dto/JwtTokenDto.java @@ -18,4 +18,8 @@ public static JwtTokenDto of(String accessToken) { .accessToken(accessToken) .build(); } + + public boolean isTemporaryUser(){ + return this.refreshToken == null || this.refreshToken.isEmpty(); + } } From 7738d5855bb9d53c684d58278546c57b8e052560 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 19:58:43 +0900 Subject: [PATCH 319/770] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/exception/ErrorMessage.java | 1 + .../gachtaxi/global/common/mail/service/EmailService.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index 24739683..a971f7bc 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -9,6 +9,7 @@ public enum ErrorMessage { DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."), + DUPLICATED_EMAIL("중복된 이메일입니다."), EMAIL_FROM_INVALID("가천대 이메일 형식이 아닙니다."); private final String message; diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index 492ae3dd..88413b9f 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -1,5 +1,7 @@ package com.gachtaxi.global.common.mail.service; +import com.gachtaxi.domain.members.exception.DuplicatedEmailException; +import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.global.common.mail.exception.AuthCodeNotMatchException; import com.gachtaxi.domain.members.exception.EmailFormInvalidException; import com.gachtaxi.global.common.redis.RedisUtil; @@ -27,6 +29,7 @@ public class EmailService { private final SesClient sesClient; private final RedisUtil redisUtil; private final SecureRandom secureRandom = new SecureRandom(); + private final MemberRepository memberRepository; @Value("${aws.ses.templateName}") private String emailTemplateName; @@ -35,6 +38,7 @@ public class EmailService { public void sendEmail(String recipientEmail) { checkGachonEmail(recipientEmail); + checkDuplicatedEmail(recipientEmail); String code = generateCode(); redisUtil.setEmailAuthCode(recipientEmail, code); @@ -62,6 +66,10 @@ private void checkGachonEmail(String email){ throw new EmailFormInvalidException(); } } + private void checkDuplicatedEmail(String email){ + memberRepository.findByEmail(email) + .orElseThrow(DuplicatedEmailException::new); + } private String generateCode() { return String.format(CODE_LENGTH, secureRandom.nextInt(BOUND) + OFFSET); From d976cea68a390412895ed9f97e04f974beb8c751 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 20:06:35 +0900 Subject: [PATCH 320/770] =?UTF-8?q?fix:=20=EC=A3=BC=EC=98=81=EB=8B=98=20PR?= =?UTF-8?q?=20=EC=84=A0=20=EB=B0=98=EC=98=81,=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/MemberService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index de873760..173d744b 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -29,26 +29,21 @@ public InactiveMemberDto saveTmpMember(Long kakaoId){ @Transactional public void updateMemberEmail(String email, Long userId) { - Members members = memberRepository.findById(userId) - .orElseThrow(MemberNotFoundException::new); - + Members members = findById(userId); members.updateEmail(email); } @Transactional public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId) { - Members members = memberRepository.findById(userId) - .orElseThrow(MemberNotFoundException::new); - + Members members = findById(userId); members.updateAgreement(dto); } @Transactional public void updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { checkDuplicatedStudentNumber(dto.studentNumber()); - Members members = memberRepository.findById(userId) - .orElseThrow(MemberNotFoundException::new); + Members members = findById(userId); members.updateSupplment(dto); } @@ -60,6 +55,11 @@ public Optional findByKakaoId(Long kakaoId) { * refactor * */ + public Members findById(Long id) { + return memberRepository.findById(id) + .orElseThrow(MemberNotFoundException::new); + } + private void checkDuplicatedStudentNumber(Long studentNumber) { memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { throw new DuplicatedStudentNumberException(); From 48e779eda35c52f28d7be3f163354c6befb45822 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 12 Jan 2025 21:16:02 +0900 Subject: [PATCH 321/770] =?UTF-8?q?feat:=20DuplicatedEmailException=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/exception/DuplicatedEmailException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/DuplicatedEmailException.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedEmailException.java b/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedEmailException.java new file mode 100644 index 00000000..ce6dff3c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedEmailException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.members.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.DUPLICATED_EMAIL; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class DuplicatedEmailException extends BaseException { + public DuplicatedEmailException() { + super(BAD_REQUEST, DUPLICATED_EMAIL.getMessage()); + } +} From ffb6cdba2d76d5d993ea1ca6b666f648b72adfc5 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:07:37 +0900 Subject: [PATCH 322/770] =?UTF-8?q?feat:=20=EC=9D=B4=EC=A0=84=20=EC=B1=84?= =?UTF-8?q?=ED=8C=85=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/controller/ChattingController.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index e156d5e3..3f35a12e 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -1,19 +1,27 @@ package com.gachtaxi.domain.chat.controller; import com.gachtaxi.domain.chat.dto.request.ChatMessageRequest; -import com.gachtaxi.domain.chat.dto.request.ChattingRoomResponse; +import com.gachtaxi.domain.chat.dto.response.ChatResponse; +import com.gachtaxi.domain.chat.dto.response.ChattingRoomResponse; import com.gachtaxi.domain.chat.service.ChattingRoomService; import com.gachtaxi.domain.chat.service.ChattingService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; import static com.gachtaxi.domain.chat.controller.ResponseMessage.CREATE_CHATTING_ROOM_SUCCESS; +import static com.gachtaxi.domain.chat.controller.ResponseMessage.GET_CHATTING_MESSAGE_SUCCESS; import static org.springframework.http.HttpStatus.OK; +@Tag(name = "CHAT") @RestController @RequiredArgsConstructor public class ChattingController { @@ -22,12 +30,25 @@ public class ChattingController { private final ChattingRoomService chattingRoomService; @PostMapping("/api/chat/room") + @Operation(summary = "채팅방을 생성하기 위한 API입니다. 임시 구현으로 차후 제거될 수 있습니다.") public ApiResponse createChattingRoom() { ChattingRoomResponse response = chattingRoomService.save(); return ApiResponse.response(OK, CREATE_CHATTING_ROOM_SUCCESS.getMessage(), response); } + @GetMapping("/api/chat/{roomId}") + @Operation(summary = "채팅방 재입장시 이전 메시지를 조회하기 위한 API입니다.") + public ApiResponse getChattingMessages(@PathVariable Long roomId, + @CurrentMemberId Long memberId, + @RequestParam int pageNumber, + @RequestParam int pageSize, + @RequestParam(required = false) @Parameter(required = false) LocalDateTime lastMessageTimeStamp) { + ChatResponse response = chattingService.getMessage(roomId, memberId, pageNumber, pageSize, lastMessageTimeStamp); + + return ApiResponse.response(OK, GET_CHATTING_MESSAGE_SUCCESS.getMessage(), response); + } + @MessageMapping("/chat/message") public void message(ChatMessageRequest request, SimpMessageHeaderAccessor headerAccessor) { chattingService.chat(request, headerAccessor); From 9cafea90cf4501506cb92d6ac1617370cebddb18 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:07:57 +0900 Subject: [PATCH 323/770] =?UTF-8?q?feat:=20=EC=9D=B4=EC=A0=84=20=EC=B1=84?= =?UTF-8?q?=ED=8C=85=20=EC=A1=B0=ED=9A=8C=EB=A5=BC=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?dto=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/ChatPageableResponse.java | 26 +++++++++++++++++++ .../chat/dto/response/ChatResponse.java | 24 +++++++++++++++++ .../dto/response/ChattingMessageResponse.java | 24 +++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/dto/response/ChatPageableResponse.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatPageableResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatPageableResponse.java new file mode 100644 index 00000000..572742a2 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatPageableResponse.java @@ -0,0 +1,26 @@ +package com.gachtaxi.domain.chat.dto.response; + +import com.gachtaxi.domain.chat.entity.ChattingMessage; +import lombok.Builder; +import org.springframework.data.domain.Slice; + +@Builder +public record ChatPageableResponse( + int pageNumber, + int pageSize, + int numberOfElements, + boolean first, + boolean last, + boolean empty +) { + public static ChatPageableResponse of(int pageNumber, Slice slice) { + return ChatPageableResponse.builder() + .pageNumber(pageNumber) + .pageSize(slice.getSize()) + .numberOfElements(slice.getNumberOfElements()) + .first(slice.isFirst()) + .last(slice.isLast()) + .empty(slice.isEmpty()) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java new file mode 100644 index 00000000..60f64ff1 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java @@ -0,0 +1,24 @@ +package com.gachtaxi.domain.chat.dto.response; + +import com.gachtaxi.domain.chat.entity.ChattingParticipant; +import lombok.Builder; + +import java.time.LocalDateTime; +import java.util.List; + +@Builder +public record ChatResponse( + Long memberId, + LocalDateTime disconnectedAt, + List chattingMessage, + ChatPageableResponse pageable +) { + public static ChatResponse of(ChattingParticipant chattingParticipant, List chattingMessages, ChatPageableResponse chatPageableResponse) { + return ChatResponse.builder() + .memberId(chattingParticipant.getMembers().getId()) + .disconnectedAt(chattingParticipant.getDisconnectedAt()) + .chattingMessage(chattingMessages) + .pageable(chatPageableResponse) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java new file mode 100644 index 00000000..9b6509c8 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java @@ -0,0 +1,24 @@ +package com.gachtaxi.domain.chat.dto.response; + +import com.gachtaxi.domain.chat.entity.ChattingMessage; +import com.gachtaxi.domain.chat.entity.enums.MessageType; +import lombok.Builder; + +import java.time.LocalDateTime; + +@Builder +public record ChattingMessageResponse( + String senderName, + String message, + LocalDateTime timeStamp, + MessageType messageType +) { + public static ChattingMessageResponse from(ChattingMessage chattingMessage) { + return ChattingMessageResponse.builder() + .senderName(chattingMessage.getSenderName()) + .message(chattingMessage.getMessage()) + .timeStamp(chattingMessage.getTimeStamp()) + .messageType(chattingMessage.getMessageType()) + .build(); + } +} From fdedd5bcdc82838c6b7ce51f251fe3dc69145f8d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:08:39 +0900 Subject: [PATCH 324/770] =?UTF-8?q?feat:=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/entity/ChattingMessage.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java index c329517f..a06e2254 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java @@ -1,8 +1,11 @@ package com.gachtaxi.domain.chat.entity; import com.gachtaxi.domain.chat.dto.request.ChatMessage; +import com.gachtaxi.domain.chat.entity.enums.MessageType; import jakarta.persistence.Id; -import lombok.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.mongodb.core.mapping.Document; @@ -26,6 +29,8 @@ public class ChattingMessage { private String message; + private MessageType messageType; + private LocalDateTime timeStamp; @LastModifiedDate @@ -38,6 +43,7 @@ public static ChattingMessage from(ChatMessage chatMessage) { .roomId(chatMessage.roomId()) .message(chatMessage.message()) .timeStamp(chatMessage.timeStamp()) + .messageType(chatMessage.messageType()) .build(); } } From 56fab24942f97880b0365368dbe55b7d74514fab Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:09:21 +0900 Subject: [PATCH 325/770] =?UTF-8?q?feat:=20=EC=B0=B8=EC=97=AC=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EB=B0=8F=20=EC=B0=B8=EC=97=AC=EC=9D=BC,=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0=20=ED=95=B4=EC=A0=9C=20=EC=9D=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/entity/ChattingParticipant.java | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 663e6853..0a35aebb 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -1,14 +1,17 @@ package com.gachtaxi.domain.chat.entity; +import com.gachtaxi.domain.chat.entity.enums.Status; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.common.entity.BaseEntity; -import jakarta.persistence.Entity; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; +import jakarta.persistence.*; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import org.springframework.data.annotation.CreatedDate; + +import java.time.LocalDateTime; @Getter @Entity @@ -24,10 +27,32 @@ public class ChattingParticipant extends BaseEntity { @JoinColumn(name = "members_id") private Members members; + @Builder.Default + @Enumerated(EnumType.STRING) + private Status status = Status.ACTIVE; + + @CreatedDate + @Column(updatable = false) + private LocalDateTime joinedAt; + + private LocalDateTime disconnectedAt; + public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) { return ChattingParticipant.builder() .chattingRoom(chattingRoom) .members(members) .build(); } + + public void subscribe() { + this.status = Status.ACTIVE; + } + + /* + todo disconnect 이벤트 처리 시 요청하기 + */ + public void disconnect(Status status) { + this.status = status; + this.disconnectedAt = LocalDateTime.now(); + } } From 392584b8ea6f17ca0770a0467b28b8e039025752 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:09:47 +0900 Subject: [PATCH 326/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC=EC=9E=90=20=EA=B4=80=EB=A0=A8=20=EA=B3=B5=ED=86=B5=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ChattingParticipantService.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java new file mode 100644 index 00000000..642ef9a7 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -0,0 +1,25 @@ +package com.gachtaxi.domain.chat.service; + +import com.gachtaxi.domain.chat.entity.ChattingParticipant; +import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; +import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; +import com.gachtaxi.domain.members.entity.Members; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ChattingParticipantService { + + private final ChattingParticipantRepository chattingParticipantRepository; + + public void save(ChattingParticipant chattingParticipant) { + chattingParticipantRepository.save(chattingParticipant); + } + + public ChattingParticipant find(ChattingRoom chattingRoom, Members member) { + return chattingParticipantRepository.findByChattingRoomAndMembers(chattingRoom, member) + .orElseThrow(ChattingParticipantNotFoundException::new); + } +} From de05aea9b1897b6c6c6a1f02fa23a43bbee1c77b Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:10:03 +0900 Subject: [PATCH 327/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=9E=AC=EC=9E=85=EC=9E=A5=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/ChattingRoomService.java | 50 ++++++++++++++++--- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index afa5a53e..530bd5b6 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -1,13 +1,18 @@ package com.gachtaxi.domain.chat.service; import com.gachtaxi.domain.chat.dto.request.ChatMessage; -import com.gachtaxi.domain.chat.dto.request.ChattingRoomResponse; +import com.gachtaxi.domain.chat.dto.response.ChattingRoomResponse; +import com.gachtaxi.domain.chat.entity.ChattingMessage; +import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; import com.gachtaxi.domain.chat.entity.enums.Status; import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; +import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; +import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; import com.gachtaxi.domain.chat.repository.ChattingRoomRepository; +import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; @@ -15,6 +20,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Optional; + @Service @RequiredArgsConstructor public class ChattingRoomService { @@ -23,6 +30,8 @@ public class ChattingRoomService { private final ChattingRoomRepository chattingRoomRepository; private final ChattingParticipantRepository chattingParticipantRepository; + private final ChattingMessageRepository chattingMessageRepository; + private final ChattingParticipantService chattingParticipantService; private final MemberService memberService; private final RedisChatPublisher redisChatPublisher; @@ -47,15 +56,23 @@ public void delete(long chattingRoomId) { @Transactional public void subscribeChatRoom(long roomId, long senderId, String senderName) { ChattingRoom chattingRoom = find(roomId); -// Members members = memberService.find(); + Members members = memberService.find(senderId); - ChannelTopic topic = new ChannelTopic(chatTopic + roomId); - ChatMessage chatMessage = ChatMessage.subscribe(roomId, senderId, senderName, senderName + ENTER_MESSAGE); + Optional optionalChattingParticipant = find(chattingRoom, members); -// ChattingParticipant chattingParticipant = ChattingParticipant.of(chattingRoom, members); -// chattingParticipantRepository.save(chattingParticipant); + if (optionalChattingParticipant.isPresent()) { + ChattingParticipant presentParticipant = optionalChattingParticipant.get(); - redisChatPublisher.publish(topic, chatMessage); + checkDuplicateSubscription(presentParticipant); + presentParticipant.subscribe(); + + return; + } + + ChattingParticipant newParticipant = ChattingParticipant.of(chattingRoom, members); + chattingParticipantService.save(newParticipant); + + publishEnterMessage(roomId, senderId, senderName); } public ChattingRoom find(long chattingRoomId) { @@ -63,4 +80,23 @@ public ChattingRoom find(long chattingRoomId) { .filter(chattingRoom -> chattingRoom.getStatus() == Status.ACTIVE) .orElseThrow(ChattingRoomNotFoundException::new); } + + private void publishEnterMessage(long roomId, long senderId, String senderName) { + ChannelTopic topic = new ChannelTopic(chatTopic + roomId); + ChatMessage chatMessage = ChatMessage.subscribe(roomId, senderId, senderName, senderName + ENTER_MESSAGE); + ChattingMessage chattingMessage = ChattingMessage.from(chatMessage); + + chattingMessageRepository.save(chattingMessage); + redisChatPublisher.publish(topic, chatMessage); + } + + private Optional find(ChattingRoom chattingRoom, Members members) { + return chattingParticipantRepository.findByChattingRoomAndMembers(chattingRoom, members); + } + + private void checkDuplicateSubscription(ChattingParticipant chattingParticipant) { + if (chattingParticipant.getStatus() == Status.ACTIVE) { + throw new DuplicateSubscribeException(); + } + } } From c8f841e2aa8168536db24f5971fa572c62faff35 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:10:17 +0900 Subject: [PATCH 328/770] =?UTF-8?q?feat:=20=EC=9D=B4=EC=A0=84=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChattingService.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 27ae8f93..10491dcb 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -2,16 +2,28 @@ import com.gachtaxi.domain.chat.dto.request.ChatMessage; import com.gachtaxi.domain.chat.dto.request.ChatMessageRequest; +import com.gachtaxi.domain.chat.dto.response.ChatPageableResponse; +import com.gachtaxi.domain.chat.dto.response.ChatResponse; +import com.gachtaxi.domain.chat.dto.response.ChattingMessageResponse; import com.gachtaxi.domain.chat.entity.ChattingMessage; +import com.gachtaxi.domain.chat.entity.ChattingParticipant; +import com.gachtaxi.domain.chat.entity.ChattingRoom; import com.gachtaxi.domain.chat.exception.WebSocketSessionException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.service.MemberService; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; +import java.util.List; import java.util.Optional; import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; @@ -23,6 +35,9 @@ public class ChattingService { private final ChattingMessageRepository chattingMessageRepository; private final RedisChatPublisher redisChatPublisher; + private final ChattingRoomService chattingRoomService; + private final ChattingParticipantService chattingParticipantService; + private final MemberService memberService; @Value("${chat.topic}") public String chatTopic; @@ -39,6 +54,45 @@ public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) redisChatPublisher.publish(topic, chatMessage); } + public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int pageSize, LocalDateTime lastMessageTimeStamp) { + ChattingRoom chattingRoom = chattingRoomService.find(roomId); + Members members = memberService.find(senderId); + ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); + + Slice chattingMessages = checkPageNumber(roomId, chattingParticipant, pageNumber, pageSize, lastMessageTimeStamp); + + List chattingMessageResponses = chattingMessages.stream() + .map(ChattingMessageResponse::from) + .toList(); + + ChatPageableResponse chatPageableResponse = ChatPageableResponse.of(pageNumber, chattingMessages); + + return ChatResponse.of(chattingParticipant, chattingMessageResponses, chatPageableResponse); + } + + private Slice checkPageNumber(long roomId, ChattingParticipant chattingParticipant, int pageNumber, int pageSize, LocalDateTime lastMessageTimeStamp) { + if (pageNumber == 0) { + return loadInitialMessage(roomId, chattingParticipant); + } + + return loadMessage(roomId, chattingParticipant.getJoinedAt(), lastMessageTimeStamp, pageNumber, pageSize); + } + + private Slice loadInitialMessage(long roomId, ChattingParticipant chattingParticipant) { + int chattingCount = chattingMessageRepository.countAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getDisconnectedAt()); + + int effectivePageSize = Math.max(chattingCount, 20); + Pageable pageable = PageRequest.of(0, effectivePageSize); + + return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getJoinedAt(), pageable); + } + + private Slice loadMessage(long roomId, LocalDateTime joinedAt, LocalDateTime lastMessageTime, int pageNumber, int pageSize) { + Pageable pageable = PageRequest.of(pageNumber - 1, pageSize); + + return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterAndTimeStampBeforeOrderByTimeStampDesc(roomId, joinedAt, lastMessageTime, pageable); + } + private T getSessionAttribute(SimpMessageHeaderAccessor accessor, String attributeName, Class type) { return Optional.ofNullable(accessor.getSessionAttributes()) .map(attrs -> type.cast(attrs.get(attributeName))) From b417738f2fb4a382754caab8a4971771a9877172 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:10:34 +0900 Subject: [PATCH 329/770] =?UTF-8?q?feat:=20=EC=BB=A4=EC=8A=A4=ED=85=80=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChattingParticipantNotFoundException.java | 12 ++++++++++++ .../exception/ChattingRoomNotFoundException.java | 4 ++-- .../chat/exception/DuplicateSubscribeException.java | 12 ++++++++++++ .../gachtaxi/domain/chat/exception/ErrorMessage.java | 6 +++++- .../exception/LastMessageTimeStampNullException.java | 12 ++++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/exception/ChattingParticipantNotFoundException.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/exception/DuplicateSubscribeException.java create mode 100644 src/main/java/com/gachtaxi/domain/chat/exception/LastMessageTimeStampNullException.java diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ChattingParticipantNotFoundException.java b/src/main/java/com/gachtaxi/domain/chat/exception/ChattingParticipantNotFoundException.java new file mode 100644 index 00000000..920d3707 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ChattingParticipantNotFoundException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.chat.exception.ErrorMessage.CHATTING_PARTICIPANT_NOT_FOUND; +import static org.springframework.http.HttpStatus.NOT_FOUND; + +public class ChattingParticipantNotFoundException extends BaseException { + public ChattingParticipantNotFoundException() { + super(NOT_FOUND, CHATTING_PARTICIPANT_NOT_FOUND.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ChattingRoomNotFoundException.java b/src/main/java/com/gachtaxi/domain/chat/exception/ChattingRoomNotFoundException.java index 9ec77f6c..c30c9ea9 100644 --- a/src/main/java/com/gachtaxi/domain/chat/exception/ChattingRoomNotFoundException.java +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ChattingRoomNotFoundException.java @@ -3,10 +3,10 @@ import com.gachtaxi.global.common.exception.BaseException; import static com.gachtaxi.domain.chat.exception.ErrorMessage.CHATTING_ROOM_NOT_FOUND; -import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.NOT_FOUND; public class ChattingRoomNotFoundException extends BaseException { public ChattingRoomNotFoundException() { - super(BAD_REQUEST, CHATTING_ROOM_NOT_FOUND.getMessage()); + super(NOT_FOUND, CHATTING_ROOM_NOT_FOUND.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/DuplicateSubscribeException.java b/src/main/java/com/gachtaxi/domain/chat/exception/DuplicateSubscribeException.java new file mode 100644 index 00000000..6d91c409 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/exception/DuplicateSubscribeException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.chat.exception.ErrorMessage.DUPLICATE_SUBSCRIBE; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class DuplicateSubscribeException extends BaseException { + public DuplicateSubscribeException() { + super(BAD_REQUEST, DUPLICATE_SUBSCRIBE.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java index edf2fefa..5a6f56c5 100644 --- a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java @@ -14,6 +14,10 @@ public enum ErrorMessage { CHAT_SUBSCRIBE_ERROR("올바르지 않은 채팅 구독 경로입니다."), CHATTING_ROOM_NOT_FOUND("존재하지 않는 채팅방입니다."), CHAT_SEND_END_POINT_ERROR("올바르지 않은 채팅 메시지 경로입니다."), - WEB_SOCKET_SESSION_ATTR_NOT_FOUND(" 가 웹소켓 세션에 존재하지 않습니다."); + WEB_SOCKET_SESSION_ATTR_NOT_FOUND(" 가 웹소켓 세션에 존재하지 않습니다."), + DUPLICATE_SUBSCRIBE("같은 채팅방을 중복으로 구독했습니다."), + CHATTING_PARTICIPANT_NOT_FOUND("존재하지 않는 채팅 참여자 입니다."), + LAST_TIME_STAMP_NULL("마지막 채팅의 일자는 필수입니다."); + private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/LastMessageTimeStampNullException.java b/src/main/java/com/gachtaxi/domain/chat/exception/LastMessageTimeStampNullException.java new file mode 100644 index 00000000..b00249d2 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/exception/LastMessageTimeStampNullException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.chat.exception.ErrorMessage.LAST_TIME_STAMP_NULL; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class LastMessageTimeStampNullException extends BaseException { + public LastMessageTimeStampNullException() { + super(BAD_REQUEST, LAST_TIME_STAMP_NULL.getMessage()); + } +} From a1565829367e5a4807d20aec9824f5f7079db193 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:10:48 +0900 Subject: [PATCH 330/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ChattingMessageRepository.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageRepository.java index ffb78c3a..0071ec4d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageRepository.java +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageRepository.java @@ -1,7 +1,26 @@ package com.gachtaxi.domain.chat.repository; import com.gachtaxi.domain.chat.entity.ChattingMessage; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; import org.springframework.data.mongodb.repository.MongoRepository; +import org.springframework.data.mongodb.repository.Query; + +import java.time.LocalDateTime; public interface ChattingMessageRepository extends MongoRepository { + Slice findAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(Long roomId, LocalDateTime joinedAt, Pageable pageable); + + @Query(""" + { + 'roomId': ?0, + 'timeStamp': { + $gt: ?1, + $lt: ?2 + } + } + """) + Slice findAllByRoomIdAndTimeStampAfterAndTimeStampBeforeOrderByTimeStampDesc(Long roomId, LocalDateTime joinedAt, LocalDateTime lastMessageTimeStamp, Pageable pageable); + + Integer countAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(Long roomId, LocalDateTime timestamp); } From 9793a0310069a35e1ebe114dca074abc066c11f1 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:10:54 +0900 Subject: [PATCH 331/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC=EC=9E=90=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/repository/ChattingParticipantRepository.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java index cdde5955..7fcf0332 100644 --- a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java @@ -1,7 +1,13 @@ package com.gachtaxi.domain.chat.repository; import com.gachtaxi.domain.chat.entity.ChattingParticipant; +import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.members.entity.Members; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; + public interface ChattingParticipantRepository extends JpaRepository { + + Optional findByChattingRoomAndMembers(ChattingRoom chattingRoom, Members member); } From 40b108489497383d71f3b3f255332145bb2059c3 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:11:14 +0900 Subject: [PATCH 332/770] =?UTF-8?q?feat:=20API=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/controller/ResponseMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java index b1245a0b..921b3ccc 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java @@ -7,7 +7,8 @@ @AllArgsConstructor public enum ResponseMessage { - CREATE_CHATTING_ROOM_SUCCESS("채팅방 생성에 성공했습니다."); + CREATE_CHATTING_ROOM_SUCCESS("채팅방 생성에 성공했습니다."), + GET_CHATTING_MESSAGE_SUCCESS("이전 메시지 조회에 성공 했습니다."); private final String message; } From fbad2452ad0223ed62f96ee07d74777236630c3d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:11:23 +0900 Subject: [PATCH 333/770] =?UTF-8?q?refactor:=20=EB=94=94=EB=A0=89=ED=86=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/dto/{request => response}/ChattingRoomResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/com/gachtaxi/domain/chat/dto/{request => response}/ChattingRoomResponse.java (88%) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChattingRoomResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomResponse.java similarity index 88% rename from src/main/java/com/gachtaxi/domain/chat/dto/request/ChattingRoomResponse.java rename to src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomResponse.java index 97f6eb71..9fce29dc 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChattingRoomResponse.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomResponse.java @@ -1,4 +1,4 @@ -package com.gachtaxi.domain.chat.dto.request; +package com.gachtaxi.domain.chat.dto.response; import com.gachtaxi.domain.chat.entity.ChattingRoom; import com.gachtaxi.domain.chat.entity.enums.Status; From 8acff716add9d20a6207d0477ce5048a8612397d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:47:56 +0900 Subject: [PATCH 334/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=ED=87=B4=EC=9E=A5=20API=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20Sen?= =?UTF-8?q?derName=EB=8F=84=20=EC=84=B8=EC=85=98=EC=97=90=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/controller/ChattingController.java | 12 +++++-- .../domain/chat/dto/request/ChatMessage.java | 8 ++--- .../chat/dto/request/ChatMessageRequest.java | 1 - .../service/ChattingParticipantService.java | 4 +++ .../chat/service/ChattingRoomService.java | 35 ++++++++++++++++--- .../domain/chat/service/ChattingService.java | 4 ++- 6 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index 3f35a12e..90561e15 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -17,8 +17,7 @@ import java.time.LocalDateTime; -import static com.gachtaxi.domain.chat.controller.ResponseMessage.CREATE_CHATTING_ROOM_SUCCESS; -import static com.gachtaxi.domain.chat.controller.ResponseMessage.GET_CHATTING_MESSAGE_SUCCESS; +import static com.gachtaxi.domain.chat.controller.ResponseMessage.*; import static org.springframework.http.HttpStatus.OK; @Tag(name = "CHAT") @@ -49,6 +48,15 @@ public ApiResponse getChattingMessages(@PathVariable Long roomId, return ApiResponse.response(OK, GET_CHATTING_MESSAGE_SUCCESS.getMessage(), response); } + @DeleteMapping("/api/chat/{roomId}") + @Operation(summary = "채팅방을 퇴장하는 API입니다.") + public ApiResponse exitChattingRoom(@PathVariable Long roomId, + @CurrentMemberId Long memberId) { + chattingRoomService.exitChatRoom(roomId, memberId); + + return ApiResponse.response(OK, EXIT_CHATTING_ROOM_SUCCESS.getMessage()); + } + @MessageMapping("/chat/message") public void message(ChatMessageRequest request, SimpMessageHeaderAccessor headerAccessor) { chattingService.chat(request, headerAccessor); diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index 6b5e56f4..805fbd27 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -14,25 +14,25 @@ public record ChatMessage( LocalDateTime timeStamp, MessageType messageType ) { - public static ChatMessage of(ChatMessageRequest request, long roomId, long senderId) { + public static ChatMessage of(ChatMessageRequest request, long roomId, long senderId, String senderName) { return ChatMessage.builder() .roomId(roomId) .senderId(senderId) - .senderName(request.senderName()) + .senderName(senderName) .message(request.message()) .timeStamp(LocalDateTime.now()) .messageType(MessageType.MESSAGE) .build(); } - public static ChatMessage subscribe(long roomId, Long senderId, String senderName, String message) { + public static ChatMessage of(long roomId, Long senderId, String senderName, String message, MessageType messageType) { return ChatMessage.builder() .roomId(roomId) .senderId(senderId) .senderName(senderName) .message(message) .timeStamp(LocalDateTime.now()) - .messageType(MessageType.ENTER) + .messageType(messageType) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java index 0bcccff1..23ca5a97 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java @@ -1,7 +1,6 @@ package com.gachtaxi.domain.chat.dto.request; public record ChatMessageRequest( - String senderName, String message ) { } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 642ef9a7..6472d2bd 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -22,4 +22,8 @@ public ChattingParticipant find(ChattingRoom chattingRoom, Members member) { return chattingParticipantRepository.findByChattingRoomAndMembers(chattingRoom, member) .orElseThrow(ChattingParticipantNotFoundException::new); } + + public void delete(ChattingParticipant chattingParticipant) { + chattingParticipantRepository.delete(chattingParticipant); + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 530bd5b6..083ea994 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -5,6 +5,7 @@ import com.gachtaxi.domain.chat.entity.ChattingMessage; import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.entity.enums.MessageType; import com.gachtaxi.domain.chat.entity.enums.Status; import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; @@ -17,16 +18,23 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Optional; +import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; +import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_ROOM_ID; +import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_USER_NAME; + @Service @RequiredArgsConstructor public class ChattingRoomService { private static final String ENTER_MESSAGE =" 님이 입장하셨습니다."; + private static final String EXIT_MESSAGE =" 님이 퇴장하셨습니다."; + private final ChattingRoomRepository chattingRoomRepository; private final ChattingParticipantRepository chattingParticipantRepository; @@ -54,10 +62,15 @@ public void delete(long chattingRoomId) { } @Transactional - public void subscribeChatRoom(long roomId, long senderId, String senderName) { + public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { + Long senderId = (Long) accessor.getSessionAttributes().get(CHAT_USER_ID); + ChattingRoom chattingRoom = find(roomId); Members members = memberService.find(senderId); + accessor.getSessionAttributes().put(CHAT_ROOM_ID, roomId); + accessor.getSessionAttributes().put(CHAT_USER_NAME, members.getNickname()); + Optional optionalChattingParticipant = find(chattingRoom, members); if (optionalChattingParticipant.isPresent()) { @@ -72,7 +85,21 @@ public void subscribeChatRoom(long roomId, long senderId, String senderName) { ChattingParticipant newParticipant = ChattingParticipant.of(chattingRoom, members); chattingParticipantService.save(newParticipant); - publishEnterMessage(roomId, senderId, senderName); + publishMessage(roomId, senderId, members.getNickname(), ENTER_MESSAGE, MessageType.ENTER); + } + + @Transactional + public void exitChatRoom(long roomId, long senderId) { + /* + 웹소켓 연결도 해제 될텐데 삭제가 먼저 되면 NPE는 어떻게 하지. + */ + ChattingRoom chattingRoom = find(roomId); + Members members = memberService.find(senderId); + ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); + + chattingParticipantService.delete(chattingParticipant); + + publishMessage(roomId, senderId, members.getNickname(), EXIT_MESSAGE, MessageType.EXIT); } public ChattingRoom find(long chattingRoomId) { @@ -81,9 +108,9 @@ public ChattingRoom find(long chattingRoomId) { .orElseThrow(ChattingRoomNotFoundException::new); } - private void publishEnterMessage(long roomId, long senderId, String senderName) { + private void publishMessage(long roomId, long senderId, String senderName, String message, MessageType messageType) { ChannelTopic topic = new ChannelTopic(chatTopic + roomId); - ChatMessage chatMessage = ChatMessage.subscribe(roomId, senderId, senderName, senderName + ENTER_MESSAGE); + ChatMessage chatMessage = ChatMessage.of(roomId, senderId, senderName, senderName + message, messageType); ChattingMessage chattingMessage = ChattingMessage.from(chatMessage); chattingMessageRepository.save(chattingMessage); diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 10491dcb..08261302 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -28,6 +28,7 @@ import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_ROOM_ID; +import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_USER_NAME; @Service @RequiredArgsConstructor @@ -45,8 +46,9 @@ public class ChattingService { public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) { long roomId = getSessionAttribute(accessor, CHAT_ROOM_ID, Long.class); long userId = getSessionAttribute(accessor, CHAT_USER_ID, Long.class); + String senderName = getSessionAttribute(accessor, CHAT_USER_NAME, String.class); - ChatMessage chatMessage = ChatMessage.of(request, roomId, userId); + ChatMessage chatMessage = ChatMessage.of(request, roomId, userId, senderName); ChannelTopic topic = new ChannelTopic(chatTopic + chatMessage.roomId()); ChattingMessage chattingMessage = ChattingMessage.from(chatMessage); From 8b7f2a6b60459c0872f921a46b28d1b2ebdec15d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:52:32 +0900 Subject: [PATCH 335/770] =?UTF-8?q?refactor:=20enderName=EB=8F=84=20?= =?UTF-8?q?=EC=84=B8=EC=85=98=EC=97=90=20=EC=A0=80=EC=9E=A5=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/stomp/strategy/StompSubscribeStrategy.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java index 95e0a5f1..1d6b7373 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java @@ -10,15 +10,13 @@ import org.springframework.messaging.simp.stomp.StompHeaderAccessor; import org.springframework.stereotype.Component; -import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; - @Component @RequiredArgsConstructor public class StompSubscribeStrategy implements StompCommandStrategy { private static final String SUB_END_POINT = "/sub/chat/room/"; public static final String CHAT_ROOM_ID = "CHAT_ROOM_ID"; - + public static final String CHAT_USER_NAME = "CHAT_USER_NAME"; private final ChattingRoomService chattingRoomService; @@ -38,12 +36,9 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess throw new ChatSubscribeException(); } - Long senderId = (Long) accessor.getSessionAttributes().get(CHAT_USER_ID); Long roomId = Long.valueOf(destination.replace(SUB_END_POINT, "")); - String senderName = accessor.getFirstNativeHeader("senderName"); - chattingRoomService.subscribeChatRoom(roomId, senderId, senderName); - accessor.getSessionAttributes().put(CHAT_ROOM_ID, roomId); + chattingRoomService.subscribeChatRoom(roomId, accessor); return message; } From 250b7227cf2a11e510968fcb5c6dc7677e198622 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:52:46 +0900 Subject: [PATCH 336/770] =?UTF-8?q?feat:=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/controller/ResponseMessage.java | 3 ++- .../com/gachtaxi/domain/chat/entity/enums/MessageType.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java index 921b3ccc..c214df66 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java @@ -8,7 +8,8 @@ public enum ResponseMessage { CREATE_CHATTING_ROOM_SUCCESS("채팅방 생성에 성공했습니다."), - GET_CHATTING_MESSAGE_SUCCESS("이전 메시지 조회에 성공 했습니다."); + GET_CHATTING_MESSAGE_SUCCESS("이전 메시지 조회에 성공 했습니다."), + EXIT_CHATTING_ROOM_SUCCESS("채팅방 퇴장에 성공했습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java b/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java index 81c07738..2bab8cb0 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.chat.entity.enums; public enum MessageType { - MESSAGE, ENTER + MESSAGE, ENTER, EXIT } From 248e9648067fa28f9bdbc75c505ed30c43e70c79 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 13 Jan 2025 13:56:47 +0900 Subject: [PATCH 337/770] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=20=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChattingService.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 08261302..6cca551b 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -61,7 +61,7 @@ public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int p Members members = memberService.find(senderId); ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); - Slice chattingMessages = checkPageNumber(roomId, chattingParticipant, pageNumber, pageSize, lastMessageTimeStamp); + Slice chattingMessages = loadMessage(roomId, chattingParticipant, pageNumber, pageSize, lastMessageTimeStamp); List chattingMessageResponses = chattingMessages.stream() .map(ChattingMessageResponse::from) @@ -72,12 +72,13 @@ public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int p return ChatResponse.of(chattingParticipant, chattingMessageResponses, chatPageableResponse); } - private Slice checkPageNumber(long roomId, ChattingParticipant chattingParticipant, int pageNumber, int pageSize, LocalDateTime lastMessageTimeStamp) { + private Slice loadMessage(long roomId, ChattingParticipant chattingParticipant, int pageNumber, int pageSize, LocalDateTime lastMessageTimeStamp) { if (pageNumber == 0) { return loadInitialMessage(roomId, chattingParticipant); } - return loadMessage(roomId, chattingParticipant.getJoinedAt(), lastMessageTimeStamp, pageNumber, pageSize); + Pageable pageable = PageRequest.of(pageNumber - 1, pageSize); + return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterAndTimeStampBeforeOrderByTimeStampDesc(roomId, chattingParticipant.getJoinedAt(), lastMessageTimeStamp, pageable); } private Slice loadInitialMessage(long roomId, ChattingParticipant chattingParticipant) { @@ -89,12 +90,6 @@ private Slice loadInitialMessage(long roomId, ChattingParticipa return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getJoinedAt(), pageable); } - private Slice loadMessage(long roomId, LocalDateTime joinedAt, LocalDateTime lastMessageTime, int pageNumber, int pageSize) { - Pageable pageable = PageRequest.of(pageNumber - 1, pageSize); - - return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterAndTimeStampBeforeOrderByTimeStampDesc(roomId, joinedAt, lastMessageTime, pageable); - } - private T getSessionAttribute(SimpMessageHeaderAccessor accessor, String attributeName, Class type) { return Optional.ofNullable(accessor.getSessionAttributes()) .map(attrs -> type.cast(attrs.get(attributeName))) From d2f18af5c026242d5006a27a4e47b41bee936a3f Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 15:12:03 +0900 Subject: [PATCH 338/770] =?UTF-8?q?remove:=20NoSuchMemberException=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/exception/NoSuchMemberException.java | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/members/exception/NoSuchMemberException.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/NoSuchMemberException.java b/src/main/java/com/gachtaxi/domain/members/exception/NoSuchMemberException.java deleted file mode 100644 index e40e034a..00000000 --- a/src/main/java/com/gachtaxi/domain/members/exception/NoSuchMemberException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.gachtaxi.domain.members.exception; - -import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; - -public class NoSuchMemberException extends BaseException { - - public NoSuchMemberException() { - super(HttpStatus.NOT_FOUND, ErrorMessage.NO_SUCH_MEMBER.getMessage()); - } -} From c8a0bb2e1267a310ca23128d7aa96f408010feea Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 15:15:00 +0900 Subject: [PATCH 339/770] =?UTF-8?q?fix:=20MemberNotFoundException=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/members/service/MemberService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 9cb7434d..722620ba 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -62,6 +62,6 @@ private void checkDuplicatedStudentNumber(UserSignUpRequestDto dto) { } public Members findById(Long id) { - return memberRepository.findById(id).orElseThrow(NoSuchMemberException::new); + return memberRepository.findById(id).orElseThrow(MemberNotFoundException::new); } } From a91b9bb14a7ac4cbe51530d8f52128fdaab4716b Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 17:03:36 +0900 Subject: [PATCH 340/770] =?UTF-8?q?hotfix:=20=EC=84=A4=EC=A0=95=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=93=A4=EC=97=AC=EC=93=B0=EA=B8=B0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-local.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index cf96314f..d362d759 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -54,12 +54,14 @@ gachtaxi: cookieMaxAge: ${JWT_COOKIE_MAX_AGE} secureOption: ${COOKIE_SECURE_OPTION} cookiePathOption: ${COOKIE_PATH_OPTION} + redis: + emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} kafka: topics: match-room-created: ${KAFKA_TOPIC_MATCH_ROOM_CREATED} match-member-joined: ${KAFKA_TOPIC_MATCH_MEMBER_JOINED} + match-member-cancelled: ${KAFKA_TOPIC_MATCH_MEMBER_CANCELLED} match-room-cancelled: ${KAFKA_TOPIC_MATCH_ROOM_CANCELLED} partition-count: ${KAFKA_PARTITION_COUNT} replication-factor: ${KAFKA_REPLICATION_FACTOR} - redis: - emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} + From d0c8c68a78b1f367b711b5e7033b8f3aee7398ac Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 13 Jan 2025 17:12:24 +0900 Subject: [PATCH 341/770] =?UTF-8?q?remove:=20=EC=A4=91=EB=B3=B5=EB=90=98?= =?UTF-8?q?=EB=8A=94=20findById?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/MemberService.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 23933fe0..173d744b 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -65,8 +65,4 @@ private void checkDuplicatedStudentNumber(Long studentNumber) { throw new DuplicatedStudentNumberException(); }); } - - public Members findById(Long id) { - return memberRepository.findById(id).orElseThrow(MemberNotFoundException::new); - } } From d51d25d60af43f11f28ee61f1c0dfd0770b99a6e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 13 Jan 2025 17:27:55 +0900 Subject: [PATCH 342/770] =?UTF-8?q?fix:=20AuthCode=20API=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AuthController.java | 6 +++--- .../domain/members/dto/response/OauthResponse.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/OauthResponse.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index d27bda2f..7ec3836d 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -40,16 +40,16 @@ public class AuthController { @PostMapping("/login/kakao") @Operation(summary = "인가 코드를 전달받아, 소셜 로그인을 진행합니다.") - public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { + public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { JwtTokenDto jwtTokenDto = authService.kakaoLogin(kakaoAuthCode.authCode()); response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); if(jwtTokenDto.isTemporaryUser()){ // 임시 유저 - return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage()); + return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage(), UN_REGISTER); } cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); - return ApiResponse.response(HttpStatus.OK, LOGIN_SUCCESS.getMessage()); + return ApiResponse.response(HttpStatus.OK, LOGIN_SUCCESS.getMessage(), LOGIN_SUCCESS); } @PostMapping("/refresh") diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/OauthResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/OauthResponse.java new file mode 100644 index 00000000..10d49f45 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/OauthResponse.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.members.dto.response; + +import com.gachtaxi.domain.members.controller.ResponseMessage; + +public record OauthResponse( + String status +) { + public static OauthResponse from(ResponseMessage responseMessage) { + return new OauthResponse(responseMessage.name()); + } +} From 3469ba78feb79fe81cdf1d0d0d755ef2406b1228 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:23:01 +0900 Subject: [PATCH 343/770] =?UTF-8?q?fix:=20application=20local=20yml=20?= =?UTF-8?q?=EB=93=A4=EC=97=AC=EC=93=B0=EA=B8=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-local.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index cf96314f..5a1d6220 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -54,12 +54,14 @@ gachtaxi: cookieMaxAge: ${JWT_COOKIE_MAX_AGE} secureOption: ${COOKIE_SECURE_OPTION} cookiePathOption: ${COOKIE_PATH_OPTION} + redis: + emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} kafka: topics: match-room-created: ${KAFKA_TOPIC_MATCH_ROOM_CREATED} match-member-joined: ${KAFKA_TOPIC_MATCH_MEMBER_JOINED} match-room-cancelled: ${KAFKA_TOPIC_MATCH_ROOM_CANCELLED} + match-member-cancelled: ${KAFKA_TOPIC_MATCH_MEMBER_CANCELLED} partition-count: ${KAFKA_PARTITION_COUNT} replication-factor: ${KAFKA_REPLICATION_FACTOR} - redis: - emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} + From 021e85c3f57006194ea1891f13f66ec73c789d05 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:23:15 +0900 Subject: [PATCH 344/770] =?UTF-8?q?feat:=20EnableJpaAuditing=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/GachtaxiApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/GachtaxiApplication.java b/src/main/java/com/gachtaxi/GachtaxiApplication.java index 6b14e6e2..26a66dec 100644 --- a/src/main/java/com/gachtaxi/GachtaxiApplication.java +++ b/src/main/java/com/gachtaxi/GachtaxiApplication.java @@ -3,9 +3,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.mongodb.config.EnableMongoAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; @SpringBootApplication @EnableMongoAuditing +@EnableJpaAuditing public class GachtaxiApplication { public static void main(String[] args) { From 959419d0ae61938e24fb56eaece6b63212ecea2d Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:23:56 +0900 Subject: [PATCH 345/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EA=B4=80=EB=A0=A8=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=86=A0=ED=94=BD=20DTO=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kafka_topic/MatchMemberCancelledEvent.java | 16 ++++++++++++++++ .../dto/kafka_topic/MatchRoomCancelledEvent.java | 10 ++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java new file mode 100644 index 00000000..fd93e073 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java @@ -0,0 +1,16 @@ +package com.gachtaxi.domain.matching.event.dto.kafka_topic; + +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; +import lombok.Builder; + +@Builder +public record MatchMemberCancelledEvent( + Long roomId, + Long memberId, + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + LocalDateTime canceledAt +) { + +} diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java new file mode 100644 index 00000000..f7ab0cb5 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.matching.event.dto.kafka_topic; + +import lombok.Builder; + +@Builder +public record MatchRoomCancelledEvent( + Long roomId +) { + +} From 1cd28fe2a0dcc236285de4b75bca0b636c757414 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:24:43 +0900 Subject: [PATCH 346/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EA=B4=80=EB=A0=A8=20enum=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/dto/enums/AutoMatchingStatus.java | 4 ++-- .../matching/common/entity/enums/MatchingRoomStatus.java | 2 +- .../domain/matching/common/entity/enums/PaymentStatus.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/enums/AutoMatchingStatus.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/enums/AutoMatchingStatus.java index c1dee135..03401cad 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/enums/AutoMatchingStatus.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/enums/AutoMatchingStatus.java @@ -7,7 +7,7 @@ @AllArgsConstructor public enum AutoMatchingStatus { REQUESTED("REQUESTED"), - REJECTED("REJECTED"); - + REJECTED("REJECTED"), + CANCELLED("CANCELLED"); private final String value; } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java index ddfcd386..8da75f23 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.matching.common.entity.enums; public enum MatchingRoomStatus { - PROCESS, COMPLETE, CANCELED, ACTIVE + PROCESS, COMPLETE, CANCELLED, ACTIVE } \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/PaymentStatus.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/PaymentStatus.java index c754bfb3..bc0c4be4 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/PaymentStatus.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/PaymentStatus.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.matching.common.entity.enums; public enum PaymentStatus { - PAYED, NOT_PAYED, FAILED + PAYED, NOT_PAYED, FAILED, LEFT } From 67e59851a3133f0b7b31a1044d6e76d012ea2797 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:25:03 +0900 Subject: [PATCH 347/770] =?UTF-8?q?feat:=20Member=20entity=EC=97=90=20?= =?UTF-8?q?=EB=B0=A9=EC=9E=A5=20=ED=99=95=EC=9D=B8=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/entity/Members.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index ed4c5ef8..1aedd0d1 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -1,11 +1,13 @@ package com.gachtaxi.domain.members.entity; +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.domain.members.entity.enums.UserStatus; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.*; +import java.util.Objects; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -110,4 +112,26 @@ public static Members ofKakaoId(Long kakaoId){ .role(Role.MEMBER) .build(); } + + public boolean isRoomMaster(MatchingRoom matchingRoom){ + return this.equals(matchingRoom.getRoomMaster()); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Members members = (Members) o; + return Objects.equals(studentNumber, members.studentNumber) && Objects.equals( + kakaoId, members.kakaoId); + } + + @Override + public int hashCode() { + return Objects.hash(studentNumber, kakaoId); + } } From ad3fabaff545de0ea234f477b37205a65aa044dc Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:25:24 +0900 Subject: [PATCH 348/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EC=97=94=EB=93=9C=ED=8F=AC=EC=9D=B8=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AutoMatchingController.java | 26 ++++++++++++++----- .../common/controller/ResponseMessage.java | 3 ++- .../request/AutoMatchingCancelledRequest.java | 7 +++++ 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingCancelledRequest.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java index cd32b3cd..601f5b6e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java @@ -1,10 +1,13 @@ package com.gachtaxi.domain.matching.common.controller; +import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingCancelledRequest; import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; import com.gachtaxi.domain.matching.common.dto.response.AutoMatchingPostResponse; import com.gachtaxi.domain.matching.common.service.AutoMatchingService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; @@ -15,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +@Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/api/matching/auto") @@ -23,20 +27,15 @@ public class AutoMatchingController { private final AutoMatchingService autoMatchingService; @GetMapping(value = "/subscribe", produces = MediaType.TEXT_EVENT_STREAM_VALUE) - public SseEmitter subscribeSse(@RequestParam Long memberId) { - // TODO: 인가 로직 완성되면 해당 멤버의 아이디를 가져오도록 변경 -// Long memberId = 1L; - + public SseEmitter subscribeSse(@CurrentMemberId Long memberId) { return this.autoMatchingService.handleSubscribe(memberId); } @PostMapping("/request") public ApiResponse requestMatching( - @RequestParam Long memberId, + @CurrentMemberId Long memberId, @RequestBody AutoMatchingPostRequest autoMatchingPostRequest ) { - // TODO: 인가 로직 완성되면 해당 멤버의 아이디를 가져오도록 변경 -// Long memberId = 1L; if (!this.autoMatchingService.isSseSubscribed(memberId)) { return ApiResponse.response( HttpStatus.BAD_REQUEST, @@ -50,4 +49,17 @@ public ApiResponse requestMatching( this.autoMatchingService.handlerAutoRequestMatching(memberId, autoMatchingPostRequest) ); } + + @PostMapping("/cancel") + public ApiResponse cancelMatching( + @CurrentMemberId Long memberId, + @RequestBody AutoMatchingCancelledRequest autoMatchingCancelledRequest + ) { + log.info("memberId: {}, autoMatchingCancelledRequest: {}", memberId, autoMatchingCancelledRequest); + return ApiResponse.response( + HttpStatus.OK, + ResponseMessage.AUTO_MATCHING_REQUEST_CANCELLED.getMessage(), + this.autoMatchingService.handlerAutoCancelMatching(memberId, autoMatchingCancelledRequest) + ); + } } \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java index 63dcff16..859df93d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java @@ -12,7 +12,8 @@ public enum ResponseMessage { // auto matching AUTO_MATCHING_REQUEST_ACCEPTED("자동 매칭 요청 전송에 성공했습니다."), - NOT_SUBSCRIBED_SSE("SSE 구독 후 자동 매칭을 요청할 수 있습니다."); + NOT_SUBSCRIBED_SSE("SSE 구독 후 자동 매칭을 요청할 수 있습니다."), + AUTO_MATCHING_REQUEST_CANCELLED("자동 매칭 취소 요청 전송에 성공했습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingCancelledRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingCancelledRequest.java new file mode 100644 index 00000000..bd0c66fe --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingCancelledRequest.java @@ -0,0 +1,7 @@ +package com.gachtaxi.domain.matching.common.dto.request; + +public record AutoMatchingCancelledRequest( + Long roomId +) { + +} From 61af1880248f8b49c8f10a63137222474528aef6 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:25:41 +0900 Subject: [PATCH 349/770] =?UTF-8?q?feat:=20MatchingRoom=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=EC=97=90=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EA=B4=80=EB=A0=A8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoom.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 2f51ceb6..a61bd8c5 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -18,6 +18,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; @Entity @Table(name = "matching_room") @@ -38,6 +39,8 @@ public class MatchingRoom extends BaseEntity { private List memberMatchingRoomChargingInfo; @ManyToOne(cascade = CascadeType.PERSIST, optional = false) + @Getter + @Setter private Members roomMaster; @Column(name = "title", nullable = false) @@ -59,4 +62,12 @@ public class MatchingRoom extends BaseEntity { public boolean isActiveMatchingRoom() { return this.matchingRoomStatus == MatchingRoomStatus.ACTIVE; } + + public void changeRoomMaster(Members members) { + this.setRoomMaster(members); + } + + public void cancelMatchingRoom() { + this.matchingRoomStatus = MatchingRoomStatus.CANCELLED; + } } From 871b065520dfe9c1d369188d6739bc98a0647559 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:25:54 +0900 Subject: [PATCH 350/770] =?UTF-8?q?feat:=20kafka=20consumer,=20producer=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=B7=A8=EC=86=8C=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/kafka/KafkaConsumerConfig.java | 52 +++++++++++++++++++ .../config/kafka/KafkaProducerConfig.java | 45 ++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java index 4cfb0cc9..323af01a 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java @@ -1,6 +1,8 @@ package com.gachtaxi.global.config.kafka; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import java.util.HashMap; import java.util.Map; @@ -72,4 +74,54 @@ public ConcurrentKafkaListenerContainerFactory m factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); return factory; } + + // MatchMemberCanceledEvent + @Bean + public ConsumerFactory matchMemberCancelledEventConsumerFactory() { + Map configs = new HashMap<>(); + configs.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); + configs.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); + + JsonDeserializer jsonDeserializer = + new JsonDeserializer<>(MatchMemberCancelledEvent.class); + jsonDeserializer.addTrustedPackages("com.gachtaxi.domain.matching.event.dto"); + + return new DefaultKafkaConsumerFactory<>(configs, new StringDeserializer(), jsonDeserializer); + } + + @Bean + public ConcurrentKafkaListenerContainerFactory matchMemberCancelledEventListenerFactory() { + ConcurrentKafkaListenerContainerFactory factory + = new ConcurrentKafkaListenerContainerFactory<>(); + factory.setConsumerFactory(matchMemberCancelledEventConsumerFactory()); + factory.setConcurrency(3); + factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); + return factory; + } + + // MatchRoomCancelledEvent + @Bean + public ConsumerFactory matchRoomCancelledEventConsumerFactory() { + Map configs = new HashMap<>(); + configs.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); + configs.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); + + JsonDeserializer jsonDeserializer = + new JsonDeserializer<>(MatchRoomCancelledEvent.class); + jsonDeserializer.addTrustedPackages("com.gachtaxi.domain.matching.event.dto"); + + return new DefaultKafkaConsumerFactory<>(configs, new StringDeserializer(), jsonDeserializer); + } + + @Bean + public ConcurrentKafkaListenerContainerFactory matchRoomCancelledEventListenerFactory() { + ConcurrentKafkaListenerContainerFactory factory + = new ConcurrentKafkaListenerContainerFactory<>(); + factory.setConsumerFactory(matchRoomCancelledEventConsumerFactory()); + factory.setConcurrency(3); + factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); + return factory; + } } \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java index 651f676d..f4028071 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java @@ -1,6 +1,8 @@ package com.gachtaxi.global.config.kafka; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import java.util.HashMap; import java.util.Map; @@ -51,9 +53,40 @@ public ProducerFactory matchMemberJoinedEventPro return new DefaultKafkaProducerFactory<>(configs); } + @Bean + @Qualifier("matchMemberCanceledEventProducerFactory") + public ProducerFactory matchMemberCanceledEventProducerFactory() { + Map configs = new HashMap<>(); + configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + + configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); + configs.put(ProducerConfig.ACKS_CONFIG, "all"); + configs.put(ProducerConfig.RETRIES_CONFIG, 3); + + return new DefaultKafkaProducerFactory<>(configs); + } + + @Bean + @Qualifier("matchRoomCancelledEventProducerFactory") + public ProducerFactory matchRoomCanclledEventProducerFactory() { + Map configs = new HashMap<>(); + configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + + configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); + configs.put(ProducerConfig.ACKS_CONFIG, "all"); + configs.put(ProducerConfig.RETRIES_CONFIG, 3); + + return new DefaultKafkaProducerFactory<>(configs); + } + @Bean @Qualifier("matchMemberJoinedEventKafkaTemplate") public KafkaTemplate matchMemberJoinedEventKafkaTemplate() { + return new KafkaTemplate<>(matchMemberJoinedEventProducerFactory()); } @@ -62,4 +95,16 @@ public KafkaTemplate matchMemberJoinedEventKafka public KafkaTemplate matchRoomCreatedEventKafkaTemplate() { return new KafkaTemplate<>(matchRoomCreatedEventProducerFactory()); } + + @Bean + @Qualifier("matchMemberCanceledEventKafkaTemplate") + public KafkaTemplate matchMemberCancelledEventKafkaTemplate() { + return new KafkaTemplate<>(matchMemberCanceledEventProducerFactory()); + } + + @Bean + @Qualifier("matchRoomCancelledEventKafkaTemplate") + public KafkaTemplate matchRoomCancelledEventKafkaTemplate() { + return new KafkaTemplate<>(matchRoomCanclledEventProducerFactory()); + } } \ No newline at end of file From 6b6b5c09726835d4d11d86b767a0f22b8e55755d Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:26:16 +0900 Subject: [PATCH 351/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EA=B4=80=EB=A0=A8=20=EB=B9=84=EC=A6=88=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 1eab6c64..69b084fb 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -5,22 +5,31 @@ import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; +import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.matching.common.exception.MemberAlreadyJoinedException; +import com.gachtaxi.domain.matching.common.exception.MemberNotInMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NotActiveMatchingRoomException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.matching.common.repository.MatchingRoomTagInfoRepository; import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; import com.gachtaxi.domain.matching.common.repository.RouteRepository; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import com.gachtaxi.domain.matching.event.service.kafka.AutoMatchingProducer; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; import jakarta.transaction.Transactional; import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +@Slf4j @Service @RequiredArgsConstructor @Transactional @@ -28,6 +37,7 @@ public class MatchingRoomService { // service private final MemberService memberService; + private final AutoMatchingProducer autoMatchingProducer; // repository private final MatchingRoomRepository matchingRoomRepository; @@ -83,6 +93,7 @@ private void saveHostMemberChargingInfo(MatchingRoom matchingRoom, Members membe .matchingRoom(matchingRoom) .members(members) .charge(matchingRoom.getTotalCharge()) + .paymentStatus(PaymentStatus.NOT_PAYED) .build(); this.memberMatchingRoomChargingInfoRepository.save(matchingRoomChargingInfo); @@ -94,6 +105,10 @@ public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEve matchMemberJoinedEvent.roomId()).orElseThrow( NoSuchMatchingRoomException::new); + if (this.memberMatchingRoomChargingInfoRepository.findByMembersAndMatchingRoom(members, matchingRoom).isPresent()) { + throw new MemberAlreadyJoinedException(); + } + if (!matchingRoom.isActiveMatchingRoom()) { throw new NotActiveMatchingRoomException(); } @@ -109,6 +124,7 @@ public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEve .matchingRoom(matchingRoom) .members(members) .charge(distributedCharge) + .paymentStatus(PaymentStatus.NOT_PAYED) .build() ); @@ -121,4 +137,48 @@ private void updateExistMembersCharge(List exist } this.memberMatchingRoomChargingInfoRepository.saveAll(existMembers); } + + public void leaveMemberFromMatchingRoom(MatchMemberCancelledEvent matchMemberCancelledEvent) { + Members members = this.memberService.findById(matchMemberCancelledEvent.memberId()); + MatchingRoom matchingRoom = this.matchingRoomRepository.findById( + matchMemberCancelledEvent.roomId()).orElseThrow( + NoSuchMatchingRoomException::new); + + MemberMatchingRoomChargingInfo memberMatchingRoomChargingInfo = this.memberMatchingRoomChargingInfoRepository.findByMembersAndMatchingRoom( + members, matchingRoom) + .orElseThrow(MemberNotInMatchingRoomException::new); + + memberMatchingRoomChargingInfo.leftMatchingRoom(); + + this.memberMatchingRoomChargingInfoRepository.save(memberMatchingRoomChargingInfo); + + if (members.isRoomMaster(matchingRoom)) { + this.findNextRoomMaster(matchingRoom, members) + .ifPresentOrElse( + nextRoomMaster -> matchingRoom.changeRoomMaster(nextRoomMaster), + () -> this.autoMatchingProducer.sendMatchRoomCancelledEvent( + MatchRoomCancelledEvent.builder().roomId(matchingRoom.getId()).build() + ) + ); + } + } + + private Optional findNextRoomMaster(MatchingRoom matchingRoom, Members members) { + List existMembers = this.memberMatchingRoomChargingInfoRepository.findByMatchingRoom( + matchingRoom); + + return existMembers.stream() + .map(MemberMatchingRoomChargingInfo::getMembers) + .filter(member -> !member.equals(members)) + .findFirst(); + } + + public void cancelMatchingRoom(MatchRoomCancelledEvent matchRoomCancelledEvent) { + MatchingRoom matchingRoom = this.matchingRoomRepository.findById( + matchRoomCancelledEvent.roomId()).orElseThrow( + NoSuchMatchingRoomException::new); + + matchingRoom.cancelMatchingRoom(); + this.matchingRoomRepository.save(matchingRoom); + } } From 05dc9dcf77f821f3ac9faf57ac229cb310627072 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:26:33 +0900 Subject: [PATCH 352/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EA=B4=80=EB=A0=A8=20kafka=20consumer,=20producer?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/kafka/AutoMatchingConsumer.java | 49 +++++++++++++- .../service/kafka/AutoMatchingProducer.java | 66 +++++++++++++++++-- 2 files changed, 110 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index 9f041594..3432bba3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -1,7 +1,9 @@ package com.gachtaxi.domain.matching.event.service.kafka; import com.gachtaxi.domain.matching.common.service.MatchingRoomService; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.matching.event.service.sse.SseService; import lombok.RequiredArgsConstructor; @@ -36,6 +38,7 @@ public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) ack.acknowledge(); } catch (Exception e) { log.error("[KAFKA CONSUMER] Error processing MatchRoomCreatedEvent", e); + this.sseService.sendToClient(event.hostMemberId(), "MATCH_ROOM_CREATED", e.getMessage()); } } @@ -52,12 +55,56 @@ public void onMatchMemberJoined(MatchMemberJoinedEvent event, Acknowledgment ack this.matchingRoomService.joinMemberToMatchingRoom(event); - this.sseService.sendToClient(event.memberId(), "MATCH_MEMBER_JOINED", event); this.sseService.broadcast("MATCH_MEMBER_JOINED", event); ack.acknowledge(); } catch (Exception e) { log.error("[KAFKA CONSUMER] Error processing MatchMemberJoinedEvent", e); + this.sseService.sendToClient(event.memberId(), "MATCH_MEMBER_JOINED", e.getMessage()); + } + } + + /** + * 방 멤버 취소 이벤트 구독 + */ + @KafkaListener( + topics = "${gachtaxi.kafka.topics.match-member-cancelled}", + containerFactory = "matchMemberCancelledEventListenerFactory" + ) + public void onMatchMemberLeft(MatchMemberCancelledEvent event, Acknowledgment ack) { + try { + log.info("[KAFKA CONSUMER] Received MatchMemberLeftEvent: {}", event); + + this.matchingRoomService.leaveMemberFromMatchingRoom(event); + + this.sseService.broadcast("MATCH_MEMBER_LEFT", event); + + ack.acknowledge(); + } catch (Exception e) { + log.error("[KAFKA CONSUMER] Error processing MatchMemberLeftEvent", e); + this.sseService.sendToClient(event.memberId(), "MATCH_MEMBER_LEFT", e.getMessage()); + } + } + + /** + * 방 취소 이벤트 구독 + */ + @KafkaListener( + topics = "${gachtaxi.kafka.topics.match-room-cancelled}", + containerFactory = "matchRoomCancelledEventListenerFactory" + ) + public void onMatchRoomCancelled(MatchRoomCancelledEvent event, Acknowledgment ack) { + try { + log.info("[KAFKA CONSUMER] Received MatchRoomCancelledEvent: {}", event); + + this.matchingRoomService.cancelMatchingRoom(event); + + this.sseService.broadcast("MATCH_ROOM_CANCELLED", event); + + ack.acknowledge(); + } catch (Exception e) { + log.error("[KAFKA CONSUMER] Error processing MatchRoomCancelledEvent", e); + this.sseService.sendToClient(event.roomId(), "MATCH_ROOM_CANCELLED", e.getMessage()); } } } \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java index 406b9d37..a004b253 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java @@ -1,6 +1,8 @@ package com.gachtaxi.domain.matching.event.service.kafka; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import java.util.concurrent.CompletableFuture; import lombok.RequiredArgsConstructor; @@ -17,20 +19,29 @@ public class AutoMatchingProducer { private final KafkaTemplate matchRoomCreatedEventKafkaTemplate; private final KafkaTemplate matchMemberJoinedEventKafkaTemplate; + private final KafkaTemplate matchMemberCanceledEventKafkaTemplate; + private final KafkaTemplate matchRoomCancelledEventKafkaTemplate; - @Value("${kafka.topic.match-room-created}") + @Value("${gachtaxi.kafka.topics.match-room-created}") private String matchRoomCreatedTopic; - @Value("${kafka.topic.match-member-joined}") + @Value("${gachtaxi.kafka.topics.match-member-joined}") private String matchMemberJoinedTopic; + @Value("${gachtaxi.kafka.topics.match-member-cancelled}") + private String matchMemberCanceledTopic; + + @Value("${gachtaxi.kafka.topics.match-room-cancelled}") + private String matchRoomCancelledTopic; + /** * 방 생성 이벤트를 발행 */ public void sendMatchRoomCreatedEvent(MatchRoomCreatedEvent matchRoomCreatedEvent) { String key = matchRoomCreatedEvent.title(); - CompletableFuture future = this.matchRoomCreatedEventKafkaTemplate.send(matchRoomCreatedTopic, key, matchRoomCreatedEvent); + CompletableFuture future = this.matchRoomCreatedEventKafkaTemplate.send( + matchRoomCreatedTopic, key, matchRoomCreatedEvent); future.thenAccept(result -> { if (result instanceof RecordMetadata metadata) { @@ -52,7 +63,8 @@ public void sendMatchRoomCreatedEvent(MatchRoomCreatedEvent matchRoomCreatedEven public void sendMatchMemberJoinedEvent(MatchMemberJoinedEvent matchMemberJoinedEvent) { String key = String.valueOf(matchMemberJoinedEvent.roomId()); - CompletableFuture future = this.matchMemberJoinedEventKafkaTemplate.send(matchMemberJoinedTopic, key, matchMemberJoinedEvent); + CompletableFuture future = this.matchMemberJoinedEventKafkaTemplate.send( + matchMemberJoinedTopic, key, matchMemberJoinedEvent); future.thenAccept(result -> { if (result instanceof RecordMetadata metadata) { @@ -67,4 +79,50 @@ public void sendMatchMemberJoinedEvent(MatchMemberJoinedEvent matchMemberJoinedE return null; }); } + + /** + * 방 멤버 취소 이벤트를 발행 + */ + public void sendMatchMemberLeftEvent(MatchMemberCancelledEvent matchMemberCancelledEvent) { + String key = String.valueOf(matchMemberCancelledEvent.roomId()); + + CompletableFuture future = this.matchMemberCanceledEventKafkaTemplate.send( + matchMemberCanceledTopic, key, matchMemberCancelledEvent); + + future.thenAccept(result -> { + if (result instanceof RecordMetadata metadata) { + log.info("[KAFKA PRODUCER] Success sending MatchMemberLeftEvent: " + + "topic={}, partition={}, offset={}, key={}", + metadata.topic(), metadata.partition(), metadata.offset(), key + ); + } + } + ).exceptionally(ex -> { + log.error("[KAFKA PRODUCER] Failed to send MatchMemberLeftEvent key={}", key, ex); + return null; + }); + } + + /** + * 방 취소 이벤트를 발행 + */ + public void sendMatchRoomCancelledEvent(MatchRoomCancelledEvent matchRoomCancelledEvent) { + String key = String.valueOf(matchRoomCancelledEvent.roomId()); + + CompletableFuture future = this.matchRoomCancelledEventKafkaTemplate.send( + matchRoomCancelledTopic, key, matchRoomCancelledEvent); + + future.thenAccept(result -> { + if (result instanceof RecordMetadata metadata) { + log.info("[KAFKA PRODUCER] Success sending MatchRoomCancelledEvent: " + + "topic={}, partition={}, offset={}, key={}", + metadata.topic(), metadata.partition(), metadata.offset(), key + ); + } + } + ).exceptionally(ex -> { + log.error("[KAFKA PRODUCER] Failed to send MatchRoomCancelledEvent key={}", key, ex); + return null; + }); + } } \ No newline at end of file From 51de6b43cb3da7be0b9bba301a9086c7e246f560 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:26:46 +0900 Subject: [PATCH 353/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=B0=9C=ED=96=89=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/AutoMatchingService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 2428f12f..2c6e9575 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -3,9 +3,11 @@ import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.algorithm.service.MatchingAlgorithmService; import com.gachtaxi.domain.matching.common.dto.enums.AutoMatchingStatus; +import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingCancelledRequest; import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; import com.gachtaxi.domain.matching.common.dto.response.AutoMatchingPostResponse; import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.matching.event.service.kafka.AutoMatchingProducer; @@ -15,9 +17,11 @@ import java.util.Optional; import java.util.UUID; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +@Slf4j @Service @RequiredArgsConstructor public class AutoMatchingService { @@ -84,4 +88,17 @@ private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult this.autoMatchingProducer.sendMatchMemberJoinedEvent(joinedEvent); } + + public AutoMatchingPostResponse handlerAutoCancelMatching(Long memberId, + AutoMatchingCancelledRequest autoMatchingCancelledRequest) { + + MatchMemberCancelledEvent matchMemberCancelledEvent = MatchMemberCancelledEvent.builder() + .roomId(autoMatchingCancelledRequest.roomId()) + .memberId(memberId) + .build(); + + this.autoMatchingProducer.sendMatchMemberLeftEvent(matchMemberCancelledEvent); + + return AutoMatchingPostResponse.of(AutoMatchingStatus.CANCELLED); + } } From 00bb278f0656011814be6fcaca5574e1b041fea5 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:27:15 +0900 Subject: [PATCH 354/770] =?UTF-8?q?feat:=20MemberNotInMatchingRoom=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/exception/ErrorMessage.java | 4 +++- .../exception/MemberNotInMatchingRoomException.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/MemberNotInMatchingRoomException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index f7569666..89f8344b 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -8,7 +8,9 @@ public enum ErrorMessage { NO_SUCH_MATCHING_ROOM("해당 매칭 방이 존재하지 않습니다."), - NOT_ACTIVE_MATCHING_ROOM("열린 매칭 방이 아닙니다."); + NOT_ACTIVE_MATCHING_ROOM("열린 매칭 방이 아닙니다."), + MEMBER_NOT_IN_MATCHING_ROOM("해당 매칭 방에 참가한 멤버가 아닙니다."), + MEMBER_ALREADY_JOINED_MATCHING_ROOM("해당 맴버는 이미 매칭 방에 참가한 멤버입니다"); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberNotInMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberNotInMatchingRoomException.java new file mode 100644 index 00000000..f8f52374 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberNotInMatchingRoomException.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.matching.common.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +public class MemberNotInMatchingRoomException extends BaseException { + + public MemberNotInMatchingRoomException() { + super(HttpStatus.BAD_REQUEST, ErrorMessage.MEMBER_NOT_IN_MATCHING_ROOM.getMessage()); + } +} From c34a82c95214988c2c6b45a6cfd8764e8e181af4 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:27:29 +0900 Subject: [PATCH 355/770] =?UTF-8?q?feat:=20MemberAlreadyJoined=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/MemberAlreadyJoinedException.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyJoinedException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyJoinedException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyJoinedException.java new file mode 100644 index 00000000..6e83315c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyJoinedException.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.matching.common.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +public class MemberAlreadyJoinedException extends BaseException { + + public MemberAlreadyJoinedException() { + super(HttpStatus.CONFLICT, ErrorMessage.MEMBER_ALREADY_JOINED_MATCHING_ROOM.getMessage()); + } +} From c454d929573681af53ba2555a0b2ef4a43edcb45 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:27:59 +0900 Subject: [PATCH 356/770] =?UTF-8?q?feat:=20Member=20ChargingInfo=EC=97=90?= =?UTF-8?q?=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8=EC=86=8C=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/entity/MemberMatchingRoomChargingInfo.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java index aa4e11b3..0f676f0f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java @@ -14,6 +14,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -30,6 +31,7 @@ public class MemberMatchingRoomChargingInfo extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) + @Getter private Members members; @ManyToOne(fetch = FetchType.LAZY) @@ -40,5 +42,9 @@ public class MemberMatchingRoomChargingInfo extends BaseEntity { private Integer charge; @Enumerated(EnumType.STRING) - private PaymentStatus paymentStatus = PaymentStatus.NOT_PAYED; + private PaymentStatus paymentStatus; + + public void leftMatchingRoom() { + this.paymentStatus = PaymentStatus.LEFT; + } } From d5c389dc6c8267b8a9cb70bafde76e2696e44cd0 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:28:25 +0900 Subject: [PATCH 357/770] =?UTF-8?q?feat:=20MemberMatchingRoomChargingInfoR?= =?UTF-8?q?epository.findByMembersAndMatchinRoom=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MemberMatchingRoomChargingInfoRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java index d447c308..8f8746e1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java @@ -2,7 +2,9 @@ import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import com.gachtaxi.domain.members.entity.Members; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -10,4 +12,5 @@ public interface MemberMatchingRoomChargingInfoRepository extends JpaRepository { List findByMatchingRoom(MatchingRoom matchingRoom); + Optional findByMembersAndMatchingRoom(Members members, MatchingRoom matchingRoom); } From 541fc949a1b49087da1c9fbe94c5f7d04a60288f Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:41:16 +0900 Subject: [PATCH 358/770] =?UTF-8?q?docs:=20.gitigonre=EC=97=90=20docker=20?= =?UTF-8?q?compose=20yml=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3420b922..9c5d913e 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ out/ .vscode/ src/main/resources/.env + +docker-compose.yml \ No newline at end of file From e4be0191fe6fc250c85f7b3ff0b8b3eb19e0f210 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:42:22 +0900 Subject: [PATCH 359/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EC=9A=94=EC=B2=AD=20=EC=8B=9C=20sse=20=EA=B5=AC?= =?UTF-8?q?=EB=8F=85=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/AutoMatchingController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java index 601f5b6e..4d8931d0 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java @@ -55,7 +55,13 @@ public ApiResponse cancelMatching( @CurrentMemberId Long memberId, @RequestBody AutoMatchingCancelledRequest autoMatchingCancelledRequest ) { - log.info("memberId: {}, autoMatchingCancelledRequest: {}", memberId, autoMatchingCancelledRequest); + if (!this.autoMatchingService.isSseSubscribed(memberId)) { + return ApiResponse.response( + HttpStatus.BAD_REQUEST, + ResponseMessage.NOT_SUBSCRIBED_SSE.getMessage() + ); + } + return ApiResponse.response( HttpStatus.OK, ResponseMessage.AUTO_MATCHING_REQUEST_CANCELLED.getMessage(), From 115a3ffc9e096418749d60de649a654fe1df6331 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:50:32 +0900 Subject: [PATCH 360/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20topic=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/dto/kafka_topic/MatchRoomCompletedEvent.java | 7 +++++++ .../gachtaxi/global/config/kafka/KafkaTopicsConfig.java | 3 +++ src/main/resources/application-local.yml | 1 + 3 files changed, 11 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java new file mode 100644 index 00000000..d0321295 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java @@ -0,0 +1,7 @@ +package com.gachtaxi.domain.matching.event.dto.kafka_topic; + +public record MatchRoomCompletedEvent( + Long roomId +) { + +} diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java index 4ecda46e..80a1517f 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java @@ -17,6 +17,9 @@ public class KafkaTopicsConfig { @Value("${gachtaxi.kafka.topics.match-room-cancelled}") private String matchRoomCancelledTopic; + @Value("${gachtaxi.kafka.topics.match-room-completed}") + private String matchRoomCompletedTopic; + @Value("${gachtaxi.kafka.partition-count}") private short partitionCount; diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 5a1d6220..871b6138 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -62,6 +62,7 @@ gachtaxi: match-member-joined: ${KAFKA_TOPIC_MATCH_MEMBER_JOINED} match-room-cancelled: ${KAFKA_TOPIC_MATCH_ROOM_CANCELLED} match-member-cancelled: ${KAFKA_TOPIC_MATCH_MEMBER_CANCELLED} + match-room-completed: ${KAFKA_TOPIC_MATCH_ROOM_COMPLETED} partition-count: ${KAFKA_PARTITION_COUNT} replication-factor: ${KAFKA_REPLICATION_FACTOR} From 69c357395fb574291a9b36f27be6cb926fed5858 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:50:41 +0900 Subject: [PATCH 361/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20producer=20config=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/kafka/KafkaProducerConfig.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java index f4028071..b2a6fcd7 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import java.util.HashMap; import java.util.Map; @@ -83,6 +84,21 @@ public ProducerFactory matchRoomCanclledEventPr return new DefaultKafkaProducerFactory<>(configs); } + @Bean + @Qualifier("matchRoomCompletedEventProducerFactory") + public ProducerFactory matchRoomCompletedEventProducerFactory() { + Map configs = new HashMap<>(); + configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + + configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); + configs.put(ProducerConfig.ACKS_CONFIG, "all"); + configs.put(ProducerConfig.RETRIES_CONFIG, 3); + + return new DefaultKafkaProducerFactory<>(configs); + } + @Bean @Qualifier("matchMemberJoinedEventKafkaTemplate") public KafkaTemplate matchMemberJoinedEventKafkaTemplate() { @@ -107,4 +123,10 @@ public KafkaTemplate matchMemberCancelledEven public KafkaTemplate matchRoomCancelledEventKafkaTemplate() { return new KafkaTemplate<>(matchRoomCanclledEventProducerFactory()); } + + @Bean + @Qualifier("matchRoomCompletedEventKafkaTemplate") + public KafkaTemplate matchRoomCompletedEventKafkaTemplate() { + return new KafkaTemplate<>(matchRoomCompletedEventProducerFactory()); + } } \ No newline at end of file From e13ae216f3c56eaa79dfd2a9d2aa53203d92b791 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 18:50:51 +0900 Subject: [PATCH 362/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20consumer=20config=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/kafka/KafkaConsumerConfig.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java index 323af01a..25a925ea 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaConsumerConfig.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import java.util.HashMap; import java.util.Map; @@ -124,4 +125,29 @@ public ConcurrentKafkaListenerContainerFactory factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); return factory; } + + // MatchRoomCompleted + @Bean + public ConsumerFactory matchRoomCompletedEventConsumerFactory() { + Map configs = new HashMap<>(); + configs.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); + configs.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); + + JsonDeserializer jsonDeserializer = + new JsonDeserializer<>(MatchRoomCompletedEvent.class); + jsonDeserializer.addTrustedPackages("com.gachtaxi.domain.matching.event.dto"); + + return new DefaultKafkaConsumerFactory<>(configs, new StringDeserializer(), jsonDeserializer); + } + + @Bean + public ConcurrentKafkaListenerContainerFactory matchRoomCompletedEventListenerFactory() { + ConcurrentKafkaListenerContainerFactory factory + = new ConcurrentKafkaListenerContainerFactory<>(); + factory.setConsumerFactory(matchRoomCompletedEventConsumerFactory()); + factory.setConcurrency(3); + factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); + return factory; + } } \ No newline at end of file From 4bf3e156a9dc831cc347f5126313bcee6955ffeb Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:01:44 +0900 Subject: [PATCH 363/770] =?UTF-8?q?feat:=20MatchRoom=20=EC=99=84=EB=A3=8C?= =?UTF-8?q?=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20DTO=EC=97=90=20builder=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/dto/kafka_topic/MatchRoomCompletedEvent.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java index d0321295..50ead675 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java @@ -1,5 +1,8 @@ package com.gachtaxi.domain.matching.event.dto.kafka_topic; +import lombok.Builder; + +@Builder public record MatchRoomCompletedEvent( Long roomId ) { From f534c13173d535ded079853ab37c1ea5e42f3ee7 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:01:59 +0900 Subject: [PATCH 364/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=20=EC=83=81=ED=83=9C=EC=97=90=EC=84=9C=20PROCESS=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/enums/MatchingRoomStatus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java index 8da75f23..601abd7b 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomStatus.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.matching.common.entity.enums; public enum MatchingRoomStatus { - PROCESS, COMPLETE, CANCELLED, ACTIVE + COMPLETE, CANCELLED, ACTIVE } \ No newline at end of file From 005163edfb80504156c6df3c27a5f62eb1da799a Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:02:09 +0900 Subject: [PATCH 365/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=20=EC=97=94=ED=8B=B0=ED=8B=B0=EC=97=90=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index a61bd8c5..60baa356 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -70,4 +70,8 @@ public void changeRoomMaster(Members members) { public void cancelMatchingRoom() { this.matchingRoomStatus = MatchingRoomStatus.CANCELLED; } + + public void completeMatchingRoom() { + this.matchingRoomStatus = MatchingRoomStatus.COMPLETE; + } } From 4ef71d27bf1bb9a19c680358efef6c906c713cf4 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:02:28 +0900 Subject: [PATCH 366/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=20=EC=99=84=EB=A3=8C=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=B0=9C?= =?UTF-8?q?=ED=96=89=20producer=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/kafka/AutoMatchingProducer.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java index a004b253..11fba310 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import java.util.concurrent.CompletableFuture; import lombok.RequiredArgsConstructor; @@ -21,6 +22,7 @@ public class AutoMatchingProducer { private final KafkaTemplate matchMemberJoinedEventKafkaTemplate; private final KafkaTemplate matchMemberCanceledEventKafkaTemplate; private final KafkaTemplate matchRoomCancelledEventKafkaTemplate; + private final KafkaTemplate matchRoomCompletedEventKafkaTemplate; @Value("${gachtaxi.kafka.topics.match-room-created}") private String matchRoomCreatedTopic; @@ -34,6 +36,9 @@ public class AutoMatchingProducer { @Value("${gachtaxi.kafka.topics.match-room-cancelled}") private String matchRoomCancelledTopic; + @Value("${gachtaxi.kafka.topics.match-room-completed}") + private String matchRoomCompletedTopic; + /** * 방 생성 이벤트를 발행 */ @@ -125,4 +130,27 @@ public void sendMatchRoomCancelledEvent(MatchRoomCancelledEvent matchRoomCancell return null; }); } + + /** + * 매칭 성공 이벤트를 발행 + */ + public void sendMatchRoomCompletedEvent(MatchRoomCompletedEvent matchRoomCompletedEvent) { + String key = String.valueOf(matchRoomCompletedEvent.roomId()); + + CompletableFuture future = this.matchRoomCompletedEventKafkaTemplate.send( + matchRoomCancelledTopic, key, matchRoomCompletedEvent); + + future.thenAccept(result -> { + if (result instanceof RecordMetadata metadata) { + log.info("[KAFKA PRODUCER] Success sending MatchRoomCompleted: " + + "topic={}, partition={}, offset={}, key={}", + metadata.topic(), metadata.partition(), metadata.offset(), key + ); + } + } + ).exceptionally(ex -> { + log.error("[KAFKA PRODUCER] Failed to send MatchRoomCompleted key={}", key, ex); + return null; + }); + } } \ No newline at end of file From c98f16112f32e313f0bd087c73b3d33fa31f8bcd Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:02:39 +0900 Subject: [PATCH 367/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=20=EC=99=84=EB=A3=8C=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 69b084fb..1eb09157 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -18,6 +18,7 @@ import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.matching.event.service.kafka.AutoMatchingProducer; import com.gachtaxi.domain.members.entity.Members; @@ -129,6 +130,12 @@ public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEve ); this.updateExistMembersCharge(existMembers, distributedCharge); + + if (existMembers.size() == matchingRoom.getCapacity() - 1) { + this.autoMatchingProducer.sendMatchRoomCompletedEvent( + MatchRoomCompletedEvent.builder().roomId(matchingRoom.getId()).build() + ); + } } private void updateExistMembersCharge(List existMembers, int charge) { @@ -181,4 +188,13 @@ public void cancelMatchingRoom(MatchRoomCancelledEvent matchRoomCancelledEvent) matchingRoom.cancelMatchingRoom(); this.matchingRoomRepository.save(matchingRoom); } + + public void completeMatchingRoom(MatchRoomCompletedEvent matchRoomCompletedEvent) { + MatchingRoom matchingRoom = this.matchingRoomRepository.findById( + matchRoomCompletedEvent.roomId() + ).orElseThrow(NoSuchMatchingRoomException::new); + + matchingRoom.completeMatchingRoom(); + this.matchingRoomRepository.save(matchingRoom); + } } From 3de9118b7e556afdef5f9ee835baced06b1ac6d8 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:02:52 +0900 Subject: [PATCH 368/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=20=EC=99=84=EB=A3=8C=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EA=B5=AC?= =?UTF-8?q?=EB=8F=85=20consumer=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/kafka/AutoMatchingConsumer.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index 3432bba3..8e7e4366 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -4,6 +4,7 @@ import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.matching.event.service.sse.SseService; import lombok.RequiredArgsConstructor; @@ -107,4 +108,26 @@ public void onMatchRoomCancelled(MatchRoomCancelledEvent event, Acknowledgment a this.sseService.sendToClient(event.roomId(), "MATCH_ROOM_CANCELLED", e.getMessage()); } } + + /** + * 방 완료 이벤트 구독 + */ + @KafkaListener( + topics = "${gachtaxi.kafka.topics.match-room-completed}", + containerFactory = "matchRoomCompletedEventListenerFactory" + ) + public void onMatchingRoomCompleted(MatchRoomCompletedEvent event, Acknowledgment ack) { + try { + log.info("[KAFKA CONSUMER] Received MatchingRoomCompletedEvent: {}", event); + + this.matchingRoomService.completeMatchingRoom(event); + + this.sseService.broadcast("MATCH_ROOM_COMPLETED", event); + + ack.acknowledge(); + } catch (Exception e) { + log.error("[KAFKA CONSUMER] Error processing MatchingRoomCompletedEvent", e); + this.sseService.sendToClient(event.roomId(), "MATCH_ROOM_COMPLETED", e.getMessage()); + } + } } \ No newline at end of file From d6b4817dfc0309d8505780dafd1ee8ca52425f16 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:33:44 +0900 Subject: [PATCH 369/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=ED=86=A0=ED=94=BD=20DTO=EC=97=90=20=EC=A0=95?= =?UTF-8?q?=EC=A0=81=20=ED=8E=99=ED=84=B0=EB=A6=AC=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MatchMemberCancelledEvent.java | 9 ++++++- .../kafka_topic/MatchMemberJoinedEvent.java | 3 ++- .../kafka_topic/MatchRoomCancelledEvent.java | 6 ++++- .../kafka_topic/MatchRoomCompletedEvent.java | 6 ++++- .../kafka_topic/MatchRoomCreatedEvent.java | 27 +++++++++++++++++-- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java index fd93e073..bded5d51 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java @@ -2,9 +2,10 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; +import lombok.AccessLevel; import lombok.Builder; -@Builder +@Builder(access = AccessLevel.PRIVATE) public record MatchMemberCancelledEvent( Long roomId, Long memberId, @@ -13,4 +14,10 @@ public record MatchMemberCancelledEvent( LocalDateTime canceledAt ) { + public static MatchMemberCancelledEvent of(Long roomId, Long memberId) { + return MatchMemberCancelledEvent.builder(). + roomId(roomId) + .memberId(memberId) + .build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java index a1a313b8..989ae7da 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java @@ -2,9 +2,10 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; +import lombok.AccessLevel; import lombok.Builder; -@Builder +@Builder(access = AccessLevel.PRIVATE) public record MatchMemberJoinedEvent( Long roomId, Long memberId, diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java index f7ab0cb5..f0bbbe2c 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java @@ -1,10 +1,14 @@ package com.gachtaxi.domain.matching.event.dto.kafka_topic; +import lombok.AccessLevel; import lombok.Builder; -@Builder +@Builder(access = AccessLevel.PRIVATE) public record MatchRoomCancelledEvent( Long roomId ) { + public static MatchRoomCancelledEvent of(Long roomId) { + return MatchRoomCancelledEvent.builder().roomId(roomId).build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java index 50ead675..4022476b 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java @@ -1,10 +1,14 @@ package com.gachtaxi.domain.matching.event.dto.kafka_topic; +import lombok.AccessLevel; import lombok.Builder; -@Builder +@Builder(access = AccessLevel.PRIVATE) public record MatchRoomCompletedEvent( Long roomId ) { + public static MatchRoomCompletedEvent of(Long roomId) { + return MatchRoomCompletedEvent.builder().roomId(roomId).build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java index e1ca21c8..62b0e195 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java @@ -1,14 +1,18 @@ package com.gachtaxi.domain.matching.event.dto.kafka_topic; import com.fasterxml.jackson.annotation.JsonFormat; +import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import java.time.LocalDateTime; import java.util.List; +import java.util.UUID; +import lombok.AccessLevel; import lombok.Builder; +import org.springframework.beans.factory.annotation.Value; -@Builder +@Builder(access = AccessLevel.PRIVATE) public record MatchRoomCreatedEvent( - Long hostMemberId, + Long roomMasterId, Integer maxCapacity, String title, String description, @@ -23,4 +27,23 @@ public record MatchRoomCreatedEvent( LocalDateTime createdAt ) { + public static MatchRoomCreatedEvent of( + Long roomMasterId, + AutoMatchingPostRequest autoMatchingPostRequest, + int maxCapacity, + String description + ) { + return MatchRoomCreatedEvent.builder() + .roomMasterId(roomMasterId) + .startPoint(autoMatchingPostRequest.startPoint()) + .startName(autoMatchingPostRequest.startName()) + .destinationPoint(autoMatchingPostRequest.destinationPoint()) + .destinationName(autoMatchingPostRequest.destinationName()) + .maxCapacity(maxCapacity) + .title(UUID.randomUUID().toString()) + .description(description) + .expectedTotalCharge(autoMatchingPostRequest.expectedTotalCharge()) + .criteria(autoMatchingPostRequest.getCriteria()) + .build(); + } } From 440d91aa22f5e0a482efe31ec3703a2591eb9c3e Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:34:42 +0900 Subject: [PATCH 370/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20DTO=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EC=A0=95=EC=A0=81=20=ED=8E=99=ED=84=B0=EB=A6=AC=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=EB=A1=9C=20=EC=83=9D=EC=84=B1=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/AutoMatchingService.java | 38 +++++-------------- .../common/service/MatchingRoomService.java | 4 +- src/main/resources/application-local.yml | 3 ++ 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 2c6e9575..92b4cb9f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -18,6 +18,7 @@ import java.util.UUID; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; @@ -26,8 +27,11 @@ @RequiredArgsConstructor public class AutoMatchingService { - private static final int AUTO_MAX_CAPACITY = 4; - private static final String AUTO_DESCRIPTION = "AUTO_MATCHING"; + @Value("${gachtaxi.matching.auto-matching-max-capacity}") + private int autoMaxCapacity; + + @Value("${gachtaxi.matching.auto-matcnig-description}") + private String autoDescription; private final SseService sseService; private final AutoMatchingProducer autoMatchingProducer; @@ -61,43 +65,19 @@ public AutoMatchingPostResponse handlerAutoRequestMatching( private void sendMatchRoomCreatedEvent(Long memberId, AutoMatchingPostRequest autoMatchingPostRequest) { - MatchRoomCreatedEvent createdEvent = MatchRoomCreatedEvent.builder() - .hostMemberId(memberId) - .startPoint(autoMatchingPostRequest.startPoint()) - .startName(autoMatchingPostRequest.startName()) - .destinationPoint(autoMatchingPostRequest.destinationPoint()) - .destinationName(autoMatchingPostRequest.destinationName()) - .maxCapacity(AUTO_MAX_CAPACITY) - .title(UUID.randomUUID().toString()) - .description(AUTO_DESCRIPTION) - .expectedTotalCharge(autoMatchingPostRequest.expectedTotalCharge()) - .criteria(autoMatchingPostRequest.getCriteria()) - .build(); - - this.autoMatchingProducer.sendMatchRoomCreatedEvent(createdEvent); + this.autoMatchingProducer.sendMatchRoomCreatedEvent(MatchRoomCreatedEvent.of(memberId, autoMatchingPostRequest, autoMaxCapacity, autoDescription)); } private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult) { Long roomId = roomResult.roomId(); - MatchMemberJoinedEvent joinedEvent = MatchMemberJoinedEvent.builder() - .roomId(roomId) - .memberId(memberId) - .joinedAt(LocalDateTime.now()) - .build(); - - this.autoMatchingProducer.sendMatchMemberJoinedEvent(joinedEvent); + this.autoMatchingProducer.sendMatchMemberJoinedEvent(MatchMemberJoinedEvent.of(roomId, memberId)); } public AutoMatchingPostResponse handlerAutoCancelMatching(Long memberId, AutoMatchingCancelledRequest autoMatchingCancelledRequest) { - MatchMemberCancelledEvent matchMemberCancelledEvent = MatchMemberCancelledEvent.builder() - .roomId(autoMatchingCancelledRequest.roomId()) - .memberId(memberId) - .build(); - - this.autoMatchingProducer.sendMatchMemberLeftEvent(matchMemberCancelledEvent); + this.autoMatchingProducer.sendMatchMemberLeftEvent(MatchMemberCancelledEvent.of(autoMatchingCancelledRequest.roomId(), memberId)); return AutoMatchingPostResponse.of(AutoMatchingStatus.CANCELLED); } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 1eb09157..4045b638 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -133,7 +133,7 @@ public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEve if (existMembers.size() == matchingRoom.getCapacity() - 1) { this.autoMatchingProducer.sendMatchRoomCompletedEvent( - MatchRoomCompletedEvent.builder().roomId(matchingRoom.getId()).build() + MatchRoomCompletedEvent.of(matchingRoom.getId()) ); } } @@ -164,7 +164,7 @@ public void leaveMemberFromMatchingRoom(MatchMemberCancelledEvent matchMemberCan .ifPresentOrElse( nextRoomMaster -> matchingRoom.changeRoomMaster(nextRoomMaster), () -> this.autoMatchingProducer.sendMatchRoomCancelledEvent( - MatchRoomCancelledEvent.builder().roomId(matchingRoom.getId()).build() + MatchRoomCancelledEvent.of(matchingRoom.getId()) ) ); } diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 871b6138..e1b7d7e7 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -65,4 +65,7 @@ gachtaxi: match-room-completed: ${KAFKA_TOPIC_MATCH_ROOM_COMPLETED} partition-count: ${KAFKA_PARTITION_COUNT} replication-factor: ${KAFKA_REPLICATION_FACTOR} + matching: + auto-matching-max-capacity: ${AUTO_MATCHING_MAX_CAPACITY} + auto-matcnig-description: ${AUTO_MATCHING_DESCRIPTION} From 5acae17333aa9464d17ec8ad950d11e245817e12 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:35:19 +0900 Subject: [PATCH 371/770] =?UTF-8?q?refacrtor:=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=EC=99=80=EC=9D=98=20=ED=86=B5=EC=9D=BC=EC=84=B1?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=B4=20hostId=20->=20roomMasterId=20?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=A6=84=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/MatchingRoomService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 4045b638..131e3d44 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -47,7 +47,7 @@ public class MatchingRoomService { private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; public MatchingRoom save(MatchRoomCreatedEvent matchRoomCreatedEvent) { - Members members = this.memberService.findById(matchRoomCreatedEvent.hostMemberId()); + Members members = this.memberService.findById(matchRoomCreatedEvent.roomMasterId()); Route route = this.saveRoute(matchRoomCreatedEvent); From 6df1e8cca6d91700eb8a386f84a10af11c190e75 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:45:20 +0900 Subject: [PATCH 372/770] =?UTF-8?q?refactor:=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=EB=93=A4=EC=97=90=20=EC=A0=95=EC=A0=81=20=ED=8E=99=ED=84=B0?= =?UTF-8?q?=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/entity/MatchingRoom.java | 15 ++++++++++++++- .../common/entity/MatchingRoomTagInfo.java | 9 ++++++++- .../entity/MemberMatchingRoomChargingInfo.java | 11 ++++++++++- .../domain/matching/common/entity/Route.java | 12 +++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 60baa356..b804eaef 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.matching.common.entity; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.CascadeType; @@ -22,7 +23,7 @@ @Entity @Table(name = "matching_room") -@Builder +@Builder(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) public class MatchingRoom extends BaseEntity { @@ -74,4 +75,16 @@ public void cancelMatchingRoom() { public void completeMatchingRoom() { this.matchingRoomStatus = MatchingRoomStatus.COMPLETE; } + + public static MatchingRoom activeFrom(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route) { + return MatchingRoom.builder() + .capacity(matchRoomCreatedEvent.maxCapacity()) + .roomMaster(members) + .title(matchRoomCreatedEvent.title()) + .description(matchRoomCreatedEvent.description()) + .route(route) + .totalCharge(matchRoomCreatedEvent.expectedTotalCharge()) + .matchingRoomStatus(MatchingRoomStatus.ACTIVE) + .build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java index bd21d37e..944c1cd1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java @@ -16,7 +16,7 @@ @Table(name = "matching_room_tag_info") @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Builder +@Builder(access = AccessLevel.PRIVATE) public class MatchingRoomTagInfo extends BaseEntity { @ManyToOne @@ -24,4 +24,11 @@ public class MatchingRoomTagInfo extends BaseEntity { @Enumerated(EnumType.STRING) private Tags tags; + + public static MatchingRoomTagInfo of(MatchingRoom matchingRoom, Tags tag) { + return MatchingRoomTagInfo.builder() + .matchingRoom(matchingRoom) + .tags(tag) + .build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java index 0f676f0f..8e353341 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java @@ -27,7 +27,7 @@ ) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Builder +@Builder(access = AccessLevel.PRIVATE) public class MemberMatchingRoomChargingInfo extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) @@ -47,4 +47,13 @@ public class MemberMatchingRoomChargingInfo extends BaseEntity { public void leftMatchingRoom() { this.paymentStatus = PaymentStatus.LEFT; } + + public static MemberMatchingRoomChargingInfo notPayedOf(MatchingRoom matchingRoom, Members members) { + return MemberMatchingRoomChargingInfo.builder() + .matchingRoom(matchingRoom) + .members(members) + .charge(matchingRoom.getTotalCharge()) + .paymentStatus(PaymentStatus.NOT_PAYED) + .build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java index bb148948..412d724d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.matching.common.entity; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.Entity; import jakarta.persistence.Table; @@ -10,7 +11,7 @@ @Entity @Table(name = "route") -@Builder +@Builder(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) public class Route extends BaseEntity { @@ -20,4 +21,13 @@ public class Route extends BaseEntity { private String endLocationCoordinate; private String endLocationName; + + public static Route from(MatchRoomCreatedEvent matchRoomCreatedEvent) { + return Route.builder() + .startLocationCoordinate(matchRoomCreatedEvent.startPoint()) + .startLocationName(matchRoomCreatedEvent.startName()) + .endLocationCoordinate(matchRoomCreatedEvent.destinationPoint()) + .endLocationName(matchRoomCreatedEvent.destinationName()) + .build(); + } } From 6424e86e13477c3fbe8433176470c59b69015b48 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:45:33 +0900 Subject: [PATCH 373/770] =?UTF-8?q?refactor:=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=EC=9D=84=20=EC=A0=95=EC=A0=81=20=ED=8E=99?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A1=9C=20?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 58 +++++-------------- 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 131e3d44..aef17ef1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -51,15 +51,7 @@ public MatchingRoom save(MatchRoomCreatedEvent matchRoomCreatedEvent) { Route route = this.saveRoute(matchRoomCreatedEvent); - MatchingRoom matchingRoom = MatchingRoom.builder() - .capacity(matchRoomCreatedEvent.maxCapacity()) - .roomMaster(members) - .title(matchRoomCreatedEvent.title()) - .description(matchRoomCreatedEvent.description()) - .route(route) - .totalCharge(matchRoomCreatedEvent.expectedTotalCharge()) - .matchingRoomStatus(MatchingRoomStatus.ACTIVE) - .build(); + MatchingRoom matchingRoom = MatchingRoom.activeFrom(matchRoomCreatedEvent, members, route); this.saveMatchingRoomTagInfo(matchingRoom, matchRoomCreatedEvent.criteria()); this.saveHostMemberChargingInfo(matchingRoom, members); @@ -68,36 +60,17 @@ public MatchingRoom save(MatchRoomCreatedEvent matchRoomCreatedEvent) { } private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { - Route route = Route.builder() - .startLocationCoordinate(matchRoomCreatedEvent.startPoint()) - .startLocationName(matchRoomCreatedEvent.startName()) - .endLocationCoordinate(matchRoomCreatedEvent.destinationPoint()) - .endLocationName(matchRoomCreatedEvent.destinationName()) - .build(); - - return this.routeRepository.save(route); + return this.routeRepository.save(Route.from(matchRoomCreatedEvent)); } private void saveMatchingRoomTagInfo(MatchingRoom matchingRoom, List tags) { - for (Tags tag : tags) { - MatchingRoomTagInfo matchingRoomTagInfo = MatchingRoomTagInfo.builder() - .matchingRoom(matchingRoom) - .tags(tag) - .build(); - - this.matchingRoomTagInfoRepository.save(matchingRoomTagInfo); - } + tags.forEach(tag -> { + this.matchingRoomTagInfoRepository.save(MatchingRoomTagInfo.of(matchingRoom, tag)); + }); } private void saveHostMemberChargingInfo(MatchingRoom matchingRoom, Members members) { - MemberMatchingRoomChargingInfo matchingRoomChargingInfo = MemberMatchingRoomChargingInfo.builder() - .matchingRoom(matchingRoom) - .members(members) - .charge(matchingRoom.getTotalCharge()) - .paymentStatus(PaymentStatus.NOT_PAYED) - .build(); - - this.memberMatchingRoomChargingInfoRepository.save(matchingRoomChargingInfo); + this.memberMatchingRoomChargingInfoRepository.save(MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, members)); } public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEvent) { @@ -121,12 +94,7 @@ public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEve int distributedCharge = matchingRoom.getTotalCharge() / (existMembers.size() + 1); this.memberMatchingRoomChargingInfoRepository.save( - MemberMatchingRoomChargingInfo.builder() - .matchingRoom(matchingRoom) - .members(members) - .charge(distributedCharge) - .paymentStatus(PaymentStatus.NOT_PAYED) - .build() + MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, members) ); this.updateExistMembersCharge(existMembers, distributedCharge); @@ -181,18 +149,18 @@ private Optional findNextRoomMaster(MatchingRoom matchingRoom, Members } public void cancelMatchingRoom(MatchRoomCancelledEvent matchRoomCancelledEvent) { - MatchingRoom matchingRoom = this.matchingRoomRepository.findById( - matchRoomCancelledEvent.roomId()).orElseThrow( - NoSuchMatchingRoomException::new); + MatchingRoom matchingRoom = getMatchingRoomById(matchRoomCancelledEvent.roomId()); matchingRoom.cancelMatchingRoom(); this.matchingRoomRepository.save(matchingRoom); } + private MatchingRoom getMatchingRoomById(Long roomId) { + return this.matchingRoomRepository.findById(roomId).orElseThrow(NoSuchMatchingRoomException::new); + } + public void completeMatchingRoom(MatchRoomCompletedEvent matchRoomCompletedEvent) { - MatchingRoom matchingRoom = this.matchingRoomRepository.findById( - matchRoomCompletedEvent.roomId() - ).orElseThrow(NoSuchMatchingRoomException::new); + MatchingRoom matchingRoom = this.getMatchingRoomById(matchRoomCompletedEvent.roomId()); matchingRoom.completeMatchingRoom(); this.matchingRoomRepository.save(matchingRoom); From cd4c568e73fe45c693316ac9471077120ec3449b Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:46:31 +0900 Subject: [PATCH 374/770] =?UTF-8?q?refactor:=20consumer=EC=9D=98=20hostMem?= =?UTF-8?q?berId=20->=20roomMasterId=20=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/event/service/kafka/AutoMatchingConsumer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index 8e7e4366..df87696b 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -34,12 +34,12 @@ public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) this.matchingRoomService.save(event); - this.sseService.sendToClient(event.hostMemberId(), "MATCH_ROOM_CREATED", event); + this.sseService.sendToClient(event.roomMasterId(), "MATCH_ROOM_CREATED", event); ack.acknowledge(); } catch (Exception e) { log.error("[KAFKA CONSUMER] Error processing MatchRoomCreatedEvent", e); - this.sseService.sendToClient(event.hostMemberId(), "MATCH_ROOM_CREATED", e.getMessage()); + this.sseService.sendToClient(event.roomMasterId(), "MATCH_ROOM_CREATED", e.getMessage()); } } From f3e97b42f8ea6080f5f012627616e15931cc27ab Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:46:51 +0900 Subject: [PATCH 375/770] =?UTF-8?q?fix:=20=EB=A7=A4=EC=B9=AD=20=EC=84=B1?= =?UTF-8?q?=EA=B3=B5=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=B7=A8=EC=86=8C=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=EB=A5=BC=20=EB=B0=9C=ED=96=89=ED=95=98=EB=8D=98=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/event/service/kafka/AutoMatchingProducer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java index 11fba310..f4a11be7 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java @@ -138,7 +138,7 @@ public void sendMatchRoomCompletedEvent(MatchRoomCompletedEvent matchRoomComplet String key = String.valueOf(matchRoomCompletedEvent.roomId()); CompletableFuture future = this.matchRoomCompletedEventKafkaTemplate.send( - matchRoomCancelledTopic, key, matchRoomCompletedEvent); + matchRoomCompletedTopic, key, matchRoomCompletedEvent); future.thenAccept(result -> { if (result instanceof RecordMetadata metadata) { From a2d7000c5e5b39862709eb70397d5550c27173a3 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:50:35 +0900 Subject: [PATCH 376/770] =?UTF-8?q?refactor:=20=EC=98=88=EC=99=B8=EB=93=A4?= =?UTF-8?q?=EC=97=90=20=EC=A0=95=EC=A0=81=20=EB=B3=80=EC=88=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/MemberAlreadyJoinedException.java | 6 ++++-- .../common/exception/MemberNotInMatchingRoomException.java | 6 ++++-- .../common/exception/NoSuchMatchingRoomException.java | 6 ++++-- .../common/exception/NotActiveMatchingRoomException.java | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyJoinedException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyJoinedException.java index 6e83315c..ad935d43 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyJoinedException.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyJoinedException.java @@ -1,11 +1,13 @@ package com.gachtaxi.domain.matching.common.exception; +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.MEMBER_ALREADY_JOINED_MATCHING_ROOM; +import static org.springframework.http.HttpStatus.CONFLICT; + import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; public class MemberAlreadyJoinedException extends BaseException { public MemberAlreadyJoinedException() { - super(HttpStatus.CONFLICT, ErrorMessage.MEMBER_ALREADY_JOINED_MATCHING_ROOM.getMessage()); + super(CONFLICT, MEMBER_ALREADY_JOINED_MATCHING_ROOM.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberNotInMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberNotInMatchingRoomException.java index f8f52374..457aac99 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberNotInMatchingRoomException.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberNotInMatchingRoomException.java @@ -1,11 +1,13 @@ package com.gachtaxi.domain.matching.common.exception; +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.*; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; public class MemberNotInMatchingRoomException extends BaseException { public MemberNotInMatchingRoomException() { - super(HttpStatus.BAD_REQUEST, ErrorMessage.MEMBER_NOT_IN_MATCHING_ROOM.getMessage()); + super(BAD_REQUEST, MEMBER_NOT_IN_MATCHING_ROOM.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchMatchingRoomException.java index 997d6d41..931e7fb6 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchMatchingRoomException.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchMatchingRoomException.java @@ -1,11 +1,13 @@ package com.gachtaxi.domain.matching.common.exception; +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.NO_SUCH_MATCHING_ROOM; +import static org.springframework.http.HttpStatus.NOT_FOUND; + import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; public class NoSuchMatchingRoomException extends BaseException { public NoSuchMatchingRoomException() { - super(HttpStatus.NOT_FOUND, ErrorMessage.NO_SUCH_MATCHING_ROOM.getMessage()); + super(NOT_FOUND, NO_SUCH_MATCHING_ROOM.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java index 88ded883..46917062 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java @@ -1,11 +1,13 @@ package com.gachtaxi.domain.matching.common.exception; +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.NOT_ACTIVE_MATCHING_ROOM; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; public class NotActiveMatchingRoomException extends BaseException { public NotActiveMatchingRoomException() { - super(HttpStatus.BAD_REQUEST, ErrorMessage.NOT_ACTIVE_MATCHING_ROOM.getMessage()); + super(BAD_REQUEST, lNOT_ACTIVE_MATCHING_ROOM.getMessage()); } } From 93ee46b63822a7a36d65a084d7a32b8a54cc4fcd Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:50:48 +0900 Subject: [PATCH 377/770] =?UTF-8?q?refactor:=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/NotActiveMatchingRoomException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java index 46917062..58197e5a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotActiveMatchingRoomException.java @@ -8,6 +8,6 @@ public class NotActiveMatchingRoomException extends BaseException { public NotActiveMatchingRoomException() { - super(BAD_REQUEST, lNOT_ACTIVE_MATCHING_ROOM.getMessage()); + super(BAD_REQUEST, NOT_ACTIVE_MATCHING_ROOM.getMessage()); } } From e9faac61b5db6b5d1d8f000c33d6908632f79c53 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 19:55:45 +0900 Subject: [PATCH 378/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EB=B0=A9=20=EC=83=9D=EC=84=B1=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?createMatcingRoom=EC=9C=BC=EB=A1=9C=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=A6=AC=ED=84=B4=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20void=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/MatchingRoomService.java | 7 +++---- .../matching/event/service/kafka/AutoMatchingConsumer.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index aef17ef1..bf046c92 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -46,7 +46,7 @@ public class MatchingRoomService { private final RouteRepository routeRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; - public MatchingRoom save(MatchRoomCreatedEvent matchRoomCreatedEvent) { + public void createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { Members members = this.memberService.findById(matchRoomCreatedEvent.roomMasterId()); Route route = this.saveRoute(matchRoomCreatedEvent); @@ -56,7 +56,7 @@ public MatchingRoom save(MatchRoomCreatedEvent matchRoomCreatedEvent) { this.saveMatchingRoomTagInfo(matchingRoom, matchRoomCreatedEvent.criteria()); this.saveHostMemberChargingInfo(matchingRoom, members); - return this.matchingRoomRepository.save(matchingRoom); + this.matchingRoomRepository.save(matchingRoom); } private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { @@ -90,8 +90,7 @@ public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEve List existMembers = this.memberMatchingRoomChargingInfoRepository.findByMatchingRoom( matchingRoom); - // TODO: 딱 떨어지지 않는 금액은 어떻게 해야할지? - int distributedCharge = matchingRoom.getTotalCharge() / (existMembers.size() + 1); + int distributedCharge = (int) Math.ceil((double) matchingRoom.getTotalCharge() / (existMembers.size() + 1)); this.memberMatchingRoomChargingInfoRepository.save( MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, members) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index df87696b..62b71401 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -32,7 +32,7 @@ public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) try { log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event); - this.matchingRoomService.save(event); + this.matchingRoomService.createMatchingRoom(event); this.sseService.sendToClient(event.roomMasterId(), "MATCH_ROOM_CREATED", event); From 242b7e216f908d145060e027bc7b53f2bc69d69f Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:18:15 +0900 Subject: [PATCH 379/770] =?UTF-8?q?feat:=20MemberAlreadyLeftMatchingRoom?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/exception/ErrorMessage.java | 3 ++- .../MemberAlreadyLeftMatchingRoomException.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyLeftMatchingRoomException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index 89f8344b..0c2ae0e3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -10,7 +10,8 @@ public enum ErrorMessage { NO_SUCH_MATCHING_ROOM("해당 매칭 방이 존재하지 않습니다."), NOT_ACTIVE_MATCHING_ROOM("열린 매칭 방이 아닙니다."), MEMBER_NOT_IN_MATCHING_ROOM("해당 매칭 방에 참가한 멤버가 아닙니다."), - MEMBER_ALREADY_JOINED_MATCHING_ROOM("해당 맴버는 이미 매칭 방에 참가한 멤버입니다"); + MEMBER_ALREADY_JOINED_MATCHING_ROOM("해당 맴버는 이미 매칭 방에 참가한 멤버입니다"), + MEMBER_ALREADY_LEFT_MATCHING_ROOM("해당 멤버는 이미 매칭 방에서 나간 멤버입니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyLeftMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyLeftMatchingRoomException.java new file mode 100644 index 00000000..344789ea --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/MemberAlreadyLeftMatchingRoomException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.MEMBER_ALREADY_LEFT_MATCHING_ROOM; +import static org.springframework.http.HttpStatus.CONFLICT; + +import com.gachtaxi.global.common.exception.BaseException; + +public class MemberAlreadyLeftMatchingRoomException extends BaseException { + + public MemberAlreadyLeftMatchingRoomException() { + super(CONFLICT, MEMBER_ALREADY_LEFT_MATCHING_ROOM.getMessage()); + } +} From f9aeea4c702df81344ffa1f0e533da8967969d9b Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:18:36 +0900 Subject: [PATCH 380/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=EC=9D=B4=20=EB=8B=A4=20=EC=B0=BC=EB=8A=94=EC=A7=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=B1=85=EC=9E=84=20MatchingRoom=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoom.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index b804eaef..efc74aa7 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -60,7 +60,7 @@ public class MatchingRoom extends BaseEntity { @Enumerated(EnumType.STRING) private MatchingRoomStatus matchingRoomStatus; - public boolean isActiveMatchingRoom() { + public boolean isActive() { return this.matchingRoomStatus == MatchingRoomStatus.ACTIVE; } @@ -76,7 +76,11 @@ public void completeMatchingRoom() { this.matchingRoomStatus = MatchingRoomStatus.COMPLETE; } - public static MatchingRoom activeFrom(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route) { + public boolean isFull(int size) { + return size == totalCharge; + } + + public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route) { return MatchingRoom.builder() .capacity(matchRoomCreatedEvent.maxCapacity()) .roomMaster(members) From 56dc901ef53258d7495d4d97d0f6b82f6f602731 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:19:06 +0900 Subject: [PATCH 381/770] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=EA=B0=80=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EB=B0=A9=EC=97=90=20=EB=93=A4=EC=96=B4?= =?UTF-8?q?=EC=98=A8=20=EC=A0=81=20=EC=9E=88=EB=8A=94=EC=A7=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=97=AC=EB=B6=80=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/entity/MemberMatchingRoomChargingInfo.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java index 8e353341..ec1a7e59 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MemberMatchingRoomChargingInfo.java @@ -48,6 +48,15 @@ public void leftMatchingRoom() { this.paymentStatus = PaymentStatus.LEFT; } + public boolean isAlreadyLeft() { + return this.paymentStatus == PaymentStatus.LEFT; + } + + public MemberMatchingRoomChargingInfo joinMatchingRoom() { + this.paymentStatus = PaymentStatus.NOT_PAYED; + return this; + } + public static MemberMatchingRoomChargingInfo notPayedOf(MatchingRoom matchingRoom, Members members) { return MemberMatchingRoomChargingInfo.builder() .matchingRoom(matchingRoom) From 2b31cdb56516a5737a6f98a03123fe40b9140f10 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:19:41 +0900 Subject: [PATCH 382/770] =?UTF-8?q?refactor:=20=EB=A9=A4=EB=B2=84=EA=B0=80?= =?UTF-8?q?=20=EC=B0=B8=EC=97=AC=ED=95=9C=20=EB=A7=A4=EC=B9=AD=EB=B0=A9?= =?UTF-8?q?=EC=9D=84=20=EC=A1=B0=ED=9A=8C=ED=95=A0=EB=95=8C=20PaymentStatu?= =?UTF-8?q?s=EB=8F=84=20=ED=99=95=EC=9D=B8=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MemberMatchingRoomChargingInfoRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java index 8f8746e1..982cf175 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; import com.gachtaxi.domain.members.entity.Members; import java.util.List; import java.util.Optional; @@ -11,6 +12,6 @@ @Repository public interface MemberMatchingRoomChargingInfoRepository extends JpaRepository { - List findByMatchingRoom(MatchingRoom matchingRoom); + List findByMatchingRoomAAndPaymentStatus(MatchingRoom matchingRoom, PaymentStatus paymentStatus); Optional findByMembersAndMatchingRoom(Members members, MatchingRoom matchingRoom); } From 8e212b735d0141fa7f166192bd2cce6469ab5f53 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:19:59 +0900 Subject: [PATCH 383/770] =?UTF-8?q?refactor:=20MatchingRoomService=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=95=EB=A6=AC=20=EB=B0=8F=20=EB=A6=AC?= =?UTF-8?q?=ED=8E=99=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 81 +++++++++++-------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index bf046c92..fc877e5c 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -4,10 +4,9 @@ import com.gachtaxi.domain.matching.common.entity.MatchingRoomTagInfo; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; import com.gachtaxi.domain.matching.common.entity.Route; -import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; import com.gachtaxi.domain.matching.common.entity.enums.Tags; -import com.gachtaxi.domain.matching.common.exception.MemberAlreadyJoinedException; +import com.gachtaxi.domain.matching.common.exception.MemberAlreadyLeftMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.MemberNotInMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NotActiveMatchingRoomException; @@ -51,10 +50,10 @@ public void createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { Route route = this.saveRoute(matchRoomCreatedEvent); - MatchingRoom matchingRoom = MatchingRoom.activeFrom(matchRoomCreatedEvent, members, route); + MatchingRoom matchingRoom = MatchingRoom.activeOf(matchRoomCreatedEvent, members, route); this.saveMatchingRoomTagInfo(matchingRoom, matchRoomCreatedEvent.criteria()); - this.saveHostMemberChargingInfo(matchingRoom, members); + this.saveRoomMasterChargingInfo(matchingRoom, members); this.matchingRoomRepository.save(matchingRoom); } @@ -64,47 +63,51 @@ private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { } private void saveMatchingRoomTagInfo(MatchingRoom matchingRoom, List tags) { - tags.forEach(tag -> { - this.matchingRoomTagInfoRepository.save(MatchingRoomTagInfo.of(matchingRoom, tag)); - }); + tags.forEach(tag -> this.matchingRoomTagInfoRepository.save(MatchingRoomTagInfo.of(matchingRoom, tag))); } - private void saveHostMemberChargingInfo(MatchingRoom matchingRoom, Members members) { + private void saveRoomMasterChargingInfo(MatchingRoom matchingRoom, Members members) { this.memberMatchingRoomChargingInfoRepository.save(MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, members)); } public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEvent) { Members members = this.memberService.findById(matchMemberJoinedEvent.memberId()); - MatchingRoom matchingRoom = this.matchingRoomRepository.findById( - matchMemberJoinedEvent.roomId()).orElseThrow( - NoSuchMatchingRoomException::new); + MatchingRoom matchingRoom = this.matchingRoomRepository.findById(matchMemberJoinedEvent.roomId()).orElseThrow(NoSuchMatchingRoomException::new); - if (this.memberMatchingRoomChargingInfoRepository.findByMembersAndMatchingRoom(members, matchingRoom).isPresent()) { - throw new MemberAlreadyJoinedException(); + if (!matchingRoom.isActive()) { + throw new NotActiveMatchingRoomException(); } - if (!matchingRoom.isActiveMatchingRoom()) { - throw new NotActiveMatchingRoomException(); + MemberMatchingRoomChargingInfo requestedMembersInfo = null; + + Optional joinedInPast = this.alreadyJoinedInPast(members, matchingRoom); + + if (joinedInPast.isPresent()) { + requestedMembersInfo = joinedInPast.get().joinMatchingRoom(); + } else { + requestedMembersInfo = MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, members); } + this.memberMatchingRoomChargingInfoRepository.save(requestedMembersInfo); - List existMembers = this.memberMatchingRoomChargingInfoRepository.findByMatchingRoom( - matchingRoom); + List existMembers = this.memberMatchingRoomChargingInfoRepository.findByMatchingRoomAAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); int distributedCharge = (int) Math.ceil((double) matchingRoom.getTotalCharge() / (existMembers.size() + 1)); - this.memberMatchingRoomChargingInfoRepository.save( - MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, members) - ); - this.updateExistMembersCharge(existMembers, distributedCharge); - if (existMembers.size() == matchingRoom.getCapacity() - 1) { + int nowMemberCount = existMembers.size() + 1; + + if (matchingRoom.isFull(nowMemberCount)) { this.autoMatchingProducer.sendMatchRoomCompletedEvent( MatchRoomCompletedEvent.of(matchingRoom.getId()) ); } } + private Optional alreadyJoinedInPast(Members members, MatchingRoom matchingRoom) { + return this.memberMatchingRoomChargingInfoRepository.findByMembersAndMatchingRoom(members, matchingRoom); + } + private void updateExistMembersCharge(List existMembers, int charge) { for (MemberMatchingRoomChargingInfo memberMatchingRoomChargingInfo : existMembers) { memberMatchingRoomChargingInfo.setCharge(charge); @@ -114,14 +117,16 @@ private void updateExistMembersCharge(List exist public void leaveMemberFromMatchingRoom(MatchMemberCancelledEvent matchMemberCancelledEvent) { Members members = this.memberService.findById(matchMemberCancelledEvent.memberId()); - MatchingRoom matchingRoom = this.matchingRoomRepository.findById( - matchMemberCancelledEvent.roomId()).orElseThrow( - NoSuchMatchingRoomException::new); + MatchingRoom matchingRoom = this.matchingRoomRepository.findById(matchMemberCancelledEvent.roomId()).orElseThrow(NoSuchMatchingRoomException::new); - MemberMatchingRoomChargingInfo memberMatchingRoomChargingInfo = this.memberMatchingRoomChargingInfoRepository.findByMembersAndMatchingRoom( - members, matchingRoom) + MemberMatchingRoomChargingInfo memberMatchingRoomChargingInfo = + this.memberMatchingRoomChargingInfoRepository.findByMembersAndMatchingRoom(members, matchingRoom) .orElseThrow(MemberNotInMatchingRoomException::new); + if (memberMatchingRoomChargingInfo.isAlreadyLeft()) { + throw new MemberAlreadyLeftMatchingRoomException(); + } + memberMatchingRoomChargingInfo.leftMatchingRoom(); this.memberMatchingRoomChargingInfoRepository.save(memberMatchingRoomChargingInfo); @@ -138,8 +143,8 @@ public void leaveMemberFromMatchingRoom(MatchMemberCancelledEvent matchMemberCan } private Optional findNextRoomMaster(MatchingRoom matchingRoom, Members members) { - List existMembers = this.memberMatchingRoomChargingInfoRepository.findByMatchingRoom( - matchingRoom); + List existMembers = + this.memberMatchingRoomChargingInfoRepository.findByMatchingRoomAAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); return existMembers.stream() .map(MemberMatchingRoomChargingInfo::getMembers) @@ -148,20 +153,28 @@ private Optional findNextRoomMaster(MatchingRoom matchingRoom, Members } public void cancelMatchingRoom(MatchRoomCancelledEvent matchRoomCancelledEvent) { - MatchingRoom matchingRoom = getMatchingRoomById(matchRoomCancelledEvent.roomId()); + MatchingRoom matchingRoom = this.getMatchingRoomById(matchRoomCancelledEvent.roomId()); + + if (!matchingRoom.isActive()) { + throw new NotActiveMatchingRoomException(); + } matchingRoom.cancelMatchingRoom(); this.matchingRoomRepository.save(matchingRoom); } - private MatchingRoom getMatchingRoomById(Long roomId) { - return this.matchingRoomRepository.findById(roomId).orElseThrow(NoSuchMatchingRoomException::new); - } - public void completeMatchingRoom(MatchRoomCompletedEvent matchRoomCompletedEvent) { MatchingRoom matchingRoom = this.getMatchingRoomById(matchRoomCompletedEvent.roomId()); + if (!matchingRoom.isActive()) { + throw new NotActiveMatchingRoomException(); + } + matchingRoom.completeMatchingRoom(); this.matchingRoomRepository.save(matchingRoom); } + + private MatchingRoom getMatchingRoomById(Long roomId) { + return this.matchingRoomRepository.findById(roomId).orElseThrow(NoSuchMatchingRoomException::new); + } } From 25b6d01cbe34184b1393d43cd291ff4541e24439 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:36:28 +0900 Subject: [PATCH 384/770] =?UTF-8?q?feat:=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=EA=B0=80=20current=20member=20id=EB=A5=BC=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=EB=A1=9C=ED=95=98=EC=A7=80=EB=A7=8C=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=A1=9C=20=EB=B0=9B=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EC=95=98=EC=9D=84=20=EB=95=8C=20=EB=8D=98=EC=A7=88=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ControllerNotHasCurrentMemberIdException.java | 13 +++++++++++++ .../matching/common/exception/ErrorMessage.java | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/ControllerNotHasCurrentMemberIdException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ControllerNotHasCurrentMemberIdException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ControllerNotHasCurrentMemberIdException.java new file mode 100644 index 00000000..3e24768f --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ControllerNotHasCurrentMemberIdException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.CONTROLLER_NOT_HAS_CURRENT_MEMBER_ID; +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; + +import com.gachtaxi.global.common.exception.BaseException; + +public class ControllerNotHasCurrentMemberIdException extends BaseException { + + public ControllerNotHasCurrentMemberIdException() { + super(INTERNAL_SERVER_ERROR, CONTROLLER_NOT_HAS_CURRENT_MEMBER_ID.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index 0c2ae0e3..018b51ae 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -11,7 +11,8 @@ public enum ErrorMessage { NOT_ACTIVE_MATCHING_ROOM("열린 매칭 방이 아닙니다."), MEMBER_NOT_IN_MATCHING_ROOM("해당 매칭 방에 참가한 멤버가 아닙니다."), MEMBER_ALREADY_JOINED_MATCHING_ROOM("해당 맴버는 이미 매칭 방에 참가한 멤버입니다"), - MEMBER_ALREADY_LEFT_MATCHING_ROOM("해당 멤버는 이미 매칭 방에서 나간 멤버입니다."); + MEMBER_ALREADY_LEFT_MATCHING_ROOM("해당 멤버는 이미 매칭 방에서 나간 멤버입니다."), + CONTROLLER_NOT_HAS_CURRENT_MEMBER_ID("해당 컨트롤러는 인가된 멤버 ID가 필요합니다."); private final String message; } From c79b747ead9523fa5c85487d764ac8cb97b9c63a Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:36:45 +0900 Subject: [PATCH 385/770] =?UTF-8?q?feat:=20SSE=20=EA=B5=AC=EB=8F=85=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?AOP=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/aop/SseSubscribeRequired.java | 12 +++++ .../matching/aop/SseSubscribeRequiredAop.java | 45 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequired.java create mode 100644 src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequiredAop.java diff --git a/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequired.java b/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequired.java new file mode 100644 index 00000000..28970452 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequired.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.matching.aop; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +public @interface SseSubscribeRequired { + +} diff --git a/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequiredAop.java b/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequiredAop.java new file mode 100644 index 00000000..677a4f52 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequiredAop.java @@ -0,0 +1,45 @@ +package com.gachtaxi.domain.matching.aop; + +import com.gachtaxi.domain.matching.common.controller.ResponseMessage; +import com.gachtaxi.domain.matching.common.exception.ControllerNotHasCurrentMemberIdException; +import com.gachtaxi.domain.matching.common.service.AutoMatchingService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +import com.gachtaxi.global.common.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +@Aspect +@Component +@RequiredArgsConstructor +public class SseSubscribeRequiredAop { + + private final AutoMatchingService autoMatchingService; + + @Around("@annotation(com.gachtaxi.domain.matching.aop.SseSubscribeRequired)") + public Object checkSseSubscribe(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{ + Long memberId = null; + for (Object arg : proceedingJoinPoint.getArgs()) { + Class argClass = arg.getClass(); + if (arg instanceof Long && argClass.isAnnotationPresent(CurrentMemberId.class)) { + memberId = (Long) arg; + break; + } + } + if (memberId == null) { + throw new ControllerNotHasCurrentMemberIdException(); + } + + if (!this.autoMatchingService.isSseSubscribed(memberId)) { + return ApiResponse.response( + HttpStatus.BAD_REQUEST, + ResponseMessage.NOT_SUBSCRIBED_SSE.getMessage() + ); + } + + return proceedingJoinPoint.proceed(); + } +} From 4c2ce2c6ad9dcf26b131deb876421044357c233c Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:37:03 +0900 Subject: [PATCH 386/770] =?UTF-8?q?refactor:=20SSE=20=EA=B5=AC=EB=8F=85=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=EC=97=90=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AutoMatchingController.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java index 4d8931d0..95c2296e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.matching.common.controller; +import com.gachtaxi.domain.matching.aop.SseSubscribeRequired; import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingCancelledRequest; import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; import com.gachtaxi.domain.matching.common.dto.response.AutoMatchingPostResponse; @@ -32,17 +33,11 @@ public SseEmitter subscribeSse(@CurrentMemberId Long memberId) { } @PostMapping("/request") + @SseSubscribeRequired public ApiResponse requestMatching( @CurrentMemberId Long memberId, @RequestBody AutoMatchingPostRequest autoMatchingPostRequest ) { - if (!this.autoMatchingService.isSseSubscribed(memberId)) { - return ApiResponse.response( - HttpStatus.BAD_REQUEST, - ResponseMessage.NOT_SUBSCRIBED_SSE.getMessage() - ); - } - return ApiResponse.response( HttpStatus.OK, ResponseMessage.AUTO_MATCHING_REQUEST_ACCEPTED.getMessage(), @@ -51,17 +46,11 @@ public ApiResponse requestMatching( } @PostMapping("/cancel") + @SseSubscribeRequired public ApiResponse cancelMatching( @CurrentMemberId Long memberId, @RequestBody AutoMatchingCancelledRequest autoMatchingCancelledRequest ) { - if (!this.autoMatchingService.isSseSubscribed(memberId)) { - return ApiResponse.response( - HttpStatus.BAD_REQUEST, - ResponseMessage.NOT_SUBSCRIBED_SSE.getMessage() - ); - } - return ApiResponse.response( HttpStatus.OK, ResponseMessage.AUTO_MATCHING_REQUEST_CANCELLED.getMessage(), From a1e1171c99d725ddb447e8f76c22c1e8e0907008 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:48:17 +0900 Subject: [PATCH 387/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=B7=A8=EC=86=8C,=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EB=B0=A9=20=EB=A7=A4=EC=B9=AD=20=EC=99=84=EB=A3=8C=20Topic=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=20bean=20=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/config/kafka/KafkaTopicsConfig.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java index 80a1517f..1b73120f 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java @@ -20,6 +20,9 @@ public class KafkaTopicsConfig { @Value("${gachtaxi.kafka.topics.match-room-completed}") private String matchRoomCompletedTopic; + @Value("${gachtaxi.kafka.topics.match-member-cancelled}") + private String matchMemberCancelledTopic; + @Value("${gachtaxi.kafka.partition-count}") private short partitionCount; @@ -40,4 +43,14 @@ public NewTopic matchMemberJoinedTopic() { public NewTopic matchRoomCancelledTopic() { return new NewTopic(matchRoomCancelledTopic, partitionCount, replicationFactor); } + + @Bean + public NewTopic matchMemberCancelledTopic() { + return new NewTopic(matchMemberCancelledTopic, partitionCount, replicationFactor); + } + + @Bean + public NewTopic matchRoomCompletedTopic() { + return new NewTopic(matchRoomCompletedTopic, partitionCount, replicationFactor); + } } \ No newline at end of file From 8f3c4c8ee31f67962a8f83ff1017b4f4a7c13298 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:48:44 +0900 Subject: [PATCH 388/770] =?UTF-8?q?refactor:=20kafka=20template,=20kafka?= =?UTF-8?q?=20producer=20factory=20config=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/kafka/KafkaProducerConfig.java | 81 +++---------------- .../config/kafka/KafkaTemplateConfig.java | 56 +++++++++++++ 2 files changed, 65 insertions(+), 72 deletions(-) create mode 100644 src/main/java/com/gachtaxi/global/config/kafka/KafkaTemplateConfig.java diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java index b2a6fcd7..1e50fbb7 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java @@ -27,66 +27,34 @@ public class KafkaProducerConfig { @Bean @Qualifier("matchRoomCreatedEventProducerFactory") public ProducerFactory matchRoomCreatedEventProducerFactory() { - Map configs = new HashMap<>(); - configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); - configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); - configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); - - configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); - configs.put(ProducerConfig.ACKS_CONFIG, "all"); - configs.put(ProducerConfig.RETRIES_CONFIG, 3); - - return new DefaultKafkaProducerFactory<>(configs); + return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); } @Bean @Qualifier("matchMemberJoinedEventProducerFactory") public ProducerFactory matchMemberJoinedEventProducerFactory() { - Map configs = new HashMap<>(); - configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); - configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); - configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); - - configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); - configs.put(ProducerConfig.ACKS_CONFIG, "all"); - configs.put(ProducerConfig.RETRIES_CONFIG, 3); - - return new DefaultKafkaProducerFactory<>(configs); + return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); } @Bean @Qualifier("matchMemberCanceledEventProducerFactory") public ProducerFactory matchMemberCanceledEventProducerFactory() { - Map configs = new HashMap<>(); - configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); - configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); - configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); - - configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); - configs.put(ProducerConfig.ACKS_CONFIG, "all"); - configs.put(ProducerConfig.RETRIES_CONFIG, 3); - - return new DefaultKafkaProducerFactory<>(configs); + return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); } @Bean @Qualifier("matchRoomCancelledEventProducerFactory") public ProducerFactory matchRoomCanclledEventProducerFactory() { - Map configs = new HashMap<>(); - configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); - configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); - configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); - - configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); - configs.put(ProducerConfig.ACKS_CONFIG, "all"); - configs.put(ProducerConfig.RETRIES_CONFIG, 3); - - return new DefaultKafkaProducerFactory<>(configs); + return new DefaultKafkaProducerFactory<>(getProducerOptions()); } @Bean @Qualifier("matchRoomCompletedEventProducerFactory") public ProducerFactory matchRoomCompletedEventProducerFactory() { + return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); + } + + private Map getProducerOptions() { Map configs = new HashMap<>(); configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); @@ -96,37 +64,6 @@ public ProducerFactory matchRoomCompletedEventP configs.put(ProducerConfig.ACKS_CONFIG, "all"); configs.put(ProducerConfig.RETRIES_CONFIG, 3); - return new DefaultKafkaProducerFactory<>(configs); - } - - @Bean - @Qualifier("matchMemberJoinedEventKafkaTemplate") - public KafkaTemplate matchMemberJoinedEventKafkaTemplate() { - - return new KafkaTemplate<>(matchMemberJoinedEventProducerFactory()); - } - - @Bean - @Qualifier("matchRoomCreatedEventKafkaTemplate") - public KafkaTemplate matchRoomCreatedEventKafkaTemplate() { - return new KafkaTemplate<>(matchRoomCreatedEventProducerFactory()); - } - - @Bean - @Qualifier("matchMemberCanceledEventKafkaTemplate") - public KafkaTemplate matchMemberCancelledEventKafkaTemplate() { - return new KafkaTemplate<>(matchMemberCanceledEventProducerFactory()); - } - - @Bean - @Qualifier("matchRoomCancelledEventKafkaTemplate") - public KafkaTemplate matchRoomCancelledEventKafkaTemplate() { - return new KafkaTemplate<>(matchRoomCanclledEventProducerFactory()); - } - - @Bean - @Qualifier("matchRoomCompletedEventKafkaTemplate") - public KafkaTemplate matchRoomCompletedEventKafkaTemplate() { - return new KafkaTemplate<>(matchRoomCompletedEventProducerFactory()); + return configs; } } \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTemplateConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTemplateConfig.java new file mode 100644 index 00000000..2a774a99 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTemplateConfig.java @@ -0,0 +1,56 @@ +package com.gachtaxi.global.config.kafka; + +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.core.ProducerFactory; + +@Configuration +public class KafkaTemplateConfig { + + @Bean + @Qualifier("matchMemberJoinedEventKafkaTemplate") + public KafkaTemplate matchMemberJoinedEventKafkaTemplate( + ProducerFactory matchMemberJoinedEventProducerFactory + ) { + return new KafkaTemplate<>(matchMemberJoinedEventProducerFactory); + } + + @Bean + @Qualifier("matchRoomCreatedEventKafkaTemplate") + public KafkaTemplate matchRoomCreatedEventKafkaTemplate( + ProducerFactory matchRoomCreatedEventProducerFactory + ) { + return new KafkaTemplate<>(matchRoomCreatedEventProducerFactory); + } + + @Bean + @Qualifier("matchMemberCanceledEventKafkaTemplate") + public KafkaTemplate matchMemberCancelledEventKafkaTemplate( + ProducerFactory matchMemberCanceledEventProducerFactory + ) { + return new KafkaTemplate<>(matchMemberCanceledEventProducerFactory); + } + + @Bean + @Qualifier("matchRoomCancelledEventKafkaTemplate") + public KafkaTemplate matchRoomCancelledEventKafkaTemplate( + ProducerFactory matchRoomCancelledEventProducerFactory + ) { + return new KafkaTemplate<>(matchRoomCancelledEventProducerFactory); + } + + @Bean + @Qualifier("matchRoomCompletedEventKafkaTemplate") + public KafkaTemplate matchRoomCompletedEventKafkaTemplate( + ProducerFactory matchRoomCompletedEventProducerFactory + ) { + return new KafkaTemplate<>(matchRoomCompletedEventProducerFactory); + } +} From 3c36c2c42c5336b478069d647834de060ac63cf5 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 13 Jan 2025 23:48:51 +0900 Subject: [PATCH 389/770] =?UTF-8?q?refactor:=20=EA=B0=9C=ED=96=89=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/dto/kafka_topic/MatchMemberCancelledEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java index bded5d51..b96020f0 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java @@ -15,8 +15,8 @@ public record MatchMemberCancelledEvent( ) { public static MatchMemberCancelledEvent of(Long roomId, Long memberId) { - return MatchMemberCancelledEvent.builder(). - roomId(roomId) + return MatchMemberCancelledEvent.builder() + .roomId(roomId) .memberId(memberId) .build(); } From a3f8abbe41c39ec6de156f031103be260b28d6f5 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:08:19 +0900 Subject: [PATCH 390/770] =?UTF-8?q?refactor:=20producer,=20kafka=20templat?= =?UTF-8?q?e,=20topic=20=EB=8F=99=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=B4=20=EA=B8=B0=EC=A1=B4=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/kafka/AutoMatchingProducer.java | 156 ------------------ ...g.java => DefaultKafkaProducerConfig.java} | 65 +++++--- .../config/kafka/KafkaTemplateConfig.java | 56 ------- .../config/kafka/KafkaTopicsConfig.java | 56 ------- 4 files changed, 39 insertions(+), 294 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java rename src/main/java/com/gachtaxi/global/config/kafka/{KafkaProducerConfig.java => DefaultKafkaProducerConfig.java} (55%) delete mode 100644 src/main/java/com/gachtaxi/global/config/kafka/KafkaTemplateConfig.java delete mode 100644 src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java deleted file mode 100644 index f4a11be7..00000000 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.gachtaxi.domain.matching.event.service.kafka; - -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; -import java.util.concurrent.CompletableFuture; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.kafka.clients.producer.RecordMetadata; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.stereotype.Service; - -@Slf4j -@Service -@RequiredArgsConstructor -public class AutoMatchingProducer { - - private final KafkaTemplate matchRoomCreatedEventKafkaTemplate; - private final KafkaTemplate matchMemberJoinedEventKafkaTemplate; - private final KafkaTemplate matchMemberCanceledEventKafkaTemplate; - private final KafkaTemplate matchRoomCancelledEventKafkaTemplate; - private final KafkaTemplate matchRoomCompletedEventKafkaTemplate; - - @Value("${gachtaxi.kafka.topics.match-room-created}") - private String matchRoomCreatedTopic; - - @Value("${gachtaxi.kafka.topics.match-member-joined}") - private String matchMemberJoinedTopic; - - @Value("${gachtaxi.kafka.topics.match-member-cancelled}") - private String matchMemberCanceledTopic; - - @Value("${gachtaxi.kafka.topics.match-room-cancelled}") - private String matchRoomCancelledTopic; - - @Value("${gachtaxi.kafka.topics.match-room-completed}") - private String matchRoomCompletedTopic; - - /** - * 방 생성 이벤트를 발행 - */ - public void sendMatchRoomCreatedEvent(MatchRoomCreatedEvent matchRoomCreatedEvent) { - String key = matchRoomCreatedEvent.title(); - - CompletableFuture future = this.matchRoomCreatedEventKafkaTemplate.send( - matchRoomCreatedTopic, key, matchRoomCreatedEvent); - - future.thenAccept(result -> { - if (result instanceof RecordMetadata metadata) { - log.info("[KAFKA PRODUCER] Success sending MatchRoomCreatedEvent: " - + "topic={}, partition={}, offset={}, key={}", - metadata.topic(), metadata.partition(), metadata.offset(), key - ); - } - } - ).exceptionally(ex -> { - log.error("[KAFKA PRODUCER] Failed to send MatchRoomCreatedEvent key={}", key, ex); - return null; - }); - } - - /** - * 방 멤버 참가 이벤트를 발행 - */ - public void sendMatchMemberJoinedEvent(MatchMemberJoinedEvent matchMemberJoinedEvent) { - String key = String.valueOf(matchMemberJoinedEvent.roomId()); - - CompletableFuture future = this.matchMemberJoinedEventKafkaTemplate.send( - matchMemberJoinedTopic, key, matchMemberJoinedEvent); - - future.thenAccept(result -> { - if (result instanceof RecordMetadata metadata) { - log.info("[KAFKA PRODUCER] Success sending MatchMemberJoinedEvent: " - + "topic={}, partition={}, offset={}, key={}", - metadata.topic(), metadata.partition(), metadata.offset(), key - ); - } - } - ).exceptionally(ex -> { - log.error("[KAFKA PRODUCER] Failed to send MatchMemberJoinedEvent key={}", key, ex); - return null; - }); - } - - /** - * 방 멤버 취소 이벤트를 발행 - */ - public void sendMatchMemberLeftEvent(MatchMemberCancelledEvent matchMemberCancelledEvent) { - String key = String.valueOf(matchMemberCancelledEvent.roomId()); - - CompletableFuture future = this.matchMemberCanceledEventKafkaTemplate.send( - matchMemberCanceledTopic, key, matchMemberCancelledEvent); - - future.thenAccept(result -> { - if (result instanceof RecordMetadata metadata) { - log.info("[KAFKA PRODUCER] Success sending MatchMemberLeftEvent: " - + "topic={}, partition={}, offset={}, key={}", - metadata.topic(), metadata.partition(), metadata.offset(), key - ); - } - } - ).exceptionally(ex -> { - log.error("[KAFKA PRODUCER] Failed to send MatchMemberLeftEvent key={}", key, ex); - return null; - }); - } - - /** - * 방 취소 이벤트를 발행 - */ - public void sendMatchRoomCancelledEvent(MatchRoomCancelledEvent matchRoomCancelledEvent) { - String key = String.valueOf(matchRoomCancelledEvent.roomId()); - - CompletableFuture future = this.matchRoomCancelledEventKafkaTemplate.send( - matchRoomCancelledTopic, key, matchRoomCancelledEvent); - - future.thenAccept(result -> { - if (result instanceof RecordMetadata metadata) { - log.info("[KAFKA PRODUCER] Success sending MatchRoomCancelledEvent: " - + "topic={}, partition={}, offset={}, key={}", - metadata.topic(), metadata.partition(), metadata.offset(), key - ); - } - } - ).exceptionally(ex -> { - log.error("[KAFKA PRODUCER] Failed to send MatchRoomCancelledEvent key={}", key, ex); - return null; - }); - } - - /** - * 매칭 성공 이벤트를 발행 - */ - public void sendMatchRoomCompletedEvent(MatchRoomCompletedEvent matchRoomCompletedEvent) { - String key = String.valueOf(matchRoomCompletedEvent.roomId()); - - CompletableFuture future = this.matchRoomCompletedEventKafkaTemplate.send( - matchRoomCompletedTopic, key, matchRoomCompletedEvent); - - future.thenAccept(result -> { - if (result instanceof RecordMetadata metadata) { - log.info("[KAFKA PRODUCER] Success sending MatchRoomCompleted: " - + "topic={}, partition={}, offset={}, key={}", - metadata.topic(), metadata.partition(), metadata.offset(), key - ); - } - } - ).exceptionally(ex -> { - log.error("[KAFKA PRODUCER] Failed to send MatchRoomCompleted key={}", key, ex); - return null; - }); - } -} \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/DefaultKafkaProducerConfig.java similarity index 55% rename from src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java rename to src/main/java/com/gachtaxi/global/config/kafka/DefaultKafkaProducerConfig.java index 1e50fbb7..fab7b235 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaProducerConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/DefaultKafkaProducerConfig.java @@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.ProducerFactory; @@ -21,39 +22,51 @@ @Configuration public class KafkaProducerConfig { - @Value("${spring.kafka.bootstrap-servers}") - private String bootstrapServers; - + @Primary @Bean - @Qualifier("matchRoomCreatedEventProducerFactory") - public ProducerFactory matchRoomCreatedEventProducerFactory() { + public ProducerFactory producerFactory() { return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); } + @Primary @Bean - @Qualifier("matchMemberJoinedEventProducerFactory") - public ProducerFactory matchMemberJoinedEventProducerFactory() { - return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); - } - - @Bean - @Qualifier("matchMemberCanceledEventProducerFactory") - public ProducerFactory matchMemberCanceledEventProducerFactory() { - return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); - } - - @Bean - @Qualifier("matchRoomCancelledEventProducerFactory") - public ProducerFactory matchRoomCanclledEventProducerFactory() { - return new DefaultKafkaProducerFactory<>(getProducerOptions()); - } - - @Bean - @Qualifier("matchRoomCompletedEventProducerFactory") - public ProducerFactory matchRoomCompletedEventProducerFactory() { - return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); + public KafkaTemplate kafkaTemplate() { + return new KafkaTemplate<>(producerFactory()); } + @Value("${spring.kafka.bootstrap-servers}") + private String bootstrapServers; +// +// @Bean +// @Qualifier("matchRoomCreatedEventProducerFactory") +// public ProducerFactory matchRoomCreatedEventProducerFactory() { +// return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); +// } +// +// @Bean +// @Qualifier("matchMemberJoinedEventProducerFactory") +// public ProducerFactory matchMemberJoinedEventProducerFactory() { +// return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); +// } +// +// @Bean +// @Qualifier("matchMemberCanceledEventProducerFactory") +// public ProducerFactory matchMemberCanceledEventProducerFactory() { +// return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); +// } +// +// @Bean +// @Qualifier("matchRoomCancelledEventProducerFactory") +// public ProducerFactory matchRoomCanclledEventProducerFactory() { +// return new DefaultKafkaProducerFactory<>(getProducerOptions()); +// } +// +// @Bean +// @Qualifier("matchRoomCompletedEventProducerFactory") +// public ProducerFactory matchRoomCompletedEventProducerFactory() { +// return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); +// } +// private Map getProducerOptions() { Map configs = new HashMap<>(); configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTemplateConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTemplateConfig.java deleted file mode 100644 index 2a774a99..00000000 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTemplateConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.gachtaxi.global.config.kafka; - -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.core.ProducerFactory; - -@Configuration -public class KafkaTemplateConfig { - - @Bean - @Qualifier("matchMemberJoinedEventKafkaTemplate") - public KafkaTemplate matchMemberJoinedEventKafkaTemplate( - ProducerFactory matchMemberJoinedEventProducerFactory - ) { - return new KafkaTemplate<>(matchMemberJoinedEventProducerFactory); - } - - @Bean - @Qualifier("matchRoomCreatedEventKafkaTemplate") - public KafkaTemplate matchRoomCreatedEventKafkaTemplate( - ProducerFactory matchRoomCreatedEventProducerFactory - ) { - return new KafkaTemplate<>(matchRoomCreatedEventProducerFactory); - } - - @Bean - @Qualifier("matchMemberCanceledEventKafkaTemplate") - public KafkaTemplate matchMemberCancelledEventKafkaTemplate( - ProducerFactory matchMemberCanceledEventProducerFactory - ) { - return new KafkaTemplate<>(matchMemberCanceledEventProducerFactory); - } - - @Bean - @Qualifier("matchRoomCancelledEventKafkaTemplate") - public KafkaTemplate matchRoomCancelledEventKafkaTemplate( - ProducerFactory matchRoomCancelledEventProducerFactory - ) { - return new KafkaTemplate<>(matchRoomCancelledEventProducerFactory); - } - - @Bean - @Qualifier("matchRoomCompletedEventKafkaTemplate") - public KafkaTemplate matchRoomCompletedEventKafkaTemplate( - ProducerFactory matchRoomCompletedEventProducerFactory - ) { - return new KafkaTemplate<>(matchRoomCompletedEventProducerFactory); - } -} diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java deleted file mode 100644 index 1b73120f..00000000 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaTopicsConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.gachtaxi.global.config.kafka; - -import org.apache.kafka.clients.admin.NewTopic; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class KafkaTopicsConfig { - - @Value("${gachtaxi.kafka.topics.match-room-created}") - private String matchRoomCreatedTopic; - - @Value("${gachtaxi.kafka.topics.match-member-joined}") - private String matchMemberJoinedTopic; - - @Value("${gachtaxi.kafka.topics.match-room-cancelled}") - private String matchRoomCancelledTopic; - - @Value("${gachtaxi.kafka.topics.match-room-completed}") - private String matchRoomCompletedTopic; - - @Value("${gachtaxi.kafka.topics.match-member-cancelled}") - private String matchMemberCancelledTopic; - - @Value("${gachtaxi.kafka.partition-count}") - private short partitionCount; - - @Value("${gachtaxi.kafka.replication-factor}") - private short replicationFactor; - - @Bean - public NewTopic matchRoomCreatedTopic() { - return new NewTopic(matchRoomCreatedTopic, partitionCount, replicationFactor); - } - - @Bean - public NewTopic matchMemberJoinedTopic() { - return new NewTopic(matchMemberJoinedTopic, partitionCount, replicationFactor); - } - - @Bean - public NewTopic matchRoomCancelledTopic() { - return new NewTopic(matchRoomCancelledTopic, partitionCount, replicationFactor); - } - - @Bean - public NewTopic matchMemberCancelledTopic() { - return new NewTopic(matchMemberCancelledTopic, partitionCount, replicationFactor); - } - - @Bean - public NewTopic matchRoomCompletedTopic() { - return new NewTopic(matchRoomCompletedTopic, partitionCount, replicationFactor); - } -} \ No newline at end of file From b0af0fea0171153698f9dfba1e645ff121562021 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:08:39 +0900 Subject: [PATCH 391/770] =?UTF-8?q?feat:=20NotDefienedKafkaTemplateExcepti?= =?UTF-8?q?on=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/exception/ErrorMessage.java | 3 ++- .../exception/NotDefinedKafkaTemplateException.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/NotDefinedKafkaTemplateException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index 018b51ae..e3bd4705 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -12,7 +12,8 @@ public enum ErrorMessage { MEMBER_NOT_IN_MATCHING_ROOM("해당 매칭 방에 참가한 멤버가 아닙니다."), MEMBER_ALREADY_JOINED_MATCHING_ROOM("해당 맴버는 이미 매칭 방에 참가한 멤버입니다"), MEMBER_ALREADY_LEFT_MATCHING_ROOM("해당 멤버는 이미 매칭 방에서 나간 멤버입니다."), - CONTROLLER_NOT_HAS_CURRENT_MEMBER_ID("해당 컨트롤러는 인가된 멤버 ID가 필요합니다."); + CONTROLLER_NOT_HAS_CURRENT_MEMBER_ID("해당 컨트롤러는 인가된 멤버 ID가 필요합니다."), + NOT_DEFINED_KAFKA_TEMPLATE("해당 이벤트와 맞는 KafkaTemplate이 정의되지 않았습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/NotDefinedKafkaTemplateException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotDefinedKafkaTemplateException.java new file mode 100644 index 00000000..2bb75035 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotDefinedKafkaTemplateException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.NOT_DEFINED_KAFKA_TEMPLATE; +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; + +import com.gachtaxi.global.common.exception.BaseException; + +public class NotDefinedKafkaTemplateException extends BaseException { + + public NotDefinedKafkaTemplateException() { + super(INTERNAL_SERVER_ERROR, NOT_DEFINED_KAFKA_TEMPLATE.getMessage()); + } +} From 952d355d0a0258538956671c628c6844be502f3e Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:09:02 +0900 Subject: [PATCH 392/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=EA=B0=80=20=EA=B5=AC=ED=98=84=ED=95=B4?= =?UTF-8?q?=EC=95=BC=ED=95=98=EB=8A=94=20=EC=9D=B8=ED=84=B0=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/event/dto/kafka_topic/MatchingEvent.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchingEvent.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchingEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchingEvent.java new file mode 100644 index 00000000..a2b0ae4a --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchingEvent.java @@ -0,0 +1,7 @@ +package com.gachtaxi.domain.matching.event.dto.kafka_topic; + +public interface MatchingEvent { + + Object getKey(); + String getTopic(); +} From d3a3b29da2f5c262e6dd3458085fd87947d3bc1a Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:09:29 +0900 Subject: [PATCH 393/770] =?UTF-8?q?feat:=20=EA=B8=B0=EC=A1=B4=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EA=B4=80=EB=A0=A8=20=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=EB=93=A4=EC=9D=B4=20MatchingEvent=EB=A5=BC=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MatchMemberCancelledEvent.java | 20 ++++++++++++--- .../kafka_topic/MatchMemberJoinedEvent.java | 25 ++++++++++++++++--- .../kafka_topic/MatchRoomCancelledEvent.java | 24 +++++++++++++++--- .../kafka_topic/MatchRoomCompletedEvent.java | 24 +++++++++++++++--- .../kafka_topic/MatchRoomCreatedEvent.java | 20 ++++++++++++--- 5 files changed, 95 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java index b96020f0..32922887 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberCancelledEvent.java @@ -4,6 +4,7 @@ import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Builder; +import org.springframework.beans.factory.annotation.Value; @Builder(access = AccessLevel.PRIVATE) public record MatchMemberCancelledEvent( @@ -11,13 +12,26 @@ public record MatchMemberCancelledEvent( Long memberId, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - LocalDateTime canceledAt -) { + LocalDateTime canceledAt, - public static MatchMemberCancelledEvent of(Long roomId, Long memberId) { + String topic +) implements MatchingEvent{ + + @Override + public Object getKey() { + return String.valueOf(this.roomId); + } + + @Override + public String getTopic() { + return this.topic; + } + + public static MatchMemberCancelledEvent of(Long roomId, Long memberId, String topic) { return MatchMemberCancelledEvent.builder() .roomId(roomId) .memberId(memberId) + .topic(topic) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java index 989ae7da..22d1f395 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java @@ -4,6 +4,7 @@ import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Builder; +import org.springframework.beans.factory.annotation.Value; @Builder(access = AccessLevel.PRIVATE) public record MatchMemberJoinedEvent( @@ -11,10 +12,26 @@ public record MatchMemberJoinedEvent( Long memberId, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - LocalDateTime joinedAt -) { + LocalDateTime joinedAt, - public static MatchMemberJoinedEvent of(Long roomId, Long memberId) { - return new MatchMemberJoinedEvent(roomId, memberId, LocalDateTime.now()); + String topic +) implements MatchingEvent{ + + @Override + public Object getKey() { + return String.valueOf(this.roomId); + } + + @Override + public String getTopic() { + return this.topic; + } + + public static MatchMemberJoinedEvent of(Long roomId, Long memberId, String topic) { + return MatchMemberJoinedEvent.builder() + .roomId(roomId) + .memberId(memberId) + .topic(topic) + .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java index f0bbbe2c..b6870b74 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCancelledEvent.java @@ -2,13 +2,29 @@ import lombok.AccessLevel; import lombok.Builder; +import org.springframework.beans.factory.annotation.Value; @Builder(access = AccessLevel.PRIVATE) public record MatchRoomCancelledEvent( - Long roomId -) { + Long roomId, - public static MatchRoomCancelledEvent of(Long roomId) { - return MatchRoomCancelledEvent.builder().roomId(roomId).build(); + String topic +) implements MatchingEvent{ + + @Override + public Object getKey() { + return String.valueOf(this.roomId); + } + + @Override + public String getTopic() { + return this.topic; + } + + public static MatchRoomCancelledEvent of(Long roomId, String topic) { + return MatchRoomCancelledEvent.builder() + .roomId(roomId) + .topic(topic) + .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java index 4022476b..80669452 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCompletedEvent.java @@ -2,13 +2,29 @@ import lombok.AccessLevel; import lombok.Builder; +import org.springframework.beans.factory.annotation.Value; @Builder(access = AccessLevel.PRIVATE) public record MatchRoomCompletedEvent( - Long roomId -) { + Long roomId, - public static MatchRoomCompletedEvent of(Long roomId) { - return MatchRoomCompletedEvent.builder().roomId(roomId).build(); + String topic +) implements MatchingEvent{ + + @Override + public Object getKey() { + return String.valueOf(this.roomId); + } + + @Override + public String getTopic() { + return this.topic; + } + + public static MatchRoomCompletedEvent of(Long roomId, String topic) { + return MatchRoomCompletedEvent.builder() + .roomId(roomId) + .topic(topic) + .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java index 62b0e195..89333de7 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java @@ -24,14 +24,27 @@ public record MatchRoomCreatedEvent( Integer expectedTotalCharge, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - LocalDateTime createdAt -) { + LocalDateTime createdAt, + + String topic +) implements MatchingEvent{ + + @Override + public Object getKey() { + return null; + } + + @Override + public String getTopic() { + return this.topic; + } public static MatchRoomCreatedEvent of( Long roomMasterId, AutoMatchingPostRequest autoMatchingPostRequest, int maxCapacity, - String description + String description, + String topic ) { return MatchRoomCreatedEvent.builder() .roomMasterId(roomMasterId) @@ -44,6 +57,7 @@ public static MatchRoomCreatedEvent of( .description(description) .expectedTotalCharge(autoMatchingPostRequest.expectedTotalCharge()) .criteria(autoMatchingPostRequest.getCriteria()) + .topic(topic) .build(); } } From 12cf905ac6a9378efcb55a0c68ac706dfebffc23 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:09:54 +0900 Subject: [PATCH 394/770] =?UTF-8?q?feat:=20Kafka=20=EB=B9=88=EB=93=A4?= =?UTF-8?q?=EC=9D=84=20=EB=8F=99=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20suffix=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/kafka/KafkaBeanSuffix.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/util/kafka/KafkaBeanSuffix.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/kafka/KafkaBeanSuffix.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/kafka/KafkaBeanSuffix.java new file mode 100644 index 00000000..b008743b --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/kafka/KafkaBeanSuffix.java @@ -0,0 +1,8 @@ +package com.gachtaxi.global.auth.jwt.util.kafka; + +public abstract class KafkaBeanSuffix { + + public static final String PRODUCER_FACTORY_SUFFIX = "ProducerFactory"; + public static final String NEW_TOPIC_SUFFIX = "Topic"; + public static final String KAFKA_TEMPLATE_SUFFIX = "KafkaTemplate"; +} From b20683f7b5e853bdf0145b9248f5d72a698cbb64 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:10:08 +0900 Subject: [PATCH 395/770] =?UTF-8?q?feat:=20kafka=20=EB=B9=88=EB=93=A4?= =?UTF-8?q?=EC=9D=84=20=EB=8F=99=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=ED=95=98=EA=B8=B0=EC=9C=84=ED=95=9C=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/util/KafkaBeanUtils.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java new file mode 100644 index 00000000..dee64965 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java @@ -0,0 +1,25 @@ +package com.gachtaxi.global.auth.jwt.util; + +import java.util.StringTokenizer; + +public abstract class KafkaBeanUtils { + + public static String getBeanName(String topic, String suffix) { + StringTokenizer stringTokenizer = new StringTokenizer(topic, "-_"); + + StringBuilder beanNameBuilder = new StringBuilder(); + beanNameBuilder.append(stringTokenizer.nextToken()); + + while (stringTokenizer.hasMoreTokens()) { + beanNameBuilder.append(getFirstUpperString(stringTokenizer.nextToken())); + } + + beanNameBuilder.append(suffix); + + return beanNameBuilder.toString(); + } + + public static String getFirstUpperString(String str) { + return str.substring(0, 1).toUpperCase() + str.substring(1); + } +} From 342227eaa45d9f9bf105362e380805e3b4bf3557 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:10:27 +0900 Subject: [PATCH 396/770] =?UTF-8?q?feat:=20=EA=B8=B0=EB=B3=B8=20kafka=20pr?= =?UTF-8?q?oducer,=20kafka=20template=EC=9D=84=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kafka/DefaultKafkaProducerConfig.java | 62 ++++--------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/kafka/DefaultKafkaProducerConfig.java b/src/main/java/com/gachtaxi/global/config/kafka/DefaultKafkaProducerConfig.java index fab7b235..d2a79cbc 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/DefaultKafkaProducerConfig.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/DefaultKafkaProducerConfig.java @@ -1,15 +1,9 @@ package com.gachtaxi.global.config.kafka; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import java.util.HashMap; import java.util.Map; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.common.serialization.StringSerializer; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -20,54 +14,14 @@ import org.springframework.kafka.support.serializer.JsonSerializer; @Configuration -public class KafkaProducerConfig { +public class DefaultKafkaProducerConfig { - @Primary - @Bean - public ProducerFactory producerFactory() { - return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); - } + @Value("${spring.kafka.bootstrap-servers}") + private String bootstrapServers; @Primary @Bean - public KafkaTemplate kafkaTemplate() { - return new KafkaTemplate<>(producerFactory()); - } - - @Value("${spring.kafka.bootstrap-servers}") - private String bootstrapServers; -// -// @Bean -// @Qualifier("matchRoomCreatedEventProducerFactory") -// public ProducerFactory matchRoomCreatedEventProducerFactory() { -// return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); -// } -// -// @Bean -// @Qualifier("matchMemberJoinedEventProducerFactory") -// public ProducerFactory matchMemberJoinedEventProducerFactory() { -// return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); -// } -// -// @Bean -// @Qualifier("matchMemberCanceledEventProducerFactory") -// public ProducerFactory matchMemberCanceledEventProducerFactory() { -// return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); -// } -// -// @Bean -// @Qualifier("matchRoomCancelledEventProducerFactory") -// public ProducerFactory matchRoomCanclledEventProducerFactory() { -// return new DefaultKafkaProducerFactory<>(getProducerOptions()); -// } -// -// @Bean -// @Qualifier("matchRoomCompletedEventProducerFactory") -// public ProducerFactory matchRoomCompletedEventProducerFactory() { -// return new DefaultKafkaProducerFactory<>(this.getProducerOptions()); -// } -// - private Map getProducerOptions() { + public ProducerFactory producerFactory() { Map configs = new HashMap<>(); configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); @@ -77,6 +31,12 @@ private Map getProducerOptions() { configs.put(ProducerConfig.ACKS_CONFIG, "all"); configs.put(ProducerConfig.RETRIES_CONFIG, 3); - return configs; + return new DefaultKafkaProducerFactory<>(configs); + } + + @Primary + @Bean + public KafkaTemplate kafkaTemplate() { + return new KafkaTemplate<>(producerFactory()); } } \ No newline at end of file From 6886e2dd539be0d13364564045b124e797441e6f Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:11:00 +0900 Subject: [PATCH 397/770] =?UTF-8?q?fix:=20MemberMatchingRoomChargingInfoRe?= =?UTF-8?q?pository=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MemberMatchingRoomChargingInfoRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java index 982cf175..2a76f9f1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java @@ -12,6 +12,6 @@ @Repository public interface MemberMatchingRoomChargingInfoRepository extends JpaRepository { - List findByMatchingRoomAAndPaymentStatus(MatchingRoom matchingRoom, PaymentStatus paymentStatus); + List findByMatchingRoomAndPaymentStatus(MatchingRoom matchingRoom, PaymentStatus paymentStatus); Optional findByMembersAndMatchingRoom(Members members, MatchingRoom matchingRoom); } From 6b999ac75d7aaa4041e983af2b99445500b2ec93 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:11:27 +0900 Subject: [PATCH 398/770] =?UTF-8?q?feat:=20=EB=8F=99=EC=A0=81=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20kafka=20template,=20producer,=20topic=EC=9D=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=ED=95=98=EB=8A=94=20registrar=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/kafka/KafkaBeanRegistrar.java | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java new file mode 100644 index 00000000..aba24d70 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java @@ -0,0 +1,106 @@ +package com.gachtaxi.global.config.kafka; + +import static com.gachtaxi.global.auth.jwt.util.kafka.KafkaBeanSuffix.KAFKA_TEMPLATE_SUFFIX; +import static com.gachtaxi.global.auth.jwt.util.kafka.KafkaBeanSuffix.NEW_TOPIC_SUFFIX; +import static com.gachtaxi.global.auth.jwt.util.kafka.KafkaBeanSuffix.PRODUCER_FACTORY_SUFFIX; + +import com.gachtaxi.global.auth.jwt.util.KafkaBeanUtils; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import lombok.extern.slf4j.Slf4j; +import org.apache.kafka.clients.admin.NewTopic; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.common.serialization.StringSerializer; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.support.AbstractBeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; +import org.springframework.boot.context.properties.bind.Bindable; +import org.springframework.boot.context.properties.bind.Binder; +import org.springframework.context.EnvironmentAware; +import org.springframework.core.env.Environment; +import org.springframework.kafka.core.DefaultKafkaProducerFactory; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.support.serializer.JsonSerializer; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +public class KafkaBeanRegistrar implements BeanDefinitionRegistryPostProcessor, EnvironmentAware { + + private Environment environment; + + @Override + public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) + throws BeansException { + Map topics = Binder.get(environment) + .bind("gachtaxi.kafka.topics", Bindable.mapOf(String.class, String.class)) + .orElse(Collections.emptyMap()); + + log.info(topics.toString()); + + for (String topic : topics.values()) { + this.registerProducerFactoryAndKafkaTemplate(topic, registry); + this.registerNewTopic(topic, registry); + } + } + + private void registerKafkaTemplate(String topic, String producerFactoryBeanName, BeanDefinitionRegistry registry) { + String kafkaTemplateBeanName = KafkaBeanUtils.getBeanName(topic, KAFKA_TEMPLATE_SUFFIX); + AbstractBeanDefinition kafkaTemplateBeanDefinition = + BeanDefinitionBuilder.genericBeanDefinition(KafkaTemplate.class) + .addConstructorArgReference(producerFactoryBeanName) + .getBeanDefinition(); + + registry.registerBeanDefinition(kafkaTemplateBeanName, kafkaTemplateBeanDefinition); + } + + private void registerNewTopic(String topic, BeanDefinitionRegistry registry) { + short partitionCount = Short.valueOf(this.environment.getProperty("gachtaxi.kafka.partition-count")); + short replicationFactor = Short.valueOf(this.environment.getProperty("gachtaxi.kafka.replication-factor")); + + String topicBeanName = KafkaBeanUtils.getBeanName(topic, NEW_TOPIC_SUFFIX); + AbstractBeanDefinition newTopicBeanDefinition = + BeanDefinitionBuilder.genericBeanDefinition(NewTopic.class) + .addConstructorArgValue(topic) + .addConstructorArgValue(partitionCount) + .addConstructorArgValue(replicationFactor) + .getBeanDefinition(); + + registry.registerBeanDefinition(topicBeanName, newTopicBeanDefinition); + } + + private void registerProducerFactoryAndKafkaTemplate(String topic, BeanDefinitionRegistry registry) { + String producerBeanName = KafkaBeanUtils.getBeanName(topic, PRODUCER_FACTORY_SUFFIX); + AbstractBeanDefinition producerBeanDefinition = + BeanDefinitionBuilder.genericBeanDefinition(DefaultKafkaProducerFactory.class) + .addConstructorArgValue(this.getProducerOptions()) + .getBeanDefinition(); + + registry.registerBeanDefinition(producerBeanName, producerBeanDefinition); + + this.registerKafkaTemplate(topic, producerBeanName, registry); + } + + private Map getProducerOptions() { + String bootstrapServers = this.environment.getProperty("spring.kafka.bootstrap-servers"); + + Map configs = new HashMap<>(); + configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + + configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); + configs.put(ProducerConfig.ACKS_CONFIG, "all"); + configs.put(ProducerConfig.RETRIES_CONFIG, 3); + + return configs; + } + + @Override + public void setEnvironment(Environment environment) { + this.environment = environment; + } +} From 2d7f2ae03bca0a4dcd08c50e103ba234933f8f8b Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:11:36 +0900 Subject: [PATCH 399/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=EB=A5=BC=20=EC=83=9D=EC=84=B1=ED=95=B4?= =?UTF-8?q?=EC=A3=BC=EB=8A=94=20=ED=8C=A9=ED=86=A0=EB=A6=AC=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/event/MatchingEventFactory.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java diff --git a/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java b/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java new file mode 100644 index 00000000..3df46e84 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java @@ -0,0 +1,55 @@ +package com.gachtaxi.domain.matching.event; + +import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCompletedEvent; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class MatchingEventFactory { + + @Value("${gachtaxi.kafka.topics.match-member-cancelled}") + private String matchMemberCancelledTopic; + + @Value("${gachtaxi.kafka.topics.match-member-joined}") + private String matchMemberJoinedTopic; + + @Value("${gachtaxi.kafka.topics.match-room-cancelled}") + private String matchRoomCancelledTopic; + + @Value("${gachtaxi.kafka.topics.match-room-completed}") + private String matchRoomCompletedTopic; + + @Value("${gachtaxi.kafka.topics.match-room-created}") + private String matchRoomCreatedTopic; + + @Value("${gachtaxi.matching.auto-matching-max-capacity}") + private int autoMaxCapacity; + + @Value("${gachtaxi.matching.auto-matcnig-description}") + private String autoDescription; + + public MatchMemberCancelledEvent createMatchMemberCancelledEvent(Long roomId, Long memberId) { + return MatchMemberCancelledEvent.of(roomId, memberId, this.matchMemberCancelledTopic); + } + + public MatchMemberJoinedEvent createMatchMemberJoinedEvent(Long roomId, Long memberId) { + return MatchMemberJoinedEvent.of(roomId, memberId, this.matchMemberJoinedTopic); + } + + public MatchRoomCancelledEvent createMatchRoomCancelledEvent(Long roomId) { + return MatchRoomCancelledEvent.of(roomId, this.matchRoomCancelledTopic); + } + + public MatchRoomCompletedEvent createMatchRoomCompletedEvent(Long roomId) { + return MatchRoomCompletedEvent.of(roomId, this.matchRoomCompletedTopic); + } + + public MatchRoomCreatedEvent createMatchRoomCreatedEvent(Long memberId, AutoMatchingPostRequest autoMatchingPostRequest) { + return MatchRoomCreatedEvent.of(memberId, autoMatchingPostRequest, this.autoMaxCapacity, this.autoDescription, this.matchRoomCreatedTopic); + } +} From e09ad24962f1484d547d0888ea329597c04c703c Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:12:03 +0900 Subject: [PATCH 400/770] =?UTF-8?q?refactor:=20=EB=8F=99=EC=A0=81=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=95=EC=9D=98=EB=90=9C=20=EB=B9=88=EC=9D=84=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/AutoMatchingService.java | 23 +++------ .../common/service/MatchingRoomService.java | 16 +++--- .../service/kafka/AutoMatchingProducer.java | 49 +++++++++++++++++++ 3 files changed, 63 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 92b4cb9f..d9faebb3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -7,18 +7,13 @@ import com.gachtaxi.domain.matching.common.dto.request.AutoMatchingPostRequest; import com.gachtaxi.domain.matching.common.dto.response.AutoMatchingPostResponse; import com.gachtaxi.domain.matching.common.entity.enums.Tags; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; +import com.gachtaxi.domain.matching.event.MatchingEventFactory; import com.gachtaxi.domain.matching.event.service.kafka.AutoMatchingProducer; import com.gachtaxi.domain.matching.event.service.sse.SseService; -import java.time.LocalDateTime; import java.util.List; import java.util.Optional; -import java.util.UUID; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; @@ -27,15 +22,10 @@ @RequiredArgsConstructor public class AutoMatchingService { - @Value("${gachtaxi.matching.auto-matching-max-capacity}") - private int autoMaxCapacity; - - @Value("${gachtaxi.matching.auto-matcnig-description}") - private String autoDescription; - private final SseService sseService; - private final AutoMatchingProducer autoMatchingProducer; private final MatchingAlgorithmService matchingAlgorithmService; + private final MatchingEventFactory matchingEventFactory; + private final AutoMatchingProducer autoMatchingProducer; public SseEmitter handleSubscribe(Long userId) { return this.sseService.subscribe(userId); @@ -65,19 +55,18 @@ public AutoMatchingPostResponse handlerAutoRequestMatching( private void sendMatchRoomCreatedEvent(Long memberId, AutoMatchingPostRequest autoMatchingPostRequest) { - this.autoMatchingProducer.sendMatchRoomCreatedEvent(MatchRoomCreatedEvent.of(memberId, autoMatchingPostRequest, autoMaxCapacity, autoDescription)); + this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchRoomCreatedEvent(memberId, autoMatchingPostRequest)); } private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult) { Long roomId = roomResult.roomId(); - - this.autoMatchingProducer.sendMatchMemberJoinedEvent(MatchMemberJoinedEvent.of(roomId, memberId)); + this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchMemberJoinedEvent(roomId, memberId)); } public AutoMatchingPostResponse handlerAutoCancelMatching(Long memberId, AutoMatchingCancelledRequest autoMatchingCancelledRequest) { - this.autoMatchingProducer.sendMatchMemberLeftEvent(MatchMemberCancelledEvent.of(autoMatchingCancelledRequest.roomId(), memberId)); + this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchMemberCancelledEvent(autoMatchingCancelledRequest.roomId(), memberId)); return AutoMatchingPostResponse.of(AutoMatchingStatus.CANCELLED); } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index fc877e5c..503af0e8 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -14,6 +14,7 @@ import com.gachtaxi.domain.matching.common.repository.MatchingRoomTagInfoRepository; import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; import com.gachtaxi.domain.matching.common.repository.RouteRepository; +import com.gachtaxi.domain.matching.event.MatchingEventFactory; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberCancelledEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchMemberJoinedEvent; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCancelledEvent; @@ -45,6 +46,9 @@ public class MatchingRoomService { private final RouteRepository routeRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; + // event factory + private final MatchingEventFactory matchingEventFactory; + public void createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { Members members = this.memberService.findById(matchRoomCreatedEvent.roomMasterId()); @@ -89,7 +93,7 @@ public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEve } this.memberMatchingRoomChargingInfoRepository.save(requestedMembersInfo); - List existMembers = this.memberMatchingRoomChargingInfoRepository.findByMatchingRoomAAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); + List existMembers = this.memberMatchingRoomChargingInfoRepository.findByMatchingRoomAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); int distributedCharge = (int) Math.ceil((double) matchingRoom.getTotalCharge() / (existMembers.size() + 1)); @@ -98,9 +102,7 @@ public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEve int nowMemberCount = existMembers.size() + 1; if (matchingRoom.isFull(nowMemberCount)) { - this.autoMatchingProducer.sendMatchRoomCompletedEvent( - MatchRoomCompletedEvent.of(matchingRoom.getId()) - ); + this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchRoomCompletedEvent(matchingRoom.getId())); } } @@ -135,16 +137,14 @@ public void leaveMemberFromMatchingRoom(MatchMemberCancelledEvent matchMemberCan this.findNextRoomMaster(matchingRoom, members) .ifPresentOrElse( nextRoomMaster -> matchingRoom.changeRoomMaster(nextRoomMaster), - () -> this.autoMatchingProducer.sendMatchRoomCancelledEvent( - MatchRoomCancelledEvent.of(matchingRoom.getId()) - ) + () -> this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchRoomCancelledEvent(matchingRoom.getId())) ); } } private Optional findNextRoomMaster(MatchingRoom matchingRoom, Members members) { List existMembers = - this.memberMatchingRoomChargingInfoRepository.findByMatchingRoomAAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); + this.memberMatchingRoomChargingInfoRepository.findByMatchingRoomAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); return existMembers.stream() .map(MemberMatchingRoomChargingInfo::getMembers) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java new file mode 100644 index 00000000..037c85a6 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingProducer.java @@ -0,0 +1,49 @@ +package com.gachtaxi.domain.matching.event.service.kafka; + +import static com.gachtaxi.global.auth.jwt.util.kafka.KafkaBeanSuffix.KAFKA_TEMPLATE_SUFFIX; + +import com.gachtaxi.domain.matching.common.exception.NotDefinedKafkaTemplateException; +import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchingEvent; +import com.gachtaxi.global.auth.jwt.util.KafkaBeanUtils; +import java.util.concurrent.CompletableFuture; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.kafka.clients.producer.RecordMetadata; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Slf4j +public class AutoMatchingProducer { + + private final ApplicationContext applicationContext; + + public void sendEvent(MatchingEvent matchingEvent) { + String topic = matchingEvent.getTopic(); + Object key = matchingEvent.getKey(); + + try { + KafkaTemplate kafkaTemplate = this.applicationContext.getBean( + KafkaBeanUtils.getBeanName(topic, KAFKA_TEMPLATE_SUFFIX), KafkaTemplate.class); + CompletableFuture future = kafkaTemplate.send(matchingEvent.getTopic(), matchingEvent.getKey(), matchingEvent); + + future.thenAccept(result -> { + if (result instanceof RecordMetadata metadata) { + log.info("[KAFKA PRODUCER] Success sending MatchRoomCreatedEvent: " + + "topic={}, partition={}, offset={}, key={}", + metadata.topic(), metadata.partition(), metadata.offset(), key + ); + } + } + ).exceptionally(ex -> { + log.error("[KAFKA PRODUCER] Failed to send MatchRoomCreatedEvent key={}", key, ex); + return null; + }); + } catch (BeansException beansException) { + throw new NotDefinedKafkaTemplateException(); + } + } +} From 857ae25ab346fb99279494eab05bb55141497a61 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 03:12:33 +0900 Subject: [PATCH 401/770] =?UTF-8?q?refactor:=20sse=20=EA=B5=AC=EB=8F=85=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=A5=BC=20=ED=99=95=EC=9D=B8=ED=95=98?= =?UTF-8?q?=EB=8A=94=20AOP=20=EB=A1=9C=EC=A7=81=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EA=BA=BC=EB=82=B4=EC=98=A4=EA=B8=B0?= =?UTF-8?q?=EC=9C=84=ED=95=B4=20Method=20=EA=B0=9D=EC=B2=B4=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/aop/SseSubscribeRequired.java | 2 +- .../matching/aop/SseSubscribeRequiredAop.java | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequired.java b/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequired.java index 28970452..a75b4a1f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequired.java +++ b/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequired.java @@ -6,7 +6,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD}) +@Target(ElementType.METHOD) public @interface SseSubscribeRequired { } diff --git a/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequiredAop.java b/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequiredAop.java index 677a4f52..fce23e7d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequiredAop.java +++ b/src/main/java/com/gachtaxi/domain/matching/aop/SseSubscribeRequiredAop.java @@ -5,10 +5,12 @@ import com.gachtaxi.domain.matching.common.service.AutoMatchingService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; +import java.lang.reflect.Parameter; import lombok.RequiredArgsConstructor; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.reflect.MethodSignature; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; @@ -22,13 +24,18 @@ public class SseSubscribeRequiredAop { @Around("@annotation(com.gachtaxi.domain.matching.aop.SseSubscribeRequired)") public Object checkSseSubscribe(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{ Long memberId = null; - for (Object arg : proceedingJoinPoint.getArgs()) { - Class argClass = arg.getClass(); - if (arg instanceof Long && argClass.isAnnotationPresent(CurrentMemberId.class)) { - memberId = (Long) arg; + MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature(); + Parameter[] parameters = signature.getMethod().getParameters(); + + for (int i = 0; i < parameters.length; i++) { + Parameter parameter = parameters[i]; + if (parameter.getType().equals(Long.class) && parameter.isAnnotationPresent( + CurrentMemberId.class)) { + memberId = (Long) proceedingJoinPoint.getArgs()[i]; break; } } + if (memberId == null) { throw new ControllerNotHasCurrentMemberIdException(); } From 192f15036af237c28e365d531b10da3c44e8bd2d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:54:47 +0900 Subject: [PATCH 402/770] =?UTF-8?q?build:=20s3=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20aws=20sdk=20=EB=B2=84=EC=A0=84?= =?UTF-8?q?=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index abd3ce08..8bd6da74 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ dependencies { implementation 'software.amazon.awssdk:ses:2.29.46' // S3 Client - implementation 'software.amazon.awssdk:s3:2.20.126' + implementation 'software.amazon.awssdk:s3:2.29.46' // MongoDB, Redis, MySQL implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' From fab4e36d6b5f3b2dc7f2f9d5b820f82cb16c93f1 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:55:20 +0900 Subject: [PATCH 403/770] =?UTF-8?q?feat:=20=EC=97=B0=EA=B2=B0=20=ED=95=B4?= =?UTF-8?q?=EC=A0=9C=EC=8B=9C=20=ED=98=B8=EC=B6=9C=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/entity/ChattingParticipant.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 0a35aebb..80878dcf 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -48,11 +48,15 @@ public void subscribe() { this.status = Status.ACTIVE; } - /* - todo disconnect 이벤트 처리 시 요청하기 - */ - public void disconnect(Status status) { - this.status = status; + public void unsubscribe() { + this.status = Status.INACTIVE; this.disconnectedAt = LocalDateTime.now(); } + + public void disconnect() { + if (this.status == Status.ACTIVE) { + this.status = Status.INACTIVE; + this.disconnectedAt = LocalDateTime.now(); + } + } } From e244dd5e2e187fe3a9e4cabea8bc2c05fffc9c4f Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:55:46 +0900 Subject: [PATCH 404/770] =?UTF-8?q?feat:=20roomId=EC=99=80=20memberId?= =?UTF-8?q?=EB=A1=9C=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8A=94=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/repository/ChattingParticipantRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java index 7fcf0332..0b264dc0 100644 --- a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java @@ -10,4 +10,6 @@ public interface ChattingParticipantRepository extends JpaRepository { Optional findByChattingRoomAndMembers(ChattingRoom chattingRoom, Members member); + + Optional findByChattingRoomIdAndMembersId(long roomId, long memberId); } From 8dcbc737951e910500ecc196291716c40590192f Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:55:51 +0900 Subject: [PATCH 405/770] =?UTF-8?q?feat:=20roomId=EC=99=80=20memberId?= =?UTF-8?q?=EB=A1=9C=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8A=94=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChattingParticipantService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 6472d2bd..33b09ca6 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -23,6 +23,11 @@ public ChattingParticipant find(ChattingRoom chattingRoom, Members member) { .orElseThrow(ChattingParticipantNotFoundException::new); } + public ChattingParticipant find(long roomId, long memberId) { + return chattingParticipantRepository.findByChattingRoomIdAndMembersId(roomId, memberId) + .orElseThrow(ChattingParticipantNotFoundException::new); + } + public void delete(ChattingParticipant chattingParticipant) { chattingParticipantRepository.delete(chattingParticipant); } From 779b16e979a2451e49f25e7bb22b6541b070e29c Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:56:17 +0900 Subject: [PATCH 406/770] =?UTF-8?q?refactor:=20memberService=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=95=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/ChattingRoomService.java | 4 ++-- .../CustomMessageExceptionHandler.java | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gachtaxi/global/common/exception/handler/CustomMessageExceptionHandler.java diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 083ea994..71fce6fb 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -66,7 +66,7 @@ public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { Long senderId = (Long) accessor.getSessionAttributes().get(CHAT_USER_ID); ChattingRoom chattingRoom = find(roomId); - Members members = memberService.find(senderId); + Members members = memberService.findById(senderId); accessor.getSessionAttributes().put(CHAT_ROOM_ID, roomId); accessor.getSessionAttributes().put(CHAT_USER_NAME, members.getNickname()); @@ -94,7 +94,7 @@ public void exitChatRoom(long roomId, long senderId) { 웹소켓 연결도 해제 될텐데 삭제가 먼저 되면 NPE는 어떻게 하지. */ ChattingRoom chattingRoom = find(roomId); - Members members = memberService.find(senderId); + Members members = memberService.findById(senderId); ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); chattingParticipantService.delete(chattingParticipant); diff --git a/src/main/java/com/gachtaxi/global/common/exception/handler/CustomMessageExceptionHandler.java b/src/main/java/com/gachtaxi/global/common/exception/handler/CustomMessageExceptionHandler.java new file mode 100644 index 00000000..ac13e8ff --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/exception/handler/CustomMessageExceptionHandler.java @@ -0,0 +1,22 @@ +package com.gachtaxi.global.common.exception.handler; + +import com.gachtaxi.global.common.response.ApiResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.messaging.handler.annotation.MessageExceptionHandler; +import org.springframework.messaging.simp.annotation.SendToUser; +import org.springframework.web.bind.annotation.ControllerAdvice; + +import static com.gachtaxi.global.common.exception.handler.GlobalExceptionHandler.LOG_FORMAT; + +@Slf4j +@ControllerAdvice +public class CustomMessageExceptionHandler { + + @MessageExceptionHandler(RuntimeException.class) + @SendToUser(destinations = "/queue/errors", broadcast = false) + public ApiResponse handleRuntimeException(RuntimeException e) { + log.warn(LOG_FORMAT, e.getClass().getSimpleName(), 500, e.getMessage()); + return ApiResponse.response(HttpStatus.BAD_REQUEST, e.getMessage()); + } +} From 7e7beaa8cc0a615491f7ff1d30e483d97866db23 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:56:37 +0900 Subject: [PATCH 407/770] =?UTF-8?q?refactor:=20memberService=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=95=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/chat/service/ChattingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 6cca551b..f02d84ed 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -58,7 +58,7 @@ public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int pageSize, LocalDateTime lastMessageTimeStamp) { ChattingRoom chattingRoom = chattingRoomService.find(roomId); - Members members = memberService.find(senderId); + Members members = memberService.findById(senderId); ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); Slice chattingMessages = loadMessage(roomId, chattingParticipant, pageNumber, pageSize, lastMessageTimeStamp); From 7ce8d18ae9e3a4f51a1a154b7008af0c4af40cd9 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:56:54 +0900 Subject: [PATCH 408/770] =?UTF-8?q?refactor:=20log=20format=20public?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/handler/GlobalExceptionHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java b/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java index 48fb8391..ef377d97 100644 --- a/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java @@ -13,14 +13,15 @@ import java.util.List; -import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; @Slf4j @RestControllerAdvice public class GlobalExceptionHandler { // response format - private static final String LOG_FORMAT = "Class: {}, Code : {}, Message : {}"; + public static final String LOG_FORMAT = "Class: {}, Code : {}, Message : {}"; private static final String VALID_EXCEPTION = "Validation failed"; @ExceptionHandler(BaseException.class) From 04afca7cabfeb620d43ef089d1197665339bed14 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:57:04 +0900 Subject: [PATCH 409/770] =?UTF-8?q?refactor:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/stomp/strategy/StompConnectStrategy.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java index e997b079..4543bb5c 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java @@ -35,10 +35,6 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess String token = jwtToken.replace(TOKEN_PREFIX, "").trim(); - /* - todo 인증 객체 생성 후 설정하기 - */ - Long userId = jwtExtractor.getId(token); accessor.getSessionAttributes().put(CHAT_USER_ID, userId); From 2847a6e44726791999373384f73316d8bf3a235c Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:57:45 +0900 Subject: [PATCH 410/770] =?UTF-8?q?refactor:=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=8F=85=20=EA=B2=BD=EB=A1=9C=20=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../strategy/StompSubscribeStrategy.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java index 1d6b7373..29f08b1f 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java @@ -14,10 +14,10 @@ @RequiredArgsConstructor public class StompSubscribeStrategy implements StompCommandStrategy { - private static final String SUB_END_POINT = "/sub/chat/room/"; public static final String CHAT_ROOM_ID = "CHAT_ROOM_ID"; public static final String CHAT_USER_NAME = "CHAT_USER_NAME"; - + private static final String SUB_END_POINT = "/sub/chat/room/"; + private static final String ERROR_END_POINT = "/user/queue/errors"; private final ChattingRoomService chattingRoomService; @Value("${chat.topic}") @@ -32,15 +32,18 @@ public boolean supports(StompCommand command) { public Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel) { String destination = accessor.getDestination(); - if (!destination.startsWith(SUB_END_POINT)) { - throw new ChatSubscribeException(); - } + if (destination.startsWith(SUB_END_POINT)) { + Long roomId = Long.valueOf(destination.replace(SUB_END_POINT, "")); + chattingRoomService.subscribeChatRoom(roomId, accessor); - Long roomId = Long.valueOf(destination.replace(SUB_END_POINT, "")); + return message; + } - chattingRoomService.subscribeChatRoom(roomId, accessor); + if (destination.startsWith(ERROR_END_POINT)) { + return message; + } - return message; + throw new ChatSubscribeException(); } } From 59892904816349f97168ea52a614e206c804e5f7 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:57:54 +0900 Subject: [PATCH 411/770] =?UTF-8?q?refactor:=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=8F=85=20=EA=B2=BD=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index fb9344a4..286339e6 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -30,7 +30,7 @@ public void registerStompEndpoints(StompEndpointRegistry registry) { @Override public void configureMessageBroker(MessageBrokerRegistry registry) { - registry.enableSimpleBroker("/sub"); + registry.enableSimpleBroker("/sub", "/queue"); registry.setApplicationDestinationPrefixes("/pub"); } From aa07eba12f357922c282da7bbe5aeef669df1367 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:59:19 +0900 Subject: [PATCH 412/770] =?UTF-8?q?feat:=20=EA=B5=AC=EB=8F=85=20=ED=95=B4?= =?UTF-8?q?=EC=A0=9C,=20=EC=97=B0=EA=B2=B0=20=ED=95=B4=EC=A0=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=A6=AC=EC=8A=A4=EB=84=88=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/event/WebSocketEventHandler.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java diff --git a/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java b/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java new file mode 100644 index 00000000..2780ea54 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java @@ -0,0 +1,60 @@ +package com.gachtaxi.domain.chat.event; + +import com.gachtaxi.domain.chat.entity.ChattingParticipant; +import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; +import com.gachtaxi.domain.chat.service.ChattingParticipantService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.event.EventListener; +import org.springframework.messaging.simp.SimpMessageHeaderAccessor; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.socket.messaging.SessionDisconnectEvent; +import org.springframework.web.socket.messaging.SessionUnsubscribeEvent; + +import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; +import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_ROOM_ID; + +@Slf4j +@Component +@RequiredArgsConstructor +public class WebSocketEventHandler { + + private final ChattingParticipantService chattingParticipantService; + + @EventListener + @Transactional + public void handleDisconnect(SessionDisconnectEvent event) { + SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(event.getMessage()); + + try { + long roomId = (long) accessor.getSessionAttributes().get(CHAT_ROOM_ID); + long userId = (long) accessor.getSessionAttributes().get(CHAT_USER_ID); + + ChattingParticipant chattingParticipant = chattingParticipantService.find(roomId, userId); + + chattingParticipant.disconnect(); + } catch (NullPointerException e) { + log.info("[handleDisconnect] 구독 정보가 존재하지 않습니다."); + } catch (ChattingParticipantNotFoundException e) { + log.warn("[handleDisconnect] 이미 퇴장한 참여자 입니다."); + } + } + + @EventListener + @Transactional + public void handleUnsubscribe(SessionUnsubscribeEvent event) { + SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(event.getMessage()); + + long roomId = (long) accessor.getSessionAttributes().get(CHAT_ROOM_ID); + long userId = (long) accessor.getSessionAttributes().get(CHAT_USER_ID); + + try { + ChattingParticipant chattingParticipant = chattingParticipantService.find(roomId, userId); + + chattingParticipant.unsubscribe(); + } catch (ChattingParticipantNotFoundException e) { + log.warn("[handleUnsubscribe] 이미 퇴장한 참여자 입니다."); + } + } +} From 7e7b212da6392d55bb3dc7a436cde54df8f71e43 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 10:59:41 +0900 Subject: [PATCH 413/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/chat/controller/ChattingController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index 90561e15..f4dfed56 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; @@ -58,7 +59,7 @@ public ApiResponse exitChattingRoom(@PathVariable Long roomId, } @MessageMapping("/chat/message") - public void message(ChatMessageRequest request, SimpMessageHeaderAccessor headerAccessor) { + public void message(@Valid ChatMessageRequest request, SimpMessageHeaderAccessor headerAccessor) { chattingService.chat(request, headerAccessor); } } From 9d318515fd3673f902f043198e84ad851b70fc85 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 11:08:35 +0900 Subject: [PATCH 414/770] =?UTF-8?q?refactor:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/service/ChattingRoomService.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 71fce6fb..b04df61d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -90,9 +90,6 @@ public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { @Transactional public void exitChatRoom(long roomId, long senderId) { - /* - 웹소켓 연결도 해제 될텐데 삭제가 먼저 되면 NPE는 어떻게 하지. - */ ChattingRoom chattingRoom = find(roomId); Members members = memberService.findById(senderId); ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); From ed8211abb8911fe5b6f728d5a4be4dc68933754a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 11:21:54 +0900 Subject: [PATCH 415/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=8F=85=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/controller/ChattingController.java | 3 +-- .../domain/chat/entity/ChattingParticipant.java | 7 +++++++ .../gachtaxi/domain/chat/exception/ErrorMessage.java | 3 ++- .../chat/exception/UnSubscriptionException.java | 12 ++++++++++++ .../domain/chat/service/ChattingService.java | 6 ++++++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/exception/UnSubscriptionException.java diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index f4dfed56..05171229 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -8,7 +8,6 @@ import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -43,7 +42,7 @@ public ApiResponse getChattingMessages(@PathVariable Long roomId, @CurrentMemberId Long memberId, @RequestParam int pageNumber, @RequestParam int pageSize, - @RequestParam(required = false) @Parameter(required = false) LocalDateTime lastMessageTimeStamp) { + @RequestParam(required = false) LocalDateTime lastMessageTimeStamp) { ChatResponse response = chattingService.getMessage(roomId, memberId, pageNumber, pageSize, lastMessageTimeStamp); return ApiResponse.response(OK, GET_CHATTING_MESSAGE_SUCCESS.getMessage(), response); diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 80878dcf..9d9fde2a 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.chat.entity; import com.gachtaxi.domain.chat.entity.enums.Status; +import com.gachtaxi.domain.chat.exception.UnSubscriptionException; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.*; @@ -44,6 +45,12 @@ public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) .build(); } + public void checkSubscription() { + if (this.status == Status.INACTIVE) { + throw new UnSubscriptionException(); + } + } + public void subscribe() { this.status = Status.ACTIVE; } diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java index 5a6f56c5..e43987e1 100644 --- a/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/exception/ErrorMessage.java @@ -17,7 +17,8 @@ public enum ErrorMessage { WEB_SOCKET_SESSION_ATTR_NOT_FOUND(" 가 웹소켓 세션에 존재하지 않습니다."), DUPLICATE_SUBSCRIBE("같은 채팅방을 중복으로 구독했습니다."), CHATTING_PARTICIPANT_NOT_FOUND("존재하지 않는 채팅 참여자 입니다."), - LAST_TIME_STAMP_NULL("마지막 채팅의 일자는 필수입니다."); + LAST_TIME_STAMP_NULL("마지막 채팅의 일자는 필수입니다."), + UN_SUBSCRIBE("채팅방을 구독하지 않은 참여자 입니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/chat/exception/UnSubscriptionException.java b/src/main/java/com/gachtaxi/domain/chat/exception/UnSubscriptionException.java new file mode 100644 index 00000000..d8129423 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/exception/UnSubscriptionException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.chat.exception.ErrorMessage.UN_SUBSCRIBE; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class UnSubscriptionException extends BaseException { + public UnSubscriptionException() { + super(BAD_REQUEST, UN_SUBSCRIBE.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index f02d84ed..de9b7ff0 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -61,8 +61,14 @@ public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int p Members members = memberService.findById(senderId); ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); + chattingParticipant.checkSubscription(); + Slice chattingMessages = loadMessage(roomId, chattingParticipant, pageNumber, pageSize, lastMessageTimeStamp); + return getChatResponse(pageNumber, chattingMessages, chattingParticipant); + } + + private ChatResponse getChatResponse(int pageNumber, Slice chattingMessages, ChattingParticipant chattingParticipant) { List chattingMessageResponses = chattingMessages.stream() .map(ChattingMessageResponse::from) .toList(); From 266cb55fe93eda411ec31c9f89abf0ae8a1e0bbd Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 11:45:13 +0900 Subject: [PATCH 416/770] =?UTF-8?q?refactor:=20=EA=B5=AC=EB=8F=85=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EB=A1=9C=EC=A7=81=EC=9D=84=20ChattingPart?= =?UTF-8?q?icipantService=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/controller/ChattingController.java | 2 +- .../chat/entity/ChattingParticipant.java | 2 +- .../service/ChattingParticipantService.java | 25 +++++++++++++++++++ .../chat/service/ChattingRoomService.java | 22 +--------------- .../domain/chat/service/ChattingService.java | 2 +- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index 05171229..85a29256 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -49,7 +49,7 @@ public ApiResponse getChattingMessages(@PathVariable Long roomId, } @DeleteMapping("/api/chat/{roomId}") - @Operation(summary = "채팅방을 퇴장하는 API입니다.") + @Operation(summary = "채팅방을 퇴장하는 API입니다. 퇴장시 STOMP UNSUBSCRIBE를 꼭 해주세요") public ApiResponse exitChattingRoom(@PathVariable Long roomId, @CurrentMemberId Long memberId) { chattingRoomService.exitChatRoom(roomId, memberId); diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 9d9fde2a..96fe7a21 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -45,7 +45,7 @@ public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) .build(); } - public void checkSubscription() { + public void checkSubscriptionStatus() { if (this.status == Status.INACTIVE) { throw new UnSubscriptionException(); } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 33b09ca6..03ba60aa 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -2,12 +2,16 @@ import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.entity.enums.Status; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; +import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; import com.gachtaxi.domain.members.entity.Members; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.Optional; + @Service @RequiredArgsConstructor public class ChattingParticipantService { @@ -28,7 +32,28 @@ public ChattingParticipant find(long roomId, long memberId) { .orElseThrow(ChattingParticipantNotFoundException::new); } + public boolean checkSubscription(ChattingRoom chattingRoom, Members members) { + Optional optionalParticipant = chattingParticipantRepository.findByChattingRoomAndMembers(chattingRoom, members); + + if (optionalParticipant.isPresent()) { + ChattingParticipant chattingParticipant = optionalParticipant.get(); + + checkDuplicateSubscription(chattingParticipant); + chattingParticipant.subscribe(); + + return true; + } + + return false; + } + public void delete(ChattingParticipant chattingParticipant) { chattingParticipantRepository.delete(chattingParticipant); } + + private void checkDuplicateSubscription(ChattingParticipant chattingParticipant) { + if (chattingParticipant.getStatus() == Status.ACTIVE) { + throw new DuplicateSubscribeException(); + } + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index b04df61d..a5f2251b 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -8,10 +8,8 @@ import com.gachtaxi.domain.chat.entity.enums.MessageType; import com.gachtaxi.domain.chat.entity.enums.Status; import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; -import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; -import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; import com.gachtaxi.domain.chat.repository.ChattingRoomRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; @@ -22,8 +20,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Optional; - import static com.gachtaxi.domain.chat.stomp.strategy.StompConnectStrategy.CHAT_USER_ID; import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_ROOM_ID; import static com.gachtaxi.domain.chat.stomp.strategy.StompSubscribeStrategy.CHAT_USER_NAME; @@ -37,7 +33,6 @@ public class ChattingRoomService { private final ChattingRoomRepository chattingRoomRepository; - private final ChattingParticipantRepository chattingParticipantRepository; private final ChattingMessageRepository chattingMessageRepository; private final ChattingParticipantService chattingParticipantService; private final MemberService memberService; @@ -71,14 +66,7 @@ public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { accessor.getSessionAttributes().put(CHAT_ROOM_ID, roomId); accessor.getSessionAttributes().put(CHAT_USER_NAME, members.getNickname()); - Optional optionalChattingParticipant = find(chattingRoom, members); - - if (optionalChattingParticipant.isPresent()) { - ChattingParticipant presentParticipant = optionalChattingParticipant.get(); - - checkDuplicateSubscription(presentParticipant); - presentParticipant.subscribe(); - + if (chattingParticipantService.checkSubscription(chattingRoom, members)) { return; } @@ -114,13 +102,5 @@ private void publishMessage(long roomId, long senderId, String senderName, Strin redisChatPublisher.publish(topic, chatMessage); } - private Optional find(ChattingRoom chattingRoom, Members members) { - return chattingParticipantRepository.findByChattingRoomAndMembers(chattingRoom, members); - } - private void checkDuplicateSubscription(ChattingParticipant chattingParticipant) { - if (chattingParticipant.getStatus() == Status.ACTIVE) { - throw new DuplicateSubscribeException(); - } - } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index de9b7ff0..32f0674d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -61,7 +61,7 @@ public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int p Members members = memberService.findById(senderId); ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); - chattingParticipant.checkSubscription(); + chattingParticipant.checkSubscriptionStatus(); Slice chattingMessages = loadMessage(roomId, chattingParticipant, pageNumber, pageSize, lastMessageTimeStamp); From dcb535cb893d8ac8c9e6038ef878a7dddec4cc75 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 13:27:20 +0900 Subject: [PATCH 417/770] =?UTF-8?q?refactor:=20pageSize=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/service/ChattingService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 32f0674d..cedd3f3d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -80,17 +80,17 @@ private ChatResponse getChatResponse(int pageNumber, Slice chat private Slice loadMessage(long roomId, ChattingParticipant chattingParticipant, int pageNumber, int pageSize, LocalDateTime lastMessageTimeStamp) { if (pageNumber == 0) { - return loadInitialMessage(roomId, chattingParticipant); + return loadInitialMessage(roomId, chattingParticipant, pageSize); } Pageable pageable = PageRequest.of(pageNumber - 1, pageSize); return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterAndTimeStampBeforeOrderByTimeStampDesc(roomId, chattingParticipant.getJoinedAt(), lastMessageTimeStamp, pageable); } - private Slice loadInitialMessage(long roomId, ChattingParticipant chattingParticipant) { + private Slice loadInitialMessage(long roomId, ChattingParticipant chattingParticipant, int pageSize) { int chattingCount = chattingMessageRepository.countAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getDisconnectedAt()); - int effectivePageSize = Math.max(chattingCount, 20); + int effectivePageSize = Math.max(chattingCount, pageSize); Pageable pageable = PageRequest.of(0, effectivePageSize); return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getJoinedAt(), pageable); From 9f2495cfedc4061af82ad3e52f6164596287f1a5 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 14:06:11 +0900 Subject: [PATCH 418/770] =?UTF-8?q?refactor:=20dto=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=A0=95=EB=A0=AC=20=EB=AA=85?= =?UTF-8?q?=EC=8B=9C=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/dto/response/ChatPageableResponse.java | 2 -- .../com/gachtaxi/domain/chat/service/ChattingService.java | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatPageableResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatPageableResponse.java index 572742a2..3ca3ff13 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatPageableResponse.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatPageableResponse.java @@ -9,7 +9,6 @@ public record ChatPageableResponse( int pageNumber, int pageSize, int numberOfElements, - boolean first, boolean last, boolean empty ) { @@ -18,7 +17,6 @@ public static ChatPageableResponse of(int pageNumber, Slice sli .pageNumber(pageNumber) .pageSize(slice.getSize()) .numberOfElements(slice.getNumberOfElements()) - .first(slice.isFirst()) .last(slice.isLast()) .empty(slice.isEmpty()) .build(); diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index cedd3f3d..b216ce36 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -18,6 +18,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Sort; import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.stereotype.Service; @@ -83,7 +84,7 @@ private Slice loadMessage(long roomId, ChattingParticipant chat return loadInitialMessage(roomId, chattingParticipant, pageSize); } - Pageable pageable = PageRequest.of(pageNumber - 1, pageSize); + Pageable pageable = PageRequest.of(pageNumber - 1, pageSize, Sort.by(Sort.Direction.DESC, "timeStamp")); return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterAndTimeStampBeforeOrderByTimeStampDesc(roomId, chattingParticipant.getJoinedAt(), lastMessageTimeStamp, pageable); } @@ -91,7 +92,7 @@ private Slice loadInitialMessage(long roomId, ChattingParticipa int chattingCount = chattingMessageRepository.countAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getDisconnectedAt()); int effectivePageSize = Math.max(chattingCount, pageSize); - Pageable pageable = PageRequest.of(0, effectivePageSize); + Pageable pageable = PageRequest.of(0, effectivePageSize, Sort.by(Sort.Direction.DESC, "timeStamp")); return chattingMessageRepository.findAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getJoinedAt(), pageable); } From 1dfdac975cf35dc7c8e8ab64fb09dc808e589b55 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 14 Jan 2025 14:13:35 +0900 Subject: [PATCH 419/770] =?UTF-8?q?refactor:=20notblank=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/chat/dto/request/ChatMessageRequest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java index 23ca5a97..c25afa98 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessageRequest.java @@ -1,6 +1,8 @@ package com.gachtaxi.domain.chat.dto.request; +import jakarta.validation.constraints.NotBlank; + public record ChatMessageRequest( - String message + @NotBlank String message ) { } From c0996ead00d371b2898a130e826807291d644b87 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 14:14:35 +0900 Subject: [PATCH 420/770] =?UTF-8?q?refactor:=20=ED=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EB=A1=9C=EA=B7=B8=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A0=91=EA=B7=BC=20=EC=A0=9C=EC=96=B4=EC=9E=90=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java | 2 +- .../gachtaxi/global/config/kafka/KafkaBeanRegistrar.java | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java b/src/main/java/com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java index dee64965..b31e8655 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/util/KafkaBeanUtils.java @@ -19,7 +19,7 @@ public static String getBeanName(String topic, String suffix) { return beanNameBuilder.toString(); } - public static String getFirstUpperString(String str) { + private static String getFirstUpperString(String str) { return str.substring(0, 1).toUpperCase() + str.substring(1); } } diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java index aba24d70..a6a338c7 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java @@ -8,7 +8,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import lombok.extern.slf4j.Slf4j; import org.apache.kafka.clients.admin.NewTopic; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.common.serialization.StringSerializer; @@ -24,10 +23,7 @@ import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.serializer.JsonSerializer; -import org.springframework.stereotype.Component; -@Slf4j -@Component public class KafkaBeanRegistrar implements BeanDefinitionRegistryPostProcessor, EnvironmentAware { private Environment environment; @@ -39,8 +35,6 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) .bind("gachtaxi.kafka.topics", Bindable.mapOf(String.class, String.class)) .orElse(Collections.emptyMap()); - log.info(topics.toString()); - for (String topic : topics.values()) { this.registerProducerFactoryAndKafkaTemplate(topic, registry); this.registerNewTopic(topic, registry); From d93eb15b5a9c963e10a76aead16ef04025ba7639 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 14:35:52 +0900 Subject: [PATCH 421/770] =?UTF-8?q?chore:=20dev=20yml=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 30 +++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 6be8f1a0..e1b7d7e7 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -16,6 +16,21 @@ spring: host: ${REDIS_HOST} port: ${REDIS_PORT} password: ${REDIS_PASSWORD} + kafka: + bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS} + producer: + retries: ${KAFKA_PRODUCER_RETRIES} + acks: ${KAFKA_PRODUCER_ACKS} + properties: + enable.idempotence: ${KAFKA_PRODUCER_ENABLE_IDEMPOTENCE} + max.in.flight.requests.per.connection: ${KAFKA_PRODUCER_MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION} + consumer: + group-id: ${KAFKA_CONSUMER_GROUP_ID} + auto-offset-reset: ${KAFKA_CONSUMER_AUTO_OFFSET_RESET} + enable-auto-commit: ${KAFKA_CONSUMER_ENABLE_AUTO_COMMIT} + admin: + properties: + client.id: ${KAFKA_ADMIN_CLIENT_ID} mongodb: uri: ${MONGODB_URI} @@ -40,4 +55,17 @@ gachtaxi: secureOption: ${COOKIE_SECURE_OPTION} cookiePathOption: ${COOKIE_PATH_OPTION} redis: - emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} \ No newline at end of file + emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} + kafka: + topics: + match-room-created: ${KAFKA_TOPIC_MATCH_ROOM_CREATED} + match-member-joined: ${KAFKA_TOPIC_MATCH_MEMBER_JOINED} + match-room-cancelled: ${KAFKA_TOPIC_MATCH_ROOM_CANCELLED} + match-member-cancelled: ${KAFKA_TOPIC_MATCH_MEMBER_CANCELLED} + match-room-completed: ${KAFKA_TOPIC_MATCH_ROOM_COMPLETED} + partition-count: ${KAFKA_PARTITION_COUNT} + replication-factor: ${KAFKA_REPLICATION_FACTOR} + matching: + auto-matching-max-capacity: ${AUTO_MATCHING_MAX_CAPACITY} + auto-matcnig-description: ${AUTO_MATCHING_DESCRIPTION} + From 6392c06f08b14a73d791738ee8615061d244655e Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 14 Jan 2025 14:48:00 +0900 Subject: [PATCH 422/770] =?UTF-8?q?hotfix:=20dev=20yml=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 30 +++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 6be8f1a0..e1b7d7e7 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -16,6 +16,21 @@ spring: host: ${REDIS_HOST} port: ${REDIS_PORT} password: ${REDIS_PASSWORD} + kafka: + bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS} + producer: + retries: ${KAFKA_PRODUCER_RETRIES} + acks: ${KAFKA_PRODUCER_ACKS} + properties: + enable.idempotence: ${KAFKA_PRODUCER_ENABLE_IDEMPOTENCE} + max.in.flight.requests.per.connection: ${KAFKA_PRODUCER_MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION} + consumer: + group-id: ${KAFKA_CONSUMER_GROUP_ID} + auto-offset-reset: ${KAFKA_CONSUMER_AUTO_OFFSET_RESET} + enable-auto-commit: ${KAFKA_CONSUMER_ENABLE_AUTO_COMMIT} + admin: + properties: + client.id: ${KAFKA_ADMIN_CLIENT_ID} mongodb: uri: ${MONGODB_URI} @@ -40,4 +55,17 @@ gachtaxi: secureOption: ${COOKIE_SECURE_OPTION} cookiePathOption: ${COOKIE_PATH_OPTION} redis: - emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} \ No newline at end of file + emailAuthCodeExpiration: ${REDIS_EMAIL_AUTH_CODE_EXPIRATION} + kafka: + topics: + match-room-created: ${KAFKA_TOPIC_MATCH_ROOM_CREATED} + match-member-joined: ${KAFKA_TOPIC_MATCH_MEMBER_JOINED} + match-room-cancelled: ${KAFKA_TOPIC_MATCH_ROOM_CANCELLED} + match-member-cancelled: ${KAFKA_TOPIC_MATCH_MEMBER_CANCELLED} + match-room-completed: ${KAFKA_TOPIC_MATCH_ROOM_COMPLETED} + partition-count: ${KAFKA_PARTITION_COUNT} + replication-factor: ${KAFKA_REPLICATION_FACTOR} + matching: + auto-matching-max-capacity: ${AUTO_MATCHING_MAX_CAPACITY} + auto-matcnig-description: ${AUTO_MATCHING_DESCRIPTION} + From 27028a49c96c1fc67127a7f63531752a484ec8d9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 03:30:30 +0900 Subject: [PATCH 423/770] feat: application-dev, local to google env --- src/main/resources/application-dev.yml | 6 ++++++ src/main/resources/application-local.yml | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index e1b7d7e7..e9330c21 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -46,6 +46,12 @@ gachtaxi: redirect: ${KAKAO_REDIRECT_URL} token_uri: ${KAKAO_TOKEN_URI} user_profile: ${KAKAO_USER_PROFILE} + google: + client: ${GOOGLE_CLIENT_ID} + client-secret: ${GOOGLE_CLIENT_SECRET} + redirect: ${GOOGLE_REDIRECT_URL} + token_uri: ${GOOGLE_TOKEN_URI} + user_profile: ${GOOGLE_USER_PROFILE} jwt: key: ${JWT_SECRET_KEY} accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index d362d759..9f47f5e8 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -46,6 +46,12 @@ gachtaxi: redirect: ${KAKAO_REDIRECT_URL} token_uri: ${KAKAO_TOKEN_URI} user_profile: ${KAKAO_USER_PROFILE} + google: + client: ${GOOGLE_CLIENT_ID} + client-secret: ${GOOGLE_CLIENT_SECRET} + redirect: ${GOOGLE_REDIRECT_URL} + token_uri: ${GOOGLE_TOKEN_URI} + user_profile: ${GOOGLE_USER_PROFILE} jwt: key: ${JWT_SECRET_KEY} accessTokenExpiration: ${JWT_ACCESS_TOKEN_EXPIRATION} @@ -65,3 +71,4 @@ gachtaxi: partition-count: ${KAFKA_PARTITION_COUNT} replication-factor: ${KAFKA_REPLICATION_FACTOR} + From 1f8ba72593279cbe489774d4be6c62ac89f66234 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 03:32:08 +0900 Subject: [PATCH 424/770] feat: GoogleUtils --- .../auth/google/dto/GoogleAuthCode.java | 8 +++ .../auth/google/dto/GoogleTokenResponse.java | 10 ++++ .../google/dto/GoogleUserInfoResponse.java | 7 +++ .../global/auth/google/utils/GoogleUtils.java | 59 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/auth/google/dto/GoogleAuthCode.java create mode 100644 src/main/java/com/gachtaxi/global/auth/google/dto/GoogleTokenResponse.java create mode 100644 src/main/java/com/gachtaxi/global/auth/google/dto/GoogleUserInfoResponse.java create mode 100644 src/main/java/com/gachtaxi/global/auth/google/utils/GoogleUtils.java diff --git a/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleAuthCode.java b/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleAuthCode.java new file mode 100644 index 00000000..7dbb199b --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleAuthCode.java @@ -0,0 +1,8 @@ +package com.gachtaxi.global.auth.google.dto; + +import jakarta.validation.constraints.NotBlank; + +public record GoogleAuthCode( + @NotBlank String authCode +) { +} diff --git a/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleTokenResponse.java b/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleTokenResponse.java new file mode 100644 index 00000000..07a95209 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleTokenResponse.java @@ -0,0 +1,10 @@ +package com.gachtaxi.global.auth.google.dto; + +public record GoogleTokenResponse( + String access_token, + String expires_in, + String scope, + String token_type, + String id_token +) { +} \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleUserInfoResponse.java b/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleUserInfoResponse.java new file mode 100644 index 00000000..54c2c76f --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/google/dto/GoogleUserInfoResponse.java @@ -0,0 +1,7 @@ +package com.gachtaxi.global.auth.google.dto; + +public record GoogleUserInfoResponse( + String id, + String email +) { +} \ No newline at end of file diff --git a/src/main/java/com/gachtaxi/global/auth/google/utils/GoogleUtils.java b/src/main/java/com/gachtaxi/global/auth/google/utils/GoogleUtils.java new file mode 100644 index 00000000..d2d17114 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/auth/google/utils/GoogleUtils.java @@ -0,0 +1,59 @@ +package com.gachtaxi.global.auth.google.utils; + +import com.gachtaxi.global.auth.google.dto.GoogleTokenResponse; +import com.gachtaxi.global.auth.google.dto.GoogleUserInfoResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestClient; + +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; + +@Component +public class GoogleUtils { + + @Value("${gachtaxi.auth.google.client}") + private String googleClient; + + @Value("${gachtaxi.auth.google.client-secret}") + private String clientSecret; + + @Value("${gachtaxi.auth.google.redirect}") + private String googleRedirect; + + @Value("${gachtaxi.auth.google.token_uri}") + private String GoogleTokenUri; + + @Value("${gachtaxi.auth.google.user_profile}") + private String GoogleProfileUri; + + private final RestClient restClient = RestClient.create(); + + public GoogleTokenResponse reqeustGoogleToken(String authCode){ + String decodeCode = URLDecoder.decode(authCode, StandardCharsets.UTF_8); + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("grant_type", "authorization_code"); + params.add("client_id", googleClient); + params.add("client_secret", clientSecret); + params.add("redirect_uri", googleRedirect); + params.add("code", decodeCode); + + return restClient.post() + .uri(GoogleTokenUri) + .body(params) + .contentType(MediaType.APPLICATION_FORM_URLENCODED) + .retrieve() + .body(GoogleTokenResponse.class); + } + + public GoogleUserInfoResponse requestGoogleProfile(String Token){ + return restClient.get() + .uri(GoogleProfileUri) + .header("Authorization", "Bearer " + Token) + .retrieve() + .body(GoogleUserInfoResponse.class); + } +} From cc74fcb9f7d1ad2981b4423f9271dcc6ddd945c5 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 03:33:43 +0900 Subject: [PATCH 425/770] =?UTF-8?q?feat:=20MemberService=20=EB=B9=84?= =?UTF-8?q?=EC=A7=80=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/entity/Members.java | 14 +++++++++++++- .../members/repository/MemberRepository.java | 2 ++ .../domain/members/service/MemberService.java | 15 +++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 1548b64f..5039eeaf 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -42,7 +42,7 @@ public class Members extends BaseEntity { private Long kakaoId; @Column(name = "google_id", unique = true) - private Long googleId; + private String googleId; @Enumerated(EnumType.STRING) private Role role; @@ -110,4 +110,16 @@ public static Members ofKakaoId(Long kakaoId){ .twoFactorAuthentication(false) .build(); } + + public static Members ofGoogleId(String googleId){ + return Members.builder() + .googleId(googleId) + .status(UserStatus.INACTIVE) + .role(Role.MEMBER) + .termsAgreement(false) + .privacyAgreement(false) + .marketingAgreement(false) + .twoFactorAuthentication(false) + .build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 2ac1fa52..3d7c85de 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -14,4 +14,6 @@ public interface MemberRepository extends JpaRepository { Optional findByStudentNumber(Long studentNumber); Optional findByKakaoId(Long kakaoId); + + Optional findByGoogleId(String googleId); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 173d744b..ec0d2b1b 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -21,12 +21,19 @@ public class MemberService { // 임시 유저 저장 @Transactional - public InactiveMemberDto saveTmpMember(Long kakaoId){ + public InactiveMemberDto saveTmpKakaoMember(Long kakaoId){ Members tmpMember = Members.ofKakaoId(kakaoId); memberRepository.save(tmpMember); return InactiveMemberDto.of(tmpMember); } + @Transactional + public InactiveMemberDto saveTmpGoogleMember(String googleId){ + Members tmpMember = Members.ofGoogleId(googleId); + memberRepository.save(tmpMember); + return InactiveMemberDto.of(tmpMember); + } + @Transactional public void updateMemberEmail(String email, Long userId) { Members members = findById(userId); @@ -47,9 +54,9 @@ public void updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { members.updateSupplment(dto); } - public Optional findByKakaoId(Long kakaoId) { - return memberRepository.findByKakaoId(kakaoId); - } + public Optional findByKakaoId(Long kakaoId) {return memberRepository.findByKakaoId(kakaoId);} + + public Optional findByGoogleId(String googleId) {return memberRepository.findByGoogleId(googleId);} /* * refactor From ae5e712c0528f2c40ea4ab1edd81462c0bbe7925 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 03:35:30 +0900 Subject: [PATCH 426/770] =?UTF-8?q?feat:=20=EA=B5=AC=EA=B8=80=20=EC=86=8C?= =?UTF-8?q?=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 22 +++++++++++++- .../members/controller/ResponseMessage.java | 2 ++ .../domain/members/service/AuthService.java | 29 +++++++++++++++++-- .../common/mail/service/EmailService.java | 19 +++++++++--- .../global/config/PermitUrlConfig.java | 1 + 5 files changed, 66 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 7ec3836d..dc85f407 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -6,6 +6,7 @@ import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; import com.gachtaxi.domain.members.service.AuthService; import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.global.auth.google.dto.GoogleAuthCode; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.service.JwtService; @@ -44,7 +45,20 @@ public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode JwtTokenDto jwtTokenDto = authService.kakaoLogin(kakaoAuthCode.authCode()); response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); - if(jwtTokenDto.isTemporaryUser()){ // 임시 유저 + if (jwtTokenDto.isTemporaryUser()) { // 임시 유저 + return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage(), UN_REGISTER); + } + + cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); + return ApiResponse.response(HttpStatus.OK, LOGIN_SUCCESS.getMessage(), LOGIN_SUCCESS); + } + + @PostMapping("/login/google") + public ApiResponse googleLogin(@RequestBody @Valid GoogleAuthCode googleAuthCode, HttpServletResponse response) { + JwtTokenDto jwtTokenDto = authService.googleLogin(googleAuthCode.authCode()); + response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); + + if (jwtTokenDto.isTemporaryUser()) { // 임시 유저 return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage(), UN_REGISTER); } @@ -71,7 +85,13 @@ public ApiResponse sendEmail( @RequestBody @Valid EmailAddressDto emailDto, @CurrentMemberId Long userId ) { + // emailService의 sendEmail은 정말 이메일에 authcode만 보내도록 + // memberService에서 email에 대해서 ACTIVE한 유저가 있는 지 확인 -> 통합 dto 반환 + // + // memberService에서 email에 대해 ACTIVE한 유저가 없으면 그냥 이메일 전송 -> 일반 응답 dto 반환 + emailService.sendEmail(emailDto.email()); + // 응답 데이터를 AUTH_MAIL, KAKAO, GOOGLE_LOGIN return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); } diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 5f550565..affb72b9 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -10,6 +10,8 @@ public enum ResponseMessage { REGISTER_SUCCESS("회원가입에 성공했습니다."), // AuthController + KAKAO_INTEGRATE("기존 구글 회원가입, 카카오 계정으로 통합 로그인합니다."), + GOOGLE_INTEGRATE("기존 카카오 회원가입, 구글 계정으로 통합 로그인합니다."), REFRESH_TOKEN_REISSUE("토큰 재발급에 성공했습니다."), LOGIN_SUCCESS("로그인 성공에 성공했습니다."), UN_REGISTER("회원가입을 진행해주세요"); diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index df4ab4eb..43c90d01 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -2,6 +2,9 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.global.auth.google.dto.GoogleTokenResponse; +import com.gachtaxi.global.auth.google.dto.GoogleUserInfoResponse; +import com.gachtaxi.global.auth.google.utils.GoogleUtils; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; @@ -11,13 +14,15 @@ import java.util.Optional; import static com.gachtaxi.domain.members.entity.enums.UserStatus.INACTIVE; -import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.*; +import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.KakaoAccessToken; +import static com.gachtaxi.global.auth.kakao.dto.KaKaoDTO.KakaoUserInfoResponse; @Service @RequiredArgsConstructor public class AuthService { private final KakaoUtil kakaoUtil; + private final GoogleUtils googleUtils; private final JwtService jwtService; private final MemberService memberService; @@ -29,7 +34,7 @@ public JwtTokenDto kakaoLogin(String authCode) { Optional optionalMember = memberService.findByKakaoId(kakaoId); if(optionalMember.isEmpty()) { - return jwtService.generateTmpAccessToken(memberService.saveTmpMember(kakaoId)); + return jwtService.generateTmpAccessToken(memberService.saveTmpKakaoMember(kakaoId)); } // 회원 가입 진행 중 중단된 유저 또한 다시 임시 토큰을 재발급해준다. @@ -40,4 +45,24 @@ public JwtTokenDto kakaoLogin(String authCode) { return jwtService.generateJwtToken(member.getId(), member.getEmail(), member.getRole().name()); } + + public JwtTokenDto googleLogin(String authCode) { + GoogleTokenResponse googleAccessToken = googleUtils.reqeustGoogleToken(authCode); + GoogleUserInfoResponse userInfo = googleUtils.requestGoogleProfile(googleAccessToken.access_token()); + + String googleId = userInfo.id(); + Optional optionalMember = memberService.findByGoogleId(googleId); + + if(optionalMember.isEmpty()) { //-> 정상 작동 확인 O + return jwtService.generateTmpAccessToken(memberService.saveTmpGoogleMember(googleId)); + } + + Members member = optionalMember.get(); + if(member.getStatus() == INACTIVE){ // -> 정상 작동 확인 O + return jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())); + } + + // ACTIVE일 경우 Refresh, Access 정상 작동 확인 O + return jwtService.generateJwtToken(member.getId(), member.getEmail(), member.getRole().name()); + } } diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index 88413b9f..8d7edbd3 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -1,9 +1,10 @@ package com.gachtaxi.global.common.mail.service; +import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedEmailException; +import com.gachtaxi.domain.members.exception.EmailFormInvalidException; import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.global.common.mail.exception.AuthCodeNotMatchException; -import com.gachtaxi.domain.members.exception.EmailFormInvalidException; import com.gachtaxi.global.common.redis.RedisUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -14,6 +15,7 @@ import software.amazon.awssdk.services.ses.model.SendTemplatedEmailRequest; import java.security.SecureRandom; +import java.util.Optional; @Slf4j @Service @@ -38,7 +40,13 @@ public class EmailService { public void sendEmail(String recipientEmail) { checkGachonEmail(recipientEmail); - checkDuplicatedEmail(recipientEmail); +// checkDuplicatedEmail(recipientEmail); + + /* + * 1. 학교 이메일로 조회 시 유저가 존재하는 경우 + ACTIVE라면 다른 소셜로 로그인 했다는 의미 + * 따라서 + * 2. else -> 이메일로 인증 코드르 보낸다. (INACTIVE 유저여도 상관 X) + * */ String code = generateCode(); redisUtil.setEmailAuthCode(recipientEmail, code); @@ -67,8 +75,11 @@ private void checkGachonEmail(String email){ } } private void checkDuplicatedEmail(String email){ - memberRepository.findByEmail(email) - .orElseThrow(DuplicatedEmailException::new); + // 여기서 member가 INACTIVE면 넘어가게 해야함. 무조건 중복 email이라고 넘기면 안됨. + Optional members = memberRepository.findByEmail(email); + if(members.isPresent()){ + throw new DuplicatedEmailException(); + } } private String generateCode() { diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index 34c762ad..1af448c3 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -8,6 +8,7 @@ public class PermitUrlConfig { public String[] getPublicUrl(){ return new String[]{ "/auth/login/kakao", + "/auth/login/google", "/auth/refresh", "/api/members", From 2089dff0d4f085ec0a6ac5e94e74eb938954d4e3 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 03:54:32 +0900 Subject: [PATCH 427/770] =?UTF-8?q?fix:=20=EC=BD=94=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/common/mail/service/EmailService.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index 8d7edbd3..ede8975a 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -1,6 +1,5 @@ package com.gachtaxi.global.common.mail.service; -import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedEmailException; import com.gachtaxi.domain.members.exception.EmailFormInvalidException; import com.gachtaxi.domain.members.repository.MemberRepository; @@ -15,7 +14,6 @@ import software.amazon.awssdk.services.ses.model.SendTemplatedEmailRequest; import java.security.SecureRandom; -import java.util.Optional; @Slf4j @Service @@ -76,10 +74,10 @@ private void checkGachonEmail(String email){ } private void checkDuplicatedEmail(String email){ // 여기서 member가 INACTIVE면 넘어가게 해야함. 무조건 중복 email이라고 넘기면 안됨. - Optional members = memberRepository.findByEmail(email); - if(members.isPresent()){ + memberRepository.findByEmail(email).ifPresent(member -> { throw new DuplicatedEmailException(); - } + }); + } private String generateCode() { From 99f305a28e4770c015256b75528b51e5ddc95806 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 03:56:45 +0900 Subject: [PATCH 428/770] =?UTF-8?q?feat:=20=EC=A4=91=EB=B3=B5=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/DuplicatedNickNameException.java | 12 ++++++++++++ .../domain/members/exception/ErrorMessage.java | 1 + .../members/repository/MemberRepository.java | 2 ++ .../domain/members/service/MemberService.java | 14 +++++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/DuplicatedNickNameException.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedNickNameException.java b/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedNickNameException.java new file mode 100644 index 00000000..dec96c92 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedNickNameException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.members.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.DUPLICATED_NICKNAME; + +public class DuplicatedNickNameException extends BaseException { + public DuplicatedNickNameException() { + super(HttpStatus.BAD_REQUEST, DUPLICATED_NICKNAME.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index a971f7bc..e80edfb8 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -7,6 +7,7 @@ @AllArgsConstructor public enum ErrorMessage { + DUPLICATED_NICKNAME("중복되는 닉네임입니다."), DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."), DUPLICATED_EMAIL("중복된 이메일입니다."), diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 3d7c85de..e3d88b28 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -16,4 +16,6 @@ public interface MemberRepository extends JpaRepository { Optional findByKakaoId(Long kakaoId); Optional findByGoogleId(String googleId); + + Optional findByNickname(String nickname); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index ec0d2b1b..b08bf52c 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -3,7 +3,9 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberTokenDto; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.exception.DuplicatedNickNameException; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; import com.gachtaxi.domain.members.exception.MemberNotFoundException; import com.gachtaxi.domain.members.repository.MemberRepository; @@ -47,11 +49,14 @@ public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId) { } @Transactional - public void updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { + public MemberTokenDto updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { + checkDuplicatedNickName(dto.nickname()); checkDuplicatedStudentNumber(dto.studentNumber()); Members members = findById(userId); members.updateSupplment(dto); + + return MemberTokenDto.from(members); } public Optional findByKakaoId(Long kakaoId) {return memberRepository.findByKakaoId(kakaoId);} @@ -72,4 +77,11 @@ private void checkDuplicatedStudentNumber(Long studentNumber) { throw new DuplicatedStudentNumberException(); }); } + + private void checkDuplicatedNickName(String nickName) { + memberRepository.findByNickname(nickName).ifPresent(m -> { + throw new DuplicatedNickNameException(); + }); + } + } From a7813af0d89359b2f24d424498baa8ba2b64ceaf Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 03:57:19 +0900 Subject: [PATCH 429/770] =?UTF-8?q?refactoring:=20MemberTokenDto=EB=A1=9C?= =?UTF-8?q?=20JwtToken=20=EB=B0=9C=EA=B8=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 9 +++++-- .../members/dto/request/MemberTokenDto.java | 27 +++++++++++++++++++ .../domain/members/service/AuthService.java | 13 ++++----- .../global/auth/jwt/service/JwtService.java | 11 ++++---- 4 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/MemberTokenDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index dc85f407..fd085e2f 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -120,9 +120,14 @@ public ApiResponse updateUserAgreement( @Operation(summary = "사용자 추가 정보 업데이트하는 API 입니다. (프로필, 닉네임, 실명, 학번, 성별,)") public ApiResponse updateMemberSupplement( @RequestBody MemberSupplmentRequestDto dto, - @CurrentMemberId Long userId + @CurrentMemberId Long userId, + HttpServletResponse response ){ - memberService.updateMemberSupplement(dto, userId); + JwtTokenDto jwtTokenDto = jwtService + .generateJwtToken(memberService.updateMemberSupplement(dto, userId)); + + response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); + cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); return ApiResponse.response(OK, SUPPLEMENT_UPDATE_SUCCESS.getMessage()); } diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberTokenDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberTokenDto.java new file mode 100644 index 00000000..7decacfe --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberTokenDto.java @@ -0,0 +1,27 @@ +package com.gachtaxi.domain.members.dto.request; + +import com.gachtaxi.domain.members.entity.Members; +import lombok.Builder; + +@Builder +public record MemberTokenDto( + Long id, + String email, + String role +){ + public static MemberTokenDto from(Members members){ + return MemberTokenDto.builder() + .id(members.getId()) + .email(members.getEmail()) + .role(members.getRole().name()) + .build(); + } + + public static MemberTokenDto of(Long id, String email, String role){ + return MemberTokenDto.builder() + .id(id) + .email(email) + .role(role) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 43c90d01..b8c17851 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.members.service; import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; +import com.gachtaxi.domain.members.dto.request.MemberTokenDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.auth.google.dto.GoogleTokenResponse; import com.gachtaxi.global.auth.google.dto.GoogleUserInfoResponse; @@ -38,12 +39,12 @@ public JwtTokenDto kakaoLogin(String authCode) { } // 회원 가입 진행 중 중단된 유저 또한 다시 임시 토큰을 재발급해준다. - Members member = optionalMember.get(); - if(member.getStatus() == INACTIVE){ + Members members = optionalMember.get(); + if(members.getStatus() == INACTIVE){ return jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())); } - return jwtService.generateJwtToken(member.getId(), member.getEmail(), member.getRole().name()); + return jwtService.generateJwtToken(MemberTokenDto.from(members)); } public JwtTokenDto googleLogin(String authCode) { @@ -57,12 +58,12 @@ public JwtTokenDto googleLogin(String authCode) { return jwtService.generateTmpAccessToken(memberService.saveTmpGoogleMember(googleId)); } - Members member = optionalMember.get(); - if(member.getStatus() == INACTIVE){ // -> 정상 작동 확인 O + Members members = optionalMember.get(); + if(members.getStatus() == INACTIVE){ // -> 정상 작동 확인 O return jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())); } // ACTIVE일 경우 Refresh, Access 정상 작동 확인 O - return jwtService.generateJwtToken(member.getId(), member.getEmail(), member.getRole().name()); + return jwtService.generateJwtToken(MemberTokenDto.from(members)); } } diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java index 0262cdc9..39ecc36f 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/service/JwtService.java @@ -1,6 +1,7 @@ package com.gachtaxi.global.auth.jwt.service; import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; +import com.gachtaxi.domain.members.dto.request.MemberTokenDto; import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.exception.CookieNotFoundException; import com.gachtaxi.global.auth.jwt.exception.TokenExpiredException; @@ -23,11 +24,11 @@ public class JwtService { private final JwtExtractor jwtExtractor; // JwtToken 생성 + Redis 저장 - public JwtTokenDto generateJwtToken(Long userId, String email, String role) { - String accessToken = jwtProvider.generateAccessToken(userId, email, role); - String refreshToken = jwtProvider.generateRefreshToken(userId, email, role); + public JwtTokenDto generateJwtToken(MemberTokenDto dto) { + String accessToken = jwtProvider.generateAccessToken(dto.id(), dto.email(), dto.role()); + String refreshToken = jwtProvider.generateRefreshToken(dto.id(), dto.email(), dto.role()); - redisUtil.setRefreshToken(userId, refreshToken); + redisUtil.setRefreshToken(dto.id(), refreshToken); return JwtTokenDto.of(accessToken, refreshToken); } @@ -49,7 +50,7 @@ public JwtTokenDto reissueJwtToken(String refreshToken) { String email = jwtExtractor.getEmail(refreshToken); String role = jwtExtractor.getRole(refreshToken); - return generateJwtToken(userId, email, role); + return generateJwtToken(MemberTokenDto.of(userId, email, role)); } /* From 542000103b568a4a8506243ddd001c5220c82eed Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 05:58:29 +0900 Subject: [PATCH 430/770] =?UTF-8?q?feat:=20=ED=86=B5=ED=95=A9=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20Dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/MemberIntegrationRequestDto.java | 9 +++++++++ .../members/dto/response/MemberMailResponseDto.java | 11 +++++++++++ .../global/common/mail/dto/enums/EmailStatus.java | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/MemberIntegrationRequestDto.java create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/MemberMailResponseDto.java create mode 100644 src/main/java/com/gachtaxi/global/common/mail/dto/enums/EmailStatus.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberIntegrationRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberIntegrationRequestDto.java new file mode 100644 index 00000000..bc59fc26 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberIntegrationRequestDto.java @@ -0,0 +1,9 @@ +package com.gachtaxi.domain.members.dto.request; + +public record MemberIntegrationRequestDto( + String email, + String authCode, + Long kakaoId, + String googleId +) { +} diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/MemberMailResponseDto.java b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberMailResponseDto.java new file mode 100644 index 00000000..d57f6616 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberMailResponseDto.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.members.dto.response; + +import com.gachtaxi.global.common.mail.dto.enums.EmailStatus; + +public record MemberMailResponseDto( + EmailStatus status, + String email, + Long kakaoId, + String googleId +) { +} diff --git a/src/main/java/com/gachtaxi/global/common/mail/dto/enums/EmailStatus.java b/src/main/java/com/gachtaxi/global/common/mail/dto/enums/EmailStatus.java new file mode 100644 index 00000000..ee07d3b4 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/common/mail/dto/enums/EmailStatus.java @@ -0,0 +1,5 @@ +package com.gachtaxi.global.common.mail.dto.enums; + +public enum EmailStatus { + MAIL_SUCCESS, KAKAO_INTEGRATE, GOOGLE_INTEGRATE +} From 64adca7ec782a1ef8dab546d5ab49c758e172865 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 06:04:06 +0900 Subject: [PATCH 431/770] =?UTF-8?q?fix:=20sendEmail()=EC=9D=98=20=EC=B1=85?= =?UTF-8?q?=EC=9E=84=EC=9D=84=20=EC=9D=B8=EC=A6=9D=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/mail/service/EmailService.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index ede8975a..03f00373 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -1,6 +1,5 @@ package com.gachtaxi.global.common.mail.service; -import com.gachtaxi.domain.members.exception.DuplicatedEmailException; import com.gachtaxi.domain.members.exception.EmailFormInvalidException; import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.global.common.mail.exception.AuthCodeNotMatchException; @@ -38,13 +37,6 @@ public class EmailService { public void sendEmail(String recipientEmail) { checkGachonEmail(recipientEmail); -// checkDuplicatedEmail(recipientEmail); - - /* - * 1. 학교 이메일로 조회 시 유저가 존재하는 경우 + ACTIVE라면 다른 소셜로 로그인 했다는 의미 - * 따라서 - * 2. else -> 이메일로 인증 코드르 보낸다. (INACTIVE 유저여도 상관 X) - * */ String code = generateCode(); redisUtil.setEmailAuthCode(recipientEmail, code); @@ -72,13 +64,6 @@ private void checkGachonEmail(String email){ throw new EmailFormInvalidException(); } } - private void checkDuplicatedEmail(String email){ - // 여기서 member가 INACTIVE면 넘어가게 해야함. 무조건 중복 email이라고 넘기면 안됨. - memberRepository.findByEmail(email).ifPresent(member -> { - throw new DuplicatedEmailException(); - }); - - } private String generateCode() { return String.format(CODE_LENGTH, secureRandom.nextInt(BOUND) + OFFSET); From 6c11f8c2e0b1767d82067fa0d6f4fcdf7c6a0038 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 06:05:36 +0900 Subject: [PATCH 432/770] =?UTF-8?q?feat:=20=ED=86=B5=ED=95=A9=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=ED=8C=90=EB=8B=A8=20=EB=B9=84=EC=A7=80?= =?UTF-8?q?=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 24 +++++------ .../domain/members/service/MemberService.java | 43 +++++++++++++++++-- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index fd085e2f..77929979 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -1,9 +1,8 @@ package com.gachtaxi.domain.members.controller; -import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; -import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; -import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; +import com.gachtaxi.domain.members.dto.request.*; import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; +import com.gachtaxi.domain.members.dto.response.MemberMailResponseDto; import com.gachtaxi.domain.members.service.AuthService; import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.auth.google.dto.GoogleAuthCode; @@ -85,14 +84,9 @@ public ApiResponse sendEmail( @RequestBody @Valid EmailAddressDto emailDto, @CurrentMemberId Long userId ) { - // emailService의 sendEmail은 정말 이메일에 authcode만 보내도록 - // memberService에서 email에 대해서 ACTIVE한 유저가 있는 지 확인 -> 통합 dto 반환 - // - // memberService에서 email에 대해 ACTIVE한 유저가 없으면 그냥 이메일 전송 -> 일반 응답 dto 반환 - + MemberMailResponseDto dto = memberService.IsAlreadySignEmail(emailDto.email(), userId); emailService.sendEmail(emailDto.email()); - // 응답 데이터를 AUTH_MAIL, KAKAO, GOOGLE_LOGIN - return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), InactiveMemberResponseDto.from(userId)); + return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), dto); } @PatchMapping("/code/mail") @@ -106,6 +100,8 @@ public ApiResponse checkAuthCodeAndUpdateEmail( return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); } + + @PatchMapping("/agreement") @Operation(summary = "약관 동의 정보를 업데이트하는 API 입니다.") public ApiResponse updateUserAgreement( @@ -126,12 +122,16 @@ public ApiResponse updateMemberSupplement( JwtTokenDto jwtTokenDto = jwtService .generateJwtToken(memberService.updateMemberSupplement(dto, userId)); - response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); - cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); + responseToken(jwtTokenDto, response); return ApiResponse.response(OK, SUPPLEMENT_UPDATE_SUCCESS.getMessage()); } /* * refactoring * */ + + private void responseToken(JwtTokenDto jwtTokenDto, HttpServletResponse response) { + response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); + cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); + } } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index b08bf52c..f344cfad 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,10 +1,9 @@ package com.gachtaxi.domain.members.service; -import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; -import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; -import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; -import com.gachtaxi.domain.members.dto.request.MemberTokenDto; +import com.gachtaxi.domain.members.dto.request.*; +import com.gachtaxi.domain.members.dto.response.MemberMailResponseDto; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.exception.DuplicatedEmailException; import com.gachtaxi.domain.members.exception.DuplicatedNickNameException; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; import com.gachtaxi.domain.members.exception.MemberNotFoundException; @@ -15,12 +14,43 @@ import java.util.Optional; +import static com.gachtaxi.domain.members.entity.enums.UserStatus.ACTIVE; +import static com.gachtaxi.global.common.mail.dto.enums.EmailStatus.*; + @Service @RequiredArgsConstructor public class MemberService { private final MemberRepository memberRepository; + public MemberMailResponseDto IsAlreadySignEmail(String email, Long tmpId) { + Optional findMembers = memberRepository.findByEmailAndStatus(email, ACTIVE); + if(findMembers.isPresent()) { // 이미 가입되어 있는 회원 가입 한 유저면 + Members members = findMembers.get(); // 이미 가입되어있는 멤버 + Members tmpMembers = findById(tmpId); + //만약 카카오 Id가 있다면 KAKAO_INTEGRATE + if (members.getKakaoId() != null) { + if(tmpMembers.getGoogleId() != null) { + return new MemberMailResponseDto(KAKAO_INTEGRATE, email, null, tmpMembers.getGoogleId()); + }else{ + // 임시 유저 구글 ID도 null이다? -> 회원가입한 카카오 계정이 아닌 다른 카카오 계정을 로그인 해 + // 다른 카카오 계정으로 로그인하고 같은 학교 이메일을 사용한 경우 + throw new DuplicatedEmailException(); + } + } + if (members.getGoogleId() != null){ // 구글 Id가 있다는 의미므로 GOOGLE_INTEGRATE + if(tmpMembers.getKakaoId() != null) { + return new MemberMailResponseDto(GOOGLE_INTEGRATE, email, tmpMembers.getKakaoId(), null); + }else{ + // 임시 유저 카카오ID도 null -> 회원가입한 구글 계정이 아닌 다른 구글 계정으로 로그인한 경우 + // 다른 구글 계정으로 로그인하고 같은 학교 이메일을 사용한 경우 + throw new DuplicatedEmailException(); + } + } + } + return new MemberMailResponseDto(MAIL_SUCCESS, email, null, null); + } + // 임시 유저 저장 @Transactional public InactiveMemberDto saveTmpKakaoMember(Long kakaoId){ @@ -72,6 +102,11 @@ public Members findById(Long id) { .orElseThrow(MemberNotFoundException::new); } + public Members findActiveByEmail(String email) { + return memberRepository.findByEmailAndStatus(email, ACTIVE) + .orElseThrow(MemberNotFoundException::new); + } + private void checkDuplicatedStudentNumber(Long studentNumber) { memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { throw new DuplicatedStudentNumberException(); From 7b99af59ff955d001b42514f316f02fa7743c6dd Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 06:06:44 +0900 Subject: [PATCH 433/770] =?UTF-8?q?feat:=20=EC=8B=A4=EC=A0=9C=20=ED=86=B5?= =?UTF-8?q?=ED=95=A9=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B9=84=EC=A7=80?= =?UTF-8?q?=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 21 +++++++++++++++++++ .../members/controller/ResponseMessage.java | 3 +-- .../domain/members/entity/Members.java | 8 +++++++ .../members/exception/ErrorMessage.java | 2 +- .../members/repository/MemberRepository.java | 3 +++ .../domain/members/service/MemberService.java | 20 ++++++++++++++++++ 6 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 77929979..6e04c876 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -100,7 +100,18 @@ public ApiResponse checkAuthCodeAndUpdateEmail( return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); } + @PatchMapping("/code/integration") + public ApiResponse checkAuthCodeAndKakaoIntegration( + @RequestBody MemberIntegrationRequestDto dto, + @CurrentMemberId Long userId, + HttpServletResponse response + ) { + emailService.checkEmailAuthCode(dto.email(), dto.authCode()); + JwtTokenDto jwtTokenDto = generateIntegration(dto, userId); + responseToken(jwtTokenDto, response); + return ApiResponse.response(OK, INTEGRATION_SUCCESS.getMessage()); + } @PatchMapping("/agreement") @Operation(summary = "약관 동의 정보를 업데이트하는 API 입니다.") @@ -134,4 +145,14 @@ private void responseToken(JwtTokenDto jwtTokenDto, HttpServletResponse response response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); } + + private JwtTokenDto generateIntegration(MemberIntegrationRequestDto dto, Long userId){ + if(dto.kakaoId() != null){ // 카카오Id에 값이 있으면 구글로 통합 로그인 + return jwtService + .generateJwtToken(memberService.IntegrationMemberToGoogle(dto, userId)); + }else{ //카카오로 통합 로그인 + return jwtService + .generateJwtToken(memberService.IntegrationMemberToKakao(dto, userId)); + } + } } diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index affb72b9..9257e609 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -10,8 +10,7 @@ public enum ResponseMessage { REGISTER_SUCCESS("회원가입에 성공했습니다."), // AuthController - KAKAO_INTEGRATE("기존 구글 회원가입, 카카오 계정으로 통합 로그인합니다."), - GOOGLE_INTEGRATE("기존 카카오 회원가입, 구글 계정으로 통합 로그인합니다."), + INTEGRATION_SUCCESS("통합 로그인을 성공했습니다!"), REFRESH_TOKEN_REISSUE("토큰 재발급에 성공했습니다."), LOGIN_SUCCESS("로그인 성공에 성공했습니다."), UN_REGISTER("회원가입을 진행해주세요"); diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 5039eeaf..79e02141 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -84,6 +84,14 @@ public void updateEmail(String email) { this.email = email; } + public void updateKakaoId(Long kakaoId) { + this.kakaoId = kakaoId; + } + + public void updateGoogleId(String googleId) { + this.googleId = googleId; + } + public void updateAgreement(MemberAgreementRequestDto dto) { this.termsAgreement = dto.termsAgreement(); this.privacyAgreement = dto.privacyAgreement(); diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index e80edfb8..aea189e9 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -10,7 +10,7 @@ public enum ErrorMessage { DUPLICATED_NICKNAME("중복되는 닉네임입니다."), DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."), - DUPLICATED_EMAIL("중복된 이메일입니다."), + DUPLICATED_EMAIL("이미 가입된 이메일입니다."), EMAIL_FROM_INVALID("가천대 이메일 형식이 아닙니다."); private final String message; diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index e3d88b28..994d1634 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.members.repository; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.entity.enums.UserStatus; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -18,4 +19,6 @@ public interface MemberRepository extends JpaRepository { Optional findByGoogleId(String googleId); Optional findByNickname(String nickname); + + Optional findByEmailAndStatus(String email, UserStatus status); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index f344cfad..54464740 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -51,6 +51,26 @@ public MemberMailResponseDto IsAlreadySignEmail(String email, Long tmpId) { return new MemberMailResponseDto(MAIL_SUCCESS, email, null, null); } + @Transactional + public MemberTokenDto IntegrationMemberToKakao(MemberIntegrationRequestDto dto, Long tmpId) { + Members existsMembers = findActiveByEmail(dto.email()); + memberRepository.deleteById(tmpId); + memberRepository.flush(); + + existsMembers.updateGoogleId(dto.googleId()); + return MemberTokenDto.from(existsMembers); + } + + @Transactional + public MemberTokenDto IntegrationMemberToGoogle(MemberIntegrationRequestDto dto, Long tmpId) { + Members existsMembers = findActiveByEmail(dto.email()); + memberRepository.deleteById(tmpId); + memberRepository.flush(); + + existsMembers.updateKakaoId(dto.kakaoId()); + return MemberTokenDto.from(existsMembers); + } + // 임시 유저 저장 @Transactional public InactiveMemberDto saveTmpKakaoMember(Long kakaoId){ From 9b7e461da1f94fb3a008e3e5a674ae49fc8ad1ed Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 06:19:52 +0900 Subject: [PATCH 434/770] =?UTF-8?q?feat:=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20?= =?UTF-8?q?=EB=AA=85=EC=84=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 27 ++++++++++++++----- .../common/mail/service/EmailService.java | 2 -- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 6e04c876..72fb010e 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -39,8 +39,11 @@ public class AuthController { private final MemberService memberService; @PostMapping("/login/kakao") - @Operation(summary = "인가 코드를 전달받아, 소셜 로그인을 진행합니다.") - public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode kakaoAuthCode, HttpServletResponse response) { + @Operation(summary = "인가 코드를 전달받아, 카카오 소셜 로그인을 진행합니다.") + public ApiResponse kakaoLogin( + @RequestBody @Valid KakaoAuthCode kakaoAuthCode + , HttpServletResponse response) + { JwtTokenDto jwtTokenDto = authService.kakaoLogin(kakaoAuthCode.authCode()); response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); @@ -53,7 +56,11 @@ public ApiResponse kakaoLogin(@RequestBody @Valid KakaoAuthCode } @PostMapping("/login/google") - public ApiResponse googleLogin(@RequestBody @Valid GoogleAuthCode googleAuthCode, HttpServletResponse response) { + @Operation(summary = "인가 코드를 전달받아, 구글 소셜 로그인을 진행합니다.") + public ApiResponse googleLogin( + @RequestBody @Valid GoogleAuthCode googleAuthCode + , HttpServletResponse response) + { JwtTokenDto jwtTokenDto = authService.googleLogin(googleAuthCode.authCode()); response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); @@ -71,21 +78,23 @@ public ApiResponse reissueRefreshToken( @CookieValue(value = REFRESH_TOKEN_SUBJECT) String refreshToken, HttpServletResponse response ) { + JwtTokenDto jwtTokenDto = jwtService.reissueJwtToken(refreshToken); - response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); - cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); + responseToken(jwtTokenDto, response); return ApiResponse.response(HttpStatus.OK, REFRESH_TOKEN_REISSUE.getMessage()); } @PostMapping("/code/mail") - @Operation(summary = "이메일 인증 코드를 보내는 API입니다.") + @Operation(summary = "이메일 인증 코드를 보내는 API입니다. 기존 가입자의 경우 통합 로그인을 해주세요.") public ApiResponse sendEmail( @RequestBody @Valid EmailAddressDto emailDto, @CurrentMemberId Long userId ) { + MemberMailResponseDto dto = memberService.IsAlreadySignEmail(emailDto.email(), userId); emailService.sendEmail(emailDto.email()); + return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), dto); } @@ -95,12 +104,15 @@ public ApiResponse checkAuthCodeAndUpdateEmail( @RequestBody @Valid InactiveMemberAuthCodeRequestDto dto, @CurrentMemberId Long userId ) { + emailService.checkEmailAuthCode(dto.email(), dto.authCode()); memberService.updateMemberEmail(dto.email(), userId); + return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); } @PatchMapping("/code/integration") + @Operation(summary = "인증코드 검증 + 통합 로그인을 진행하는 API 입니다. 성공 시 토큰을 발행합니다. ") public ApiResponse checkAuthCodeAndKakaoIntegration( @RequestBody MemberIntegrationRequestDto dto, @CurrentMemberId Long userId, @@ -110,6 +122,7 @@ public ApiResponse checkAuthCodeAndKakaoIntegration( JwtTokenDto jwtTokenDto = generateIntegration(dto, userId); responseToken(jwtTokenDto, response); + return ApiResponse.response(OK, INTEGRATION_SUCCESS.getMessage()); } @@ -132,8 +145,8 @@ public ApiResponse updateMemberSupplement( ){ JwtTokenDto jwtTokenDto = jwtService .generateJwtToken(memberService.updateMemberSupplement(dto, userId)); - responseToken(jwtTokenDto, response); + return ApiResponse.response(OK, SUPPLEMENT_UPDATE_SUCCESS.getMessage()); } diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index 03f00373..efbb9659 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -53,8 +53,6 @@ public void checkEmailAuthCode(String recipientEmail, String inputCode) { } } - // 인증 코드 검증 - /* * refactoring * */ From f821088f6af4dc755d49a1c059c21ae635021a67 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 06:51:38 +0900 Subject: [PATCH 435/770] =?UTF-8?q?feat:=20=ED=86=B5=ED=95=A9=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=ED=8C=90=EB=8B=A8=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/entity/Members.java | 14 +++++++++++ .../domain/members/service/MemberService.java | 24 ++++++------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 79e02141..746c806c 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -80,6 +80,20 @@ public class Members extends BaseEntity { * friend_info * */ + public boolean hasKakaoId(){ + if(kakaoId == null){ + return false; + } + return true; + } + + public boolean hasGoogleId(){ + if(googleId == null){ + return false; + } + return true; + } + public void updateEmail(String email) { this.email = email; } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 54464740..7c16d189 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -28,25 +28,15 @@ public MemberMailResponseDto IsAlreadySignEmail(String email, Long tmpId) { if(findMembers.isPresent()) { // 이미 가입되어 있는 회원 가입 한 유저면 Members members = findMembers.get(); // 이미 가입되어있는 멤버 Members tmpMembers = findById(tmpId); - //만약 카카오 Id가 있다면 KAKAO_INTEGRATE - if (members.getKakaoId() != null) { - if(tmpMembers.getGoogleId() != null) { - return new MemberMailResponseDto(KAKAO_INTEGRATE, email, null, tmpMembers.getGoogleId()); - }else{ - // 임시 유저 구글 ID도 null이다? -> 회원가입한 카카오 계정이 아닌 다른 카카오 계정을 로그인 해 - // 다른 카카오 계정으로 로그인하고 같은 학교 이메일을 사용한 경우 - throw new DuplicatedEmailException(); - } + + if (members.hasKakaoId() && !members.hasGoogleId() && tmpMembers.hasGoogleId()) { + return new MemberMailResponseDto(KAKAO_INTEGRATE, email, null, tmpMembers.getGoogleId()); } - if (members.getGoogleId() != null){ // 구글 Id가 있다는 의미므로 GOOGLE_INTEGRATE - if(tmpMembers.getKakaoId() != null) { - return new MemberMailResponseDto(GOOGLE_INTEGRATE, email, tmpMembers.getKakaoId(), null); - }else{ - // 임시 유저 카카오ID도 null -> 회원가입한 구글 계정이 아닌 다른 구글 계정으로 로그인한 경우 - // 다른 구글 계정으로 로그인하고 같은 학교 이메일을 사용한 경우 - throw new DuplicatedEmailException(); - } + if (members.hasGoogleId() && !members.hasKakaoId() && tmpMembers.hasKakaoId()){ // 구글 Id가 있다는 의미므로 GOOGLE_INTEGRATE + return new MemberMailResponseDto(GOOGLE_INTEGRATE, email, tmpMembers.getKakaoId(), null); } + + throw new DuplicatedEmailException(); } return new MemberMailResponseDto(MAIL_SUCCESS, email, null, null); } From 349a34a7d56647ef6b3d6a1da7158aa5cb95ba5d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 16 Jan 2025 15:16:58 +0900 Subject: [PATCH 436/770] =?UTF-8?q?chore:=20FCM=20=EB=B9=84=EA=B3=B5?= =?UTF-8?q?=EA=B0=9C=ED=82=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 3420b922..25cd1039 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,7 @@ out/ .vscode/ src/main/resources/.env + +### firebase ### +/src/main/resources/firebase/serviceAccountKey.json + From eb591316c826eb6f2455c67cfcc40728cc179afe Mon Sep 17 00:00:00 2001 From: senna Date: Thu, 16 Jan 2025 18:59:00 +0900 Subject: [PATCH 437/770] =?UTF-8?q?fix:=20=EC=84=A4=EC=A0=95=20=EC=98=A4?= =?UTF-8?q?=ED=83=80=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20registarar?= =?UTF-8?q?=EC=97=90=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/event/MatchingEventFactory.java | 2 +- .../com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java | 2 ++ src/main/resources/application-local.yml | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java b/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java index 3df46e84..d44bf9bb 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java @@ -30,7 +30,7 @@ public class MatchingEventFactory { @Value("${gachtaxi.matching.auto-matching-max-capacity}") private int autoMaxCapacity; - @Value("${gachtaxi.matching.auto-matcnig-description}") + @Value("${gachtaxi.matching.auto-matching-description}") private String autoDescription; public MatchMemberCancelledEvent createMatchMemberCancelledEvent(Long roomId, Long memberId) { diff --git a/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java b/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java index a6a338c7..dc2b3472 100644 --- a/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java +++ b/src/main/java/com/gachtaxi/global/config/kafka/KafkaBeanRegistrar.java @@ -23,7 +23,9 @@ import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.serializer.JsonSerializer; +import org.springframework.stereotype.Component; +@Component public class KafkaBeanRegistrar implements BeanDefinitionRegistryPostProcessor, EnvironmentAware { private Environment environment; diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 35f3af98..ecc88f5a 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -62,10 +62,9 @@ gachtaxi: match-member-joined: ${KAFKA_TOPIC_MATCH_MEMBER_JOINED} match-member-cancelled: ${KAFKA_TOPIC_MATCH_MEMBER_CANCELLED} match-room-cancelled: ${KAFKA_TOPIC_MATCH_ROOM_CANCELLED} - match-member-cancelled: ${KAFKA_TOPIC_MATCH_MEMBER_CANCELLED} match-room-completed: ${KAFKA_TOPIC_MATCH_ROOM_COMPLETED} partition-count: ${KAFKA_PARTITION_COUNT} replication-factor: ${KAFKA_REPLICATION_FACTOR} matching: auto-matching-max-capacity: ${AUTO_MATCHING_MAX_CAPACITY} - auto-matcnig-description: ${AUTO_MATCHING_DESCRIPTION} + auto-matching-description: ${AUTO_MATCHING_DESCRIPTION} From 98c9bc2aa685568c36c3fc69bd6e4402da3a7b79 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 19:42:57 +0900 Subject: [PATCH 438/770] =?UTF-8?q?fix:=20=ED=86=B5=ED=95=A9=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=EC=9D=84=20=EA=B5=AC=ED=98=84=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=9A=94=EA=B5=AC?= =?UTF-8?q?=EC=82=AC=ED=95=AD=EC=9D=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 36 ++------------- .../members/controller/ResponseMessage.java | 2 +- .../dto/response/MemberMailResponseDto.java | 11 ----- .../members/exception/ErrorMessage.java | 4 +- .../domain/members/service/MemberService.java | 46 ++----------------- .../common/mail/dto/enums/EmailStatus.java | 5 -- .../common/mail/service/EmailService.java | 21 +++++++-- 7 files changed, 28 insertions(+), 97 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/MemberMailResponseDto.java delete mode 100644 src/main/java/com/gachtaxi/global/common/mail/dto/enums/EmailStatus.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 72fb010e..20a7b83f 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -1,8 +1,8 @@ package com.gachtaxi.domain.members.controller; -import com.gachtaxi.domain.members.dto.request.*; -import com.gachtaxi.domain.members.dto.response.InactiveMemberResponseDto; -import com.gachtaxi.domain.members.dto.response.MemberMailResponseDto; +import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; import com.gachtaxi.domain.members.service.AuthService; import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.auth.google.dto.GoogleAuthCode; @@ -92,10 +92,9 @@ public ApiResponse sendEmail( @CurrentMemberId Long userId ) { - MemberMailResponseDto dto = memberService.IsAlreadySignEmail(emailDto.email(), userId); emailService.sendEmail(emailDto.email()); - return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage(), dto); + return ApiResponse.response(OK, EMAIL_SEND_SUCCESS.getMessage()); } @PatchMapping("/code/mail") @@ -108,22 +107,7 @@ public ApiResponse checkAuthCodeAndUpdateEmail( emailService.checkEmailAuthCode(dto.email(), dto.authCode()); memberService.updateMemberEmail(dto.email(), userId); - return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage(), InactiveMemberResponseDto.from(userId)); - } - - @PatchMapping("/code/integration") - @Operation(summary = "인증코드 검증 + 통합 로그인을 진행하는 API 입니다. 성공 시 토큰을 발행합니다. ") - public ApiResponse checkAuthCodeAndKakaoIntegration( - @RequestBody MemberIntegrationRequestDto dto, - @CurrentMemberId Long userId, - HttpServletResponse response - ) { - emailService.checkEmailAuthCode(dto.email(), dto.authCode()); - - JwtTokenDto jwtTokenDto = generateIntegration(dto, userId); - responseToken(jwtTokenDto, response); - - return ApiResponse.response(OK, INTEGRATION_SUCCESS.getMessage()); + return ApiResponse.response(OK, EMAIL_AUTHENTICATION_SUCESS.getMessage()); } @PatchMapping("/agreement") @@ -158,14 +142,4 @@ private void responseToken(JwtTokenDto jwtTokenDto, HttpServletResponse response response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); } - - private JwtTokenDto generateIntegration(MemberIntegrationRequestDto dto, Long userId){ - if(dto.kakaoId() != null){ // 카카오Id에 값이 있으면 구글로 통합 로그인 - return jwtService - .generateJwtToken(memberService.IntegrationMemberToGoogle(dto, userId)); - }else{ //카카오로 통합 로그인 - return jwtService - .generateJwtToken(memberService.IntegrationMemberToKakao(dto, userId)); - } - } } diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 9257e609..113bcd8d 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -10,7 +10,7 @@ public enum ResponseMessage { REGISTER_SUCCESS("회원가입에 성공했습니다."), // AuthController - INTEGRATION_SUCCESS("통합 로그인을 성공했습니다!"), + ALREADY_SIGN_UP("이미 가입된 이메일 입니다!"), REFRESH_TOKEN_REISSUE("토큰 재발급에 성공했습니다."), LOGIN_SUCCESS("로그인 성공에 성공했습니다."), UN_REGISTER("회원가입을 진행해주세요"); diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/MemberMailResponseDto.java b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberMailResponseDto.java deleted file mode 100644 index d57f6616..00000000 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/MemberMailResponseDto.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.gachtaxi.domain.members.dto.response; - -import com.gachtaxi.global.common.mail.dto.enums.EmailStatus; - -public record MemberMailResponseDto( - EmailStatus status, - String email, - Long kakaoId, - String googleId -) { -} diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index aea189e9..8a71cd13 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -10,8 +10,8 @@ public enum ErrorMessage { DUPLICATED_NICKNAME("중복되는 닉네임입니다."), DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."), - DUPLICATED_EMAIL("이미 가입된 이메일입니다."), - EMAIL_FROM_INVALID("가천대 이메일 형식이 아닙니다."); + DUPLICATED_EMAIL("이미 가입된 이메일이에요!"), + EMAIL_FROM_INVALID("가천대학교 이메일이 아니에요!"); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 7c16d189..c851ed75 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,9 +1,10 @@ package com.gachtaxi.domain.members.service; -import com.gachtaxi.domain.members.dto.request.*; -import com.gachtaxi.domain.members.dto.response.MemberMailResponseDto; +import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; +import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberTokenDto; import com.gachtaxi.domain.members.entity.Members; -import com.gachtaxi.domain.members.exception.DuplicatedEmailException; import com.gachtaxi.domain.members.exception.DuplicatedNickNameException; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; import com.gachtaxi.domain.members.exception.MemberNotFoundException; @@ -15,7 +16,6 @@ import java.util.Optional; import static com.gachtaxi.domain.members.entity.enums.UserStatus.ACTIVE; -import static com.gachtaxi.global.common.mail.dto.enums.EmailStatus.*; @Service @RequiredArgsConstructor @@ -23,44 +23,6 @@ public class MemberService { private final MemberRepository memberRepository; - public MemberMailResponseDto IsAlreadySignEmail(String email, Long tmpId) { - Optional findMembers = memberRepository.findByEmailAndStatus(email, ACTIVE); - if(findMembers.isPresent()) { // 이미 가입되어 있는 회원 가입 한 유저면 - Members members = findMembers.get(); // 이미 가입되어있는 멤버 - Members tmpMembers = findById(tmpId); - - if (members.hasKakaoId() && !members.hasGoogleId() && tmpMembers.hasGoogleId()) { - return new MemberMailResponseDto(KAKAO_INTEGRATE, email, null, tmpMembers.getGoogleId()); - } - if (members.hasGoogleId() && !members.hasKakaoId() && tmpMembers.hasKakaoId()){ // 구글 Id가 있다는 의미므로 GOOGLE_INTEGRATE - return new MemberMailResponseDto(GOOGLE_INTEGRATE, email, tmpMembers.getKakaoId(), null); - } - - throw new DuplicatedEmailException(); - } - return new MemberMailResponseDto(MAIL_SUCCESS, email, null, null); - } - - @Transactional - public MemberTokenDto IntegrationMemberToKakao(MemberIntegrationRequestDto dto, Long tmpId) { - Members existsMembers = findActiveByEmail(dto.email()); - memberRepository.deleteById(tmpId); - memberRepository.flush(); - - existsMembers.updateGoogleId(dto.googleId()); - return MemberTokenDto.from(existsMembers); - } - - @Transactional - public MemberTokenDto IntegrationMemberToGoogle(MemberIntegrationRequestDto dto, Long tmpId) { - Members existsMembers = findActiveByEmail(dto.email()); - memberRepository.deleteById(tmpId); - memberRepository.flush(); - - existsMembers.updateKakaoId(dto.kakaoId()); - return MemberTokenDto.from(existsMembers); - } - // 임시 유저 저장 @Transactional public InactiveMemberDto saveTmpKakaoMember(Long kakaoId){ diff --git a/src/main/java/com/gachtaxi/global/common/mail/dto/enums/EmailStatus.java b/src/main/java/com/gachtaxi/global/common/mail/dto/enums/EmailStatus.java deleted file mode 100644 index ee07d3b4..00000000 --- a/src/main/java/com/gachtaxi/global/common/mail/dto/enums/EmailStatus.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.gachtaxi.global.common.mail.dto.enums; - -public enum EmailStatus { - MAIL_SUCCESS, KAKAO_INTEGRATE, GOOGLE_INTEGRATE -} diff --git a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java index efbb9659..83af7252 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java +++ b/src/main/java/com/gachtaxi/global/common/mail/service/EmailService.java @@ -1,5 +1,6 @@ package com.gachtaxi.global.common.mail.service; +import com.gachtaxi.domain.members.exception.DuplicatedEmailException; import com.gachtaxi.domain.members.exception.EmailFormInvalidException; import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.global.common.mail.exception.AuthCodeNotMatchException; @@ -14,6 +15,8 @@ import java.security.SecureRandom; +import static com.gachtaxi.domain.members.entity.enums.UserStatus.ACTIVE; + @Slf4j @Service @RequiredArgsConstructor @@ -35,14 +38,15 @@ public class EmailService { @Value("${aws.ses.from}") private String senderEmail; - public void sendEmail(String recipientEmail) { - checkGachonEmail(recipientEmail); + public void sendEmail(String email) { + checkGachonEmail(email); + checkDuplicatedEmail(email); String code = generateCode(); - redisUtil.setEmailAuthCode(recipientEmail, code); + redisUtil.setEmailAuthCode(email, code); - sendAuthCodeEmail(recipientEmail, code); - log.info("\n Email: " + recipientEmail + "\n Code: " + code + "\n 전달"); + sendAuthCodeEmail(email, code); + log.info("\n Email: " + email + "\n Code: " + code + "\n 전달"); } public void checkEmailAuthCode(String recipientEmail, String inputCode) { @@ -63,6 +67,13 @@ private void checkGachonEmail(String email){ } } + public void checkDuplicatedEmail(String email){ + memberRepository.findByEmailAndStatus(email, ACTIVE). + ifPresent(members -> { + throw new DuplicatedEmailException(); + }); + } + private String generateCode() { return String.format(CODE_LENGTH, secureRandom.nextInt(BOUND) + OFFSET); } From d1c841bbf7cfd075f09afccdc26ee1157e19662e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 20:01:29 +0900 Subject: [PATCH 439/770] =?UTF-8?q?refactor:=20AuthService=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/AuthService.java | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index b8c17851..50dc6210 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -28,17 +28,14 @@ public class AuthService { private final MemberService memberService; public JwtTokenDto kakaoLogin(String authCode) { - KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); - KakaoUserInfoResponse userInfo = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); - + KakaoUserInfoResponse userInfo = getKakaoUserInfoResponse(authCode); Long kakaoId = userInfo.id(); - Optional optionalMember = memberService.findByKakaoId(kakaoId); + Optional optionalMember = memberService.findByKakaoId(kakaoId); if(optionalMember.isEmpty()) { return jwtService.generateTmpAccessToken(memberService.saveTmpKakaoMember(kakaoId)); } - // 회원 가입 진행 중 중단된 유저 또한 다시 임시 토큰을 재발급해준다. Members members = optionalMember.get(); if(members.getStatus() == INACTIVE){ return jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())); @@ -48,22 +45,37 @@ public JwtTokenDto kakaoLogin(String authCode) { } public JwtTokenDto googleLogin(String authCode) { - GoogleTokenResponse googleAccessToken = googleUtils.reqeustGoogleToken(authCode); - GoogleUserInfoResponse userInfo = googleUtils.requestGoogleProfile(googleAccessToken.access_token()); - + GoogleUserInfoResponse userInfo = getGoogleUserInfoResponse(authCode); String googleId = userInfo.id(); - Optional optionalMember = memberService.findByGoogleId(googleId); - if(optionalMember.isEmpty()) { //-> 정상 작동 확인 O + Optional optionalMember = memberService.findByGoogleId(googleId); + if(optionalMember.isEmpty()) { return jwtService.generateTmpAccessToken(memberService.saveTmpGoogleMember(googleId)); } Members members = optionalMember.get(); - if(members.getStatus() == INACTIVE){ // -> 정상 작동 확인 O + if(members.getStatus() == INACTIVE){ return jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())); } - // ACTIVE일 경우 Refresh, Access 정상 작동 확인 O return jwtService.generateJwtToken(MemberTokenDto.from(members)); } + + + /* + * refactoring + * */ + + private KakaoUserInfoResponse getKakaoUserInfoResponse(String authCode) { + KakaoAccessToken kakaoAccessToken = kakaoUtil.reqeustKakaoToken(authCode); + KakaoUserInfoResponse userInfo = kakaoUtil.requestKakaoProfile(kakaoAccessToken.access_token()); + return userInfo; + } + + private GoogleUserInfoResponse getGoogleUserInfoResponse(String authCode) { + GoogleTokenResponse googleAccessToken = googleUtils.reqeustGoogleToken(authCode); + GoogleUserInfoResponse userInfo = googleUtils.requestGoogleProfile(googleAccessToken.access_token()); + return userInfo; + } + } From b9a99b41b03495d88312598e44eb2f70be3c4e60 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 20:01:51 +0900 Subject: [PATCH 440/770] =?UTF-8?q?remove:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EB=B0=8F=20=EB=AC=B4=EC=9D=98=EB=AF=B8=ED=95=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/AuthController.java | 8 ++++---- .../gachtaxi/domain/members/service/MemberService.java | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 20a7b83f..67263877 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -48,11 +48,11 @@ public ApiResponse kakaoLogin( response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); if (jwtTokenDto.isTemporaryUser()) { // 임시 유저 - return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage(), UN_REGISTER); + return ApiResponse.response(OK, UN_REGISTER.getMessage(), UN_REGISTER); } cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); - return ApiResponse.response(HttpStatus.OK, LOGIN_SUCCESS.getMessage(), LOGIN_SUCCESS); + return ApiResponse.response(OK, LOGIN_SUCCESS.getMessage(), LOGIN_SUCCESS); } @PostMapping("/login/google") @@ -69,7 +69,7 @@ public ApiResponse googleLogin( } cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); - return ApiResponse.response(HttpStatus.OK, LOGIN_SUCCESS.getMessage(), LOGIN_SUCCESS); + return ApiResponse.response(OK, LOGIN_SUCCESS.getMessage(), LOGIN_SUCCESS); } @PostMapping("/refresh") @@ -82,7 +82,7 @@ public ApiResponse reissueRefreshToken( JwtTokenDto jwtTokenDto = jwtService.reissueJwtToken(refreshToken); responseToken(jwtTokenDto, response); - return ApiResponse.response(HttpStatus.OK, REFRESH_TOKEN_REISSUE.getMessage()); + return ApiResponse.response(OK, REFRESH_TOKEN_REISSUE.getMessage()); } @PostMapping("/code/mail") diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index c851ed75..1bbe4299 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -23,7 +23,6 @@ public class MemberService { private final MemberRepository memberRepository; - // 임시 유저 저장 @Transactional public InactiveMemberDto saveTmpKakaoMember(Long kakaoId){ Members tmpMember = Members.ofKakaoId(kakaoId); From a0dd88ac43bc65d8b4fe0dd8d775cfd1ee0e020f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 16 Jan 2025 20:05:29 +0900 Subject: [PATCH 441/770] =?UTF-8?q?fix:=20=EC=9D=91=EB=8B=B5=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/common/mail/message/ResponseMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java b/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java index ca84e31d..468bd0b9 100644 --- a/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/global/common/mail/message/ResponseMessage.java @@ -7,7 +7,7 @@ @AllArgsConstructor public enum ResponseMessage { - EMAIL_SEND_SUCCESS("이메일을 성공적으로 전송했습니다"), + EMAIL_SEND_SUCCESS("인증 번호를 발송했습니다! 이메일을 확인하세요!"), EMAIL_AUTHENTICATION_SUCESS("이메일 인증에 성공했습니다!"), AGREEEMENT_UPDATE_SUCCESS("약관 동의 정보를 업데이트 했습니다!"), SUPPLEMENT_UPDATE_SUCCESS("사용자 추가 정보를 업데이트 했습니다!"), From eef7b34a49e75e7827a880adbbc791a655fc3978 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Thu, 16 Jan 2025 22:42:05 +0900 Subject: [PATCH 442/770] =?UTF-8?q?refactor:=20=EC=9E=90=EB=8F=99=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20handlerAutoRequestMatching=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=9C=84=EB=8F=84=20=EA=B2=BD=EB=8F=84=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=82=AC=EC=9A=A9=ED=95=B4=EC=A3=BC?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/AutoMatchingService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 2428f12f..56b960b3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -42,9 +42,17 @@ public AutoMatchingPostResponse handlerAutoRequestMatching( AutoMatchingPostRequest autoMatchingPostRequest ) { List criteria = autoMatchingPostRequest.getCriteria(); + + String[] startCoordinates = autoMatchingPostRequest.startPoint().split(","); + double startLongitude = Double.parseDouble(startCoordinates[0]); + double startLatitude = Double.parseDouble(startCoordinates[1]); + + String[] destinationCoordinates = autoMatchingPostRequest.destinationPoint().split(","); + double destinationLongitude = Double.parseDouble(destinationCoordinates[0]); + double destinationLatitude = Double.parseDouble(destinationCoordinates[1]); + Optional optionalRoom = - this.matchingAlgorithmService.findRoom(memberId, autoMatchingPostRequest.startPoint(), - autoMatchingPostRequest.destinationPoint(), criteria); + this.matchingAlgorithmService.findRoom(memberId, startLongitude, startLatitude, destinationLongitude, destinationLatitude, criteria); optionalRoom .ifPresentOrElse( From d796daa036ae00c1e069547264305b0ed411d37f Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Thu, 16 Jan 2025 22:42:30 +0900 Subject: [PATCH 443/770] =?UTF-8?q?refactor:=20300m=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20=EB=B0=98=EA=B2=BD=20=EC=A7=80=EC=A0=95=20=EC=9C=84=ED=95=B4?= =?UTF-8?q?=20=EC=9C=84=EB=8F=84=20=EA=B2=BD=EB=8F=84=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/service/MatchingAlgorithmService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java index 778256e6..3bfb9247 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java @@ -11,10 +11,12 @@ public interface MatchingAlgorithmService { * 방을 찾는 메서드 * 이미 방에 들어가있는 멤버가 다시 요청했을 때 Optional.empty()를 반환하도록 로직을 구성해야함 * @param userId 방에 들어가려는 사용자 ID - * @param startPoint 매칭 시작 지점 좌표 - * @param destinationPoint 도착지 좌표 + * @param startLongitude 시작 지점 경도 + * @param startLatitude 시작 지점 위도 + * @param destinationLongitude 도착 지점 경도 + * @param destinationLatitude 도착 지점 위도 * @param criteria 방 검색에 필요한 기타 조건 (태그 등) * @return Optional - 매칭 가능한 방 정보가 있으면 값이 있고, 없으면 empty */ - Optional findRoom(Long userId, String startPoint, String destinationPoint, List criteria); + Optional findRoom(Long userId, double startLongitude, double startLatitude, double destinationLongitude, double destinationLatitude, List criteria); } From 103f446b984ccd3ef40b40c939121bed7f3f58dd Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Thu, 16 Jan 2025 22:44:18 +0900 Subject: [PATCH 444/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EB=B0=A9=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EA=B2=80=EC=83=89=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EB=B0=8F=20=EC=A4=91=EB=B3=B5=20=EC=B0=B8=EC=97=AC?= =?UTF-8?q?=20=EB=B0=A9=EC=A7=80=20=EC=BF=BC=EB=A6=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MatchingRoomRepository.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index a95e57f1..74dd3e3f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -1,10 +1,33 @@ package com.gachtaxi.domain.matching.common.repository; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; +import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.members.entity.Members; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository public interface MatchingRoomRepository extends JpaRepository { + @Query("SELECT r FROM MatchingRoom r " + + "JOIN r.matchingRoomTagInfo ti " + + "WHERE " + + "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLongitude, :startLatitude), FUNCTION('POINT', r.route.startLongitude, r.route.startLatitude)) <= 300 " + + "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= 300 " + + "AND ti.tags IN (:tags) " + + "AND r.matchingRoomStatus = 'ACTIVE'") + List findRoomsByStartAndDestinationAndTags( + @Param("startLongitude") double startLongitude, + @Param("startLatitude") double startLatitude, + @Param("destinationLongitude") double destinationLongitude, + @Param("destinationLatitude") double destinationLatitude, + @Param("tags") List tags + ); + @Query("SELECT CASE WHEN COUNT(m) > 0 THEN true ELSE false END " + + "FROM MatchingRoom r JOIN r.memberMatchingRoomChargingInfo m " + + "WHERE m.members = :user") + boolean existsByMemberInMatchingRoom(@Param("user") Members user); } From 8edc5489fd80cfb05ea5691a95fa5aa004308440 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Thu, 16 Jan 2025 22:45:08 +0900 Subject: [PATCH 445/770] =?UTF-8?q?refactor:=20saveRoute=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=9C=84=EB=8F=84=EC=99=80=20=EA=B2=BD?= =?UTF-8?q?=EB=8F=84=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 1eab6c64..703bc0ad 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -57,13 +57,22 @@ public MatchingRoom save(MatchRoomCreatedEvent matchRoomCreatedEvent) { } private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { - Route route = Route.builder() - .startLocationCoordinate(matchRoomCreatedEvent.startPoint()) - .startLocationName(matchRoomCreatedEvent.startName()) - .endLocationCoordinate(matchRoomCreatedEvent.destinationPoint()) - .endLocationName(matchRoomCreatedEvent.destinationName()) - .build(); + String[] startCoordinates = matchRoomCreatedEvent.startPoint().split(","); + double startLongitude = Double.parseDouble(startCoordinates[0]); + double startLatitude = Double.parseDouble(startCoordinates[1]); + String[] endCoordinates = matchRoomCreatedEvent.destinationPoint().split(","); + double endLongitude = Double.parseDouble(endCoordinates[0]); + double endLatitude = Double.parseDouble(endCoordinates[1]); + + Route route = Route.builder() + .startLongitude(startLongitude) + .startLatitude(startLatitude) + .startLocationName(matchRoomCreatedEvent.startName()) + .endLongitude(endLongitude) + .endLatitude(endLatitude) + .endLocationName(matchRoomCreatedEvent.destinationName()) + .build(); return this.routeRepository.save(route); } From 43382cadc3b2fe2f56f0356c61916b295ebcbd4c Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Thu, 16 Jan 2025 22:45:43 +0900 Subject: [PATCH 446/770] =?UTF-8?q?refactor:=20Route=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=9C=84=EB=8F=84=EC=99=80=20=EA=B2=BD=EB=8F=84=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/matching/common/entity/Route.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java index bb148948..1a942627 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java @@ -15,9 +15,11 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) public class Route extends BaseEntity { - private String startLocationCoordinate; + private double startLongitude; + private double startLatitude; private String startLocationName; - private String endLocationCoordinate; + private double endLongitude; + private double endLatitude; private String endLocationName; } From b305484a3c18846bca535e737796518a7eaf9698 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Thu, 16 Jan 2025 22:48:22 +0900 Subject: [PATCH 447/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B6=9C?= =?UTF-8?q?=EB=B0=9C=EC=A7=80=EC=99=80=20=EB=8F=84=EC=B0=A9=EC=A7=80=20?= =?UTF-8?q?=EC=A2=8C=ED=91=9C,=20=ED=83=9C=EA=B7=B8=20=EC=A1=B0=EA=B1=B4?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=ED=95=84=ED=84=B0=EB=A7=81=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MockMatchingAlgorithmService.java | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 655d629d..dc429675 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -4,6 +4,9 @@ import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.exception.MemberNotFoundException; +import com.gachtaxi.domain.members.repository.MemberRepository; import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; @@ -14,18 +17,46 @@ public class MockMatchingAlgorithmService implements MatchingAlgorithmService { private final MatchingRoomRepository matchingRoomRepository; + private final MemberRepository memberRepository; @Override - public Optional findRoom(Long userId, String startPoint, String destinationPoint, List criteria) { - List matchingRoomList = this.matchingRoomRepository.findAll(); - if (!matchingRoomList.isEmpty()) { - MatchingRoom matchingRoom = matchingRoomList.get(0); + public Optional findRoom(Long userId, double startLongitude, double startLatitude, double destinationLongitude, double destinationLatitude, + List criteria) { + /* + 사용자 ID로 사용자 정보 조회(이미 방에 참여하고 있는지 중복체크) + */ + Members user = memberRepository.findById(userId) + .orElseThrow(MemberNotFoundException::new); + + boolean isAlreadyInRoom = matchingRoomRepository.existsByMemberInMatchingRoom(user); + if (isAlreadyInRoom) { + return Optional.empty(); + } + /* + 출발지 기준 300m 이내 + 태그 조건에 맞는 방 검색 + */ + List matchingRooms = matchingRoomRepository.findRoomsByStartAndDestinationAndTags( + startLongitude, + startLatitude, + destinationLongitude, + destinationLatitude, + criteria + ); + /* + 조건에 맞는 방이 있으면 첫 번째 방의 상세 정보 반환 + */ + if (!matchingRooms.isEmpty()) { + MatchingRoom room = matchingRooms.get(0); return Optional.of( - FindRoomResult.builder() - .roomId(matchingRoom.getId()) - .maxCapacity(matchingRoom.getCapacity()) - .build()); + FindRoomResult.builder() + .roomId(room.getId()) + .maxCapacity(room.getCapacity()) + .build() + ); } + /* + 조건에 맞는 방이 없으면 empty 반환 + */ return Optional.empty(); } } From 243d0ee76b339831486f96a62fd6aeae26a2ca16 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 00:08:40 +0900 Subject: [PATCH 448/770] =?UTF-8?q?HOTFIX:=20=EC=9B=B9=EC=86=8C=EC=BC=93?= =?UTF-8?q?=20=EA=B2=BD=EB=A1=9C=20=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index 34c762ad..1447183f 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -14,7 +14,7 @@ public String[] getPublicUrl(){ "/swagger-ui/**", "/v3/api-docs/**", - "/ws" + "/ws/**" }; } From e13c0c3bb627a83d1c8ef65f5549d0fa2bc2644b Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 00:14:31 +0900 Subject: [PATCH 449/770] =?UTF-8?q?HOTFIX:=20SockJs=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index fb9344a4..e2e60596 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -25,7 +25,8 @@ public void registerStompEndpoints(StompEndpointRegistry registry) { registry .setErrorHandler(stompExceptionHandler) .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3000"); + .setAllowedOriginPatterns("http://localhost:3000") + .withSockJS(); } @Override From 579a8dd37487681da854b710d637a859a6dd2d91 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 00:20:54 +0900 Subject: [PATCH 450/770] =?UTF-8?q?feat:=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=EC=9D=B8=20PageNotFoundExc?= =?UTF-8?q?eption=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/PageNotFoundException.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/PageNotFoundException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/PageNotFoundException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/PageNotFoundException.java new file mode 100644 index 00000000..96e01c83 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/PageNotFoundException.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.matching.common.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +public class PageNotFoundException extends BaseException { + public PageNotFoundException() { + super(HttpStatus.NOT_FOUND, ErrorMessage.NOT_FOUND_PAGE.getMessage()); + } +} From f29a3ba530680f96ae6866ef0d2536d5eb07a8cc Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 00:21:14 +0900 Subject: [PATCH 451/770] =?UTF-8?q?feat:=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/exception/ErrorMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index f7569666..a94d9421 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -8,7 +8,8 @@ public enum ErrorMessage { NO_SUCH_MATCHING_ROOM("해당 매칭 방이 존재하지 않습니다."), - NOT_ACTIVE_MATCHING_ROOM("열린 매칭 방이 아닙니다."); + NOT_ACTIVE_MATCHING_ROOM("열린 매칭 방이 아닙니다."), + NOT_FOUND_PAGE("페이지 번호는 0 이상이어야 합니다."); private final String message; } From 24198937215f57d5bfbbff7243d0a3a8741838f2 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 00:21:37 +0900 Subject: [PATCH 452/770] =?UTF-8?q?feat:=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=ED=95=B4=EC=98=A4=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MockMatchingAlgorithmService.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index dc429675..7cb03e99 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.matching.common.exception.PageNotFoundException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.MemberNotFoundException; @@ -10,6 +11,9 @@ import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; @Service @@ -59,4 +63,16 @@ public Optional findRoom(Long userId, double startLongitude, dou */ return Optional.empty(); } + @Override + public Page findMatchingRooms(int pageNumber, int pageSize) { + + if (pageNumber < 0) { + throw new PageNotFoundException(); + } + + PageRequest pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "id")); + + return matchingRoomRepository.findAll(pageable); + } + } From 109e7d23784aa321c5b293c7f87d4184bdf62382 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 00:21:59 +0900 Subject: [PATCH 453/770] =?UTF-8?q?feat:=20=EC=9D=B8=ED=84=B0=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=EC=97=90=EC=84=9C=20findMatchingRooms=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/service/MatchingAlgorithmService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java index 3bfb9247..449548f5 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java @@ -1,9 +1,11 @@ package com.gachtaxi.domain.matching.algorithm.service; import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import java.util.List; import java.util.Optional; +import org.springframework.data.domain.Page; public interface MatchingAlgorithmService { @@ -19,4 +21,13 @@ public interface MatchingAlgorithmService { * @return Optional - 매칭 가능한 방 정보가 있으면 값이 있고, 없으면 empty */ Optional findRoom(Long userId, double startLongitude, double startLatitude, double destinationLongitude, double destinationLatitude, List criteria); + + /** + * 전체 매칭 방을 페이지 단위로 조회 + * + * @param pageNumber 페이지 번호 (0부터 시작) + * @param pageSize 한 페이지에 포함될 매칭 방의 개수 + * @return Page - 페이지별 매칭 방 정보 + */ + Page findMatchingRooms(int pageNumber, int pageSize); } From 18030a7c469051dcd746966abe056318641a42ae Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 00:27:03 +0900 Subject: [PATCH 454/770] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=EC=A4=91=EC=9D=B8=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/service/MockMatchingAlgorithmService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 7cb03e99..3fb867ed 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -32,8 +32,7 @@ public Optional findRoom(Long userId, double startLongitude, dou Members user = memberRepository.findById(userId) .orElseThrow(MemberNotFoundException::new); - boolean isAlreadyInRoom = matchingRoomRepository.existsByMemberInMatchingRoom(user); - if (isAlreadyInRoom) { + if (matchingRoomRepository.existsByMemberInMatchingRoom(user)) { return Optional.empty(); } /* From 7f4004a807af1e1efba7cb4fef09c70593ee29e1 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 00:35:56 +0900 Subject: [PATCH 455/770] =?UTF-8?q?feat:=20=ED=83=9C=EA=B7=B8=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=EC=9D=B4=20=EB=B9=84=EC=96=B4=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20findRoomsByStartAndDestination=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/repository/MatchingRoomRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index 74dd3e3f..bfc2762a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -26,6 +26,17 @@ List findRoomsByStartAndDestinationAndTags( @Param("tags") List tags ); + @Query("SELECT r FROM MatchingRoom r " + + "WHERE " + + "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLongitude, :startLatitude), FUNCTION('POINT', r.route.startLongitude, r.route.startLatitude)) <= 300 " + + "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= 300 " + + "AND r.matchingRoomStatus = 'ACTIVE'") + List findRoomsByStartAndDestination( + @Param("startLongitude") double startLongitude, + @Param("startLatitude") double startLatitude, + @Param("destinationLongitude") double destinationLongitude, + @Param("destinationLatitude") double destinationLatitude + ); @Query("SELECT CASE WHEN COUNT(m) > 0 THEN true ELSE false END " + "FROM MatchingRoom r JOIN r.memberMatchingRoomChargingInfo m " + "WHERE m.members = :user") From add4ca92e86ffc02ecc0eaa5df54660270493465 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 00:36:15 +0900 Subject: [PATCH 456/770] =?UTF-8?q?feat:=20findRoomsByStartAndDestination?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=84=9C=EB=B9=84=EC=8A=A4=20?= =?UTF-8?q?=EB=8B=A8=EC=97=90=EC=84=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MockMatchingAlgorithmService.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 3fb867ed..66955579 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -36,15 +36,29 @@ public Optional findRoom(Long userId, double startLongitude, dou return Optional.empty(); } /* - 출발지 기준 300m 이내 + 태그 조건에 맞는 방 검색 + 태그 조건이 비어있는 경우에는 위치 정보만 이용한 방 검색(300M 이내, ACTIVE 상태) */ - List matchingRooms = matchingRoomRepository.findRoomsByStartAndDestinationAndTags( - startLongitude, - startLatitude, - destinationLongitude, - destinationLatitude, - criteria - ); + List matchingRooms; + if (criteria == null || criteria.isEmpty()) { + matchingRooms = matchingRoomRepository.findRoomsByStartAndDestination( + startLongitude, + startLatitude, + destinationLongitude, + destinationLatitude + ); + } + /* + 태그 조건이 있는 경우에 위치 정보와 태그 정보를 이용한 방 검색(300M 이내, ACTIVE 상태) + */ + else { + matchingRooms = matchingRoomRepository.findRoomsByStartAndDestinationAndTags( + startLongitude, + startLatitude, + destinationLongitude, + destinationLatitude, + criteria + ); + } /* 조건에 맞는 방이 있으면 첫 번째 방의 상세 정보 반환 */ From 848e35df49abb8c4a37ba3a010be5ccc01d3cec2 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 04:28:23 +0900 Subject: [PATCH 457/770] =?UTF-8?q?refactor:=20memberService=EC=97=90=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20findById=EB=A1=9C=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/service/MockMatchingAlgorithmService.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 66955579..5bd773ff 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -6,8 +6,7 @@ import com.gachtaxi.domain.matching.common.exception.PageNotFoundException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.members.entity.Members; -import com.gachtaxi.domain.members.exception.MemberNotFoundException; -import com.gachtaxi.domain.members.repository.MemberRepository; +import com.gachtaxi.domain.members.service.MemberService; import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; @@ -21,7 +20,7 @@ public class MockMatchingAlgorithmService implements MatchingAlgorithmService { private final MatchingRoomRepository matchingRoomRepository; - private final MemberRepository memberRepository; + private final MemberService memberService; @Override public Optional findRoom(Long userId, double startLongitude, double startLatitude, double destinationLongitude, double destinationLatitude, @@ -29,8 +28,7 @@ public Optional findRoom(Long userId, double startLongitude, dou /* 사용자 ID로 사용자 정보 조회(이미 방에 참여하고 있는지 중복체크) */ - Members user = memberRepository.findById(userId) - .orElseThrow(MemberNotFoundException::new); + Members user = memberService.findById(userId); if (matchingRoomRepository.existsByMemberInMatchingRoom(user)) { return Optional.empty(); From d7fe04d96a2dda79790cb5484d61050c7edb737d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 04:56:05 +0900 Subject: [PATCH 458/770] =?UTF-8?q?feat:=20containsTag=20=ED=8A=B9?= =?UTF-8?q?=EC=A0=95=20=ED=83=9C=EA=B7=B8=EB=A5=BC=20=ED=8F=AC=ED=95=A8?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=B0=A9=EC=9D=B8=EC=A7=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=ED=95=98=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 2f51ceb6..a0b54603 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.matching.common.entity; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; +import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.CascadeType; @@ -59,4 +60,8 @@ public class MatchingRoom extends BaseEntity { public boolean isActiveMatchingRoom() { return this.matchingRoomStatus == MatchingRoomStatus.ACTIVE; } + public boolean containsTag(Tags tag) { + return this.matchingRoomTagInfo.stream() + .anyMatch(tagInfo -> tagInfo.matchesTag(tag)); + } } From a2903835795bceca5d3e762d0ed1f07ac134e65e Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 04:56:50 +0900 Subject: [PATCH 459/770] =?UTF-8?q?refactor:=20=EB=A0=88=ED=8F=AC=EC=97=90?= =?UTF-8?q?=EC=84=9C=EB=8A=94=20=EA=B1=B0=EB=A6=AC=EC=99=80=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=EB=90=9C=20=EC=A0=95=EB=B3=B4=EB=A7=8C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=ED=95=B4=EC=98=A4=EB=8F=84=EB=A1=9D=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=EB=AC=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MatchingRoomRepository.java | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index bfc2762a..93212746 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -1,7 +1,6 @@ package com.gachtaxi.domain.matching.common.repository; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; -import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.members.entity.Members; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; @@ -12,25 +11,9 @@ @Repository public interface MatchingRoomRepository extends JpaRepository { @Query("SELECT r FROM MatchingRoom r " + - "JOIN r.matchingRoomTagInfo ti " + "WHERE " + "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLongitude, :startLatitude), FUNCTION('POINT', r.route.startLongitude, r.route.startLatitude)) <= 300 " + - "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= 300 " + - "AND ti.tags IN (:tags) " + - "AND r.matchingRoomStatus = 'ACTIVE'") - List findRoomsByStartAndDestinationAndTags( - @Param("startLongitude") double startLongitude, - @Param("startLatitude") double startLatitude, - @Param("destinationLongitude") double destinationLongitude, - @Param("destinationLatitude") double destinationLatitude, - @Param("tags") List tags - ); - - @Query("SELECT r FROM MatchingRoom r " + - "WHERE " + - "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLongitude, :startLatitude), FUNCTION('POINT', r.route.startLongitude, r.route.startLatitude)) <= 300 " + - "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= 300 " + - "AND r.matchingRoomStatus = 'ACTIVE'") + "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= 300 ") List findRoomsByStartAndDestination( @Param("startLongitude") double startLongitude, @Param("startLatitude") double startLatitude, From dd9a66848c231ee03decd66c3c1beed57f473d6b Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 04:57:17 +0900 Subject: [PATCH 460/770] =?UTF-8?q?feat:=20=ED=8A=B9=EC=A0=95=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=ED=8F=AC=ED=95=A8=ED=95=98=EB=8A=94?= =?UTF-8?q?=EC=A7=80=20=ED=99=95=EC=9D=B8=ED=95=98=EB=8A=94=20matchesTag?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoomTagInfo.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java index bd21d37e..8bbad8a9 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java @@ -24,4 +24,8 @@ public class MatchingRoomTagInfo extends BaseEntity { @Enumerated(EnumType.STRING) private Tags tags; + + public boolean matchesTag(Tags tag) { + return this.tags == tag; + } } From dee5512821bec8bceaf257a8f63a08aa16fc5690 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 04:58:00 +0900 Subject: [PATCH 461/770] =?UTF-8?q?refactor:=20=ED=95=84=ED=84=B0=EB=A7=81?= =?UTF-8?q?=20=EB=B6=80=EB=B6=84=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MockMatchingAlgorithmService.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 5bd773ff..267b51fb 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -34,28 +34,27 @@ public Optional findRoom(Long userId, double startLongitude, dou return Optional.empty(); } /* - 태그 조건이 비어있는 경우에는 위치 정보만 이용한 방 검색(300M 이내, ACTIVE 상태) + 위치 정보를 이용한 방 검색(300M 이내) */ - List matchingRooms; - if (criteria == null || criteria.isEmpty()) { - matchingRooms = matchingRoomRepository.findRoomsByStartAndDestination( + List matchingRooms = matchingRoomRepository.findRoomsByStartAndDestination( startLongitude, startLatitude, destinationLongitude, destinationLatitude ); - } /* - 태그 조건이 있는 경우에 위치 정보와 태그 정보를 이용한 방 검색(300M 이내, ACTIVE 상태) + ACTIVE 상태인 방만 필터링 */ - else { - matchingRooms = matchingRoomRepository.findRoomsByStartAndDestinationAndTags( - startLongitude, - startLatitude, - destinationLongitude, - destinationLatitude, - criteria - ); + matchingRooms = matchingRooms.stream() + .filter(MatchingRoom::isActiveMatchingRoom) + .toList(); + /* + 태그 조건이 있는 경우에 태그정보까지 필터링 + */ + if (criteria != null && !criteria.isEmpty()) { + matchingRooms = matchingRooms.stream() + .filter(room -> criteria.stream().anyMatch(room::containsTag)) + .toList(); } /* 조건에 맞는 방이 있으면 첫 번째 방의 상세 정보 반환 From 53befbb8eb4ca97e74408a80c556e5547b49aa24 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 05:11:49 +0900 Subject: [PATCH 462/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EB=B0=A9=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EC=83=9D=EC=84=B1=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/DuplicatedMatchingRoomException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/DuplicatedMatchingRoomException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/DuplicatedMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/DuplicatedMatchingRoomException.java new file mode 100644 index 00000000..3d13f73f --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/DuplicatedMatchingRoomException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.DUPLICATED_MATCHING_ROOM; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +import com.gachtaxi.global.common.exception.BaseException; + +public class DuplicatedMatchingRoomException extends BaseException { + public DuplicatedMatchingRoomException() { + super(BAD_REQUEST, DUPLICATED_MATCHING_ROOM.getMessage()); + } +} From 4ce39e3d6d53804e2379607d63368994061ca9bd Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 05:12:05 +0900 Subject: [PATCH 463/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EB=B0=A9=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EC=83=9D=EC=84=B1=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/exception/ErrorMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index a94d9421..b51b80b8 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -9,6 +9,7 @@ public enum ErrorMessage { NO_SUCH_MATCHING_ROOM("해당 매칭 방이 존재하지 않습니다."), NOT_ACTIVE_MATCHING_ROOM("열린 매칭 방이 아닙니다."), + DUPLICATED_MATCHING_ROOM("이미 존재하는 매칭 방입니다."), NOT_FOUND_PAGE("페이지 번호는 0 이상이어야 합니다."); private final String message; From f5d9b527c174ed5d494d622f7b45e6da39494192 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 05:12:49 +0900 Subject: [PATCH 464/770] =?UTF-8?q?refactor:=20=EB=8F=99=EC=9D=BC=ED=95=9C?= =?UTF-8?q?=20=EC=9C=A0=EC=A0=80=EA=B0=80=20=EB=98=91=EA=B0=99=EC=9D=80=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=EC=9D=98=20=EB=B0=A9=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=8B=9C=20=EC=A4=91=EB=B3=B5=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/service/MockMatchingAlgorithmService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 267b51fb..ebb10e7d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import com.gachtaxi.domain.matching.common.exception.DuplicatedMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.PageNotFoundException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.members.entity.Members; @@ -31,7 +32,7 @@ public Optional findRoom(Long userId, double startLongitude, dou Members user = memberService.findById(userId); if (matchingRoomRepository.existsByMemberInMatchingRoom(user)) { - return Optional.empty(); + throw new DuplicatedMatchingRoomException(); // * 추후 논의 후 리팩토링 필요 * 똑같은 조건으로 방 생성시 예외 던져주기 } /* 위치 정보를 이용한 방 검색(300M 이내) From 289fea53bc7949da70c7d700823a8bc10cd142f4 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 12:42:27 +0900 Subject: [PATCH 465/770] =?UTF-8?q?refactor:=20=EB=B9=8C=EB=8D=94=ED=8C=A8?= =?UTF-8?q?=ED=84=B4=20MatchingRoom=20=EC=97=94=ED=8B=B0=ED=8B=B0=20?= =?UTF-8?q?=EB=82=B4=EB=B6=80=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoom.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index a0b54603..e625fd1e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.matching.common.entity; +import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.members.entity.Members; @@ -64,4 +65,10 @@ public boolean containsTag(Tags tag) { return this.matchingRoomTagInfo.stream() .anyMatch(tagInfo -> tagInfo.matchesTag(tag)); } + public FindRoomResult toFindRoomResult() { + return FindRoomResult.builder() + .roomId(this.getId()) + .maxCapacity(this.getCapacity()) + .build(); + } } From 68ef3a1cfd96e13fb2e53841318b98e5225c9491 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 12:42:52 +0900 Subject: [PATCH 466/770] =?UTF-8?q?refactor:=20=EC=84=9C=EB=B9=84=EC=8A=A4?= =?UTF-8?q?=EB=8B=A8=20=EB=B9=8C=EB=8D=94=20=ED=8C=A8=ED=84=B4=20=EA=B0=84?= =?UTF-8?q?=EB=8B=A8=ED=95=98=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/service/MockMatchingAlgorithmService.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index ebb10e7d..080289b4 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -62,12 +62,7 @@ public Optional findRoom(Long userId, double startLongitude, dou */ if (!matchingRooms.isEmpty()) { MatchingRoom room = matchingRooms.get(0); - return Optional.of( - FindRoomResult.builder() - .roomId(room.getId()) - .maxCapacity(room.getCapacity()) - .build() - ); + return Optional.of(room.toFindRoomResult()); } /* 조건에 맞는 방이 없으면 empty 반환 From 783fdd9f7205a238d7c7abbe35b6451fa835eb2d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 13:02:22 +0900 Subject: [PATCH 467/770] =?UTF-8?q?refactor:=20300m=20=EA=B1=B0=EB=A6=AC?= =?UTF-8?q?=20=EB=8F=99=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D=20=ED=8C=8C=EB=9D=BC=EB=AF=B8?= =?UTF-8?q?=ED=84=B0=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/repository/MatchingRoomRepository.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index 93212746..264dc0bc 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -12,13 +12,14 @@ public interface MatchingRoomRepository extends JpaRepository { @Query("SELECT r FROM MatchingRoom r " + "WHERE " + - "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLongitude, :startLatitude), FUNCTION('POINT', r.route.startLongitude, r.route.startLatitude)) <= 300 " + - "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= 300 ") + "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLongitude, :startLatitude), FUNCTION('POINT', r.route.startLongitude, r.route.startLatitude)) <= :radius " + + "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= :radius ") List findRoomsByStartAndDestination( @Param("startLongitude") double startLongitude, @Param("startLatitude") double startLatitude, @Param("destinationLongitude") double destinationLongitude, - @Param("destinationLatitude") double destinationLatitude + @Param("destinationLatitude") double destinationLatitude, + @Param("radius") double radius ); @Query("SELECT CASE WHEN COUNT(m) > 0 THEN true ELSE false END " + "FROM MatchingRoom r JOIN r.memberMatchingRoomChargingInfo m " + From c7889f6a12fc1d97c96fc9bb53e32aae78163d2d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 17 Jan 2025 13:03:20 +0900 Subject: [PATCH 468/770] =?UTF-8?q?refactor:=20SEARCH=5FRADIUS=20=EA=B1=B0?= =?UTF-8?q?=EB=A6=AC=20=EC=83=81=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/service/MockMatchingAlgorithmService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 080289b4..31ea0762 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -23,6 +23,8 @@ public class MockMatchingAlgorithmService implements MatchingAlgorithmService { private final MatchingRoomRepository matchingRoomRepository; private final MemberService memberService; + private static final double SEARCH_RADIUS = 300.0; + @Override public Optional findRoom(Long userId, double startLongitude, double startLatitude, double destinationLongitude, double destinationLatitude, List criteria) { @@ -41,7 +43,8 @@ public Optional findRoom(Long userId, double startLongitude, dou startLongitude, startLatitude, destinationLongitude, - destinationLatitude + destinationLatitude, + SEARCH_RADIUS ); /* ACTIVE 상태인 방만 필터링 From 9a0cc9a4659918b270f637d1130a98b9b17e1e9c Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:09:02 +0900 Subject: [PATCH 469/770] =?UTF-8?q?chore:=20Firebase=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle b/build.gradle index abd3ce08..b1634867 100644 --- a/build.gradle +++ b/build.gradle @@ -52,6 +52,9 @@ dependencies { // Kafka implementation 'org.springframework.kafka:spring-kafka' + // Firebase + implementation 'com.google.firebase:firebase-admin:9.4.2' + // Test testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' From a13f64a9b06d7ddc1c546a83b94cd62ea41cc4b1 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:09:40 +0900 Subject: [PATCH 470/770] =?UTF-8?q?chore:=20firebase=20=ED=82=A4=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 25cd1039..d690fba2 100644 --- a/.gitignore +++ b/.gitignore @@ -39,5 +39,5 @@ out/ src/main/resources/.env ### firebase ### -/src/main/resources/firebase/serviceAccountKey.json +/src/main/resources/serviceAccountKey.json From 54487105a3f77c87ed6df8003883bcf0817a2caa Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:10:21 +0900 Subject: [PATCH 471/770] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/entity/Notification.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/entity/Notification.java diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/Notification.java b/src/main/java/com/gachtaxi/domain/notification/entity/Notification.java new file mode 100644 index 00000000..e4717452 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/entity/Notification.java @@ -0,0 +1,69 @@ +package com.gachtaxi.domain.notification.entity; + +import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; +import com.gachtaxi.domain.notification.entity.enums.NotificationType; +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.time.LocalDateTime; + +import static com.gachtaxi.domain.notification.entity.enums.NotificationStatus.*; + +@Getter +@Entity +@SuperBuilder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Notification extends BaseEntity { + + private Long senderId; + + private Long receiverId; + + @Enumerated(EnumType.STRING) + private NotificationType type; + + private String title; + + @Column(columnDefinition = "text") + private String content; + + @Builder.Default + @Enumerated(EnumType.STRING) + private NotificationStatus status = UNREAD; + + private LocalDateTime readAt; + + public static Notification of(Long senderId, Long receiverId, NotificationType type, String content) { + return Notification.builder() + .senderId(senderId) + .receiverId(receiverId) + .type(type) + .content(content) + .build(); + } + + public static Notification of(Long receiverId, NotificationType type, String content) { + return Notification.builder() + .receiverId(receiverId) + .type(type) + .content(content) + .build(); + } + + public void read() { + this.status = READ; + this.readAt = LocalDateTime.now(); + } + + public void failToSend() { + this.status = UNSENT; + } +} From 341282d8ad9dcb3556bdb661072abc34c15abb81 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:10:31 +0900 Subject: [PATCH 472/770] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NotificationController.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java diff --git a/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java b/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java new file mode 100644 index 00000000..93a880a4 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java @@ -0,0 +1,54 @@ +package com.gachtaxi.domain.notification.controller; + +import com.gachtaxi.domain.notification.dto.response.NotificationInfoResponse; +import com.gachtaxi.domain.notification.dto.response.NotificationResponse; +import com.gachtaxi.domain.notification.service.NotificationService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Slice; +import org.springframework.web.bind.annotation.*; + +import static com.gachtaxi.domain.notification.controller.ResponseMessage.NOTIFICATION_DELETE_SUCCESS; +import static com.gachtaxi.domain.notification.controller.ResponseMessage.NOTIFICATION_GET_SUCCESS; +import static org.springframework.http.HttpStatus.OK; + +@Tag(name = "NOTIFICATION") +@RestController +@RequestMapping("/api/notifications") +@RequiredArgsConstructor +public class NotificationController { + + private final NotificationService notificationService; + + @GetMapping + @Operation(summary = "전체 알림을 조회하는 API입니다.") + public ApiResponse> getNotifications(@CurrentMemberId Long memberId, + @RequestParam int pageNum, + @RequestParam int pageSize) { + Slice response = notificationService.getNotifications(memberId, pageNum, pageSize); + + return ApiResponse.response(OK, NOTIFICATION_GET_SUCCESS.getMessage(), response); + } + + @GetMapping("/unread") + @Operation(summary = "홈에서 알림 개수와 여부를 확인하는 API입니다.") + public ApiResponse getInfo(@CurrentMemberId Long memberId) { + NotificationInfoResponse response = notificationService.getInfo(memberId); + + return ApiResponse.response(OK, NOTIFICATION_GET_SUCCESS.getMessage(), response); + } + + @DeleteMapping("/{notificationId}") + @Operation(summary = "알림을 개별 삭제하는 API입니다.") + public ApiResponse delete(@CurrentMemberId Long memberId, + @PathVariable Long notificationId) { + notificationService.delete(memberId, notificationId); + + return ApiResponse.response(OK, NOTIFICATION_DELETE_SUCCESS.getMessage()); + + } + +} From 3b32901f377677f94bd1895942694d8d80ed584e Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:10:52 +0900 Subject: [PATCH 473/770] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20dto=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/NotificationInfoResponse.java | 7 ++++ .../dto/response/NotificationResponse.java | 33 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationInfoResponse.java create mode 100644 src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java diff --git a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationInfoResponse.java b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationInfoResponse.java new file mode 100644 index 00000000..b1b551cd --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationInfoResponse.java @@ -0,0 +1,7 @@ +package com.gachtaxi.domain.notification.dto.response; + +public record NotificationInfoResponse( + int unreadCount, + boolean hasUnreadNotifications +) { +} diff --git a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java new file mode 100644 index 00000000..077569d7 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java @@ -0,0 +1,33 @@ +package com.gachtaxi.domain.notification.dto.response; + +import com.gachtaxi.domain.notification.entity.Notification; +import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; +import com.gachtaxi.domain.notification.entity.enums.NotificationType; +import lombok.Builder; + +import java.time.LocalDateTime; + +@Builder +public record NotificationResponse( + long notificationId, + long senderId, + long receiverId, + NotificationType type, + NotificationStatus status, + String title, + String content, + LocalDateTime readAt +) { + public static NotificationResponse from(Notification notification) { + return NotificationResponse.builder() + .notificationId(notification.getId()) + .senderId(notification.getSenderId()) + .receiverId(notification.getReceiverId()) + .type(notification.getType()) + .status(notification.getStatus()) + .title(notification.getTitle()) + .content(notification.getContent()) + .readAt(notification.getReadAt()) + .build(); + } +} From 61f0b74c042717202ec36f05b7752748d13b3785 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:11:05 +0900 Subject: [PATCH 474/770] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C,=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8,=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/NotificationService.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java new file mode 100644 index 00000000..053cd877 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -0,0 +1,84 @@ +package com.gachtaxi.domain.notification.service; + +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.notification.dto.response.NotificationInfoResponse; +import com.gachtaxi.domain.notification.dto.response.NotificationResponse; +import com.gachtaxi.domain.notification.entity.Notification; +import com.gachtaxi.domain.notification.entity.enums.NotificationType; +import com.gachtaxi.domain.notification.exception.MemberNotMatchException; +import com.gachtaxi.domain.notification.exception.NotificationNotFoundException; +import com.gachtaxi.domain.notification.repository.NotificationRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import static com.gachtaxi.domain.notification.entity.enums.NotificationStatus.UNREAD; +import static com.gachtaxi.domain.notification.entity.enums.NotificationStatus.UNSENT; + +@Service +@RequiredArgsConstructor +public class NotificationService { + + private final NotificationRepository notificationRepository; + private final FcmService fcmService; + + @Transactional + public Slice getNotifications(Long receiverId, int pageNum, int pageSize) { + Pageable pageable = PageRequest.of(pageNum, pageSize, Sort.by(Sort.Direction.DESC, "createDate")); + + Slice notifications = notificationRepository.findAllByReceiverId(receiverId, pageable); + notifications.forEach(Notification::read); + + return notifications + .map(NotificationResponse::from); + } + + public NotificationInfoResponse getInfo(Long receiverId) { + Integer count = notificationRepository.countAllByReceiverIdAndStatusAndStatus(receiverId, UNREAD, UNSENT); + + if (count > 0) { + return new NotificationInfoResponse(count, true); + } + + return new NotificationInfoResponse(count, false); + } + + @Transactional + public void sendWithPush(Long senderId, Members receiver, NotificationType type, String content) { + Notification notification = Notification.of(senderId, receiver.getId(), type, content); + + notificationRepository.save(notification); + fcmService.sendNotification(receiver.getFcmToken(), notification.getTitle(), notification.getContent()); + } + + @Transactional + public void sendWithOutPush(Long senderId, Members receiver, NotificationType type, String content) { + Notification notification = Notification.of(senderId, receiver.getId(), type, content); + + notificationRepository.save(notification); + } + + @Transactional + public void delete(Long receiverId, Long notificationId) { + validateMember(receiverId, notificationId); + + notificationRepository.deleteById(notificationId); + } + + private Notification find(Long notificationId) { + return notificationRepository.findById(notificationId) + .orElseThrow(NotificationNotFoundException::new); + } + + private void validateMember(long receiverId, long notificationId) { + Notification notification = find(notificationId); + + if (!notification.getReceiverId().equals(receiverId)) { + throw new MemberNotMatchException(); + } + } +} From 4c4d630fd079ea48e8b48a10022f7b54ca98b61f Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:12:26 +0900 Subject: [PATCH 475/770] =?UTF-8?q?feat:=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/MemberNotMatchException.java | 12 ++++++++++++ .../exception/NotificationNotFoundException.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/exception/MemberNotMatchException.java create mode 100644 src/main/java/com/gachtaxi/domain/notification/exception/NotificationNotFoundException.java diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/MemberNotMatchException.java b/src/main/java/com/gachtaxi/domain/notification/exception/MemberNotMatchException.java new file mode 100644 index 00000000..c8133c26 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/exception/MemberNotMatchException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.notification.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.notification.exception.ErrorMessage.INVALID_MEMBER_MATCH; +import static org.springframework.http.HttpStatus.FORBIDDEN; + +public class MemberNotMatchException extends BaseException { + public MemberNotMatchException() { + super(FORBIDDEN, INVALID_MEMBER_MATCH.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/NotificationNotFoundException.java b/src/main/java/com/gachtaxi/domain/notification/exception/NotificationNotFoundException.java new file mode 100644 index 00000000..2e98e79d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/exception/NotificationNotFoundException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.notification.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.notification.exception.ErrorMessage.NOTIFICATION_NOT_FOUND; +import static org.springframework.http.HttpStatus.NOT_FOUND; + +public class NotificationNotFoundException extends BaseException { + public NotificationNotFoundException() { + super(NOT_FOUND, NOTIFICATION_NOT_FOUND.getMessage()); + } +} From 230e1ac7d8e232ed26d7462beb75bbb188f8dac0 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:12:44 +0900 Subject: [PATCH 476/770] =?UTF-8?q?feat:=20=EC=95=88=20=EC=9D=BD=EC=9D=8C?= =?UTF-8?q?=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EA=B0=9C=EC=88=98=EC=99=80=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/NotificationRepository.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java diff --git a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java new file mode 100644 index 00000000..e6f28aad --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java @@ -0,0 +1,14 @@ +package com.gachtaxi.domain.notification.repository; + +import com.gachtaxi.domain.notification.entity.Notification; +import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface NotificationRepository extends JpaRepository { + + Integer countAllByReceiverIdAndStatusAndStatus(Long receiverId, NotificationStatus status, NotificationStatus newStatus); + + Slice findAllByReceiverId(Long receiverId, Pageable pageable); +} From 031fdbbf661ba2252b0b6b7e4e4b55cb567ac457 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:12:59 +0900 Subject: [PATCH 477/770] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EA=B3=BC=20=EC=83=81=ED=83=9C=20enum=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notification/entity/enums/NotificationStatus.java | 5 +++++ .../domain/notification/entity/enums/NotificationType.java | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationStatus.java create mode 100644 src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationStatus.java b/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationStatus.java new file mode 100644 index 00000000..7b7be866 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationStatus.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.notification.entity.enums; + +public enum NotificationStatus { + UNREAD, READ, UNSENT +} diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java b/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java new file mode 100644 index 00000000..09f43304 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.notification.entity.enums; + +public enum NotificationType { + CHAT, MATCH_SUCCESS, MATCH_FAILURE, MATCH_FINISH, FRIEND_REQUEST +} From 400b375048d21f461a94a6630ec6dac44bddedd6 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:13:22 +0900 Subject: [PATCH 478/770] =?UTF-8?q?feat:=20=EC=9D=91=EB=8B=B5=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/controller/ResponseMessage.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/controller/ResponseMessage.java diff --git a/src/main/java/com/gachtaxi/domain/notification/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/notification/controller/ResponseMessage.java new file mode 100644 index 00000000..c6b7d720 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/controller/ResponseMessage.java @@ -0,0 +1,14 @@ +package com.gachtaxi.domain.notification.controller; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ResponseMessage { + + NOTIFICATION_GET_SUCCESS("알림 조회에 성공했습니다."), + NOTIFICATION_DELETE_SUCCESS("알림 삭제에 성공했습니다."); + + private final String message; +} From 61b9b692f5ef5a1429d169dc72fda60bc4c94c86 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:14:28 +0900 Subject: [PATCH 479/770] =?UTF-8?q?feat:=20FCM=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/service/FcmService.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/service/FcmService.java diff --git a/src/main/java/com/gachtaxi/domain/notification/service/FcmService.java b/src/main/java/com/gachtaxi/domain/notification/service/FcmService.java new file mode 100644 index 00000000..d1837357 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/service/FcmService.java @@ -0,0 +1,42 @@ +package com.gachtaxi.domain.notification.service; + +import com.gachtaxi.domain.notification.exception.FcmTokenNotFoundException; +import com.gachtaxi.domain.notification.exception.InvalidFcmTokenException; +import com.google.firebase.messaging.FirebaseMessaging; +import com.google.firebase.messaging.FirebaseMessagingException; +import com.google.firebase.messaging.Message; +import com.google.firebase.messaging.Notification; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class FcmService { + + public void sendNotification(String targetToken, String title, String body) { + try{ + Message message = Message.builder() + .setToken(targetToken) + .setNotification(Notification.builder() + .setTitle(title) + .setBody(body) + .build()) + .build(); + + String response = FirebaseMessaging.getInstance().send(message); + } catch (FirebaseMessagingException e) { + handleException(e); + } + } + + private void handleException(FirebaseMessagingException exception) { + int statusCode = exception.getHttpResponse().getStatusCode(); + String errorCode = exception.getErrorCode().toString(); + + if (statusCode == 404) { + throw new FcmTokenNotFoundException(statusCode, errorCode); + } else if (statusCode == 400) { + throw new InvalidFcmTokenException(statusCode, errorCode); + } + } +} From c42e8e50a9232660aa4a0a6cb2b371cbccdf2518 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:15:15 +0900 Subject: [PATCH 480/770] =?UTF-8?q?feat:=20FirebaseConfig=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/config/FirebaseConfig.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/config/FirebaseConfig.java diff --git a/src/main/java/com/gachtaxi/global/config/FirebaseConfig.java b/src/main/java/com/gachtaxi/global/config/FirebaseConfig.java new file mode 100644 index 00000000..e736d27d --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/FirebaseConfig.java @@ -0,0 +1,43 @@ +package com.gachtaxi.global.config; + +import com.google.auth.oauth2.GoogleCredentials; +import com.google.firebase.FirebaseApp; +import com.google.firebase.FirebaseOptions; +import jakarta.annotation.PostConstruct; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; + +import java.io.IOException; +import java.io.InputStream; + +@Slf4j +@Configuration +public class FirebaseConfig { + + @Value("${firebase.adminSdk}") + private String adminSdkPath; + + @PostConstruct + public void initialize() { + + try { + ClassPathResource resource = new ClassPathResource(adminSdkPath); + + InputStream inputStream = resource.getInputStream(); + + FirebaseOptions options = FirebaseOptions.builder() + .setCredentials(GoogleCredentials.fromStream(inputStream)) + .build(); + + if (FirebaseApp.getApps().isEmpty()) { + FirebaseApp.initializeApp(options); + log.info("Firebase 설정 완료"); + } + + } catch (IOException e) { + log.warn("Firebase 설정 중 예외 발생", e); + } + } +} From 46210b866eb1b91e8db361f1f58c43f1551f9815 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:16:03 +0900 Subject: [PATCH 481/770] =?UTF-8?q?feat:=20member=20=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EB=B8=94=EC=97=90=20fcm=20token=EC=9D=84=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20API=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/MemberController.java | 23 +++++++++++++++++++ .../domain/members/entity/Members.java | 7 ++++++ .../domain/members/service/MemberService.java | 8 +++++++ 3 files changed, 38 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index 9c808b9e..35b0f311 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -1,12 +1,35 @@ package com.gachtaxi.domain.members.controller; +import com.gachtaxi.domain.members.dto.request.FcmTokenRequest; +import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import static com.gachtaxi.domain.members.controller.ResponseMessage.FCM_TOKEN_UPDATE_SUCCESS; +import static org.springframework.http.HttpStatus.OK; + +@Tag(name = "MEMBER") @RequestMapping("/api/members") @RestController @RequiredArgsConstructor public class MemberController { + private final MemberService memberService; + + @PatchMapping("/firebase") + @Operation(summary = "fcm 토큰을 저장하기 위한 API입니다. 매 로그인 혹은 토큰 리프레시가 발생할 때 저장해주세요") + public ApiResponse save(@CurrentMemberId Long memberId, + @RequestBody @Valid FcmTokenRequest request) { + memberService.updateFcmToken(memberId, request); + + return ApiResponse.response(OK, FCM_TOKEN_UPDATE_SUCCESS.getMessage()); + } } diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 1548b64f..63d4580d 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -73,6 +73,9 @@ public class Members extends BaseEntity { @ColumnDefault("false") private Boolean twoFactorAuthentication; + @Column(name = "fcm_token") + private String fcmToken; + /* * 추가할 사항 * blackList @@ -90,6 +93,10 @@ public void updateAgreement(MemberAgreementRequestDto dto) { this.marketingAgreement = dto.marketingAgreement(); } + public void updateToken(String fcmToken) { + this.fcmToken = fcmToken; + } + public void updateSupplment(MemberSupplmentRequestDto dto) { this.profilePicture = dto.profilePicture(); this.nickname = dto.nickname(); diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 173d744b..65e2afb5 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.members.dto.request.FcmTokenRequest; import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; @@ -51,6 +52,13 @@ public Optional findByKakaoId(Long kakaoId) { return memberRepository.findByKakaoId(kakaoId); } + @Transactional + public void updateFcmToken(Long userId, FcmTokenRequest request) { + Members member = findById(userId); + + member.updateToken(request.fcmToken()); + } + /* * refactor * */ From d23a6c3b2d48da57672368e3af570a363ef30587 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:16:16 +0900 Subject: [PATCH 482/770] =?UTF-8?q?feat:=20fcm=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/exception/ErrorMessage.java | 17 +++++++++++++++++ .../exception/FcmTokenNotFoundException.java | 12 ++++++++++++ .../exception/InvalidFcmTokenException.java | 12 ++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/exception/ErrorMessage.java create mode 100644 src/main/java/com/gachtaxi/domain/notification/exception/FcmTokenNotFoundException.java create mode 100644 src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/notification/exception/ErrorMessage.java new file mode 100644 index 00000000..d8463ebf --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/exception/ErrorMessage.java @@ -0,0 +1,17 @@ +package com.gachtaxi.domain.notification.exception; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ErrorMessage { + + SSE_NOT_SUBSCRIBED("SSE를 구독하고 있지 않습니다."), + NOTIFICATION_NOT_FOUND("존재하지 않는 알림입니다."), + FCM_TOKEN_NOT_FOUND(" Fcm 토큰이 존재하지 않습니다"), + INVALID_FCM_TOKEN("Fcm 토큰 형식이 올바르지 않습니다."), + INVALID_MEMBER_MATCH("알림을 삭제할 권한이 없습니다."); + + private final String message; +} diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/FcmTokenNotFoundException.java b/src/main/java/com/gachtaxi/domain/notification/exception/FcmTokenNotFoundException.java new file mode 100644 index 00000000..54f84181 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/exception/FcmTokenNotFoundException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.notification.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.domain.notification.exception.ErrorMessage.*; + +public class FcmTokenNotFoundException extends BaseException { + public FcmTokenNotFoundException(int statusCode, String statusMessage) { + super(HttpStatus.valueOf(statusCode), statusMessage + FCM_TOKEN_NOT_FOUND.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java b/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java new file mode 100644 index 00000000..317e3efd --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.notification.exception; + +import com.gachtaxi.global.common.exception.BaseException; +import org.springframework.http.HttpStatus; + +import static com.gachtaxi.domain.notification.exception.ErrorMessage.INVALID_FCM_TOKEN; + +public class InvalidFcmTokenException extends BaseException { + public InvalidFcmTokenException(int statusCode, String statusMessage) { + super(HttpStatus.valueOf(statusCode), statusMessage + INVALID_FCM_TOKEN.getMessage()); + } +} From 82fdd5833d9268fd02a3738655d9015e00b1a8aa Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:16:25 +0900 Subject: [PATCH 483/770] =?UTF-8?q?feat:=20fcmToken=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20dto=CB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/request/FcmTokenRequest.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/FcmTokenRequest.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/FcmTokenRequest.java b/src/main/java/com/gachtaxi/domain/members/dto/request/FcmTokenRequest.java new file mode 100644 index 00000000..a36ce098 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/FcmTokenRequest.java @@ -0,0 +1,8 @@ +package com.gachtaxi.domain.members.dto.request; + +import jakarta.validation.constraints.NotBlank; + +public record FcmTokenRequest( + @NotBlank String fcmToken +) { +} From 7c34c90c8f7dfe12b51f79b4aa2f38085a93d266 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:20:52 +0900 Subject: [PATCH 484/770] =?UTF-8?q?feat:=20=EC=9D=91=EB=8B=B5=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/controller/ResponseMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 5f550565..fe53834c 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -8,6 +8,7 @@ public enum ResponseMessage { // MemberController REGISTER_SUCCESS("회원가입에 성공했습니다."), + FCM_TOKEN_UPDATE_SUCCESS("FCM 토큰 업데이트에 성공했습니다."), // AuthController REFRESH_TOKEN_REISSUE("토큰 재발급에 성공했습니다."), From e3783b20bd1d4f371290d17976575b5b864f0bc9 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 14:21:11 +0900 Subject: [PATCH 485/770] =?UTF-8?q?refactor:=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/dto/response/NotificationResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java index 077569d7..6823b640 100644 --- a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java +++ b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java @@ -16,7 +16,7 @@ public record NotificationResponse( NotificationStatus status, String title, String content, - LocalDateTime readAt + LocalDateTime createdAt ) { public static NotificationResponse from(Notification notification) { return NotificationResponse.builder() @@ -27,7 +27,7 @@ public static NotificationResponse from(Notification notification) { .status(notification.getStatus()) .title(notification.getTitle()) .content(notification.getContent()) - .readAt(notification.getReadAt()) + .createdAt(notification.getCreateDate()) .build(); } } From d3ee4aa6808a511114b3966b622272470aa3fbf4 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 15:08:32 +0900 Subject: [PATCH 486/770] =?UTF-8?q?refactor:=20=EC=88=98=EC=A0=95=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/notification/exception/ErrorMessage.java | 1 - .../notification/exception/InvalidFcmTokenException.java | 3 ++- .../domain/notification/repository/NotificationRepository.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/notification/exception/ErrorMessage.java index d8463ebf..d5cbeb65 100644 --- a/src/main/java/com/gachtaxi/domain/notification/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/notification/exception/ErrorMessage.java @@ -7,7 +7,6 @@ @AllArgsConstructor public enum ErrorMessage { - SSE_NOT_SUBSCRIBED("SSE를 구독하고 있지 않습니다."), NOTIFICATION_NOT_FOUND("존재하지 않는 알림입니다."), FCM_TOKEN_NOT_FOUND(" Fcm 토큰이 존재하지 않습니다"), INVALID_FCM_TOKEN("Fcm 토큰 형식이 올바르지 않습니다."), diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java b/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java index 317e3efd..f478d279 100644 --- a/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java +++ b/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java @@ -4,9 +4,10 @@ import org.springframework.http.HttpStatus; import static com.gachtaxi.domain.notification.exception.ErrorMessage.INVALID_FCM_TOKEN; +import static org.springframework.http.HttpStatus.*; public class InvalidFcmTokenException extends BaseException { public InvalidFcmTokenException(int statusCode, String statusMessage) { - super(HttpStatus.valueOf(statusCode), statusMessage + INVALID_FCM_TOKEN.getMessage()); + super(valueOf(statusCode), statusMessage + INVALID_FCM_TOKEN.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java index e6f28aad..ccce9792 100644 --- a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java +++ b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java @@ -8,7 +8,7 @@ public interface NotificationRepository extends JpaRepository { - Integer countAllByReceiverIdAndStatusAndStatus(Long receiverId, NotificationStatus status, NotificationStatus newStatus); + Integer countAllByReceiverIdAndStatusAndStatus(Long receiverId, NotificationStatus firstCondition, NotificationStatus secondCondition); Slice findAllByReceiverId(Long receiverId, Pageable pageable); } From 2e985d32a6ea11786577c2ab2b91e11a013e41ae Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 15:09:24 +0900 Subject: [PATCH 487/770] =?UTF-8?q?chore:=20firebase=20=ED=99=98=EA=B2=BD?= =?UTF-8?q?=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 2 ++ src/main/resources/application-local.yml | 2 ++ src/main/resources/application-prod.yml | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index e1b7d7e7..6481fb5b 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -69,3 +69,5 @@ gachtaxi: auto-matching-max-capacity: ${AUTO_MATCHING_MAX_CAPACITY} auto-matcnig-description: ${AUTO_MATCHING_DESCRIPTION} +firebase: + adminSdk: ${FIREBASE_ADMIN_SDK_PATH} \ No newline at end of file diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index d362d759..73ebcc3a 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -65,3 +65,5 @@ gachtaxi: partition-count: ${KAFKA_PARTITION_COUNT} replication-factor: ${KAFKA_REPLICATION_FACTOR} +firebase: + adminSdk: ${FIREBASE_ADMIN_SDK_PATH} \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 76631a5f..a593b318 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -17,4 +17,7 @@ spring: # port: ${REDIS_PORT} # password: ${REDIS_PASSWORD} # mongodb: -# uri: ${MONGODB_URI} \ No newline at end of file +# uri: ${MONGODB_URI} + +firebase: + adminSdk: ${FIREBASE_ADMIN_SDK_PATH} \ No newline at end of file From 03803d88b6df04e2b1e85730745133647fb6859d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 17 Jan 2025 17:52:56 +0900 Subject: [PATCH 488/770] =?UTF-8?q?refactor:=20chatstatus=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/dto/response/ChattingRoomResponse.java | 4 ++-- .../domain/chat/entity/ChattingParticipant.java | 14 +++++++------- .../gachtaxi/domain/chat/entity/ChattingRoom.java | 6 +++--- .../entity/enums/{Status.java => ChatStatus.java} | 2 +- .../chat/service/ChattingParticipantService.java | 4 ++-- .../domain/chat/service/ChattingRoomService.java | 4 ++-- .../handler/CustomMessageExceptionHandler.java | 4 ++-- .../exception/handler/GlobalExceptionHandler.java | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) rename src/main/java/com/gachtaxi/domain/chat/entity/enums/{Status.java => ChatStatus.java} (73%) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomResponse.java index 9fce29dc..d6b32522 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomResponse.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomResponse.java @@ -1,11 +1,11 @@ package com.gachtaxi.domain.chat.dto.response; import com.gachtaxi.domain.chat.entity.ChattingRoom; -import com.gachtaxi.domain.chat.entity.enums.Status; +import com.gachtaxi.domain.chat.entity.enums.ChatStatus; public record ChattingRoomResponse( Long roomId, - Status status + ChatStatus status ) { public static ChattingRoomResponse from(ChattingRoom chattingRoom) { return new ChattingRoomResponse(chattingRoom.getId(), chattingRoom.getStatus()); diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 96fe7a21..c2b45779 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -1,6 +1,6 @@ package com.gachtaxi.domain.chat.entity; -import com.gachtaxi.domain.chat.entity.enums.Status; +import com.gachtaxi.domain.chat.entity.enums.ChatStatus; import com.gachtaxi.domain.chat.exception.UnSubscriptionException; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.common.entity.BaseEntity; @@ -30,7 +30,7 @@ public class ChattingParticipant extends BaseEntity { @Builder.Default @Enumerated(EnumType.STRING) - private Status status = Status.ACTIVE; + private ChatStatus status = ChatStatus.ACTIVE; @CreatedDate @Column(updatable = false) @@ -46,23 +46,23 @@ public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) } public void checkSubscriptionStatus() { - if (this.status == Status.INACTIVE) { + if (this.status == ChatStatus.INACTIVE) { throw new UnSubscriptionException(); } } public void subscribe() { - this.status = Status.ACTIVE; + this.status = ChatStatus.ACTIVE; } public void unsubscribe() { - this.status = Status.INACTIVE; + this.status = ChatStatus.INACTIVE; this.disconnectedAt = LocalDateTime.now(); } public void disconnect() { - if (this.status == Status.ACTIVE) { - this.status = Status.INACTIVE; + if (this.status == ChatStatus.ACTIVE) { + this.status = ChatStatus.INACTIVE; this.disconnectedAt = LocalDateTime.now(); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java index febc341a..7a86d219 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingRoom.java @@ -1,6 +1,6 @@ package com.gachtaxi.domain.chat.entity; -import com.gachtaxi.domain.chat.entity.enums.Status; +import com.gachtaxi.domain.chat.entity.enums.ChatStatus; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -16,9 +16,9 @@ public class ChattingRoom extends BaseEntity { @Builder.Default @Enumerated(EnumType.STRING) - private Status status = Status.ACTIVE; + private ChatStatus status = ChatStatus.ACTIVE; public void delete() { - status = Status.INACTIVE; + status = ChatStatus.INACTIVE; } } diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/enums/Status.java b/src/main/java/com/gachtaxi/domain/chat/entity/enums/ChatStatus.java similarity index 73% rename from src/main/java/com/gachtaxi/domain/chat/entity/enums/Status.java rename to src/main/java/com/gachtaxi/domain/chat/entity/enums/ChatStatus.java index 94a11fb6..2bb1d2ab 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/enums/Status.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/enums/ChatStatus.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.chat.entity.enums; -public enum Status { +public enum ChatStatus { ACTIVE, INACTIVE } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 03ba60aa..6533ee25 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -2,7 +2,7 @@ import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; -import com.gachtaxi.domain.chat.entity.enums.Status; +import com.gachtaxi.domain.chat.entity.enums.ChatStatus; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; @@ -52,7 +52,7 @@ public void delete(ChattingParticipant chattingParticipant) { } private void checkDuplicateSubscription(ChattingParticipant chattingParticipant) { - if (chattingParticipant.getStatus() == Status.ACTIVE) { + if (chattingParticipant.getStatus() == ChatStatus.ACTIVE) { throw new DuplicateSubscribeException(); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index a5f2251b..25ba3b2e 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -6,7 +6,7 @@ import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; import com.gachtaxi.domain.chat.entity.enums.MessageType; -import com.gachtaxi.domain.chat.entity.enums.Status; +import com.gachtaxi.domain.chat.entity.enums.ChatStatus; import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; @@ -89,7 +89,7 @@ public void exitChatRoom(long roomId, long senderId) { public ChattingRoom find(long chattingRoomId) { return chattingRoomRepository.findById(chattingRoomId) - .filter(chattingRoom -> chattingRoom.getStatus() == Status.ACTIVE) + .filter(chattingRoom -> chattingRoom.getStatus() == ChatStatus.ACTIVE) .orElseThrow(ChattingRoomNotFoundException::new); } diff --git a/src/main/java/com/gachtaxi/global/common/exception/handler/CustomMessageExceptionHandler.java b/src/main/java/com/gachtaxi/global/common/exception/handler/CustomMessageExceptionHandler.java index ac13e8ff..08ff529b 100644 --- a/src/main/java/com/gachtaxi/global/common/exception/handler/CustomMessageExceptionHandler.java +++ b/src/main/java/com/gachtaxi/global/common/exception/handler/CustomMessageExceptionHandler.java @@ -7,12 +7,12 @@ import org.springframework.messaging.simp.annotation.SendToUser; import org.springframework.web.bind.annotation.ControllerAdvice; -import static com.gachtaxi.global.common.exception.handler.GlobalExceptionHandler.LOG_FORMAT; - @Slf4j @ControllerAdvice public class CustomMessageExceptionHandler { + private static final String LOG_FORMAT = "Class: {}, Code : {}, Message : {}"; + @MessageExceptionHandler(RuntimeException.class) @SendToUser(destinations = "/queue/errors", broadcast = false) public ApiResponse handleRuntimeException(RuntimeException e) { diff --git a/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java b/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java index ef377d97..c26d87f5 100644 --- a/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/gachtaxi/global/common/exception/handler/GlobalExceptionHandler.java @@ -21,7 +21,7 @@ public class GlobalExceptionHandler { // response format - public static final String LOG_FORMAT = "Class: {}, Code : {}, Message : {}"; + private static final String LOG_FORMAT = "Class: {}, Code : {}, Message : {}"; private static final String VALID_EXCEPTION = "Validation failed"; @ExceptionHandler(BaseException.class) From de727bc1b360762458b8c824615454fc92a13d11 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 18 Jan 2025 09:55:19 +0900 Subject: [PATCH 489/770] =?UTF-8?q?fix:=20=EC=A0=95=EC=A0=81=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/exception/DuplicatedNickNameException.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedNickNameException.java b/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedNickNameException.java index dec96c92..f7c294f8 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedNickNameException.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/DuplicatedNickNameException.java @@ -1,12 +1,12 @@ package com.gachtaxi.domain.members.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; import static com.gachtaxi.domain.members.exception.ErrorMessage.DUPLICATED_NICKNAME; +import static org.springframework.http.HttpStatus.BAD_REQUEST; public class DuplicatedNickNameException extends BaseException { public DuplicatedNickNameException() { - super(HttpStatus.BAD_REQUEST, DUPLICATED_NICKNAME.getMessage()); + super(BAD_REQUEST, DUPLICATED_NICKNAME.getMessage()); } } From 3d354194195b75c4f19ef14cf4d9f5dfe34d1b74 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 18 Jan 2025 09:55:34 +0900 Subject: [PATCH 490/770] =?UTF-8?q?fix:=20Members=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/entity/Members.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 746c806c..5a81b79e 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -81,17 +81,11 @@ public class Members extends BaseEntity { * */ public boolean hasKakaoId(){ - if(kakaoId == null){ - return false; - } - return true; + return kakaoId != null; } public boolean hasGoogleId(){ - if(googleId == null){ - return false; - } - return true; + return googleId != null; } public void updateEmail(String email) { From ee547dfb6d8718b3021c26cc5e1041fdb9dadcd6 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 18 Jan 2025 09:56:03 +0900 Subject: [PATCH 491/770] =?UTF-8?q?docs:=20=ED=86=B5=ED=95=A9=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=84=A4?= =?UTF-8?q?=EB=AA=85=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/controller/AuthController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 67263877..4fe27616 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -86,7 +86,7 @@ public ApiResponse reissueRefreshToken( } @PostMapping("/code/mail") - @Operation(summary = "이메일 인증 코드를 보내는 API입니다. 기존 가입자의 경우 통합 로그인을 해주세요.") + @Operation(summary = "이메일 인증 코드를 보내는 API입니다.") public ApiResponse sendEmail( @RequestBody @Valid EmailAddressDto emailDto, @CurrentMemberId Long userId From 311f2301d44be573192a73684ae7438fc1f6fbe5 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 18 Jan 2025 10:02:53 +0900 Subject: [PATCH 492/770] =?UTF-8?q?fix:=20@Builder.Default=EB=A1=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/entity/Members.java | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 5a81b79e..f61773e9 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -8,6 +8,7 @@ import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.*; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -45,33 +46,39 @@ public class Members extends BaseEntity { private String googleId; @Enumerated(EnumType.STRING) - private Role role; + @Builder.Default + private Role role = Role.MEMBER; @Enumerated(EnumType.STRING) private Gender gender; @Enumerated(EnumType.STRING) - private UserStatus status; + @Builder.Default + private UserStatus status = UserStatus.INACTIVE; // 이용 약관 동의 @Column(name = "terms_agreement") - @ColumnDefault("true") - private Boolean termsAgreement; + @ColumnDefault("false") + @Builder.Default + private Boolean termsAgreement = false; // 개인정보 수집 동의 @Column(name = "privacy_agreement") - @ColumnDefault("true") - private Boolean privacyAgreement; + @ColumnDefault("false") + @Builder.Default + private Boolean privacyAgreement = false; // 광고성 정보 수신 동의 @Column(name = "marketing_agreement") @ColumnDefault("false") - private Boolean marketingAgreement; + @Builder.Default + private Boolean marketingAgreement = false; // 2차 인증 (전화번호) @Column(name = "two_factor_authentication") @ColumnDefault("false") - private Boolean twoFactorAuthentication; + @Builder.Default + private Boolean twoFactorAuthentication = false; /* * 추가할 사항 @@ -118,24 +125,12 @@ public void updateSupplment(MemberSupplmentRequestDto dto) { public static Members ofKakaoId(Long kakaoId){ return Members.builder() .kakaoId(kakaoId) - .status(UserStatus.INACTIVE) - .role(Role.MEMBER) - .termsAgreement(false) - .privacyAgreement(false) - .marketingAgreement(false) - .twoFactorAuthentication(false) .build(); } public static Members ofGoogleId(String googleId){ return Members.builder() .googleId(googleId) - .status(UserStatus.INACTIVE) - .role(Role.MEMBER) - .termsAgreement(false) - .privacyAgreement(false) - .marketingAgreement(false) - .twoFactorAuthentication(false) .build(); } } From f3b3e2f9835d4e5146e37164d5d85754432fe123 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sat, 18 Jan 2025 17:23:39 +0900 Subject: [PATCH 493/770] =?UTF-8?q?feat:=20chatRoomRedisTemplate=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/config/RedisConfig.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/RedisConfig.java b/src/main/java/com/gachtaxi/global/config/RedisConfig.java index 1de0f55c..295be35e 100644 --- a/src/main/java/com/gachtaxi/global/config/RedisConfig.java +++ b/src/main/java/com/gachtaxi/global/config/RedisConfig.java @@ -14,6 +14,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.listener.PatternTopic; import org.springframework.data.redis.listener.RedisMessageListenerContainer; +import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; @@ -76,13 +77,13 @@ public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnecti return container; } - // @Bean - // @Qualifier("jwtRedisTemplate") - // public RedisTemplate jwtRedisTemplate(RedisConnectionFactory factory) { - // RedisTemplate redisTemplate = new RedisTemplate<>(); - // redisTemplate.setConnectionFactory(factory); - // redisTemplate.setKeySerializer(new StringRedisSerializer()); - // redisTemplate.setValueSerializer(new StringRedisSerializer()); - // return redisTemplate; - // } + @Bean + @Qualifier("chatRoomRedisTemplate") + public RedisTemplate chatRoomRedisTemplate(RedisConnectionFactory factory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(factory); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); + return redisTemplate; + } } From 2192fecefb404cef40ce0a37f1fb59ce5a534bc3 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sat, 18 Jan 2025 17:25:28 +0900 Subject: [PATCH 494/770] =?UTF-8?q?feat:=20=EC=B0=B8=EC=97=AC=EC=9E=90=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A0=80=EC=9E=A5=EC=97=90=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=A0=20ChatRedisService=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChatRedisService.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java new file mode 100644 index 00000000..3e7d1697 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java @@ -0,0 +1,38 @@ +package com.gachtaxi.domain.chat.service; + +import com.gachtaxi.domain.chat.exception.UnSubscriptionException; +import lombok.RequiredArgsConstructor; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ChatRedisService { + public static final String REDIS_CHAT_KEY_PREFIX = "ROOM:"; + + private final RedisTemplate chatRoomRedisTemplate; + + public void saveSubscribeMember(long roomId, long senderId) { + String key = REDIS_CHAT_KEY_PREFIX + roomId; + + chatRoomRedisTemplate.opsForSet().add(key, senderId); + } + + public boolean isActive(long roomId, long senderId) { + String key = REDIS_CHAT_KEY_PREFIX + roomId; + + return Boolean.TRUE.equals(chatRoomRedisTemplate.opsForSet().isMember(key, senderId)); + } + + public void removeSubscribeMember(long roomId, long senderId) { + String key = REDIS_CHAT_KEY_PREFIX + roomId; + + chatRoomRedisTemplate.opsForSet().remove(key, senderId); + } + + public void checkSubscriptionStatus(long roomId, long senderId) { + if (!isActive(roomId, senderId)) { + throw new UnSubscriptionException(); + } + } +} From 11f6412c47f42b1faa317367662ac8153df2f4d3 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sat, 18 Jan 2025 17:26:23 +0900 Subject: [PATCH 495/770] =?UTF-8?q?refactor:=20=EC=B0=B8=EC=97=AC=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EA=B4=80=EB=A6=AC=EB=A5=BC=20redis?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/entity/ChattingParticipant.java | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index c2b45779..9adb1753 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -1,12 +1,12 @@ package com.gachtaxi.domain.chat.entity; -import com.gachtaxi.domain.chat.entity.enums.ChatStatus; -import com.gachtaxi.domain.chat.exception.UnSubscriptionException; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.common.entity.BaseEntity; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -28,10 +28,6 @@ public class ChattingParticipant extends BaseEntity { @JoinColumn(name = "members_id") private Members members; - @Builder.Default - @Enumerated(EnumType.STRING) - private ChatStatus status = ChatStatus.ACTIVE; - @CreatedDate @Column(updatable = false) private LocalDateTime joinedAt; @@ -45,25 +41,11 @@ public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) .build(); } - public void checkSubscriptionStatus() { - if (this.status == ChatStatus.INACTIVE) { - throw new UnSubscriptionException(); - } - } - - public void subscribe() { - this.status = ChatStatus.ACTIVE; - } - public void unsubscribe() { - this.status = ChatStatus.INACTIVE; this.disconnectedAt = LocalDateTime.now(); } public void disconnect() { - if (this.status == ChatStatus.ACTIVE) { - this.status = ChatStatus.INACTIVE; - this.disconnectedAt = LocalDateTime.now(); - } + this.disconnectedAt = LocalDateTime.now(); } } From 4324d496be79e9a372bde49f89de664ad82a4dfc Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sat, 18 Jan 2025 17:26:31 +0900 Subject: [PATCH 496/770] =?UTF-8?q?refactor:=20=EC=B0=B8=EC=97=AC=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EA=B4=80=EB=A6=AC=EB=A5=BC=20redis?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/ChattingParticipantService.java | 10 +++++----- .../gachtaxi/domain/chat/service/ChattingService.java | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 6533ee25..620c6711 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -2,7 +2,6 @@ import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; -import com.gachtaxi.domain.chat.entity.enums.ChatStatus; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; @@ -17,6 +16,7 @@ public class ChattingParticipantService { private final ChattingParticipantRepository chattingParticipantRepository; + private final ChatRedisService chatRedisService; public void save(ChattingParticipant chattingParticipant) { chattingParticipantRepository.save(chattingParticipant); @@ -38,8 +38,8 @@ public boolean checkSubscription(ChattingRoom chattingRoom, Members members) { if (optionalParticipant.isPresent()) { ChattingParticipant chattingParticipant = optionalParticipant.get(); - checkDuplicateSubscription(chattingParticipant); - chattingParticipant.subscribe(); + checkDuplicateSubscription(chattingRoom.getId(), members.getId()); + chatRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); return true; } @@ -51,8 +51,8 @@ public void delete(ChattingParticipant chattingParticipant) { chattingParticipantRepository.delete(chattingParticipant); } - private void checkDuplicateSubscription(ChattingParticipant chattingParticipant) { - if (chattingParticipant.getStatus() == ChatStatus.ACTIVE) { + private void checkDuplicateSubscription(long roomId, long memberId) { + if (chatRedisService.isActive(roomId, memberId)) { throw new DuplicateSubscribeException(); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index b216ce36..2f4bf789 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -40,6 +40,7 @@ public class ChattingService { private final ChattingRoomService chattingRoomService; private final ChattingParticipantService chattingParticipantService; private final MemberService memberService; + private final ChatRedisService chatRedisService; @Value("${chat.topic}") public String chatTopic; @@ -62,7 +63,7 @@ public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int p Members members = memberService.findById(senderId); ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); - chattingParticipant.checkSubscriptionStatus(); + chatRedisService.checkSubscriptionStatus(roomId, senderId); Slice chattingMessages = loadMessage(roomId, chattingParticipant, pageNumber, pageSize, lastMessageTimeStamp); From 8fd210ad2dd689a01e402482f320532c0c624efa Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:56:13 +0900 Subject: [PATCH 497/770] =?UTF-8?q?refactor:=20=EC=BB=AC=EB=9F=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=ED=8C=A9=ED=86=A0=EB=A6=AC=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/dto/request/ChatMessage.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index 805fbd27..b342167a 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -1,5 +1,7 @@ package com.gachtaxi.domain.chat.dto.request; +import com.gachtaxi.domain.chat.dto.response.ReadMessageRange; +import com.gachtaxi.domain.chat.entity.ChattingMessage; import com.gachtaxi.domain.chat.entity.enums.MessageType; import lombok.Builder; @@ -7,30 +9,35 @@ @Builder public record ChatMessage( + String messageId, Long roomId, Long senderId, String senderName, String message, + ReadMessageRange range, + Long unreadCount, LocalDateTime timeStamp, MessageType messageType ) { - public static ChatMessage of(ChatMessageRequest request, long roomId, long senderId, String senderName) { + public static ChatMessage from(ChattingMessage chattingMessage) { return ChatMessage.builder() - .roomId(roomId) - .senderId(senderId) - .senderName(senderName) - .message(request.message()) - .timeStamp(LocalDateTime.now()) - .messageType(MessageType.MESSAGE) + .messageId(chattingMessage.getId()) + .roomId(chattingMessage.getRoomId()) + .senderId(chattingMessage.getSenderId()) + .senderName(chattingMessage.getSenderName()) + .message(chattingMessage.getMessage()) + .unreadCount(chattingMessage.getUnreadCount()) + .timeStamp(chattingMessage.getTimeStamp()) + .messageType(chattingMessage.getMessageType()) .build(); } - public static ChatMessage of(long roomId, Long senderId, String senderName, String message, MessageType messageType) { + public static ChatMessage of(long roomId, Long senderId, String senderName, ReadMessageRange range, MessageType messageType) { return ChatMessage.builder() .roomId(roomId) .senderId(senderId) .senderName(senderName) - .message(message) + .range(range) .timeStamp(LocalDateTime.now()) .messageType(messageType) .build(); From 4f1f9dc2de427fb4fb15f982c4ebb30b6aff0b51 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:56:24 +0900 Subject: [PATCH 498/770] =?UTF-8?q?refactor:=20=EC=BB=AC=EB=9F=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=ED=8C=A9=ED=86=A0=EB=A6=AC=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/dto/response/ChattingMessageResponse.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java index 9b6509c8..088c9d18 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java @@ -8,15 +8,21 @@ @Builder public record ChattingMessageResponse( + String messageId, + Long senderId, String senderName, String message, + Long unreadCount, LocalDateTime timeStamp, MessageType messageType ) { public static ChattingMessageResponse from(ChattingMessage chattingMessage) { return ChattingMessageResponse.builder() + .messageId(chattingMessage.getId()) + .senderId(chattingMessage.getSenderId()) .senderName(chattingMessage.getSenderName()) .message(chattingMessage.getMessage()) + .unreadCount(chattingMessage.getUnreadCount()) .timeStamp(chattingMessage.getTimeStamp()) .messageType(chattingMessage.getMessageType()) .build(); From dcfb7482c0339d077890643767477395c0273c6a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:56:34 +0900 Subject: [PATCH 499/770] =?UTF-8?q?refactor:=20unreadCount=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=ED=8C=A9=ED=86=A0=EB=A6=AC=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/entity/ChattingMessage.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java index a06e2254..4f75f4c8 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java @@ -1,6 +1,6 @@ package com.gachtaxi.domain.chat.entity; -import com.gachtaxi.domain.chat.dto.request.ChatMessage; +import com.gachtaxi.domain.chat.dto.request.ChatMessageRequest; import com.gachtaxi.domain.chat.entity.enums.MessageType; import jakarta.persistence.Id; import lombok.AccessLevel; @@ -29,6 +29,8 @@ public class ChattingMessage { private String message; + private Long unreadCount; + private MessageType messageType; private LocalDateTime timeStamp; @@ -36,14 +38,26 @@ public class ChattingMessage { @LastModifiedDate private LocalDateTime updatedAt; - public static ChattingMessage from(ChatMessage chatMessage) { + public static ChattingMessage of(ChatMessageRequest request, long roomId, long senderId, String senderName, long unreadCount) { + return ChattingMessage.builder() + .senderId(senderId) + .senderName(senderName) + .roomId(roomId) + .message(request.message()) + .unreadCount(unreadCount) + .messageType(MessageType.MESSAGE) + .timeStamp(LocalDateTime.now()) + .build(); + } + + public static ChattingMessage of(long roomId, Long senderId, String senderName, String message, MessageType messageType) { return ChattingMessage.builder() - .senderId(chatMessage.senderId()) - .senderName(chatMessage.senderName()) - .roomId(chatMessage.roomId()) - .message(chatMessage.message()) - .timeStamp(chatMessage.timeStamp()) - .messageType(chatMessage.messageType()) + .senderId(senderId) + .senderName(senderName) + .roomId(roomId) + .message(message) + .messageType(messageType) + .timeStamp(LocalDateTime.now()) .build(); } } From 2da2c70daab548afc8003fbc6894c71e2e58bee6 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:56:43 +0900 Subject: [PATCH 500/770] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/dto/response/ChatResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java index 60f64ff1..830cfb83 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java @@ -16,7 +16,7 @@ public record ChatResponse( public static ChatResponse of(ChattingParticipant chattingParticipant, List chattingMessages, ChatPageableResponse chatPageableResponse) { return ChatResponse.builder() .memberId(chattingParticipant.getMembers().getId()) - .disconnectedAt(chattingParticipant.getDisconnectedAt()) + .disconnectedAt(chattingParticipant.getLastReadAt()) .chattingMessage(chattingMessages) .pageable(chatPageableResponse) .build(); From 46b90bbf3645951eac325f8a02419395ef677fb2 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:57:29 +0900 Subject: [PATCH 501/770] =?UTF-8?q?feat:=20=EA=B3=B5=ED=86=B5=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EB=B6=84=EB=A6=AC=20=EB=B0=8F=20=EC=8B=A4?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EC=B0=B8=EC=97=AC=EC=9E=90=20=EC=88=AB?= =?UTF-8?q?=EC=9E=90=20=EB=B0=98=ED=99=98=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChatRedisService.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java index 3e7d1697..b5ffa613 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.chat.service; +import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.exception.UnSubscriptionException; import lombok.RequiredArgsConstructor; import org.springframework.data.redis.core.RedisTemplate; @@ -13,19 +14,19 @@ public class ChatRedisService { private final RedisTemplate chatRoomRedisTemplate; public void saveSubscribeMember(long roomId, long senderId) { - String key = REDIS_CHAT_KEY_PREFIX + roomId; + String key = getKey(roomId); chatRoomRedisTemplate.opsForSet().add(key, senderId); } public boolean isActive(long roomId, long senderId) { - String key = REDIS_CHAT_KEY_PREFIX + roomId; + String key = getKey(roomId); return Boolean.TRUE.equals(chatRoomRedisTemplate.opsForSet().isMember(key, senderId)); } public void removeSubscribeMember(long roomId, long senderId) { - String key = REDIS_CHAT_KEY_PREFIX + roomId; + String key = getKey(roomId); chatRoomRedisTemplate.opsForSet().remove(key, senderId); } @@ -35,4 +36,20 @@ public void checkSubscriptionStatus(long roomId, long senderId) { throw new UnSubscriptionException(); } } + + public long getSubscriberCount(long roomId) { + String key = getKey(roomId); + + Long size = chatRoomRedisTemplate.opsForSet().size(key); + + if (size == null) { + throw new ChattingRoomNotFoundException(); + } + + return size; + } + + private String getKey(long roomId) { + return REDIS_CHAT_KEY_PREFIX + roomId; + } } From dd2f27c3ca22365cf5cf98d1652da7c36e3443cd Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:57:39 +0900 Subject: [PATCH 502/770] =?UTF-8?q?feat:=20=EB=B3=80=EC=88=98=20=EB=AA=85?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/entity/ChattingParticipant.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 9adb1753..8a14ed3c 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -32,7 +32,8 @@ public class ChattingParticipant extends BaseEntity { @Column(updatable = false) private LocalDateTime joinedAt; - private LocalDateTime disconnectedAt; + @CreatedDate + private LocalDateTime lastReadAt; public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) { return ChattingParticipant.builder() @@ -41,11 +42,15 @@ public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) .build(); } + public void reSubscribe() { + this.lastReadAt = LocalDateTime.now(); + } + public void unsubscribe() { - this.disconnectedAt = LocalDateTime.now(); + this.lastReadAt = LocalDateTime.now(); } public void disconnect() { - this.disconnectedAt = LocalDateTime.now(); + this.lastReadAt = LocalDateTime.now(); } } From 7652d6d2bd0fa24ae718e8f2192e2e10999e042b Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:57:51 +0900 Subject: [PATCH 503/770] =?UTF-8?q?feat:=20=EC=A0=84=EC=B2=B4=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC=EC=9E=90=20=EC=88=98=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/repository/ChattingParticipantRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java index 0b264dc0..1eb70788 100644 --- a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingParticipantRepository.java @@ -12,4 +12,6 @@ public interface ChattingParticipantRepository extends JpaRepository findByChattingRoomAndMembers(ChattingRoom chattingRoom, Members member); Optional findByChattingRoomIdAndMembersId(long roomId, long memberId); + + long countByChattingRoomId(long chattingRoomId); } From df44bc626473c2e3d712bb8ab7c3644abc68db42 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:58:35 +0900 Subject: [PATCH 504/770] =?UTF-8?q?feat:=20=EC=9E=AC=EC=9E=85=EC=9E=A5=20?= =?UTF-8?q?=EC=8B=9C=20=EC=9D=BD=EC=9D=8C=20=EC=B2=98=EB=A6=AC=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ChattingParticipantService.java | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 620c6711..8108b47c 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -1,22 +1,43 @@ package com.gachtaxi.domain.chat.service; +import com.gachtaxi.domain.chat.dto.request.ChatMessage; +import com.gachtaxi.domain.chat.dto.response.ReadMessageRange; +import com.gachtaxi.domain.chat.entity.ChattingMessage; import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.entity.enums.MessageType; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; +import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; import com.gachtaxi.domain.members.entity.Members; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Sort; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.core.query.Update; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.Optional; +@Slf4j @Service @RequiredArgsConstructor public class ChattingParticipantService { private final ChattingParticipantRepository chattingParticipantRepository; private final ChatRedisService chatRedisService; + private final MongoTemplate mongoTemplate; + private final RedisChatPublisher redisChatPublisher; + + @Value("${chat.topic}") + public String chatTopic; public void save(ChattingParticipant chattingParticipant) { chattingParticipantRepository.save(chattingParticipant); @@ -39,7 +60,14 @@ public boolean checkSubscription(ChattingRoom chattingRoom, Members members) { ChattingParticipant chattingParticipant = optionalParticipant.get(); checkDuplicateSubscription(chattingRoom.getId(), members.getId()); - chatRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); + + updateUnreadCount(chattingRoom.getId(), chattingParticipant.getLastReadAt(), members.getId()); + + Pair pair = getUpdatedMessageRange(chattingRoom.getId(), chattingParticipant.getLastReadAt(), members.getId()); + + reEnterEvent(chattingRoom.getId(), members.getId(), members.getNickname(), ReadMessageRange.of(pair)); + + chattingParticipant.reSubscribe(); return true; } @@ -51,9 +79,58 @@ public void delete(ChattingParticipant chattingParticipant) { chattingParticipantRepository.delete(chattingParticipant); } + public long getParticipantCount(Long roomId) { + return chattingParticipantRepository.countByChattingRoomId(roomId); + } + private void checkDuplicateSubscription(long roomId, long memberId) { if (chatRedisService.isActive(roomId, memberId)) { + log.info("memberId {}", memberId); throw new DuplicateSubscribeException(); } } + + public void updateUnreadCount(Long roomId, LocalDateTime lastReadAt, Long senderId) { + Query query = new Query().addCriteria( + Criteria.where("roomId").is(roomId) + .and("timeStamp").gt(lastReadAt) + .and("senderId").ne(senderId) + .and("unreadCount").gt(0) + ); + + Update update = new Update().inc("unreadCount", -1); + + mongoTemplate.updateMulti(query, update, ChattingMessage.class); + } + + public Pair getUpdatedMessageRange(Long roomId, LocalDateTime lastReadAt, Long senderId) { + Query minQuery = new Query().addCriteria( + Criteria.where("roomId").is(roomId) + .and("timeStamp").gt(lastReadAt) + .and("senderId").ne(senderId) + .and("unreadCount").gt(0) + ).with(Sort.by(Sort.Direction.ASC, "_id")).limit(1); + + Query maxQuery = new Query().addCriteria( + Criteria.where("roomId").is(roomId) + .and("timeStamp").gt(lastReadAt) + .and("senderId").ne(senderId) + .and("unreadCount").gt(0) + ).with(Sort.by(Sort.Direction.DESC, "_id")).limit(1); + + ChattingMessage minMessage = mongoTemplate.findOne(minQuery, ChattingMessage.class, "chatting_messages"); + ChattingMessage maxMessage = mongoTemplate.findOne(maxQuery, ChattingMessage.class, "chatting_messages"); + + String minId = (minMessage != null) ? minMessage.getId() : "NO_MESSAGES"; + String maxId = (maxMessage != null) ? maxMessage.getId() : "NO_MESSAGES"; + + return Pair.of(minId, maxId); + } + + private void reEnterEvent(long roomId, long senderId, String senderName, ReadMessageRange range) { + ChannelTopic topic = new ChannelTopic(chatTopic + roomId); + ChatMessage chatMessage = ChatMessage.of(roomId, senderId, senderName, range, MessageType.READ); + + redisChatPublisher.publish(topic, chatMessage); + } } From 65ab71c2dc9af45987f60564344d99eb0d962082 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:58:48 +0900 Subject: [PATCH 505/770] =?UTF-8?q?feat:=20=EC=9E=AC=EC=9E=85=EC=9E=A5=20?= =?UTF-8?q?=EC=8B=9C=20=EC=9D=BD=EC=9D=8C=20=EC=B2=98=EB=A6=AC=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/ChattingRoomService.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 25ba3b2e..6e97b855 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -5,8 +5,8 @@ import com.gachtaxi.domain.chat.entity.ChattingMessage; import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; -import com.gachtaxi.domain.chat.entity.enums.MessageType; import com.gachtaxi.domain.chat.entity.enums.ChatStatus; +import com.gachtaxi.domain.chat.entity.enums.MessageType; import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; @@ -31,12 +31,12 @@ public class ChattingRoomService { private static final String ENTER_MESSAGE =" 님이 입장하셨습니다."; private static final String EXIT_MESSAGE =" 님이 퇴장하셨습니다."; - private final ChattingRoomRepository chattingRoomRepository; private final ChattingMessageRepository chattingMessageRepository; private final ChattingParticipantService chattingParticipantService; private final MemberService memberService; private final RedisChatPublisher redisChatPublisher; + private final ChatRedisService chatRedisService; @Value("${chat.topic}") public String chatTopic; @@ -67,9 +67,13 @@ public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { accessor.getSessionAttributes().put(CHAT_USER_NAME, members.getNickname()); if (chattingParticipantService.checkSubscription(chattingRoom, members)) { + chatRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); + return; } + chatRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); + ChattingParticipant newParticipant = ChattingParticipant.of(chattingRoom, members); chattingParticipantService.save(newParticipant); @@ -94,13 +98,14 @@ public ChattingRoom find(long chattingRoomId) { } private void publishMessage(long roomId, long senderId, String senderName, String message, MessageType messageType) { - ChannelTopic topic = new ChannelTopic(chatTopic + roomId); - ChatMessage chatMessage = ChatMessage.of(roomId, senderId, senderName, senderName + message, messageType); - ChattingMessage chattingMessage = ChattingMessage.from(chatMessage); + ChattingMessage chattingMessage = ChattingMessage.of(roomId, senderId, senderName, senderName + message, messageType); chattingMessageRepository.save(chattingMessage); + + ChannelTopic topic = new ChannelTopic(chatTopic + roomId); + ChatMessage chatMessage = ChatMessage.from(chattingMessage); + redisChatPublisher.publish(topic, chatMessage); } - } From 81fb238465b9e04845ff0d8823442b4b29d0a560 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:59:01 +0900 Subject: [PATCH 506/770] =?UTF-8?q?feat:=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=EB=B0=9C=ED=96=89=EC=8B=9C=20unreadCount=EB=A5=BC=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=ED=95=B4=EC=84=9C=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChattingService.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 2f4bf789..809b6f0f 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -22,6 +22,7 @@ import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.List; @@ -45,17 +46,25 @@ public class ChattingService { @Value("${chat.topic}") public String chatTopic; + @Transactional public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) { long roomId = getSessionAttribute(accessor, CHAT_ROOM_ID, Long.class); long userId = getSessionAttribute(accessor, CHAT_USER_ID, Long.class); String senderName = getSessionAttribute(accessor, CHAT_USER_NAME, String.class); - ChatMessage chatMessage = ChatMessage.of(request, roomId, userId, senderName); - ChannelTopic topic = new ChannelTopic(chatTopic + chatMessage.roomId()); - ChattingMessage chattingMessage = ChattingMessage.from(chatMessage); + long unreadCount = getUnreadCount(roomId); + + ChattingMessage chattingMessage = ChattingMessage.of(request, roomId, userId, senderName, unreadCount); chattingMessageRepository.save(chattingMessage); + + ChannelTopic topic = new ChannelTopic(chatTopic + roomId); + ChatMessage chatMessage = ChatMessage.from(chattingMessage); + redisChatPublisher.publish(topic, chatMessage); + /* + todo 채팅에 알림이 도입되면 redis에 참여하지 않은 사람 리스트를 가져와서 푸시알림 보내기. 참여하고 있다면 X + */ } public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int pageSize, LocalDateTime lastMessageTimeStamp) { @@ -90,7 +99,7 @@ private Slice loadMessage(long roomId, ChattingParticipant chat } private Slice loadInitialMessage(long roomId, ChattingParticipant chattingParticipant, int pageSize) { - int chattingCount = chattingMessageRepository.countAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getDisconnectedAt()); + int chattingCount = chattingMessageRepository.countAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getLastReadAt()); int effectivePageSize = Math.max(chattingCount, pageSize); Pageable pageable = PageRequest.of(0, effectivePageSize, Sort.by(Sort.Direction.DESC, "timeStamp")); @@ -103,4 +112,11 @@ private T getSessionAttribute(SimpMessageHeaderAccessor accessor, String att .map(attrs -> type.cast(attrs.get(attributeName))) .orElseThrow(() -> new WebSocketSessionException(attributeName)); } + + private long getUnreadCount(long roomId) { + long totalCount = chattingParticipantService.getParticipantCount(roomId); + long nowCount = chatRedisService.getSubscriberCount(roomId); + + return totalCount - nowCount; + } } From ee6338821ff8bcfe0c50e3ca1094111a4dfb2a66 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:59:19 +0900 Subject: [PATCH 507/770] =?UTF-8?q?feat:=20=EC=9D=BD=EC=9D=8C=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EB=B2=94=EC=9C=84=20dto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/dto/response/ReadMessageRange.java | 12 ++++++++++++ .../domain/chat/entity/enums/MessageType.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java new file mode 100644 index 00000000..b104d3c3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.chat.dto.response; + +import org.springframework.data.util.Pair; + +public record ReadMessageRange( + String startMessageId, + String endMessageId +) { + public static ReadMessageRange of(Pair pair) { + return new ReadMessageRange(pair.getFirst(), pair.getSecond()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java b/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java index 2bab8cb0..095750a7 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/enums/MessageType.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.chat.entity.enums; public enum MessageType { - MESSAGE, ENTER, EXIT + MESSAGE, ENTER, EXIT, READ } From f2add888a68d870c41c1e1359ea73e7cbaafdc60 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:59:33 +0900 Subject: [PATCH 508/770] =?UTF-8?q?feat:=20mongoTemplate=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/global/config/MongoConfig.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/gachtaxi/global/config/MongoConfig.java diff --git a/src/main/java/com/gachtaxi/global/config/MongoConfig.java b/src/main/java/com/gachtaxi/global/config/MongoConfig.java new file mode 100644 index 00000000..2a6dbc32 --- /dev/null +++ b/src/main/java/com/gachtaxi/global/config/MongoConfig.java @@ -0,0 +1,19 @@ +package com.gachtaxi.global.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory; + +@Configuration +public class MongoConfig { + + @Value("${spring.kafka.mongodb.uri}") + private String mongoUri; + + @Bean + public MongoTemplate mongoTemplate() { + return new MongoTemplate(new SimpleMongoClientDatabaseFactory(mongoUri)); + } +} From 2d2110d0b60c606c136fb8e4996cdbedef4f8924 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 13:59:55 +0900 Subject: [PATCH 509/770] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=20=EB=B0=9C=EC=83=9D=EC=8B=9C=20redis=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=EC=9E=90=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/event/WebSocketEventHandler.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java b/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java index 2780ea54..5116a057 100644 --- a/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java +++ b/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; +import com.gachtaxi.domain.chat.service.ChatRedisService; import com.gachtaxi.domain.chat.service.ChattingParticipantService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -21,6 +22,7 @@ public class WebSocketEventHandler { private final ChattingParticipantService chattingParticipantService; + private final ChatRedisService chatRedisService; @EventListener @Transactional @@ -33,7 +35,10 @@ public void handleDisconnect(SessionDisconnectEvent event) { ChattingParticipant chattingParticipant = chattingParticipantService.find(roomId, userId); - chattingParticipant.disconnect(); + if (chatRedisService.isActive(roomId, userId)) { + chattingParticipant.disconnect(); + chatRedisService.removeSubscribeMember(roomId, userId); + } } catch (NullPointerException e) { log.info("[handleDisconnect] 구독 정보가 존재하지 않습니다."); } catch (ChattingParticipantNotFoundException e) { @@ -52,7 +57,10 @@ public void handleUnsubscribe(SessionUnsubscribeEvent event) { try { ChattingParticipant chattingParticipant = chattingParticipantService.find(roomId, userId); - chattingParticipant.unsubscribe(); + if (chatRedisService.isActive(roomId, userId)) { + chattingParticipant.unsubscribe(); + chatRedisService.removeSubscribeMember(roomId, userId); + } } catch (ChattingParticipantNotFoundException e) { log.warn("[handleUnsubscribe] 이미 퇴장한 참여자 입니다."); } From f9349b81471fb8b9d3438429440d0a3756c40288 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 20 Jan 2025 18:47:19 +0900 Subject: [PATCH 510/770] =?UTF-8?q?refactor:=20=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=20=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/event/WebSocketEventHandler.java | 12 ++++++------ .../chat/service/ChattingParticipantService.java | 7 ++----- ...atRedisService.java => ChattingRedisService.java} | 2 +- .../domain/chat/service/ChattingRoomService.java | 6 +++--- .../domain/chat/service/ChattingService.java | 6 +++--- 5 files changed, 15 insertions(+), 18 deletions(-) rename src/main/java/com/gachtaxi/domain/chat/service/{ChatRedisService.java => ChattingRedisService.java} (97%) diff --git a/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java b/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java index 5116a057..4e81f1fc 100644 --- a/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java +++ b/src/main/java/com/gachtaxi/domain/chat/event/WebSocketEventHandler.java @@ -2,8 +2,8 @@ import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; -import com.gachtaxi.domain.chat.service.ChatRedisService; import com.gachtaxi.domain.chat.service.ChattingParticipantService; +import com.gachtaxi.domain.chat.service.ChattingRedisService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.event.EventListener; @@ -22,7 +22,7 @@ public class WebSocketEventHandler { private final ChattingParticipantService chattingParticipantService; - private final ChatRedisService chatRedisService; + private final ChattingRedisService chattingRedisService; @EventListener @Transactional @@ -35,9 +35,9 @@ public void handleDisconnect(SessionDisconnectEvent event) { ChattingParticipant chattingParticipant = chattingParticipantService.find(roomId, userId); - if (chatRedisService.isActive(roomId, userId)) { + if (chattingRedisService.isActive(roomId, userId)) { chattingParticipant.disconnect(); - chatRedisService.removeSubscribeMember(roomId, userId); + chattingRedisService.removeSubscribeMember(roomId, userId); } } catch (NullPointerException e) { log.info("[handleDisconnect] 구독 정보가 존재하지 않습니다."); @@ -57,9 +57,9 @@ public void handleUnsubscribe(SessionUnsubscribeEvent event) { try { ChattingParticipant chattingParticipant = chattingParticipantService.find(roomId, userId); - if (chatRedisService.isActive(roomId, userId)) { + if (chattingRedisService.isActive(roomId, userId)) { chattingParticipant.unsubscribe(); - chatRedisService.removeSubscribeMember(roomId, userId); + chattingRedisService.removeSubscribeMember(roomId, userId); } } catch (ChattingParticipantNotFoundException e) { log.warn("[handleUnsubscribe] 이미 퇴장한 참여자 입니다."); diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 8108b47c..3d38ac26 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -12,7 +12,6 @@ import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; import com.gachtaxi.domain.members.entity.Members; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.MongoTemplate; @@ -26,13 +25,12 @@ import java.time.LocalDateTime; import java.util.Optional; -@Slf4j @Service @RequiredArgsConstructor public class ChattingParticipantService { private final ChattingParticipantRepository chattingParticipantRepository; - private final ChatRedisService chatRedisService; + private final ChattingRedisService chattingRedisService; private final MongoTemplate mongoTemplate; private final RedisChatPublisher redisChatPublisher; @@ -84,8 +82,7 @@ public long getParticipantCount(Long roomId) { } private void checkDuplicateSubscription(long roomId, long memberId) { - if (chatRedisService.isActive(roomId, memberId)) { - log.info("memberId {}", memberId); + if (chattingRedisService.isActive(roomId, memberId)) { throw new DuplicateSubscribeException(); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java similarity index 97% rename from src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java rename to src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java index b5ffa613..3abbae09 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChatRedisService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java @@ -8,7 +8,7 @@ @Service @RequiredArgsConstructor -public class ChatRedisService { +public class ChattingRedisService { public static final String REDIS_CHAT_KEY_PREFIX = "ROOM:"; private final RedisTemplate chatRoomRedisTemplate; diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 6e97b855..96f56154 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -36,7 +36,7 @@ public class ChattingRoomService { private final ChattingParticipantService chattingParticipantService; private final MemberService memberService; private final RedisChatPublisher redisChatPublisher; - private final ChatRedisService chatRedisService; + private final ChattingRedisService chattingRedisService; @Value("${chat.topic}") public String chatTopic; @@ -67,12 +67,12 @@ public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { accessor.getSessionAttributes().put(CHAT_USER_NAME, members.getNickname()); if (chattingParticipantService.checkSubscription(chattingRoom, members)) { - chatRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); + chattingRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); return; } - chatRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); + chattingRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); ChattingParticipant newParticipant = ChattingParticipant.of(chattingRoom, members); chattingParticipantService.save(newParticipant); diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 809b6f0f..efb63ad7 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -41,7 +41,7 @@ public class ChattingService { private final ChattingRoomService chattingRoomService; private final ChattingParticipantService chattingParticipantService; private final MemberService memberService; - private final ChatRedisService chatRedisService; + private final ChattingRedisService chattingRedisService; @Value("${chat.topic}") public String chatTopic; @@ -72,7 +72,7 @@ public ChatResponse getMessage(long roomId, long senderId, int pageNumber, int p Members members = memberService.findById(senderId); ChattingParticipant chattingParticipant = chattingParticipantService.find(chattingRoom, members); - chatRedisService.checkSubscriptionStatus(roomId, senderId); + chattingRedisService.checkSubscriptionStatus(roomId, senderId); Slice chattingMessages = loadMessage(roomId, chattingParticipant, pageNumber, pageSize, lastMessageTimeStamp); @@ -115,7 +115,7 @@ private T getSessionAttribute(SimpMessageHeaderAccessor accessor, String att private long getUnreadCount(long roomId) { long totalCount = chattingParticipantService.getParticipantCount(roomId); - long nowCount = chatRedisService.getSubscriberCount(roomId); + long nowCount = chattingRedisService.getSubscriberCount(roomId); return totalCount - nowCount; } From 3ad5aa05f0178fa0f3db9d87da1c11ace0cd9ee1 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 20 Jan 2025 20:32:09 +0900 Subject: [PATCH 511/770] =?UTF-8?q?fix:=20=EC=84=B8=EB=AF=B8=EC=BD=9C?= =?UTF-8?q?=EB=A1=A0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/exception/ErrorMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index 61080aec..6f8cd58b 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -13,7 +13,7 @@ public enum ErrorMessage { MEMBER_ALREADY_JOINED_MATCHING_ROOM("해당 맴버는 이미 매칭 방에 참가한 멤버입니다"), MEMBER_ALREADY_LEFT_MATCHING_ROOM("해당 멤버는 이미 매칭 방에서 나간 멤버입니다."), CONTROLLER_NOT_HAS_CURRENT_MEMBER_ID("해당 컨트롤러는 인가된 멤버 ID가 필요합니다."), - NOT_DEFINED_KAFKA_TEMPLATE("해당 이벤트와 맞는 KafkaTemplate이 정의되지 않았습니다."); + NOT_DEFINED_KAFKA_TEMPLATE("해당 이벤트와 맞는 KafkaTemplate이 정의되지 않았습니다."), DUPLICATED_MATCHING_ROOM("이미 존재하는 매칭 방입니다."), NOT_FOUND_PAGE("페이지 번호는 0 이상이어야 합니다."); From 0ed17f0cd3f5f653cf2fcb96b5ab529784b3bdd0 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 20 Jan 2025 20:34:32 +0900 Subject: [PATCH 512/770] =?UTF-8?q?fix:=20=EB=B9=8C=EB=93=9C=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/GachtaxiApplication.java | 2 -- .../service/MockMatchingAlgorithmService.java | 2 +- .../gachtaxi/domain/matching/common/entity/Route.java | 11 +---------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gachtaxi/GachtaxiApplication.java b/src/main/java/com/gachtaxi/GachtaxiApplication.java index b4780f0b..bb667bc3 100644 --- a/src/main/java/com/gachtaxi/GachtaxiApplication.java +++ b/src/main/java/com/gachtaxi/GachtaxiApplication.java @@ -4,12 +4,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.mongodb.config.EnableMongoAuditing; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; @SpringBootApplication @EnableJpaAuditing @EnableMongoAuditing -@EnableJpaAuditing public class GachtaxiApplication { public static void main(String[] args) { diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java index 31ea0762..fe90a21a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java @@ -50,7 +50,7 @@ public Optional findRoom(Long userId, double startLongitude, dou ACTIVE 상태인 방만 필터링 */ matchingRooms = matchingRooms.stream() - .filter(MatchingRoom::isActiveMatchingRoom) + .filter(MatchingRoom::isActive) .toList(); /* 태그 조건이 있는 경우에 태그정보까지 필터링 diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java index bcf3e0c7..2b7f5260 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java @@ -11,7 +11,7 @@ @Entity @Table(name = "route") -@Builder(access = AccessLevel.PRIVATE) +@Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) public class Route extends BaseEntity { @@ -23,13 +23,4 @@ public class Route extends BaseEntity { private double endLongitude; private double endLatitude; private String endLocationName; - - public static Route from(MatchRoomCreatedEvent matchRoomCreatedEvent) { - return Route.builder() - .startLocationCoordinate(matchRoomCreatedEvent.startPoint()) - .startLocationName(matchRoomCreatedEvent.startName()) - .endLocationCoordinate(matchRoomCreatedEvent.destinationPoint()) - .endLocationName(matchRoomCreatedEvent.destinationName()) - .build(); - } } From 04b32eeee25f1f7399b46f084fc0d2882e2b47f5 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 20 Jan 2025 21:09:20 +0900 Subject: [PATCH 513/770] =?UTF-8?q?hotfix:=20dev=20yml=20auto=20matching?= =?UTF-8?q?=20description=20=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index e9330c21..8e7edf04 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -73,5 +73,5 @@ gachtaxi: replication-factor: ${KAFKA_REPLICATION_FACTOR} matching: auto-matching-max-capacity: ${AUTO_MATCHING_MAX_CAPACITY} - auto-matcnig-description: ${AUTO_MATCHING_DESCRIPTION} + auto-matching-description: ${AUTO_MATCHING_DESCRIPTION} From f7e21b21390ed2b64fbdfc9a50cfd36bd9d6f3a6 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 21 Jan 2025 09:37:21 +0900 Subject: [PATCH 514/770] =?UTF-8?q?refactor:=20=ED=8C=A9=ED=86=A0=EB=A6=AC?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java | 2 +- .../domain/chat/service/ChattingParticipantService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java index b104d3c3..a47a5b58 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ReadMessageRange.java @@ -6,7 +6,7 @@ public record ReadMessageRange( String startMessageId, String endMessageId ) { - public static ReadMessageRange of(Pair pair) { + public static ReadMessageRange from(Pair pair) { return new ReadMessageRange(pair.getFirst(), pair.getSecond()); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 3d38ac26..c349c738 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -63,7 +63,7 @@ public boolean checkSubscription(ChattingRoom chattingRoom, Members members) { Pair pair = getUpdatedMessageRange(chattingRoom.getId(), chattingParticipant.getLastReadAt(), members.getId()); - reEnterEvent(chattingRoom.getId(), members.getId(), members.getNickname(), ReadMessageRange.of(pair)); + reEnterEvent(chattingRoom.getId(), members.getId(), members.getNickname(), ReadMessageRange.from(pair)); chattingParticipant.reSubscribe(); From 289513f0f1e923d4074aacfd61b8724101df6f77 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 21 Jan 2025 10:36:45 +0900 Subject: [PATCH 515/770] =?UTF-8?q?refactor:=20=EC=A0=95=EC=A0=81=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/exception/FcmTokenNotFoundException.java | 7 ++++--- .../notification/exception/InvalidFcmTokenException.java | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/FcmTokenNotFoundException.java b/src/main/java/com/gachtaxi/domain/notification/exception/FcmTokenNotFoundException.java index 54f84181..d6b517ef 100644 --- a/src/main/java/com/gachtaxi/domain/notification/exception/FcmTokenNotFoundException.java +++ b/src/main/java/com/gachtaxi/domain/notification/exception/FcmTokenNotFoundException.java @@ -1,12 +1,13 @@ package com.gachtaxi.domain.notification.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; -import static com.gachtaxi.domain.notification.exception.ErrorMessage.*; +import static com.gachtaxi.domain.notification.exception.ErrorMessage.FCM_TOKEN_NOT_FOUND; +import static org.springframework.http.HttpStatus.valueOf; + public class FcmTokenNotFoundException extends BaseException { public FcmTokenNotFoundException(int statusCode, String statusMessage) { - super(HttpStatus.valueOf(statusCode), statusMessage + FCM_TOKEN_NOT_FOUND.getMessage()); + super(valueOf(statusCode), statusMessage + FCM_TOKEN_NOT_FOUND.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java b/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java index f478d279..a4ced63d 100644 --- a/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java +++ b/src/main/java/com/gachtaxi/domain/notification/exception/InvalidFcmTokenException.java @@ -1,10 +1,9 @@ package com.gachtaxi.domain.notification.exception; import com.gachtaxi.global.common.exception.BaseException; -import org.springframework.http.HttpStatus; import static com.gachtaxi.domain.notification.exception.ErrorMessage.INVALID_FCM_TOKEN; -import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.HttpStatus.valueOf; public class InvalidFcmTokenException extends BaseException { public InvalidFcmTokenException(int statusCode, String statusMessage) { From 1f6bc32b9bbaca086ecb96d6557e7bbc45b94737 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 21 Jan 2025 10:37:05 +0900 Subject: [PATCH 516/770] =?UTF-8?q?refactor:=20DB=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EC=95=88=20?= =?UTF-8?q?=EC=9D=BD=EC=9D=80=20=EC=95=8C=EB=A6=BC=20=ED=95=84=ED=84=B0?= =?UTF-8?q?=EB=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/NotificationRepository.java | 2 +- .../notification/service/NotificationService.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java index ccce9792..754571f2 100644 --- a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java +++ b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java @@ -8,7 +8,7 @@ public interface NotificationRepository extends JpaRepository { - Integer countAllByReceiverIdAndStatusAndStatus(Long receiverId, NotificationStatus firstCondition, NotificationStatus secondCondition); + Integer countAllByReceiverIdAndStatus(Long receiverId, NotificationStatus status); Slice findAllByReceiverId(Long receiverId, Pageable pageable); } diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java index 053cd877..9103e286 100644 --- a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -9,6 +9,7 @@ import com.gachtaxi.domain.notification.exception.NotificationNotFoundException; import com.gachtaxi.domain.notification.repository.NotificationRepository; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -17,8 +18,8 @@ import org.springframework.transaction.annotation.Transactional; import static com.gachtaxi.domain.notification.entity.enums.NotificationStatus.UNREAD; -import static com.gachtaxi.domain.notification.entity.enums.NotificationStatus.UNSENT; +@Slf4j @Service @RequiredArgsConstructor public class NotificationService { @@ -31,14 +32,17 @@ public Slice getNotifications(Long receiverId, int pageNum Pageable pageable = PageRequest.of(pageNum, pageSize, Sort.by(Sort.Direction.DESC, "createDate")); Slice notifications = notificationRepository.findAllByReceiverId(receiverId, pageable); - notifications.forEach(Notification::read); + + notifications.stream() + .filter(notification -> notification.getStatus() == UNREAD) + .forEach(Notification::read); return notifications .map(NotificationResponse::from); } public NotificationInfoResponse getInfo(Long receiverId) { - Integer count = notificationRepository.countAllByReceiverIdAndStatusAndStatus(receiverId, UNREAD, UNSENT); + Integer count = notificationRepository.countAllByReceiverIdAndStatus(receiverId, UNREAD); if (count > 0) { return new NotificationInfoResponse(count, true); From fa1f2faed81f35c439f8beb28471b8ce4610d841 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 21 Jan 2025 16:25:39 +0900 Subject: [PATCH 517/770] =?UTF-8?q?fix:=20SSE=20=EA=B5=AC=EB=8F=85=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=8B=9C=20=EC=B5=9C=EC=B4=88=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=EB=B0=9C=ED=96=89=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/AutoMatchingController.java | 1 - .../matching/event/service/sse/SseService.java | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java index 95c2296e..ec57f2fd 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/AutoMatchingController.java @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/sse/SseService.java b/src/main/java/com/gachtaxi/domain/matching/event/service/sse/SseService.java index d76e0fb3..3f767b23 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/sse/SseService.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/sse/SseService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.matching.event.service.sse; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; @@ -10,6 +11,7 @@ /** * 사용자별 SSE Emitter 관리 */ +@Slf4j @Service public class SseService { @@ -23,6 +25,19 @@ public SseEmitter subscribe(Long memberId) { emitter.onCompletion(() -> emitterMap.remove(memberId)); emitter.onTimeout(() -> emitterMap.remove(memberId)); this.emitterMap.put(memberId, emitter); + + Map initMessage = new ConcurrentHashMap<>( + Map.of("message", "member %s Connection established".formatted(memberId)) + ); + + try { + emitter.send(SseEmitter.event() + .name("init") + .data(initMessage)); + } catch (IOException e) { + emitter.completeWithError(e); + } + return emitter; } From c060e4b61edcc6aadec59e403d728a9b56bf4eea Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 21 Jan 2025 16:31:39 +0900 Subject: [PATCH 518/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=B0=9C?= =?UTF-8?q?=ED=96=89=20=EC=8B=9C=20=EC=83=9D=EC=84=B1=EB=90=9C=20=EB=B0=A9?= =?UTF-8?q?=20ID=EB=8F=84=20=EA=B0=99=EC=9D=B4=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 6 ++++-- .../kafka_topic/MatchRoomCreatedEvent.java | 20 +++++++++++++++++++ .../service/kafka/AutoMatchingConsumer.java | 8 ++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index cb02b2aa..3a0fbfea 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -49,7 +49,7 @@ public class MatchingRoomService { // event factory private final MatchingEventFactory matchingEventFactory; - public void createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { + public Long createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { Members members = this.memberService.findById(matchRoomCreatedEvent.roomMasterId()); Route route = this.saveRoute(matchRoomCreatedEvent); @@ -59,7 +59,9 @@ public void createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { this.saveMatchingRoomTagInfo(matchingRoom, matchRoomCreatedEvent.criteria()); this.saveRoomMasterChargingInfo(matchingRoom, members); - this.matchingRoomRepository.save(matchingRoom); + MatchingRoom savedMatchingRoom = this.matchingRoomRepository.save(matchingRoom); + + return savedMatchingRoom.getId(); } private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java index 89333de7..358d0183 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java @@ -8,6 +8,7 @@ import java.util.UUID; import lombok.AccessLevel; import lombok.Builder; +import lombok.Setter; import org.springframework.beans.factory.annotation.Value; @Builder(access = AccessLevel.PRIVATE) @@ -22,6 +23,7 @@ public record MatchRoomCreatedEvent( String destinationName, List criteria, Integer expectedTotalCharge, + Long roomId, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime createdAt, @@ -39,6 +41,24 @@ public String getTopic() { return this.topic; } + public static MatchRoomCreatedEvent of(MatchRoomCreatedEvent event, Long roomId) { + return MatchRoomCreatedEvent.builder() + .roomMasterId(event.roomMasterId()) + .maxCapacity(event.maxCapacity()) + .title(event.title()) + .description(event.description()) + .startPoint(event.startPoint()) + .startName(event.startName()) + .destinationPoint(event.destinationPoint()) + .destinationName(event.destinationName()) + .criteria(event.criteria()) + .expectedTotalCharge(event.expectedTotalCharge()) + .roomId(roomId) + .createdAt(event.createdAt()) + .topic(event.topic()) + .build(); + } + public static MatchRoomCreatedEvent of( Long roomMasterId, AutoMatchingPostRequest autoMatchingPostRequest, diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index 62b71401..d18c55ff 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -32,9 +32,13 @@ public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) try { log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event); - this.matchingRoomService.createMatchingRoom(event); + Long roomId = this.matchingRoomService.createMatchingRoom(event); - this.sseService.sendToClient(event.roomMasterId(), "MATCH_ROOM_CREATED", event); + this.sseService.sendToClient( + event.roomMasterId(), + "MATCH_ROOM_CREATED", + MatchRoomCreatedEvent.of(event, roomId) + ); ack.acknowledge(); } catch (Exception e) { From 5f28d9b48ac2ed647af8ba67c12e99cafbc819c1 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 21 Jan 2025 16:33:45 +0900 Subject: [PATCH 519/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=8B=9C=EC=9E=91=20=EC=9A=94=EC=B2=AD=20=EC=8B=9C?= =?UTF-8?q?=20=EC=B9=9C=EA=B5=AC=20=EC=A0=95=EB=B3=B4=EB=8F=84=20=ED=95=A8?= =?UTF-8?q?=EA=BB=98=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/AutoMatchingPostRequest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java index 505ad488..a678d750 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java @@ -9,6 +9,7 @@ public record AutoMatchingPostRequest( String destinationPoint, String destinationName, List criteria, + List members, Integer expectedTotalCharge ) { From 9c20c6c5c5817b8525b1fa8f13f123d4d9abc96c Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 21 Jan 2025 16:51:23 +0900 Subject: [PATCH 520/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=EC=B2=B4=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...gAlgorithmService.java => MatchingAlgorithmServiceImpl.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/com/gachtaxi/domain/matching/algorithm/service/{MockMatchingAlgorithmService.java => MatchingAlgorithmServiceImpl.java} (98%) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java similarity index 98% rename from src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java rename to src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java index fe90a21a..24ef42d0 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MockMatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java @@ -18,7 +18,7 @@ @Service @RequiredArgsConstructor -public class MockMatchingAlgorithmService implements MatchingAlgorithmService { +public class MatchingAlgorithmServiceImpl implements MatchingAlgorithmService { private final MatchingRoomRepository matchingRoomRepository; private final MemberService memberService; From 29bd0691329ef4731252210962c69cfd2676b727 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 21 Jan 2025 16:51:37 +0900 Subject: [PATCH 521/770] =?UTF-8?q?fix:=20=EB=A9=A4=EB=B2=84=EA=B0=80=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EB=B0=A9=EC=97=90=20=EC=B0=B8=EC=97=AC?= =?UTF-8?q?=EC=A4=91=EC=9D=B8=EC=A7=80=20=EC=97=AC=EB=B6=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=ED=95=98=EB=8A=94=20=EC=BF=BC=EB=A6=AC=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/repository/MatchingRoomRepository.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index 264dc0bc..3f20b7d9 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -23,6 +23,8 @@ List findRoomsByStartAndDestination( ); @Query("SELECT CASE WHEN COUNT(m) > 0 THEN true ELSE false END " + "FROM MatchingRoom r JOIN r.memberMatchingRoomChargingInfo m " + - "WHERE m.members = :user") + "WHERE m.members = :user "+ + "AND r.matchingRoomStatus = 'ACTIVE' "+ + "AND m.paymentStatus != 'LEFT'") boolean existsByMemberInMatchingRoom(@Param("user") Members user); } From 447f412880b89a5b3c9a0e15ac2e95c4da65075c Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 21 Jan 2025 18:42:58 +0900 Subject: [PATCH 522/770] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EB=B0=A9=EC=97=90=20=EC=B0=B8=EA=B0=80?= =?UTF-8?q?=ED=95=9C=20=EB=A9=A4=EB=B2=84=EC=9D=BC=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EB=8D=98=EC=A7=88=20=EC=98=88=EC=99=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingAlgorithmServiceImpl.java | 4 ++-- .../exception/AlreadyInMatchingRoomException.java | 13 +++++++++++++ .../matching/common/exception/ErrorMessage.java | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/AlreadyInMatchingRoomException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java index 24ef42d0..6951b54e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java @@ -3,7 +3,7 @@ import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.enums.Tags; -import com.gachtaxi.domain.matching.common.exception.DuplicatedMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.AlreadyInMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.PageNotFoundException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.members.entity.Members; @@ -34,7 +34,7 @@ public Optional findRoom(Long userId, double startLongitude, dou Members user = memberService.findById(userId); if (matchingRoomRepository.existsByMemberInMatchingRoom(user)) { - throw new DuplicatedMatchingRoomException(); // * 추후 논의 후 리팩토링 필요 * 똑같은 조건으로 방 생성시 예외 던져주기 + throw new AlreadyInMatchingRoomException(); // * 추후 논의 후 리팩토링 필요 * 똑같은 조건으로 방 생성시 예외 던져주기 } /* 위치 정보를 이용한 방 검색(300M 이내) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/AlreadyInMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/AlreadyInMatchingRoomException.java new file mode 100644 index 00000000..a2b2cb44 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/AlreadyInMatchingRoomException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.ALREADY_IN_MATCHING_ROOM; +import static org.springframework.http.HttpStatus.CONFLICT; + +import com.gachtaxi.global.common.exception.BaseException; + +public class AlreadyInMatchingRoomException extends BaseException { + public AlreadyInMatchingRoomException() { + super(CONFLICT, ALREADY_IN_MATCHING_ROOM.getMessage()); + } + +} diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index 6f8cd58b..3febd48f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -15,7 +15,8 @@ public enum ErrorMessage { CONTROLLER_NOT_HAS_CURRENT_MEMBER_ID("해당 컨트롤러는 인가된 멤버 ID가 필요합니다."), NOT_DEFINED_KAFKA_TEMPLATE("해당 이벤트와 맞는 KafkaTemplate이 정의되지 않았습니다."), DUPLICATED_MATCHING_ROOM("이미 존재하는 매칭 방입니다."), - NOT_FOUND_PAGE("페이지 번호는 0 이상이어야 합니다."); + NOT_FOUND_PAGE("페이지 번호는 0 이상이어야 합니다."), + ALREADY_IN_MATCHING_ROOM("이미 매칭 방에 참가한 멤버입니다."); private final String message; } From 1af953c03c081b0cd7e12a1eea8be4962e33ef37 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 21 Jan 2025 18:43:13 +0900 Subject: [PATCH 523/770] =?UTF-8?q?fix:=20=EC=9C=84=EB=8F=84,=20=EA=B2=BD?= =?UTF-8?q?=EB=8F=84=20=EA=B0=92=EC=9D=B4=20=EB=B0=94=EB=80=8C=EC=96=B4?= =?UTF-8?q?=EC=84=9C=20=EB=93=A4=EC=96=B4=EA=B0=80=EB=8A=94=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/repository/MatchingRoomRepository.java | 6 +++--- .../matching/common/service/MatchingRoomService.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index 3f20b7d9..11d69ea7 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -11,9 +11,9 @@ @Repository public interface MatchingRoomRepository extends JpaRepository { @Query("SELECT r FROM MatchingRoom r " + - "WHERE " + - "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLongitude, :startLatitude), FUNCTION('POINT', r.route.startLongitude, r.route.startLatitude)) <= :radius " + - "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= :radius ") + "WHERE " + + "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLatitude, :startLongitude), FUNCTION('POINT', r.route.startLatitude, r.route.startLongitude)) <= :radius " + + "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLatitude, :destinationLongitude), FUNCTION('POINT', r.route.endLatitude, r.route.endLongitude)) <= :radius ") List findRoomsByStartAndDestination( @Param("startLongitude") double startLongitude, @Param("startLatitude") double startLatitude, diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 3a0fbfea..e75e7494 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -66,12 +66,12 @@ public Long createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { String[] startCoordinates = matchRoomCreatedEvent.startPoint().split(","); - double startLongitude = Double.parseDouble(startCoordinates[0]); - double startLatitude = Double.parseDouble(startCoordinates[1]); + double startLatitude = Double.parseDouble(startCoordinates[0]); + double startLongitude = Double.parseDouble(startCoordinates[1]); String[] endCoordinates = matchRoomCreatedEvent.destinationPoint().split(","); - double endLongitude = Double.parseDouble(endCoordinates[0]); - double endLatitude = Double.parseDouble(endCoordinates[1]); + double endLatitude = Double.parseDouble(endCoordinates[0]); + double endLongitude = Double.parseDouble(endCoordinates[1]); Route route = Route.builder() .startLongitude(startLongitude) From c393e6959148042df04ccf9b518ed7a5f5ecbc45 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 23 Jan 2025 10:03:11 +0900 Subject: [PATCH 524/770] =?UTF-8?q?refactor:=20MongoTemplate=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChattingMessageMongoRepository.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageMongoRepository.java diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageMongoRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageMongoRepository.java new file mode 100644 index 00000000..b2a47f93 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageMongoRepository.java @@ -0,0 +1,57 @@ +package com.gachtaxi.domain.chat.repository; + +import com.gachtaxi.domain.chat.entity.ChattingMessage; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Sort; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.core.query.Update; +import org.springframework.data.util.Pair; +import org.springframework.stereotype.Repository; + +import java.time.LocalDateTime; + +@Slf4j +@Repository +@RequiredArgsConstructor +public class ChattingMessageMongoRepository { + + private static final String COLLECTION = "chatting_messages"; + private final MongoTemplate mongoTemplate; + + public Pair updateUnreadCount(Long roomId, LocalDateTime lastReadAt, Long senderId) { + Query query = new Query().addCriteria(buildCommonCriteria(roomId, lastReadAt, senderId)); + + Update update = new Update().inc("unreadCount", -1); + + Pair range = getUpdatedMessageRange(roomId, lastReadAt, senderId); + mongoTemplate.updateMulti(query, update, ChattingMessage.class); + + return range; + } + + private Pair getUpdatedMessageRange(Long roomId, LocalDateTime lastReadAt, Long senderId) { + Query minQuery = new Query().addCriteria(buildCommonCriteria(roomId, lastReadAt, senderId)) + .with(Sort.by(Sort.Direction.ASC, "_id")).limit(1); + + Query maxQuery = new Query().addCriteria(buildCommonCriteria(roomId, lastReadAt, senderId)) + .with(Sort.by(Sort.Direction.DESC, "_id")).limit(1); + + ChattingMessage minMessage = mongoTemplate.findOne(minQuery, ChattingMessage.class, COLLECTION); + ChattingMessage maxMessage = mongoTemplate.findOne(maxQuery, ChattingMessage.class, COLLECTION); + + String minId = (minMessage != null) ? minMessage.getId() : "NO_MESSAGES"; + String maxId = (maxMessage != null) ? maxMessage.getId() : "NO_MESSAGES"; + + return Pair.of(minId, maxId); + } + + private Criteria buildCommonCriteria(Long roomId, LocalDateTime lastReadAt, Long senderId) { + return Criteria.where("roomId").is(roomId) + .and("timeStamp").gt(lastReadAt) + .and("senderId").ne(senderId) + .and("unreadCount").gt(0); + } +} From e659eb643c8432f0fca04161cec080c6cfac4e2c Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 23 Jan 2025 10:03:22 +0900 Subject: [PATCH 525/770] =?UTF-8?q?refactor:=20MongoTemplate=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ChattingParticipantService.java | 51 ++----------------- 1 file changed, 3 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index c349c738..734d7445 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -2,27 +2,21 @@ import com.gachtaxi.domain.chat.dto.request.ChatMessage; import com.gachtaxi.domain.chat.dto.response.ReadMessageRange; -import com.gachtaxi.domain.chat.entity.ChattingMessage; import com.gachtaxi.domain.chat.entity.ChattingParticipant; import com.gachtaxi.domain.chat.entity.ChattingRoom; import com.gachtaxi.domain.chat.entity.enums.MessageType; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; +import com.gachtaxi.domain.chat.repository.ChattingMessageMongoRepository; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; import com.gachtaxi.domain.members.entity.Members; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.domain.Sort; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.core.query.Update; import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; -import java.time.LocalDateTime; import java.util.Optional; @Service @@ -30,8 +24,8 @@ public class ChattingParticipantService { private final ChattingParticipantRepository chattingParticipantRepository; + private final ChattingMessageMongoRepository chattingMessageMongoRepository; private final ChattingRedisService chattingRedisService; - private final MongoTemplate mongoTemplate; private final RedisChatPublisher redisChatPublisher; @Value("${chat.topic}") @@ -59,9 +53,7 @@ public boolean checkSubscription(ChattingRoom chattingRoom, Members members) { checkDuplicateSubscription(chattingRoom.getId(), members.getId()); - updateUnreadCount(chattingRoom.getId(), chattingParticipant.getLastReadAt(), members.getId()); - - Pair pair = getUpdatedMessageRange(chattingRoom.getId(), chattingParticipant.getLastReadAt(), members.getId()); + Pair pair = chattingMessageMongoRepository.updateUnreadCount(chattingRoom.getId(), chattingParticipant.getLastReadAt(), members.getId()); reEnterEvent(chattingRoom.getId(), members.getId(), members.getNickname(), ReadMessageRange.from(pair)); @@ -87,43 +79,6 @@ private void checkDuplicateSubscription(long roomId, long memberId) { } } - public void updateUnreadCount(Long roomId, LocalDateTime lastReadAt, Long senderId) { - Query query = new Query().addCriteria( - Criteria.where("roomId").is(roomId) - .and("timeStamp").gt(lastReadAt) - .and("senderId").ne(senderId) - .and("unreadCount").gt(0) - ); - - Update update = new Update().inc("unreadCount", -1); - - mongoTemplate.updateMulti(query, update, ChattingMessage.class); - } - - public Pair getUpdatedMessageRange(Long roomId, LocalDateTime lastReadAt, Long senderId) { - Query minQuery = new Query().addCriteria( - Criteria.where("roomId").is(roomId) - .and("timeStamp").gt(lastReadAt) - .and("senderId").ne(senderId) - .and("unreadCount").gt(0) - ).with(Sort.by(Sort.Direction.ASC, "_id")).limit(1); - - Query maxQuery = new Query().addCriteria( - Criteria.where("roomId").is(roomId) - .and("timeStamp").gt(lastReadAt) - .and("senderId").ne(senderId) - .and("unreadCount").gt(0) - ).with(Sort.by(Sort.Direction.DESC, "_id")).limit(1); - - ChattingMessage minMessage = mongoTemplate.findOne(minQuery, ChattingMessage.class, "chatting_messages"); - ChattingMessage maxMessage = mongoTemplate.findOne(maxQuery, ChattingMessage.class, "chatting_messages"); - - String minId = (minMessage != null) ? minMessage.getId() : "NO_MESSAGES"; - String maxId = (maxMessage != null) ? maxMessage.getId() : "NO_MESSAGES"; - - return Pair.of(minId, maxId); - } - private void reEnterEvent(long roomId, long senderId, String senderName, ReadMessageRange range) { ChannelTopic topic = new ChannelTopic(chatTopic + roomId); ChatMessage chatMessage = ChatMessage.of(roomId, senderId, senderName, range, MessageType.READ); From 5e048f4e297a8ee88a46624bc991d2d65be510a8 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 23 Jan 2025 10:23:22 +0900 Subject: [PATCH 526/770] =?UTF-8?q?refactor:=20=EA=B0=9C=EB=B0=9C=20?= =?UTF-8?q?=EC=9A=A9=EC=9D=B4=EC=84=B1=EC=9D=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EA=B5=AC=EB=8F=85=20=EC=B2=B4=ED=81=AC=20?= =?UTF-8?q?=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChattingParticipantService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index 734d7445..c0c8ca85 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -51,7 +51,7 @@ public boolean checkSubscription(ChattingRoom chattingRoom, Members members) { if (optionalParticipant.isPresent()) { ChattingParticipant chattingParticipant = optionalParticipant.get(); - checkDuplicateSubscription(chattingRoom.getId(), members.getId()); +// checkDuplicateSubscription(chattingRoom.getId(), members.getId()); Pair pair = chattingMessageMongoRepository.updateUnreadCount(chattingRoom.getId(), chattingParticipant.getLastReadAt(), members.getId()); From 941bb19c5e50b0db53b1625b5db80cc687b2d2f1 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Thu, 23 Jan 2025 10:37:12 +0900 Subject: [PATCH 527/770] =?UTF-8?q?refactor:=20=ED=8C=A9=ED=86=A0=EB=A6=AC?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/dto/response/NotificationInfoResponse.java | 3 +++ .../domain/notification/service/NotificationService.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationInfoResponse.java b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationInfoResponse.java index b1b551cd..b59a9ead 100644 --- a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationInfoResponse.java +++ b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationInfoResponse.java @@ -4,4 +4,7 @@ public record NotificationInfoResponse( int unreadCount, boolean hasUnreadNotifications ) { + public static NotificationInfoResponse of(int unreadCount, boolean hasUnreadNotifications) { + return new NotificationInfoResponse(unreadCount, hasUnreadNotifications); + } } diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java index 9103e286..b7a878a6 100644 --- a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -45,10 +45,10 @@ public NotificationInfoResponse getInfo(Long receiverId) { Integer count = notificationRepository.countAllByReceiverIdAndStatus(receiverId, UNREAD); if (count > 0) { - return new NotificationInfoResponse(count, true); + return NotificationInfoResponse.of(count, true); } - return new NotificationInfoResponse(count, false); + return NotificationInfoResponse.of(count, false); } @Transactional From 76ee995bd790aca8691a186fa1b60c92885e5027 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 24 Jan 2025 20:06:33 +0900 Subject: [PATCH 528/770] =?UTF-8?q?refactor:=20null=EC=9D=80=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index b342167a..83722cca 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.chat.dto.request; +import com.fasterxml.jackson.annotation.JsonInclude; import com.gachtaxi.domain.chat.dto.response.ReadMessageRange; import com.gachtaxi.domain.chat.entity.ChattingMessage; import com.gachtaxi.domain.chat.entity.enums.MessageType; @@ -8,6 +9,7 @@ import java.time.LocalDateTime; @Builder +@JsonInclude(JsonInclude.Include.NON_NULL) public record ChatMessage( String messageId, Long roomId, From de00be2845373276e897c98e08a014496b0d80e5 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 24 Jan 2025 20:07:53 +0900 Subject: [PATCH 529/770] =?UTF-8?q?refactor:=20=EA=B0=9C=EB=B0=9C=EC=9D=84?= =?UTF-8?q?=20=EC=9C=84=ED=95=9C=20sockjs=20=EC=84=A4=EC=A0=95=20=ED=95=B4?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index 41def4ab..797132ed 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -25,8 +25,8 @@ public void registerStompEndpoints(StompEndpointRegistry registry) { registry .setErrorHandler(stompExceptionHandler) .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3000") - .withSockJS(); + .setAllowedOriginPatterns("http://localhost:3000"); +// .withSockJS(); } @Override From e3d481257516e4d416f582469596c6590648a434 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 24 Jan 2025 20:14:12 +0900 Subject: [PATCH 530/770] =?UTF-8?q?feat:=20=EC=9C=A0=EB=8B=88=ED=81=AC=20?= =?UTF-8?q?=EC=A0=9C=EC=95=BD=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/entity/ChattingParticipant.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 8a14ed3c..496102ef 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -2,10 +2,7 @@ import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.common.entity.BaseEntity; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; +import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -18,6 +15,12 @@ @Entity @SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table( + name = "chatting_participant", + uniqueConstraints = { + @UniqueConstraint(columnNames = {"members_id", "chatting_room_id"}) + } +) public class ChattingParticipant extends BaseEntity { @ManyToOne From 3fe6abb05ffe8a26f2da5cebb6fc8a6e13541d4b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 24 Jan 2025 23:08:35 +0900 Subject: [PATCH 531/770] feat: Friends Entity --- .../domain/friend/entity/Friends.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/friend/entity/Friends.java diff --git a/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java b/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java new file mode 100644 index 00000000..50ea6410 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java @@ -0,0 +1,41 @@ +package com.gachtaxi.domain.friend.entity; + +import com.gachtaxi.domain.friend.entity.enums.FriendStatus; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import static com.gachtaxi.domain.friend.entity.enums.FriendStatus.PENDING; + + +@Entity +@Getter +@Table(name="Friends") +@SuperBuilder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Friends extends BaseEntity { + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "sender_id") + private Members sender; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "receiver_id") + private Members receiver; + + @Builder.Default + @Enumerated(EnumType.STRING) + private FriendStatus status = PENDING; + + public static Friends of(Members sender, Members receiver) { + return Friends.builder() + .sender(sender) + .receiver(receiver) + .build(); + } +} From 38aa729314fbe76c965955460056a602ace6f415 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 25 Jan 2025 16:05:53 +0900 Subject: [PATCH 532/770] =?UTF-8?q?feat:=20FriendException=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/exception/ErrorMessage.java | 14 ++++++++++++++ .../exception/FriendShipExistsException.java | 12 ++++++++++++ .../exception/FriendShipPendingException.java | 12 ++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/friend/exception/ErrorMessage.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/exception/FriendShipExistsException.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/exception/FriendShipPendingException.java diff --git a/src/main/java/com/gachtaxi/domain/friend/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/friend/exception/ErrorMessage.java new file mode 100644 index 00000000..f394c2ad --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/exception/ErrorMessage.java @@ -0,0 +1,14 @@ +package com.gachtaxi.domain.friend.exception; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ErrorMessage { + + FRIEND_SHIP_EXISTS("이미 친구 입니다."), + FRIEND_SHIP_PENDING("친구 요청 대기중입니다."); + + private final String message; +} diff --git a/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipExistsException.java b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipExistsException.java new file mode 100644 index 00000000..9d388b25 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipExistsException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.friend.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.friend.exception.ErrorMessage.FRIEND_SHIP_EXISTS; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class FriendShipExistsException extends BaseException { + public FriendShipExistsException() { + super(BAD_REQUEST, FRIEND_SHIP_EXISTS.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipPendingException.java b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipPendingException.java new file mode 100644 index 00000000..ca9011f5 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipPendingException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.friend.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.friend.exception.ErrorMessage.FRIEND_SHIP_PENDING; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class FriendShipPendingException extends BaseException { + public FriendShipPendingException() { + super(BAD_REQUEST, FRIEND_SHIP_PENDING.getMessage()); + } +} From 194b747baa84f4394b996d1af5339f4abfe1e782 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sat, 25 Jan 2025 23:51:32 +0900 Subject: [PATCH 533/770] =?UTF-8?q?feat:=20postSend=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/stomp/CustomChannelInterceptor.java | 7 +++++++ .../chat/stomp/strategy/ChatStrategyHandler.java | 10 ++++++++++ .../chat/stomp/strategy/DefaultCommandStrategy.java | 5 +++++ .../chat/stomp/strategy/StompCommandStrategy.java | 2 ++ .../chat/stomp/strategy/StompConnectStrategy.java | 5 +++++ .../domain/chat/stomp/strategy/StompSendStrategy.java | 5 +++++ .../chat/stomp/strategy/StompSubscribeStrategy.java | 9 ++++++++- 7 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/CustomChannelInterceptor.java b/src/main/java/com/gachtaxi/domain/chat/stomp/CustomChannelInterceptor.java index 7d5a5680..1c677513 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/CustomChannelInterceptor.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/CustomChannelInterceptor.java @@ -19,4 +19,11 @@ public Message preSend(Message message, MessageChannel channel) { return chatStrategyHandler.handle(message, accessor, channel); } + + @Override + public void postSend(Message message, MessageChannel channel, boolean sent) { + StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); + + chatStrategyHandler.handle(message, accessor, channel, sent); + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/ChatStrategyHandler.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/ChatStrategyHandler.java index f93f593a..adb9ad8a 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/ChatStrategyHandler.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/ChatStrategyHandler.java @@ -25,4 +25,14 @@ public Message handle(Message message, StompHeaderAccessor accessor, Messa .orElse(defaultCommandStrategy) .preSend(message, accessor, channel); } + + public void handle(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { + StompCommand command = accessor.getCommand(); + + stompCommandStrategies.stream() + .filter(strategy -> strategy.supports(command)) + .findFirst() + .orElse(defaultCommandStrategy) + .postSend(message, accessor, channel, sent); + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java index 5b9b2f72..a7e47d64 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java @@ -20,4 +20,9 @@ public boolean supports(StompCommand command) { public Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel) { return message; } + + @Override + public void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { + + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java index 2093bb4b..9152a1d0 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java @@ -10,4 +10,6 @@ public interface StompCommandStrategy { boolean supports(StompCommand command); Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel); + + void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent); } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java index 4543bb5c..e7d7fe46 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java @@ -40,4 +40,9 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess return message; } + + @Override + public void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { + + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java index dad9674d..112d9849 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java @@ -28,4 +28,9 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess return message; } + + @Override + public void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { + + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java index 29f08b1f..96545832 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSubscribeStrategy.java @@ -34,7 +34,7 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess if (destination.startsWith(SUB_END_POINT)) { Long roomId = Long.valueOf(destination.replace(SUB_END_POINT, "")); - chattingRoomService.subscribeChatRoom(roomId, accessor); + accessor.getSessionAttributes().put(CHAT_ROOM_ID, roomId); return message; } @@ -45,5 +45,12 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess throw new ChatSubscribeException(); } + + @Override + public void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { + if (sent) { + chattingRoomService.postSubscribeChatroom(accessor); + } + } } From fb7856fe28f472dc0435facc89006ef8007887b7 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sat, 25 Jan 2025 23:51:51 +0900 Subject: [PATCH 534/770] =?UTF-8?q?refactor:=20=EA=B5=AC=EB=8F=85=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20postSubscrib?= =?UTF-8?q?e=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/service/ChattingRoomService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 96f56154..5150f6a0 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -57,13 +57,13 @@ public void delete(long chattingRoomId) { } @Transactional - public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { + public void postSubscribeChatroom(SimpMessageHeaderAccessor accessor) { + Long roomId = (Long) accessor.getSessionAttributes().get(CHAT_ROOM_ID); Long senderId = (Long) accessor.getSessionAttributes().get(CHAT_USER_ID); ChattingRoom chattingRoom = find(roomId); Members members = memberService.findById(senderId); - accessor.getSessionAttributes().put(CHAT_ROOM_ID, roomId); accessor.getSessionAttributes().put(CHAT_USER_NAME, members.getNickname()); if (chattingParticipantService.checkSubscription(chattingRoom, members)) { From 6e6851c7b9a34d60e15dc16603e3f6cbfe02b4a0 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 26 Jan 2025 11:50:50 +0900 Subject: [PATCH 535/770] =?UTF-8?q?feat:=20=EA=B2=BD=EB=A1=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index d31f76a7..b41f0c5c 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -22,6 +22,8 @@ public String[] getPublicUrl(){ public String[] getMemberUrl(){ return new String[]{ "/auth/code/**", + "/api/friends", + "/api/friends/**" }; } From 5f3ab7136013e8584cdd9b70ac9ccf89c6dc8703 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 26 Jan 2025 15:32:30 +0900 Subject: [PATCH 536/770] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=20=EC=8B=9C=20=EC=82=AC=EC=9A=A9=ED=95=A0=20?= =?UTF-8?q?Dto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/response/LoginDto.java | 27 +++++++++++++++++ .../dto/response/MemberLoginResponseDto.java | 24 +++++++++++++++ .../dto/response/MemberResponseDto.java | 30 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/LoginDto.java create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/MemberLoginResponseDto.java create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/MemberResponseDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/LoginDto.java b/src/main/java/com/gachtaxi/domain/members/dto/response/LoginDto.java new file mode 100644 index 00000000..3acc10e5 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/LoginDto.java @@ -0,0 +1,27 @@ +package com.gachtaxi.domain.members.dto.response; + +import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; +import lombok.Builder; + +@Builder +public record LoginDto( + JwtTokenDto jwtTokenDto, + MemberResponseDto memberResponseDto +) { + public static LoginDto of(JwtTokenDto jwtTokenDto, MemberResponseDto memberResponseDto) { + return LoginDto.builder() + .jwtTokenDto(jwtTokenDto) + .memberResponseDto(memberResponseDto) + .build(); + } + + public static LoginDto from(JwtTokenDto jwtTokenDto) { + return LoginDto.builder() + .jwtTokenDto(jwtTokenDto) + .build(); + } + + public boolean isTemporaryUser(){ + return this.memberResponseDto == null; + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/MemberLoginResponseDto.java b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberLoginResponseDto.java new file mode 100644 index 00000000..53b7c759 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberLoginResponseDto.java @@ -0,0 +1,24 @@ +package com.gachtaxi.domain.members.dto.response; + +import lombok.Builder; + +import static com.gachtaxi.domain.members.controller.ResponseMessage.*; + +@Builder +public record MemberLoginResponseDto( + String status, + MemberResponseDto memberResponseDto +) { + public static MemberLoginResponseDto from(MemberResponseDto memberResponseDto) { + return MemberLoginResponseDto.builder() + .status(LOGIN_SUCCESS.name()) + .memberResponseDto(memberResponseDto) + .build(); + } + + public static MemberLoginResponseDto from() { + return MemberLoginResponseDto.builder() + .status(UN_REGISTER.name()) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/MemberResponseDto.java b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberResponseDto.java new file mode 100644 index 00000000..d46e6b1c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberResponseDto.java @@ -0,0 +1,30 @@ +package com.gachtaxi.domain.members.dto.response; + +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.entity.enums.Gender; +import lombok.Builder; + +@Builder +public record MemberResponseDto( + Long userId, + Long studentNumber, + String nickName, + String realName, + String profilePicture, + String email, + String role, + Gender gender +) { + public static MemberResponseDto from(Members members) { + return MemberResponseDto.builder() + .userId(members.getId()) + .studentNumber(members.getStudentNumber()) + .nickName(members.getNickname()) + .realName(members.getRealName()) + .profilePicture(members.getProfilePicture()) + .email(members.getEmail()) + .role(members.getRole().name()) + .gender(members.getGender()) + .build(); + } +} From 297b5bb1f4670796eda277208f674329b5d38cde Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 26 Jan 2025 15:32:55 +0900 Subject: [PATCH 537/770] =?UTF-8?q?fix:=20MemberTokenDto=20=EC=A0=95?= =?UTF-8?q?=EC=A0=81=ED=8C=A9=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/request/MemberTokenDto.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberTokenDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberTokenDto.java index 7decacfe..b8822ec4 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberTokenDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberTokenDto.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.dto.request; +import com.gachtaxi.domain.members.dto.response.MemberResponseDto; import com.gachtaxi.domain.members.entity.Members; import lombok.Builder; @@ -24,4 +25,12 @@ public static MemberTokenDto of(Long id, String email, String role){ .role(role) .build(); } + + public static MemberTokenDto from(MemberResponseDto dto){ + return MemberTokenDto.builder() + .id(dto.userId()) + .email(dto.email()) + .role(dto.role()) + .build(); + } } From becc30e123b3d8d58c25e646096ad2d443501f67 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 26 Jan 2025 15:34:00 +0900 Subject: [PATCH 538/770] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=20=EC=8B=9C=20=EC=9C=A0=EC=A0=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AuthController.java | 52 ++++++++++++------- .../domain/members/service/AuthService.java | 33 ++++++++---- .../domain/members/service/MemberService.java | 6 +-- 3 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java index 4fe27616..6962b435 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AuthController.java @@ -3,6 +3,10 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberAuthCodeRequestDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberTokenDto; +import com.gachtaxi.domain.members.dto.response.LoginDto; +import com.gachtaxi.domain.members.dto.response.MemberLoginResponseDto; +import com.gachtaxi.domain.members.dto.response.MemberResponseDto; import com.gachtaxi.domain.members.service.AuthService; import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.auth.google.dto.GoogleAuthCode; @@ -40,37 +44,44 @@ public class AuthController { @PostMapping("/login/kakao") @Operation(summary = "인가 코드를 전달받아, 카카오 소셜 로그인을 진행합니다.") - public ApiResponse kakaoLogin( + public ApiResponse kakaoLogin( @RequestBody @Valid KakaoAuthCode kakaoAuthCode , HttpServletResponse response) { - JwtTokenDto jwtTokenDto = authService.kakaoLogin(kakaoAuthCode.authCode()); - response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); + LoginDto loginDto = authService.kakaoLogin(kakaoAuthCode.authCode()); + response.setHeader(ACCESS_TOKEN_SUBJECT, loginDto.jwtTokenDto().accessToken()); - if (jwtTokenDto.isTemporaryUser()) { // 임시 유저 - return ApiResponse.response(OK, UN_REGISTER.getMessage(), UN_REGISTER); + if (loginDto.isTemporaryUser()) { // 임시 유저 + return ApiResponse.response(OK, UN_REGISTER.getMessage(), MemberLoginResponseDto.from()); } - cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); - return ApiResponse.response(OK, LOGIN_SUCCESS.getMessage(), LOGIN_SUCCESS); + cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, loginDto.jwtTokenDto().refreshToken(), response); + return ApiResponse.response( + OK, + LOGIN_SUCCESS.getMessage(), + MemberLoginResponseDto.from(loginDto.memberResponseDto()) + ); } @PostMapping("/login/google") @Operation(summary = "인가 코드를 전달받아, 구글 소셜 로그인을 진행합니다.") - public ApiResponse googleLogin( + public ApiResponse googleLogin( @RequestBody @Valid GoogleAuthCode googleAuthCode , HttpServletResponse response) { - JwtTokenDto jwtTokenDto = authService.googleLogin(googleAuthCode.authCode()); - response.setHeader(ACCESS_TOKEN_SUBJECT, jwtTokenDto.accessToken()); + LoginDto loginDto = authService.googleLogin(googleAuthCode.authCode()); + response.setHeader(ACCESS_TOKEN_SUBJECT, loginDto.jwtTokenDto().accessToken()); - if (jwtTokenDto.isTemporaryUser()) { // 임시 유저 - return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage(), UN_REGISTER); + if (loginDto.isTemporaryUser()) { // 임시 유저 + return ApiResponse.response(HttpStatus.OK, UN_REGISTER.getMessage(), MemberLoginResponseDto.from()); } - cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, jwtTokenDto.refreshToken(), response); - return ApiResponse.response(OK, LOGIN_SUCCESS.getMessage(), LOGIN_SUCCESS); - } + cookieUtil.setCookie(REFRESH_TOKEN_SUBJECT, loginDto.jwtTokenDto().refreshToken(), response); + return ApiResponse.response( + OK, + LOGIN_SUCCESS.getMessage(), + MemberLoginResponseDto.from(loginDto.memberResponseDto()) + ); } @PostMapping("/refresh") @Operation(summary = "RefreshToken으로 AccessToken과 RefreshToken을 재발급 하는 API 입니다.") @@ -122,16 +133,21 @@ public ApiResponse updateUserAgreement( @PatchMapping("/supplement") @Operation(summary = "사용자 추가 정보 업데이트하는 API 입니다. (프로필, 닉네임, 실명, 학번, 성별,)") - public ApiResponse updateMemberSupplement( + public ApiResponse updateMemberSupplement( @RequestBody MemberSupplmentRequestDto dto, @CurrentMemberId Long userId, HttpServletResponse response ){ + MemberResponseDto memberDto = memberService.updateMemberSupplement(dto, userId); JwtTokenDto jwtTokenDto = jwtService - .generateJwtToken(memberService.updateMemberSupplement(dto, userId)); + .generateJwtToken(MemberTokenDto.from(memberDto)); responseToken(jwtTokenDto, response); - return ApiResponse.response(OK, SUPPLEMENT_UPDATE_SUCCESS.getMessage()); + return ApiResponse.response( + OK, + SUPPLEMENT_UPDATE_SUCCESS.getMessage(), + MemberLoginResponseDto.from(memberDto) + ); } /* diff --git a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java index 50dc6210..8eb341fb 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AuthService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AuthService.java @@ -2,11 +2,12 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.dto.request.MemberTokenDto; +import com.gachtaxi.domain.members.dto.response.LoginDto; +import com.gachtaxi.domain.members.dto.response.MemberResponseDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.global.auth.google.dto.GoogleTokenResponse; import com.gachtaxi.global.auth.google.dto.GoogleUserInfoResponse; import com.gachtaxi.global.auth.google.utils.GoogleUtils; -import com.gachtaxi.global.auth.jwt.dto.JwtTokenDto; import com.gachtaxi.global.auth.jwt.service.JwtService; import com.gachtaxi.global.auth.kakao.util.KakaoUtil; import lombok.RequiredArgsConstructor; @@ -27,38 +28,52 @@ public class AuthService { private final JwtService jwtService; private final MemberService memberService; - public JwtTokenDto kakaoLogin(String authCode) { + public LoginDto kakaoLogin(String authCode) { KakaoUserInfoResponse userInfo = getKakaoUserInfoResponse(authCode); Long kakaoId = userInfo.id(); Optional optionalMember = memberService.findByKakaoId(kakaoId); if(optionalMember.isEmpty()) { - return jwtService.generateTmpAccessToken(memberService.saveTmpKakaoMember(kakaoId)); + return LoginDto.from( + jwtService.generateTmpAccessToken(memberService.saveTmpKakaoMember(kakaoId)) + ); } Members members = optionalMember.get(); if(members.getStatus() == INACTIVE){ - return jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())); + return LoginDto.from( + jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())) + ); } - return jwtService.generateJwtToken(MemberTokenDto.from(members)); + return LoginDto.of( + jwtService.generateJwtToken(MemberTokenDto.from(members)), + MemberResponseDto.from(members) + ); } - public JwtTokenDto googleLogin(String authCode) { + public LoginDto googleLogin(String authCode) { GoogleUserInfoResponse userInfo = getGoogleUserInfoResponse(authCode); String googleId = userInfo.id(); Optional optionalMember = memberService.findByGoogleId(googleId); if(optionalMember.isEmpty()) { - return jwtService.generateTmpAccessToken(memberService.saveTmpGoogleMember(googleId)); + return LoginDto.from( + jwtService.generateTmpAccessToken(memberService.saveTmpGoogleMember(googleId)) + ); } Members members = optionalMember.get(); if(members.getStatus() == INACTIVE){ - return jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())); + return LoginDto.from( + jwtService.generateTmpAccessToken(InactiveMemberDto.of(optionalMember.get())) + ); } - return jwtService.generateJwtToken(MemberTokenDto.from(members)); + return LoginDto.of( + jwtService.generateJwtToken(MemberTokenDto.from(members)), + MemberResponseDto.from(members) + ); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 5322c75f..e4977108 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -4,7 +4,7 @@ import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; -import com.gachtaxi.domain.members.dto.request.MemberTokenDto; +import com.gachtaxi.domain.members.dto.response.MemberResponseDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedNickNameException; import com.gachtaxi.domain.members.exception.DuplicatedStudentNumberException; @@ -51,14 +51,14 @@ public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId) { } @Transactional - public MemberTokenDto updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { + public MemberResponseDto updateMemberSupplement(MemberSupplmentRequestDto dto, Long userId) { checkDuplicatedNickName(dto.nickname()); checkDuplicatedStudentNumber(dto.studentNumber()); Members members = findById(userId); members.updateSupplment(dto); - return MemberTokenDto.from(members); + return MemberResponseDto.from(members); } public Optional findByKakaoId(Long kakaoId) {return memberRepository.findByKakaoId(kakaoId);} From f5aa92f459eca115cc5e8a5061c1315aa9cf2ed6 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 27 Jan 2025 16:38:08 +0900 Subject: [PATCH 539/770] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=B6=94=EA=B0=80=20=EB=B0=98?= =?UTF-8?q?=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/dto/request/ChatMessage.java | 2 ++ .../domain/chat/dto/response/ChattingMessageResponse.java | 2 ++ .../com/gachtaxi/domain/chat/entity/ChattingMessage.java | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java index 83722cca..66a75f76 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/request/ChatMessage.java @@ -16,6 +16,7 @@ public record ChatMessage( Long senderId, String senderName, String message, + String profilePicture, ReadMessageRange range, Long unreadCount, LocalDateTime timeStamp, @@ -28,6 +29,7 @@ public static ChatMessage from(ChattingMessage chattingMessage) { .senderId(chattingMessage.getSenderId()) .senderName(chattingMessage.getSenderName()) .message(chattingMessage.getMessage()) + .profilePicture(chattingMessage.getProfilePicture()) .unreadCount(chattingMessage.getUnreadCount()) .timeStamp(chattingMessage.getTimeStamp()) .messageType(chattingMessage.getMessageType()) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java index 088c9d18..a7dfaa8d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingMessageResponse.java @@ -12,6 +12,7 @@ public record ChattingMessageResponse( Long senderId, String senderName, String message, + String profilePicture, Long unreadCount, LocalDateTime timeStamp, MessageType messageType @@ -22,6 +23,7 @@ public static ChattingMessageResponse from(ChattingMessage chattingMessage) { .senderId(chattingMessage.getSenderId()) .senderName(chattingMessage.getSenderName()) .message(chattingMessage.getMessage()) + .profilePicture(chattingMessage.getProfilePicture()) .unreadCount(chattingMessage.getUnreadCount()) .timeStamp(chattingMessage.getTimeStamp()) .messageType(chattingMessage.getMessageType()) diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java index 4f75f4c8..f985b7b9 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingMessage.java @@ -25,6 +25,8 @@ public class ChattingMessage { private String senderName; + private String profilePicture; + private Long roomId; private String message; @@ -38,12 +40,13 @@ public class ChattingMessage { @LastModifiedDate private LocalDateTime updatedAt; - public static ChattingMessage of(ChatMessageRequest request, long roomId, long senderId, String senderName, long unreadCount) { + public static ChattingMessage of(ChatMessageRequest request, long roomId, long senderId, String senderName, long unreadCount, String profilePicture) { return ChattingMessage.builder() .senderId(senderId) .senderName(senderName) .roomId(roomId) .message(request.message()) + .profilePicture(profilePicture) .unreadCount(unreadCount) .messageType(MessageType.MESSAGE) .timeStamp(LocalDateTime.now()) From a75841ac355d280f3ba1caa8102fc06afc8e5f95 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 27 Jan 2025 16:41:42 +0900 Subject: [PATCH 540/770] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20Url=EC=9D=84=20redis=EC=97=90=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/ChattingRedisService.java | 23 +++++++++++-------- .../chat/service/ChattingRoomService.java | 4 ++-- .../domain/chat/service/ChattingService.java | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java index 3abbae09..19e9f1f0 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java @@ -1,6 +1,5 @@ package com.gachtaxi.domain.chat.service; -import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.exception.UnSubscriptionException; import lombok.RequiredArgsConstructor; import org.springframework.data.redis.core.RedisTemplate; @@ -13,22 +12,22 @@ public class ChattingRedisService { private final RedisTemplate chatRoomRedisTemplate; - public void saveSubscribeMember(long roomId, long senderId) { + public void saveSubscribeMember(long roomId, long senderId, String profilePicture) { String key = getKey(roomId); - chatRoomRedisTemplate.opsForSet().add(key, senderId); + chatRoomRedisTemplate.opsForHash().put(key, String.valueOf(senderId), profilePicture); } public boolean isActive(long roomId, long senderId) { String key = getKey(roomId); - return Boolean.TRUE.equals(chatRoomRedisTemplate.opsForSet().isMember(key, senderId)); + return Boolean.TRUE.equals(chatRoomRedisTemplate.opsForHash().hasKey(key, String.valueOf(senderId))); } public void removeSubscribeMember(long roomId, long senderId) { String key = getKey(roomId); - chatRoomRedisTemplate.opsForSet().remove(key, senderId); + chatRoomRedisTemplate.opsForHash().delete(key, String.valueOf(senderId)); } public void checkSubscriptionStatus(long roomId, long senderId) { @@ -40,13 +39,19 @@ public void checkSubscriptionStatus(long roomId, long senderId) { public long getSubscriberCount(long roomId) { String key = getKey(roomId); - Long size = chatRoomRedisTemplate.opsForSet().size(key); + return chatRoomRedisTemplate.opsForHash().size(key); + } + + public String getProfilePicture(long roomId, long senderId) { + String key = getKey(roomId); + + Object profileImageUrl = chatRoomRedisTemplate.opsForHash().get(key, String.valueOf(senderId)); - if (size == null) { - throw new ChattingRoomNotFoundException(); + if (profileImageUrl == null) { + return null; } - return size; + return profileImageUrl.toString(); } private String getKey(long roomId) { diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 96f56154..6397ca9d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -67,12 +67,12 @@ public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { accessor.getSessionAttributes().put(CHAT_USER_NAME, members.getNickname()); if (chattingParticipantService.checkSubscription(chattingRoom, members)) { - chattingRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); + chattingRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId(), members.getProfilePicture()); return; } - chattingRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId()); + chattingRedisService.saveSubscribeMember(chattingRoom.getId(), members.getId(), members.getProfilePicture()); ChattingParticipant newParticipant = ChattingParticipant.of(chattingRoom, members); chattingParticipantService.save(newParticipant); diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index efb63ad7..34d357df 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -53,8 +53,9 @@ public void chat(ChatMessageRequest request, SimpMessageHeaderAccessor accessor) String senderName = getSessionAttribute(accessor, CHAT_USER_NAME, String.class); long unreadCount = getUnreadCount(roomId); + String profilePicture = chattingRedisService.getProfilePicture(roomId, userId); - ChattingMessage chattingMessage = ChattingMessage.of(request, roomId, userId, senderName, unreadCount); + ChattingMessage chattingMessage = ChattingMessage.of(request, roomId, userId, senderName, unreadCount, profilePicture); chattingMessageRepository.save(chattingMessage); From b9b304cfd6b6312b48f999b1fe5316f52036d462 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Mon, 27 Jan 2025 16:57:27 +0900 Subject: [PATCH 541/770] =?UTF-8?q?feat:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=20=EC=9D=B8=EC=9B=90=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/controller/ChattingController.java | 10 ++++++++++ .../domain/chat/controller/ResponseMessage.java | 3 ++- .../chat/dto/response/ChattingRoomCountResponse.java | 10 ++++++++++ .../domain/chat/service/ChattingRoomService.java | 8 ++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomCountResponse.java diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index 85a29256..19512136 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.chat.dto.request.ChatMessageRequest; import com.gachtaxi.domain.chat.dto.response.ChatResponse; +import com.gachtaxi.domain.chat.dto.response.ChattingRoomCountResponse; import com.gachtaxi.domain.chat.dto.response.ChattingRoomResponse; import com.gachtaxi.domain.chat.service.ChattingRoomService; import com.gachtaxi.domain.chat.service.ChattingService; @@ -48,6 +49,15 @@ public ApiResponse getChattingMessages(@PathVariable Long roomId, return ApiResponse.response(OK, GET_CHATTING_MESSAGE_SUCCESS.getMessage(), response); } + @GetMapping("/api/chat/count/{roomId}") + @Operation(summary = "채팅방의 총 참여자 수를 조회하기 위한 API입니다.") + public ApiResponse getChattingMessageCount(@CurrentMemberId Long memberId, + @PathVariable Long roomId) { + ChattingRoomCountResponse response = chattingRoomService.getCount(memberId, roomId); + + return ApiResponse.response(OK, GET_CHATTING_PARTICIPANT_COUNT_SUCCESS.getMessage(), response); + } + @DeleteMapping("/api/chat/{roomId}") @Operation(summary = "채팅방을 퇴장하는 API입니다. 퇴장시 STOMP UNSUBSCRIBE를 꼭 해주세요") public ApiResponse exitChattingRoom(@PathVariable Long roomId, diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java index c214df66..020c7367 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ResponseMessage.java @@ -9,7 +9,8 @@ public enum ResponseMessage { CREATE_CHATTING_ROOM_SUCCESS("채팅방 생성에 성공했습니다."), GET_CHATTING_MESSAGE_SUCCESS("이전 메시지 조회에 성공 했습니다."), - EXIT_CHATTING_ROOM_SUCCESS("채팅방 퇴장에 성공했습니다."); + EXIT_CHATTING_ROOM_SUCCESS("채팅방 퇴장에 성공했습니다."), + GET_CHATTING_PARTICIPANT_COUNT_SUCCESS("채팅방 전체 참여자 조회에 성공했습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomCountResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomCountResponse.java new file mode 100644 index 00000000..b8cb308f --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChattingRoomCountResponse.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.chat.dto.response; + +public record ChattingRoomCountResponse( + Long roomId, + Long totalParticipantCount +) { + public static ChattingRoomCountResponse of(Long roomId, Long totalParticipantCount) { + return new ChattingRoomCountResponse(roomId, totalParticipantCount); + } +} diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 6397ca9d..e5fa8eca 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.chat.service; import com.gachtaxi.domain.chat.dto.request.ChatMessage; +import com.gachtaxi.domain.chat.dto.response.ChattingRoomCountResponse; import com.gachtaxi.domain.chat.dto.response.ChattingRoomResponse; import com.gachtaxi.domain.chat.entity.ChattingMessage; import com.gachtaxi.domain.chat.entity.ChattingParticipant; @@ -56,6 +57,13 @@ public void delete(long chattingRoomId) { chattingRoom.delete(); } + public ChattingRoomCountResponse getCount(Long memberId, Long roomId) { + chattingParticipantService.find(roomId, memberId); + Long count = chattingParticipantService.getParticipantCount(roomId); + + return ChattingRoomCountResponse.of(roomId, count); + } + @Transactional public void subscribeChatRoom(long roomId, SimpMessageHeaderAccessor accessor) { Long senderId = (Long) accessor.getSessionAttributes().get(CHAT_USER_ID); From 08432f184625c8da8b44d3dbc1687bb6f7985db3 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 27 Jan 2025 23:50:42 +0900 Subject: [PATCH 542/770] =?UTF-8?q?fix:=20Friends=202=EA=B0=9C=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=20=EC=9C=A0=EB=8B=88=ED=81=AC=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/friend/entity/Friends.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java b/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java index 50ea6410..00123ded 100644 --- a/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java +++ b/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java @@ -15,8 +15,10 @@ @Entity @Getter -@Table(name="Friends") -@SuperBuilder +@Table( + name = "Friends", + uniqueConstraints = @UniqueConstraint(columnNames = {"sender_id", "receiver_id"}) +)@SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Friends extends BaseEntity { @@ -38,4 +40,8 @@ public static Friends of(Members sender, Members receiver) { .receiver(receiver) .build(); } + + public void updateStatus(FriendStatus status){ + this.status = status; + } } From b812766adbca698b121bbd20451ba790477eda44 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 27 Jan 2025 23:50:53 +0900 Subject: [PATCH 543/770] =?UTF-8?q?feat:=20=EC=98=88=EC=99=B8=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/friend/exception/ErrorMessage.java | 6 ++++-- .../domain/friend/exception/FriendShipExistsException.java | 4 ++-- .../domain/friend/exception/FriendShipPendingException.java | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/friend/exception/ErrorMessage.java index f394c2ad..d44a79eb 100644 --- a/src/main/java/com/gachtaxi/domain/friend/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/friend/exception/ErrorMessage.java @@ -7,8 +7,10 @@ @AllArgsConstructor public enum ErrorMessage { - FRIEND_SHIP_EXISTS("이미 친구 입니다."), - FRIEND_SHIP_PENDING("친구 요청 대기중입니다."); + FRIEND_DO_NOT_SEND_MYSELF("자기 자신에게 친구 요청을 보낼 수 없어요"), + FRIEND_NOT_EXISTS("잘못된 친구 관계입니다."), + FRIEND_EXISTS("이미 친구 입니다."), + FRIEND_PENDING("친구 요청 대기중입니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipExistsException.java b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipExistsException.java index 9d388b25..38f91f71 100644 --- a/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipExistsException.java +++ b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipExistsException.java @@ -2,11 +2,11 @@ import com.gachtaxi.global.common.exception.BaseException; -import static com.gachtaxi.domain.friend.exception.ErrorMessage.FRIEND_SHIP_EXISTS; +import static com.gachtaxi.domain.friend.exception.ErrorMessage.FRIEND_EXISTS; import static org.springframework.http.HttpStatus.BAD_REQUEST; public class FriendShipExistsException extends BaseException { public FriendShipExistsException() { - super(BAD_REQUEST, FRIEND_SHIP_EXISTS.getMessage()); + super(BAD_REQUEST, FRIEND_EXISTS.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipPendingException.java b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipPendingException.java index ca9011f5..99308658 100644 --- a/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipPendingException.java +++ b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipPendingException.java @@ -2,11 +2,11 @@ import com.gachtaxi.global.common.exception.BaseException; -import static com.gachtaxi.domain.friend.exception.ErrorMessage.FRIEND_SHIP_PENDING; +import static com.gachtaxi.domain.friend.exception.ErrorMessage.FRIEND_PENDING; import static org.springframework.http.HttpStatus.BAD_REQUEST; public class FriendShipPendingException extends BaseException { public FriendShipPendingException() { - super(BAD_REQUEST, FRIEND_SHIP_PENDING.getMessage()); + super(BAD_REQUEST, FRIEND_PENDING.getMessage()); } } From d477c7c655581eab799fcff0f271874ff1649eb8 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 28 Jan 2025 00:22:41 +0900 Subject: [PATCH 544/770] =?UTF-8?q?feat:=20=EC=97=B0=EA=B2=B0=20=ED=95=B4?= =?UTF-8?q?=EC=A0=9C=20=EC=8B=9C=EA=B0=84=20=EC=B6=94=EA=B0=80=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/dto/response/ChatResponse.java | 2 +- .../com/gachtaxi/domain/chat/entity/ChattingParticipant.java | 4 ++++ .../com/gachtaxi/domain/chat/service/ChattingService.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java index 830cfb83..60f64ff1 100644 --- a/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java +++ b/src/main/java/com/gachtaxi/domain/chat/dto/response/ChatResponse.java @@ -16,7 +16,7 @@ public record ChatResponse( public static ChatResponse of(ChattingParticipant chattingParticipant, List chattingMessages, ChatPageableResponse chatPageableResponse) { return ChatResponse.builder() .memberId(chattingParticipant.getMembers().getId()) - .disconnectedAt(chattingParticipant.getLastReadAt()) + .disconnectedAt(chattingParticipant.getDisconnectedAt()) .chattingMessage(chattingMessages) .pageable(chatPageableResponse) .build(); diff --git a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java index 8a14ed3c..7cd81acd 100644 --- a/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java +++ b/src/main/java/com/gachtaxi/domain/chat/entity/ChattingParticipant.java @@ -35,6 +35,8 @@ public class ChattingParticipant extends BaseEntity { @CreatedDate private LocalDateTime lastReadAt; + private LocalDateTime disconnectedAt; + public static ChattingParticipant of(ChattingRoom chattingRoom, Members members) { return ChattingParticipant.builder() .chattingRoom(chattingRoom) @@ -48,9 +50,11 @@ public void reSubscribe() { public void unsubscribe() { this.lastReadAt = LocalDateTime.now(); + this.disconnectedAt = LocalDateTime.now(); } public void disconnect() { this.lastReadAt = LocalDateTime.now(); + this.disconnectedAt = LocalDateTime.now(); } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java index 34d357df..6868df84 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingService.java @@ -100,7 +100,7 @@ private Slice loadMessage(long roomId, ChattingParticipant chat } private Slice loadInitialMessage(long roomId, ChattingParticipant chattingParticipant, int pageSize) { - int chattingCount = chattingMessageRepository.countAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getLastReadAt()); + int chattingCount = chattingMessageRepository.countAllByRoomIdAndTimeStampAfterOrderByTimeStampDesc(roomId, chattingParticipant.getDisconnectedAt()); int effectivePageSize = Math.max(chattingCount, pageSize); Pageable pageable = PageRequest.of(0, effectivePageSize, Sort.by(Sort.Direction.DESC, "timeStamp")); From c9510b8e18104f3b5d5e3621e10c63213e5cd4c7 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 28 Jan 2025 12:25:51 +0900 Subject: [PATCH 545/770] =?UTF-8?q?refactor:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=AA=85=EC=9D=84=20=EB=B0=9B=EC=95=84=20=ED=99=95=EC=9E=A5?= =?UTF-8?q?=EC=9E=90=EB=A5=BC=20=EC=B6=94=EC=B6=9C=ED=95=B4=20url=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/common/image/ImageUtil.java | 11 +++++++++-- .../common/image/controller/ImageController.java | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/common/image/ImageUtil.java b/src/main/java/com/gachtaxi/global/common/image/ImageUtil.java index 5a17cb8e..523a72c3 100644 --- a/src/main/java/com/gachtaxi/global/common/image/ImageUtil.java +++ b/src/main/java/com/gachtaxi/global/common/image/ImageUtil.java @@ -20,8 +20,8 @@ public class ImageUtil { @Value("${cloud.aws.s3.bucket}") private String bucket; - public String generateUrl() { - String key = UUID.randomUUID().toString(); + public String generateUrl(String fileName) { + String key = generateKey(fileName); PutObjectRequest putObjectRequest = PutObjectRequest.builder() .bucket(bucket) @@ -37,4 +37,11 @@ public String generateUrl() { return presignedUrlRequest.url().toString(); } + + private String generateKey(String fileName) { + String key = UUID.randomUUID().toString(); + String extension = fileName.substring(fileName.lastIndexOf(".") + 1); + + return key + "." + extension; + } } diff --git a/src/main/java/com/gachtaxi/global/common/image/controller/ImageController.java b/src/main/java/com/gachtaxi/global/common/image/controller/ImageController.java index fb1dca55..d3e6fc6b 100644 --- a/src/main/java/com/gachtaxi/global/common/image/controller/ImageController.java +++ b/src/main/java/com/gachtaxi/global/common/image/controller/ImageController.java @@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import static com.gachtaxi.global.common.image.controller.ResponseMessage.PRESIGNED_URL_GENERATE_SUCCESS; @@ -22,8 +23,8 @@ public class ImageController { @GetMapping() @Operation(summary = "Presigned Url 반환을 위한 요청 API 입니다.") - public ApiResponse getPutUrl() { - String putUrl = imageUtil.generateUrl(); + public ApiResponse getPutUrl(@RequestParam String fileName) { + String putUrl = imageUtil.generateUrl(fileName); return ApiResponse.response(OK, PRESIGNED_URL_GENERATE_SUCCESS.getMessage(), putUrl); } From 1cc3692bcafb31567efcaa9ebfc05389df093abb Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 28 Jan 2025 13:03:48 +0900 Subject: [PATCH 546/770] =?UTF-8?q?refactor:=20pageable=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=EB=A5=BC=20=EA=B0=84=EC=86=8C=ED=99=94?= =?UTF-8?q?=ED=95=98=EC=97=AC=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NotificationController.java | 11 +++++----- .../response/NotificationListResponse.java | 12 ++++++++++ .../NotificationPageableResponse.java | 22 +++++++++++++++++++ .../dto/response/NotificationResponse.java | 3 --- .../service/NotificationService.java | 19 +++++++++++----- 5 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationListResponse.java create mode 100644 src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationPageableResponse.java diff --git a/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java b/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java index 93a880a4..2878aa2e 100644 --- a/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java +++ b/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java @@ -1,14 +1,13 @@ package com.gachtaxi.domain.notification.controller; import com.gachtaxi.domain.notification.dto.response.NotificationInfoResponse; -import com.gachtaxi.domain.notification.dto.response.NotificationResponse; +import com.gachtaxi.domain.notification.dto.response.NotificationListResponse; import com.gachtaxi.domain.notification.service.NotificationService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Slice; import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.notification.controller.ResponseMessage.NOTIFICATION_DELETE_SUCCESS; @@ -25,10 +24,10 @@ public class NotificationController { @GetMapping @Operation(summary = "전체 알림을 조회하는 API입니다.") - public ApiResponse> getNotifications(@CurrentMemberId Long memberId, - @RequestParam int pageNum, - @RequestParam int pageSize) { - Slice response = notificationService.getNotifications(memberId, pageNum, pageSize); + public ApiResponse getNotifications(@CurrentMemberId Long memberId, + @RequestParam int pageNum, + @RequestParam int pageSize) { + NotificationListResponse response = notificationService.getNotifications(memberId, pageNum, pageSize); return ApiResponse.response(OK, NOTIFICATION_GET_SUCCESS.getMessage(), response); } diff --git a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationListResponse.java b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationListResponse.java new file mode 100644 index 00000000..d1d251f2 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationListResponse.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.notification.dto.response; + +import java.util.List; + +public record NotificationListResponse( + List response, + NotificationPageableResponse pageable +) { + public static NotificationListResponse of(List response, NotificationPageableResponse pageable) { + return new NotificationListResponse(response, pageable); + } +} diff --git a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationPageableResponse.java b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationPageableResponse.java new file mode 100644 index 00000000..088310f7 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationPageableResponse.java @@ -0,0 +1,22 @@ +package com.gachtaxi.domain.notification.dto.response; + +import com.gachtaxi.domain.notification.entity.Notification; +import lombok.Builder; +import org.springframework.data.domain.Slice; + +@Builder +public record NotificationPageableResponse( + int pageNumber, + int pageSize, + int numberOfElements, + boolean last +) { + public static NotificationPageableResponse from(Slice slice) { + return NotificationPageableResponse.builder() + .pageNumber(slice.getNumber()) + .pageSize(slice.getSize()) + .numberOfElements(slice.getNumberOfElements()) + .last(slice.isLast()) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java index 6823b640..64ee1b0e 100644 --- a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java +++ b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java @@ -1,7 +1,6 @@ package com.gachtaxi.domain.notification.dto.response; import com.gachtaxi.domain.notification.entity.Notification; -import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; import com.gachtaxi.domain.notification.entity.enums.NotificationType; import lombok.Builder; @@ -13,7 +12,6 @@ public record NotificationResponse( long senderId, long receiverId, NotificationType type, - NotificationStatus status, String title, String content, LocalDateTime createdAt @@ -24,7 +22,6 @@ public static NotificationResponse from(Notification notification) { .senderId(notification.getSenderId()) .receiverId(notification.getReceiverId()) .type(notification.getType()) - .status(notification.getStatus()) .title(notification.getTitle()) .content(notification.getContent()) .createdAt(notification.getCreateDate()) diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java index b7a878a6..c79326e7 100644 --- a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -2,6 +2,8 @@ import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.notification.dto.response.NotificationInfoResponse; +import com.gachtaxi.domain.notification.dto.response.NotificationListResponse; +import com.gachtaxi.domain.notification.dto.response.NotificationPageableResponse; import com.gachtaxi.domain.notification.dto.response.NotificationResponse; import com.gachtaxi.domain.notification.entity.Notification; import com.gachtaxi.domain.notification.entity.enums.NotificationType; @@ -17,6 +19,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + import static com.gachtaxi.domain.notification.entity.enums.NotificationStatus.UNREAD; @Slf4j @@ -28,7 +32,7 @@ public class NotificationService { private final FcmService fcmService; @Transactional - public Slice getNotifications(Long receiverId, int pageNum, int pageSize) { + public NotificationListResponse getNotifications(Long receiverId, int pageNum, int pageSize) { Pageable pageable = PageRequest.of(pageNum, pageSize, Sort.by(Sort.Direction.DESC, "createDate")); Slice notifications = notificationRepository.findAllByReceiverId(receiverId, pageable); @@ -37,8 +41,13 @@ public Slice getNotifications(Long receiverId, int pageNum .filter(notification -> notification.getStatus() == UNREAD) .forEach(Notification::read); - return notifications - .map(NotificationResponse::from); + List responses = notifications.stream() + .map(NotificationResponse::from) + .toList(); + + NotificationPageableResponse pageableResponse = NotificationPageableResponse.from(notifications); + + return NotificationListResponse.of(responses, pageableResponse); } public NotificationInfoResponse getInfo(Long receiverId) { @@ -52,11 +61,11 @@ public NotificationInfoResponse getInfo(Long receiverId) { } @Transactional - public void sendWithPush(Long senderId, Members receiver, NotificationType type, String content) { + public void sendWithPush(Long senderId, Members receiver, NotificationType type, String title, String content) { Notification notification = Notification.of(senderId, receiver.getId(), type, content); notificationRepository.save(notification); - fcmService.sendNotification(receiver.getFcmToken(), notification.getTitle(), notification.getContent()); + fcmService.sendNotification(receiver.getFcmToken(), title, notification.getContent()); } @Transactional From 844cc26df13f64460a198820211658ca12b584a0 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 28 Jan 2025 13:03:57 +0900 Subject: [PATCH 547/770] =?UTF-8?q?refactor:=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=B6=95=EC=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notification/entity/enums/NotificationType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java b/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java index 09f43304..e0bedb39 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.notification.entity.enums; public enum NotificationType { - CHAT, MATCH_SUCCESS, MATCH_FAILURE, MATCH_FINISH, FRIEND_REQUEST + MATCH_START, MATCH_FINISH, FRIEND_REQUEST } From 65814e4a085e547aaa943cc4ff80d0da13ce9305 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:00:17 +0900 Subject: [PATCH 548/770] =?UTF-8?q?feat:=20Friends=20=EC=BB=A4=EC=8A=A4?= =?UTF-8?q?=ED=85=80=20=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/exception/FriendNotExistsException.java | 12 ++++++++++++ .../FriendShipDoesNotSendMySelfException.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/friend/exception/FriendNotExistsException.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/exception/FriendShipDoesNotSendMySelfException.java diff --git a/src/main/java/com/gachtaxi/domain/friend/exception/FriendNotExistsException.java b/src/main/java/com/gachtaxi/domain/friend/exception/FriendNotExistsException.java new file mode 100644 index 00000000..bb29becf --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/exception/FriendNotExistsException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.friend.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.friend.exception.ErrorMessage.FRIEND_NOT_EXISTS; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class FriendNotExistsException extends BaseException { + public FriendNotExistsException() { + super(BAD_REQUEST, FRIEND_NOT_EXISTS.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipDoesNotSendMySelfException.java b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipDoesNotSendMySelfException.java new file mode 100644 index 00000000..cdf50e63 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/exception/FriendShipDoesNotSendMySelfException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.friend.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.friend.exception.ErrorMessage.FRIEND_DO_NOT_SEND_MYSELF; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +public class FriendShipDoesNotSendMySelfException extends BaseException { + public FriendShipDoesNotSendMySelfException() { + super(BAD_REQUEST, FRIEND_DO_NOT_SEND_MYSELF.getMessage()); + } +} From 8dfd75251d0f17851617327e3c94ce47edd73298 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:00:32 +0900 Subject: [PATCH 549/770] feat: FriendsStatus --- .../gachtaxi/domain/friend/entity/enums/FriendStatus.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java diff --git a/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java b/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java new file mode 100644 index 00000000..cc0bc7e7 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.friend.entity.enums; + +public enum FriendStatus { + PENDING, ACCEPTED, REJECTED +} From 187e4fb2965923e5bd367926828d72089e4c4d06 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:03:50 +0900 Subject: [PATCH 550/770] =?UTF-8?q?fix:=20FriendsStatus=20REJECTED=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/friend/entity/Friends.java | 5 +++-- .../gachtaxi/domain/friend/entity/enums/FriendStatus.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java b/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java index 00123ded..cbcb2308 100644 --- a/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java +++ b/src/main/java/com/gachtaxi/domain/friend/entity/Friends.java @@ -10,6 +10,7 @@ import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import static com.gachtaxi.domain.friend.entity.enums.FriendStatus.ACCEPTED; import static com.gachtaxi.domain.friend.entity.enums.FriendStatus.PENDING; @@ -41,7 +42,7 @@ public static Friends of(Members sender, Members receiver) { .build(); } - public void updateStatus(FriendStatus status){ - this.status = status; + public void updateStatus(){ + this.status = ACCEPTED; } } diff --git a/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java b/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java index cc0bc7e7..bd382d4a 100644 --- a/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java +++ b/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.friend.entity.enums; public enum FriendStatus { - PENDING, ACCEPTED, REJECTED + PENDING, ACCEPTED } From 1d769184a16f3ee6243e0cbba78dac269120e6e4 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:06:30 +0900 Subject: [PATCH 551/770] =?UTF-8?q?feat:=20=EC=B9=9C=EA=B5=AC=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EB=B3=B4=EB=82=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/controller/FriendController.java | 33 ++++++++++ .../friend/controller/ResponseMessage.java | 17 +++++ .../friend/dto/request/FriendRequestDto.java | 8 +++ .../friend/repository/FriendRepository.java | 18 ++++++ .../domain/friend/service/FriendService.java | 62 +++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/controller/ResponseMessage.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/service/FriendService.java diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java new file mode 100644 index 00000000..7199bb22 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -0,0 +1,33 @@ +package com.gachtaxi.domain.friend.controller; + +import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.service.FriendService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +import com.gachtaxi.global.common.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.gachtaxi.domain.friend.controller.ResponseMessage.FRIEND_REQUEST_SUCCESS; +import static org.springframework.http.HttpStatus.OK; + +@RestController +@RequestMapping("/api/friends") +@RequiredArgsConstructor +public class FriendController { + + private final FriendService friendService; + + @PostMapping + public ApiResponse sendFriendRequest( + @CurrentMemberId Long senderId, + @RequestBody FriendRequestDto dto + ){ + friendService.sendFriendRequest(senderId, dto); + return ApiResponse.response(OK, FRIEND_REQUEST_SUCCESS.getMessage()); + } + + +} diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/friend/controller/ResponseMessage.java new file mode 100644 index 00000000..bc348559 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/controller/ResponseMessage.java @@ -0,0 +1,17 @@ +package com.gachtaxi.domain.friend.controller; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ResponseMessage { + + FRIEND_REQUEST_SUCCESS("친구 요청을 보냈습니다."), + FRIEND_STATUS_ACCEPTED("친구 요청을 수락했습니다"), + FRIEND_STATUS_REJECTED("친구 요청을 거절했습니다"), + FRIEND_DELETE("친구를 삭제했습니다."), + FRIEND_LIST_SUCCESS("친구 목록을 조회합니다"); + + private final String message; +} diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java new file mode 100644 index 00000000..e89f8d61 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java @@ -0,0 +1,8 @@ +package com.gachtaxi.domain.friend.dto.request; + +import jakarta.validation.constraints.NotNull; + +public record FriendRequestDto( + @NotNull Long receiverId +) { +} diff --git a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java new file mode 100644 index 00000000..1113e644 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java @@ -0,0 +1,18 @@ +package com.gachtaxi.domain.friend.repository; + +import com.gachtaxi.domain.friend.entity.Friends; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface FriendRepository extends JpaRepository { + + @Query("SELECT f FROM Friends f WHERE" + + "(f.sender.id = :member1Id AND f.receiver.id = :member2Id) OR" + + "(f.sender.id = :member2Id AND f.receiver.id = :member1Id)") + Optional findFriendShip(Long member1Id, Long member2Id); + +} diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java new file mode 100644 index 00000000..4162d738 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -0,0 +1,62 @@ +package com.gachtaxi.domain.friend.service; + +import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.entity.Friends; +import com.gachtaxi.domain.friend.entity.enums.FriendStatus; +import com.gachtaxi.domain.friend.exception.FriendShipDoesNotSendMySelfException; +import com.gachtaxi.domain.friend.exception.FriendShipExistsException; +import com.gachtaxi.domain.friend.exception.FriendShipPendingException; +import com.gachtaxi.domain.friend.repository.FriendRepository; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.domain.notification.service.NotificationService; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import static com.gachtaxi.domain.notification.entity.enums.NotificationType.FRIEND_REQUEST; + +@Slf4j +@Service +@RequiredArgsConstructor +public class FriendService { + + private final FriendRepository friendRepository; + private final NotificationService notificationService; + private final MemberService memberService; + + public static final String FRIEND_REQUEST_MESSAGE = "%s 님이 친구 요청을 보냈어요."; + + @Transactional + public void sendFriendRequest(Long senderId, FriendRequestDto dto) { + Members sender = memberService.findById(senderId); + Members recevier = memberService.findById(dto.receiverId()); + + checkDuplicatedFriendShip(senderId, recevier.getId()); + friendRepository.save(Friends.of(sender, recevier)); + + notificationService.sendWithPush( + sender.getId(), + recevier, + FRIEND_REQUEST, + String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); + } + + + public void checkDuplicatedFriendShip(Long senderId, Long receiverId) { + if(senderId.equals(receiverId)) { // 자기 자신한테 친구 요청을 보낼 경우 + throw new FriendShipDoesNotSendMySelfException(); + } + + friendRepository.findFriendShip(senderId, receiverId) + .ifPresent(f -> { + if(f.getStatus() == FriendStatus.ACCEPTED) { // 이미 친구 관계인 경우 + throw new FriendShipExistsException(); + } + if(f.getStatus() == FriendStatus.PENDING) { // 친구 요청 대기중인 경우 + throw new FriendShipPendingException(); + } + }); + } +} From 22eabe6d2b004ee24dfae8ee02c23850a4711376 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:09:34 +0900 Subject: [PATCH 552/770] =?UTF-8?q?feat:=20=EC=B9=9C=EA=B5=AC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/controller/FriendController.java | 18 ++++++++++++++---- .../dto/response/FriendsResponseDto.java | 19 +++++++++++++++++++ .../domain/friend/mapper/FriendsMapper.java | 15 +++++++++++++++ .../friend/repository/FriendRepository.java | 10 +++++++++- .../domain/friend/service/FriendService.java | 19 +++++++++++++++++++ 5 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/mapper/FriendsMapper.java diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 7199bb22..4f7fce3f 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -1,15 +1,16 @@ package com.gachtaxi.domain.friend.controller; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.service.FriendService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +import static com.gachtaxi.domain.friend.controller.ResponseMessage.FRIEND_LIST_SUCCESS; import static com.gachtaxi.domain.friend.controller.ResponseMessage.FRIEND_REQUEST_SUCCESS; import static org.springframework.http.HttpStatus.OK; @@ -29,5 +30,14 @@ public ApiResponse sendFriendRequest( return ApiResponse.response(OK, FRIEND_REQUEST_SUCCESS.getMessage()); } + // 나의 친구를 반환하는 API + @GetMapping + public ApiResponse> getFriendsList( + @CurrentMemberId Long memberId + ){ + + List response = friendService.getFriendsList(memberId); + return ApiResponse.response(OK, FRIEND_LIST_SUCCESS.getMessage(), response); + } } diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java new file mode 100644 index 00000000..af1aa269 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java @@ -0,0 +1,19 @@ +package com.gachtaxi.domain.friend.dto.response; + +import com.gachtaxi.domain.members.entity.Members; +import lombok.Builder; + +@Builder +public record FriendsResponseDto( + Long friendsId, + String friendsNickName, + String friendsProfileUrl +) { + public static FriendsResponseDto from(Members friends) { + return FriendsResponseDto.builder() + .friendsId(friends.getId()) + .friendsNickName(friends.getNickname()) + .friendsProfileUrl(friends.getProfilePicture()) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/friend/mapper/FriendsMapper.java b/src/main/java/com/gachtaxi/domain/friend/mapper/FriendsMapper.java new file mode 100644 index 00000000..3a4071d4 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/mapper/FriendsMapper.java @@ -0,0 +1,15 @@ +package com.gachtaxi.domain.friend.mapper; + +import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; +import com.gachtaxi.domain.friend.entity.Friends; + +public class FriendsMapper { + + public static FriendsResponseDto toResponseDto(Friends friends, Long memberId) { + if(friends.getSender().getId().equals(memberId)) { + return FriendsResponseDto.from(friends.getReceiver()); + }else{ + return FriendsResponseDto.from(friends.getSender()); + } + } +} diff --git a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java index 1113e644..8c8deeb0 100644 --- a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java +++ b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java @@ -1,18 +1,26 @@ package com.gachtaxi.domain.friend.repository; import com.gachtaxi.domain.friend.entity.Friends; +import io.lettuce.core.dynamic.annotation.Param; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.Optional; @Repository public interface FriendRepository extends JpaRepository { + @Query("SELECT f FROM Friends f " + + "JOIN FETCH f.sender " + + "JOIN FETCH f.receiver " + + "WHERE f.status = 'ACCEPTED' AND " + + "(f.sender.id = :memberId OR f.receiver.id = :memberId)") + List findAcceptedFriendsByMemberId(@Param("memberId") Long memberId); + @Query("SELECT f FROM Friends f WHERE" + "(f.sender.id = :member1Id AND f.receiver.id = :member2Id) OR" + "(f.sender.id = :member2Id AND f.receiver.id = :member1Id)") Optional findFriendShip(Long member1Id, Long member2Id); - } diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 4162d738..2455749b 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -1,11 +1,13 @@ package com.gachtaxi.domain.friend.service; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.entity.Friends; import com.gachtaxi.domain.friend.entity.enums.FriendStatus; import com.gachtaxi.domain.friend.exception.FriendShipDoesNotSendMySelfException; import com.gachtaxi.domain.friend.exception.FriendShipExistsException; import com.gachtaxi.domain.friend.exception.FriendShipPendingException; +import com.gachtaxi.domain.friend.mapper.FriendsMapper; import com.gachtaxi.domain.friend.repository.FriendRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; @@ -15,6 +17,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.List; + import static com.gachtaxi.domain.notification.entity.enums.NotificationType.FRIEND_REQUEST; @Slf4j @@ -43,6 +47,15 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); } + public List getFriendsList(Long memberId){ + List friendsList = getAcceptedFriendsList(memberId); + + return friendsList.stream() + .map(friends -> FriendsMapper.toResponseDto(friends, memberId)) + .toList(); + } + + public void checkDuplicatedFriendShip(Long senderId, Long receiverId) { if(senderId.equals(receiverId)) { // 자기 자신한테 친구 요청을 보낼 경우 @@ -59,4 +72,10 @@ public void checkDuplicatedFriendShip(Long senderId, Long receiverId) { } }); } + + public List getAcceptedFriendsList(Long memberId) { + return friendRepository.findAcceptedFriendsByMemberId(memberId); + } + + } From d25f96355747ffab7da28d45406e0ef084ebcf43 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:11:29 +0900 Subject: [PATCH 553/770] =?UTF-8?q?feat:=20=EC=B9=9C=EA=B5=AC=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=88=98=EB=9D=BD=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/controller/FriendController.java | 13 +++++++++++-- .../request/FriendStatusUpdateReqeustDto.java | 8 ++++++++ .../friend/repository/FriendRepository.java | 2 ++ .../domain/friend/service/FriendService.java | 17 +++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/friend/dto/request/FriendStatusUpdateReqeustDto.java diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 4f7fce3f..221d16df 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.friend.controller; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.dto.request.FriendStatusUpdateReqeustDto; import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.service.FriendService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; @@ -10,8 +11,7 @@ import java.util.List; -import static com.gachtaxi.domain.friend.controller.ResponseMessage.FRIEND_LIST_SUCCESS; -import static com.gachtaxi.domain.friend.controller.ResponseMessage.FRIEND_REQUEST_SUCCESS; +import static com.gachtaxi.domain.friend.controller.ResponseMessage.*; import static org.springframework.http.HttpStatus.OK; @RestController @@ -40,4 +40,13 @@ public ApiResponse> getFriendsList( return ApiResponse.response(OK, FRIEND_LIST_SUCCESS.getMessage(), response); } + @PatchMapping + public ApiResponse acceptFriendRequest( + @CurrentMemberId Long receiverId, + @RequestBody FriendStatusUpdateReqeustDto dto + ){ + friendService.updateFriendStatus(receiverId, dto); + return ApiResponse.response(OK, FRIEND_STATUS_ACCEPTED.getMessage()); + } + } diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendStatusUpdateReqeustDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendStatusUpdateReqeustDto.java new file mode 100644 index 00000000..2c580a5d --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendStatusUpdateReqeustDto.java @@ -0,0 +1,8 @@ +package com.gachtaxi.domain.friend.dto.request; + +import jakarta.validation.constraints.NotNull; + +public record FriendStatusUpdateReqeustDto( + @NotNull Long senderId +) { +} diff --git a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java index 8c8deeb0..88e72c2c 100644 --- a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java +++ b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java @@ -23,4 +23,6 @@ public interface FriendRepository extends JpaRepository { "(f.sender.id = :member1Id AND f.receiver.id = :member2Id) OR" + "(f.sender.id = :member2Id AND f.receiver.id = :member1Id)") Optional findFriendShip(Long member1Id, Long member2Id); + + Optional findBySenderIdAndReceiverId(Long senderId, Long receiverId); } diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 2455749b..269d22ea 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -1,9 +1,11 @@ package com.gachtaxi.domain.friend.service; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.dto.request.FriendStatusUpdateReqeustDto; import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.entity.Friends; import com.gachtaxi.domain.friend.entity.enums.FriendStatus; +import com.gachtaxi.domain.friend.exception.FriendNotExistsException; import com.gachtaxi.domain.friend.exception.FriendShipDoesNotSendMySelfException; import com.gachtaxi.domain.friend.exception.FriendShipExistsException; import com.gachtaxi.domain.friend.exception.FriendShipPendingException; @@ -55,6 +57,11 @@ public List getFriendsList(Long memberId){ .toList(); } + @Transactional + public void updateFriendStatus(Long receiverId, FriendStatusUpdateReqeustDto dto) { + Friends friendShip = findBySenderIdAndReceiverId(dto.senderId(), receiverId); + friendShip.updateStatus(); + } public void checkDuplicatedFriendShip(Long senderId, Long receiverId) { @@ -77,5 +84,15 @@ public List getAcceptedFriendsList(Long memberId) { return friendRepository.findAcceptedFriendsByMemberId(memberId); } + // A와 B 중 누가 sender이고 receiver인지 정확히 아는 경우 (ex Notification에 저장된 친구 요청) + public Friends findBySenderIdAndReceiverId(Long senderId, Long receiverId) { + return friendRepository.findBySenderIdAndReceiverId(senderId, receiverId) + .orElseThrow(FriendNotExistsException::new); + } + // A와 B 중 누가 sender이고 receiver인지 모르는 경우 (ex A와B가 친구인 지 확인할 때) + public Friends getFriendShip(Long senderId, Long receiverId) { + return friendRepository.findFriendShip(senderId, receiverId) + .orElseThrow(FriendNotExistsException::new); + } } From 81c3c0ace45c58db8b20923ae449d078e3c5956a Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:12:32 +0900 Subject: [PATCH 554/770] =?UTF-8?q?feat:=20=EC=B9=9C=EA=B5=AC=20=EA=B1=B0?= =?UTF-8?q?=EC=A0=88=20=EB=B0=8F=20=EC=82=AD=EC=A0=9C=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/controller/FriendController.java | 10 ++++++++++ .../gachtaxi/domain/friend/service/FriendService.java | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 221d16df..487a1408 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -49,4 +49,14 @@ public ApiResponse acceptFriendRequest( return ApiResponse.response(OK, FRIEND_STATUS_ACCEPTED.getMessage()); } + @DeleteMapping + public ApiResponse deleteFriend( + @CurrentMemberId Long memberId, + @RequestBody FriendRequestDto dto + ) { + friendService.deleteFriend(memberId, dto.receiverId()); + + return ApiResponse.response(OK, FRIEND_DELETE.getMessage()); + } + } diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 269d22ea..5dcecbb2 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -63,6 +63,14 @@ public void updateFriendStatus(Long receiverId, FriendStatusUpdateReqeustDto dto friendShip.updateStatus(); } + public void deleteFriend(Long memberId, Long receiverId) { + Friends friendShip = getFriendShip(memberId, receiverId); + friendRepository.delete(friendShip); + } + + /* + * refactoring + * */ public void checkDuplicatedFriendShip(Long senderId, Long receiverId) { if(senderId.equals(receiverId)) { // 자기 자신한테 친구 요청을 보낼 경우 From 4d8cc92938e310f34728c5bffdf855d76beebbc2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:36:18 +0900 Subject: [PATCH 555/770] =?UTF-8?q?feat:=20=EC=B9=9C=EA=B5=AC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=97=90=20=EC=84=B1=EB=B3=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/dto/response/FriendsResponseDto.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java index af1aa269..3a306b97 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java @@ -1,19 +1,22 @@ package com.gachtaxi.domain.friend.dto.response; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.entity.enums.Gender; import lombok.Builder; @Builder public record FriendsResponseDto( Long friendsId, String friendsNickName, - String friendsProfileUrl + String friendsProfileUrl, + Gender gender ) { public static FriendsResponseDto from(Members friends) { return FriendsResponseDto.builder() .friendsId(friends.getId()) .friendsNickName(friends.getNickname()) .friendsProfileUrl(friends.getProfilePicture()) + .gender(friends.getGender()) .build(); } } From 0f45ae37c42ef149984291ac2106b22b5c90f0bd Mon Sep 17 00:00:00 2001 From: koreaioi Date: Tue, 28 Jan 2025 23:46:25 +0900 Subject: [PATCH 556/770] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=A0=ED=8A=B8?= =?UTF-8?q?=EC=B8=A1=EC=9D=B4=20=ED=97=B7=EA=B0=88=EB=A6=AC=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20memberId=EB=A1=9C=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/controller/FriendController.java | 9 ++++----- .../friend/dto/request/FriendRequestDto.java | 2 +- .../domain/friend/service/FriendService.java | 17 ++++++++--------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 487a1408..aa7f2503 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -1,7 +1,6 @@ package com.gachtaxi.domain.friend.controller; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; -import com.gachtaxi.domain.friend.dto.request.FriendStatusUpdateReqeustDto; import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.service.FriendService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; @@ -42,10 +41,10 @@ public ApiResponse> getFriendsList( @PatchMapping public ApiResponse acceptFriendRequest( - @CurrentMemberId Long receiverId, - @RequestBody FriendStatusUpdateReqeustDto dto + @CurrentMemberId Long currentId, + @RequestBody FriendRequestDto dto ){ - friendService.updateFriendStatus(receiverId, dto); + friendService.updateFriendStatus(dto.memberId(), currentId); // 친구 요청 보낸 사람(dto), 받은 사람(토큰 추출) return ApiResponse.response(OK, FRIEND_STATUS_ACCEPTED.getMessage()); } @@ -54,7 +53,7 @@ public ApiResponse deleteFriend( @CurrentMemberId Long memberId, @RequestBody FriendRequestDto dto ) { - friendService.deleteFriend(memberId, dto.receiverId()); + friendService.deleteFriend(memberId, dto.memberId()); return ApiResponse.response(OK, FRIEND_DELETE.getMessage()); } diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java index e89f8d61..36e53bea 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java @@ -3,6 +3,6 @@ import jakarta.validation.constraints.NotNull; public record FriendRequestDto( - @NotNull Long receiverId + @NotNull Long memberId ) { } diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 5dcecbb2..90ffb90d 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -1,7 +1,6 @@ package com.gachtaxi.domain.friend.service; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; -import com.gachtaxi.domain.friend.dto.request.FriendStatusUpdateReqeustDto; import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.entity.Friends; import com.gachtaxi.domain.friend.entity.enums.FriendStatus; @@ -37,14 +36,14 @@ public class FriendService { @Transactional public void sendFriendRequest(Long senderId, FriendRequestDto dto) { Members sender = memberService.findById(senderId); - Members recevier = memberService.findById(dto.receiverId()); + Members receiver = memberService.findById(dto.memberId()); - checkDuplicatedFriendShip(senderId, recevier.getId()); - friendRepository.save(Friends.of(sender, recevier)); + checkDuplicatedFriendShip(senderId, receiver.getId()); + friendRepository.save(Friends.of(sender, receiver)); notificationService.sendWithPush( sender.getId(), - recevier, + receiver, FRIEND_REQUEST, String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); } @@ -58,13 +57,13 @@ public List getFriendsList(Long memberId){ } @Transactional - public void updateFriendStatus(Long receiverId, FriendStatusUpdateReqeustDto dto) { - Friends friendShip = findBySenderIdAndReceiverId(dto.senderId(), receiverId); + public void updateFriendStatus(Long senderId, Long receiverId) { + Friends friendShip = findBySenderIdAndReceiverId(senderId, receiverId); friendShip.updateStatus(); } - public void deleteFriend(Long memberId, Long receiverId) { - Friends friendShip = getFriendShip(memberId, receiverId); + public void deleteFriend(Long currentId, Long memberId) { + Friends friendShip = getFriendShip(currentId, memberId); friendRepository.delete(friendShip); } From 6f62c29d099c19323e5c4f7703564b327127f735 Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 29 Jan 2025 15:51:51 +0900 Subject: [PATCH 557/770] =?UTF-8?q?chore:=20dev=20cd=20=ED=8C=8C=EC=9D=B4?= =?UTF-8?q?=ED=94=84=EB=9D=BC=EC=9D=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 5d884105..4882d908 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -59,7 +59,7 @@ jobs: with: host: ${{ secrets.DEV_SSH_SECRET_HOST }} username: ${{ secrets.DEV_SSH_SECRET_USER }} - port: 30922 + port: 22 key: ${{ secrets.DEV_SSH_SECRET_PRIVATE_KEY }} script: | docker pull ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest From f94b6af3978ede308b3dd76c30f87d085798225b Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 29 Jan 2025 15:53:10 +0900 Subject: [PATCH 558/770] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4=20deploy=20=ED=8A=B8=EB=A6=AC=EA=B1=B0=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 4882d908..51faf78a 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -50,7 +50,7 @@ jobs: deploy: runs-on: ubuntu-latest needs: build - if: github.event_name == 'push' +# if: github.event_name == 'push' steps: # SSH를 사용하여 원격 서버에 배포 From cdbe20588fa133059ffc50b40989a1f0643e9761 Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 29 Jan 2025 15:54:09 +0900 Subject: [PATCH 559/770] test --- .github/workflows/dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 51faf78a..4e34444d 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -2,9 +2,9 @@ name: GachTaxi-BE dev CI/CD on: push: - branches: [ "dev" ] # develop 브랜치에 push 시 트리거 + branches: [ "dev" , "feat/#57/OCICICD파이프라인구축"] # develop 브랜치에 push 시 트리거 pull_request: - branches: [ "dev" ] # develop 브랜치에 대한 PR 시 트리거 + branches: [ "dev", "feat/#57/OCICICD파이프라인구축" ] # develop 브랜치에 대한 PR 시 트리거 types: [opened, synchronize, reopened] jobs: From b0de51eafd53ebc814ba4d1b0d67d77c4ef75891 Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 29 Jan 2025 16:04:55 +0900 Subject: [PATCH 560/770] =?UTF-8?q?chore:=20dev=20cd=EC=97=90=20sudo=20su?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 4e34444d..4e84882d 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -62,10 +62,12 @@ jobs: port: 22 key: ${{ secrets.DEV_SSH_SECRET_PRIVATE_KEY }} script: | + sudo su docker pull ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest docker compose up -d --no-deps gachtaxi # 사용하지 않는 이미지 정리 echo "** 사용하지 않는 Docker 이미지 정리" - echo "${{ secrets.DEV_SSH_SECRET_PASSWORD }}" | sudo docker image prune -f \ No newline at end of file +# echo "${{ secrets.DEV_SSH_SECRET_PASSWORD }}" | sudo docker image prune -f + sudo docker image prune -f \ No newline at end of file From a20649552cb95cff15ec0a8a5e43ed9b576566ce Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 29 Jan 2025 16:10:12 +0900 Subject: [PATCH 561/770] =?UTF-8?q?chore:=20=EB=AA=A8=EB=93=A0=20=EB=AA=85?= =?UTF-8?q?=EB=A0=B9=EC=96=B4=EC=97=90=20sudo=20=EB=AA=85=EB=A0=B9?= =?UTF-8?q?=EC=96=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 4e84882d..bf449a5a 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -62,10 +62,9 @@ jobs: port: 22 key: ${{ secrets.DEV_SSH_SECRET_PRIVATE_KEY }} script: | - sudo su - docker pull ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest + sudo docker pull ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest - docker compose up -d --no-deps gachtaxi + sudo docker compose up -d --no-deps gachtaxi # 사용하지 않는 이미지 정리 echo "** 사용하지 않는 Docker 이미지 정리" From d62b744a706895ff03a089105f1e08ce56cb7159 Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 29 Jan 2025 16:10:51 +0900 Subject: [PATCH 562/770] =?UTF-8?q?chore:=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=EB=82=B4=EB=B6=80=EC=9D=98=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index bf449a5a..a5bd736d 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -68,5 +68,4 @@ jobs: # 사용하지 않는 이미지 정리 echo "** 사용하지 않는 Docker 이미지 정리" -# echo "${{ secrets.DEV_SSH_SECRET_PASSWORD }}" | sudo docker image prune -f sudo docker image prune -f \ No newline at end of file From 7c1d37e9fb7e7ae780617be968a4977c6459634f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 30 Jan 2025 22:05:56 +0900 Subject: [PATCH 563/770] =?UTF-8?q?fix:=20@PathVariable=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/controller/FriendController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index aa7f2503..86a4c10b 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -48,12 +48,12 @@ public ApiResponse acceptFriendRequest( return ApiResponse.response(OK, FRIEND_STATUS_ACCEPTED.getMessage()); } - @DeleteMapping + @DeleteMapping("/{memberId}") public ApiResponse deleteFriend( - @CurrentMemberId Long memberId, - @RequestBody FriendRequestDto dto + @CurrentMemberId Long currentId, + @PathVariable Long memberId ) { - friendService.deleteFriend(memberId, dto.memberId()); + friendService.deleteFriend(currentId, memberId); return ApiResponse.response(OK, FRIEND_DELETE.getMessage()); } From 147360eb341899e9818fc7734e915889f4becb6e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 30 Jan 2025 22:50:55 +0900 Subject: [PATCH 564/770] feat: JPQL Result to DTO --- .../dto/response/FriendsResponseDto.java | 8 ++++++ .../friend/repository/FriendRepository.java | 24 ++++++++++++----- .../domain/friend/service/FriendService.java | 26 ++++++++++++------- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java index 3a306b97..e1a1b552 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsResponseDto.java @@ -19,4 +19,12 @@ public static FriendsResponseDto from(Members friends) { .gender(friends.getGender()) .build(); } + + // Constructor for JPQL Result - DTO Mapping + public FriendsResponseDto(Long friendsId, String friendsNickName, String friendsProfileUrl, Gender gender) { + this.friendsId = friendsId; + this.friendsNickName = friendsNickName; + this.friendsProfileUrl = friendsProfileUrl; + this.gender = gender; + } } diff --git a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java index 88e72c2c..755f37d4 100644 --- a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java +++ b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.friend.repository; +import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.entity.Friends; import io.lettuce.core.dynamic.annotation.Param; import org.springframework.data.jpa.repository.JpaRepository; @@ -12,12 +13,23 @@ @Repository public interface FriendRepository extends JpaRepository { - @Query("SELECT f FROM Friends f " + - "JOIN FETCH f.sender " + - "JOIN FETCH f.receiver " + - "WHERE f.status = 'ACCEPTED' AND " + - "(f.sender.id = :memberId OR f.receiver.id = :memberId)") - List findAcceptedFriendsByMemberId(@Param("memberId") Long memberId); +// @Query("SELECT f FROM Friends f " + +// "JOIN FETCH f.sender " + +// "JOIN FETCH f.receiver " + +// "WHERE f.status = 'ACCEPTED' AND " + +// "(f.sender.id = :memberId OR f.receiver.id = :memberId)") +// List findAcceptedFriendsByMemberId(@Param("memberId") Long memberId); + + @Query("SELECT new com.gachtaxi.domain.friend.dto.response.FriendsResponseDto( " + + "CASE WHEN f.sender.id = :memberId THEN f.receiver.id ELSE f.sender.id END, " + + "CASE WHEN f.sender.id = :memberId THEN f.receiver.nickname ELSE f.sender.nickname END, " + + "CASE WHEN f.sender.id = :memberId THEN f.receiver.profilePicture ELSE f.sender.profilePicture END, " + + "CASE WHEN f.sender.id = :memberId THEN f.receiver.gender ELSE f.sender.gender END " + + ") FROM Friends f " + + "WHERE f.status = 'ACCEPTED' " + + "AND (f.sender.id = :memberId OR f.receiver.id = :memberId)") + List findAcceptedFriendsByMemberId(@Param("memberId") Long memberId); + @Query("SELECT f FROM Friends f WHERE" + "(f.sender.id = :member1Id AND f.receiver.id = :member2Id) OR" + diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 90ffb90d..8316874b 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -8,7 +8,6 @@ import com.gachtaxi.domain.friend.exception.FriendShipDoesNotSendMySelfException; import com.gachtaxi.domain.friend.exception.FriendShipExistsException; import com.gachtaxi.domain.friend.exception.FriendShipPendingException; -import com.gachtaxi.domain.friend.mapper.FriendsMapper; import com.gachtaxi.domain.friend.repository.FriendRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; @@ -48,12 +47,21 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); } - public List getFriendsList(Long memberId){ - List friendsList = getAcceptedFriendsList(memberId); +// public List getFriendsList(Long memberId){ +// List friendsList = getAcceptedFriendsList(memberId); +// +// return friendsList.stream() +// .map(friends -> FriendsMapper.toResponseDto(friends, memberId)) +// .toList(); +// } - return friendsList.stream() - .map(friends -> FriendsMapper.toResponseDto(friends, memberId)) - .toList(); + public List getFriendsList(Long memberId){ + return friendRepository.findAcceptedFriendsByMemberId(memberId); +// List friendsList = getAcceptedFriendsList(memberId); +// +// return friendsList.stream() +// .map(friends -> FriendsMapper.toResponseDto(friends, memberId)) +// .toList(); } @Transactional @@ -87,9 +95,9 @@ public void checkDuplicatedFriendShip(Long senderId, Long receiverId) { }); } - public List getAcceptedFriendsList(Long memberId) { - return friendRepository.findAcceptedFriendsByMemberId(memberId); - } +// public List getAcceptedFriendsList(Long memberId) { +// return friendRepository.findAcceptedFriendsByMemberId(memberId); +// } // A와 B 중 누가 sender이고 receiver인지 정확히 아는 경우 (ex Notification에 저장된 친구 요청) public Friends findBySenderIdAndReceiverId(Long senderId, Long receiverId) { From d4789d1364627fdf9fa15f5e2a3b059c23ebbe09 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 30 Jan 2025 23:29:25 +0900 Subject: [PATCH 565/770] =?UTF-8?q?feat:=20=EA=B3=84=EC=A2=8C=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=ED=95=84=EB=93=9C=20(accountNumber)=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/entity/Members.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 2cb916f0..f06d7c54 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -1,15 +1,14 @@ package com.gachtaxi.domain.members.entity; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; -import com.gachtaxi.domain.members.dto.request.UserSignUpRequestDto; import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; +import com.gachtaxi.domain.members.dto.request.MemberInfoRequestDto; import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; import com.gachtaxi.domain.members.entity.enums.Gender; import com.gachtaxi.domain.members.entity.enums.Role; import com.gachtaxi.domain.members.entity.enums.UserStatus; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.*; -import java.util.Objects; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -17,6 +16,8 @@ import lombok.experimental.SuperBuilder; import org.hibernate.annotations.ColumnDefault; +import java.util.Objects; + @Getter @Entity @SuperBuilder @@ -42,6 +43,9 @@ public class Members extends BaseEntity { @Column(name = "phone_number", unique = true) // 피그마 참고, 일단 null 허용 private String phoneNumber; + @Column(name = "account_number", unique = true) + private String accountNumber; + @Column(name = "kakao_id", unique = true) private Long kakaoId; @@ -113,6 +117,12 @@ public void updateGoogleId(String googleId) { this.googleId = googleId; } + public void updateMemberInfo(MemberInfoRequestDto dto) { + this.profilePicture = dto.profilePicture(); + this.nickname = dto.nickName(); + this.accountNumber = dto.accountNumber(); + } + public void updateAgreement(MemberAgreementRequestDto dto) { this.termsAgreement = dto.termsAgreement(); this.privacyAgreement = dto.privacyAgreement(); From b83f9bbc9f953cd6790bad0a63402d398d71be02 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 30 Jan 2025 23:29:52 +0900 Subject: [PATCH 566/770] =?UTF-8?q?feat:=20MemberInfoRequestDto=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/request/MemberInfoRequestDto.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java new file mode 100644 index 00000000..90371cf3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java @@ -0,0 +1,8 @@ +package com.gachtaxi.domain.members.dto.request; + +public record MemberInfoRequestDto( + String profilePicture, + String nickName, + String accountNumber +) { +} From 3bf08fdc00da0b06ed693c4d5b5a64cd8e58c733 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 30 Jan 2025 23:30:05 +0900 Subject: [PATCH 567/770] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EB=B9=84=EC=A7=80=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/MemberService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index e4977108..e2105a6e 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,9 +1,6 @@ package com.gachtaxi.domain.members.service; -import com.gachtaxi.domain.members.dto.request.FcmTokenRequest; -import com.gachtaxi.domain.members.dto.request.InactiveMemberDto; -import com.gachtaxi.domain.members.dto.request.MemberAgreementRequestDto; -import com.gachtaxi.domain.members.dto.request.MemberSupplmentRequestDto; +import com.gachtaxi.domain.members.dto.request.*; import com.gachtaxi.domain.members.dto.response.MemberResponseDto; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.DuplicatedNickNameException; @@ -31,6 +28,14 @@ public InactiveMemberDto saveTmpKakaoMember(Long kakaoId){ return InactiveMemberDto.of(tmpMember); } + @Transactional + public MemberResponseDto updateMemberInfo(Long currentId, MemberInfoRequestDto dto){ + Members member = findById(currentId); + member.updateMemberInfo(dto); + + return MemberResponseDto.from(member); + } + @Transactional public InactiveMemberDto saveTmpGoogleMember(String googleId){ Members tmpMember = Members.ofGoogleId(googleId); From 848288c6f5a8c7165506294d0024e72bb6d23294 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Thu, 30 Jan 2025 23:30:18 +0900 Subject: [PATCH 568/770] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/MemberController.java | 12 ++++++++++++ .../domain/members/controller/ResponseMessage.java | 1 + 2 files changed, 13 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index 35b0f311..1bd5f974 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -1,6 +1,8 @@ package com.gachtaxi.domain.members.controller; import com.gachtaxi.domain.members.dto.request.FcmTokenRequest; +import com.gachtaxi.domain.members.dto.request.MemberInfoRequestDto; +import com.gachtaxi.domain.members.dto.response.MemberResponseDto; import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; @@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController; import static com.gachtaxi.domain.members.controller.ResponseMessage.FCM_TOKEN_UPDATE_SUCCESS; +import static com.gachtaxi.domain.members.controller.ResponseMessage.MEMBER_INFO_UPDATE; import static org.springframework.http.HttpStatus.OK; @Tag(name = "MEMBER") @@ -32,4 +35,13 @@ public ApiResponse save(@CurrentMemberId Long memberId, return ApiResponse.response(OK, FCM_TOKEN_UPDATE_SUCCESS.getMessage()); } + + @PatchMapping("/info") + public ApiResponse memberInfoModify( + @CurrentMemberId Long currentId, + @RequestBody MemberInfoRequestDto dto + ) { + MemberResponseDto response = memberService.updateMemberInfo(currentId, dto); + return ApiResponse.response(OK, MEMBER_INFO_UPDATE.getMessage(), response); + } } diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index b53d1e62..3b872ae5 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -8,6 +8,7 @@ public enum ResponseMessage { // MemberController REGISTER_SUCCESS("회원가입에 성공했습니다."), + MEMBER_INFO_UPDATE("유저 정보를 성공적으로 수정했습니다!"), FCM_TOKEN_UPDATE_SUCCESS("FCM 토큰 업데이트에 성공했습니다."), // AuthController From 3b30a559b7d87c7a13b18f03fcbdc67b1a4b90a8 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 31 Jan 2025 00:13:58 +0900 Subject: [PATCH 569/770] =?UTF-8?q?fix:=20=EC=9D=91=EB=8B=B5=20accountNumb?= =?UTF-8?q?er=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/response/MemberResponseDto.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/MemberResponseDto.java b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberResponseDto.java index d46e6b1c..e63beb90 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/MemberResponseDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/MemberResponseDto.java @@ -13,7 +13,8 @@ public record MemberResponseDto( String profilePicture, String email, String role, - Gender gender + Gender gender, + String accountNumber ) { public static MemberResponseDto from(Members members) { return MemberResponseDto.builder() @@ -25,6 +26,7 @@ public static MemberResponseDto from(Members members) { .email(members.getEmail()) .role(members.getRole().name()) .gender(members.getGender()) + .accountNumber(members.getAccountNumber()) .build(); } } From 66d5394e6389106e8646196d01504c3f1553858b Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 31 Jan 2025 00:14:14 +0900 Subject: [PATCH 570/770] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=B0=98=ED=99=98=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/MemberController.java | 14 ++++++++------ .../domain/members/controller/ResponseMessage.java | 1 + .../domain/members/service/MemberService.java | 5 +++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index 1bd5f974..ce8a7cee 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -10,13 +10,9 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; -import static com.gachtaxi.domain.members.controller.ResponseMessage.FCM_TOKEN_UPDATE_SUCCESS; -import static com.gachtaxi.domain.members.controller.ResponseMessage.MEMBER_INFO_UPDATE; +import static com.gachtaxi.domain.members.controller.ResponseMessage.*; import static org.springframework.http.HttpStatus.OK; @Tag(name = "MEMBER") @@ -36,6 +32,12 @@ public ApiResponse save(@CurrentMemberId Long memberId, return ApiResponse.response(OK, FCM_TOKEN_UPDATE_SUCCESS.getMessage()); } + @GetMapping("/info") + public ApiResponse getMemberInfo(@CurrentMemberId Long currentId) { + MemberResponseDto response = memberService.getMember(currentId); + return ApiResponse.response(OK, MEMBER_INFO_RESPONSE.getMessage(), response); + } + @PatchMapping("/info") public ApiResponse memberInfoModify( @CurrentMemberId Long currentId, diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 3b872ae5..b72cf3ae 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -9,6 +9,7 @@ public enum ResponseMessage { // MemberController REGISTER_SUCCESS("회원가입에 성공했습니다."), MEMBER_INFO_UPDATE("유저 정보를 성공적으로 수정했습니다!"), + MEMBER_INFO_RESPONSE("유저 정보를 반환합니다."), FCM_TOKEN_UPDATE_SUCCESS("FCM 토큰 업데이트에 성공했습니다."), // AuthController diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index e2105a6e..2b191a95 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -28,6 +28,11 @@ public InactiveMemberDto saveTmpKakaoMember(Long kakaoId){ return InactiveMemberDto.of(tmpMember); } + public MemberResponseDto getMember(Long currentId){ + Members members = findById(currentId); + return MemberResponseDto.from(members); + } + @Transactional public MemberResponseDto updateMemberInfo(Long currentId, MemberInfoRequestDto dto){ Members member = findById(currentId); From 7ed86bcced23493f8d33aa62f1e109e5f56967e0 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 31 Jan 2025 00:20:30 +0900 Subject: [PATCH 571/770] =?UTF-8?q?feat:=20Dto=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=EC=84=B1=20=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/request/MemberInfoRequestDto.java | 8 +++++--- .../members/dto/request/MemberIntegrationRequestDto.java | 9 --------- 2 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/MemberIntegrationRequestDto.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java index 90371cf3..23de4656 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java @@ -1,8 +1,10 @@ package com.gachtaxi.domain.members.dto.request; +import jakarta.validation.constraints.NotNull; + public record MemberInfoRequestDto( - String profilePicture, - String nickName, - String accountNumber + @NotNull String profilePicture, + @NotNull String nickName, + @NotNull String accountNumber ) { } diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberIntegrationRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberIntegrationRequestDto.java deleted file mode 100644 index bc59fc26..00000000 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberIntegrationRequestDto.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gachtaxi.domain.members.dto.request; - -public record MemberIntegrationRequestDto( - String email, - String authCode, - Long kakaoId, - String googleId -) { -} From 7e85925fc7b7e87b46da0ae56287fbdb3c975c6e Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 31 Jan 2025 00:25:28 +0900 Subject: [PATCH 572/770] =?UTF-8?q?feat:=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/controller/MemberController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index ce8a7cee..c0c63770 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -33,7 +33,7 @@ public ApiResponse save(@CurrentMemberId Long memberId, } @GetMapping("/info") - public ApiResponse getMemberInfo(@CurrentMemberId Long currentId) { + public ApiResponse memberInfoDetails(@CurrentMemberId Long currentId) { MemberResponseDto response = memberService.getMember(currentId); return ApiResponse.response(OK, MEMBER_INFO_RESPONSE.getMessage(), response); } From 59a00e7139019072b8382637d361e8622907427f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 31 Jan 2025 00:46:33 +0900 Subject: [PATCH 573/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=8B=9C=20=EC=83=81=EB=8C=80=EB=B0=A9=EC=9D=98=20?= =?UTF-8?q?nickName=EC=9D=84=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/controller/FriendController.java | 3 ++- .../domain/friend/dto/request/FriendRequestDto.java | 2 +- .../domain/friend/dto/request/FriendUpdateDto.java | 8 ++++++++ .../domain/members/repository/MemberRepository.java | 2 ++ .../gachtaxi/domain/members/service/MemberService.java | 5 +++++ 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 86a4c10b..8fe76404 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.friend.controller; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.dto.request.FriendUpdateDto; import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.service.FriendService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; @@ -42,7 +43,7 @@ public ApiResponse> getFriendsList( @PatchMapping public ApiResponse acceptFriendRequest( @CurrentMemberId Long currentId, - @RequestBody FriendRequestDto dto + @RequestBody FriendUpdateDto dto ){ friendService.updateFriendStatus(dto.memberId(), currentId); // 친구 요청 보낸 사람(dto), 받은 사람(토큰 추출) return ApiResponse.response(OK, FRIEND_STATUS_ACCEPTED.getMessage()); diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java index 36e53bea..9c0bd57b 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendRequestDto.java @@ -3,6 +3,6 @@ import jakarta.validation.constraints.NotNull; public record FriendRequestDto( - @NotNull Long memberId + @NotNull String nickName ) { } diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java new file mode 100644 index 00000000..06172f53 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java @@ -0,0 +1,8 @@ +package com.gachtaxi.domain.friend.dto.request; + +import jakarta.validation.constraints.NotNull; + +public record FriendUpdateDto( + @NotNull Long memberId +) { +} diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 994d1634..74134ff4 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -20,5 +20,7 @@ public interface MemberRepository extends JpaRepository { Optional findByNickname(String nickname); + Optional findByNicknameAndStatus(String nickname, UserStatus status); + Optional findByEmailAndStatus(String email, UserStatus status); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index e4977108..0bd77950 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -86,6 +86,11 @@ public Members findActiveByEmail(String email) { .orElseThrow(MemberNotFoundException::new); } + public Members findByNickname(String nickname) { + return memberRepository.findByNicknameAndStatus(nickname, ACTIVE) + .orElseThrow(MemberNotFoundException::new); + } + private void checkDuplicatedStudentNumber(Long studentNumber) { memberRepository.findByStudentNumber(studentNumber).ifPresent(m -> { throw new DuplicatedStudentNumberException(); From 135f425cfb1ced133abd37b0bbbbb5ec5c3c2cf2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 31 Jan 2025 00:46:58 +0900 Subject: [PATCH 574/770] =?UTF-8?q?remove:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/repository/FriendRepository.java | 7 ------- .../domain/friend/service/FriendService.java | 20 ++----------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java index 755f37d4..f986c774 100644 --- a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java +++ b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java @@ -13,13 +13,6 @@ @Repository public interface FriendRepository extends JpaRepository { -// @Query("SELECT f FROM Friends f " + -// "JOIN FETCH f.sender " + -// "JOIN FETCH f.receiver " + -// "WHERE f.status = 'ACCEPTED' AND " + -// "(f.sender.id = :memberId OR f.receiver.id = :memberId)") -// List findAcceptedFriendsByMemberId(@Param("memberId") Long memberId); - @Query("SELECT new com.gachtaxi.domain.friend.dto.response.FriendsResponseDto( " + "CASE WHEN f.sender.id = :memberId THEN f.receiver.id ELSE f.sender.id END, " + "CASE WHEN f.sender.id = :memberId THEN f.receiver.nickname ELSE f.sender.nickname END, " + diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 8316874b..cf514659 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -35,7 +35,8 @@ public class FriendService { @Transactional public void sendFriendRequest(Long senderId, FriendRequestDto dto) { Members sender = memberService.findById(senderId); - Members receiver = memberService.findById(dto.memberId()); + Members receiver = memberService.findByNickname(dto.nickName()); + checkDuplicatedFriendShip(senderId, receiver.getId()); friendRepository.save(Friends.of(sender, receiver)); @@ -47,21 +48,8 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); } -// public List getFriendsList(Long memberId){ -// List friendsList = getAcceptedFriendsList(memberId); -// -// return friendsList.stream() -// .map(friends -> FriendsMapper.toResponseDto(friends, memberId)) -// .toList(); -// } - public List getFriendsList(Long memberId){ return friendRepository.findAcceptedFriendsByMemberId(memberId); -// List friendsList = getAcceptedFriendsList(memberId); -// -// return friendsList.stream() -// .map(friends -> FriendsMapper.toResponseDto(friends, memberId)) -// .toList(); } @Transactional @@ -95,10 +83,6 @@ public void checkDuplicatedFriendShip(Long senderId, Long receiverId) { }); } -// public List getAcceptedFriendsList(Long memberId) { -// return friendRepository.findAcceptedFriendsByMemberId(memberId); -// } - // A와 B 중 누가 sender이고 receiver인지 정확히 아는 경우 (ex Notification에 저장된 친구 요청) public Friends findBySenderIdAndReceiverId(Long senderId, Long receiverId) { return friendRepository.findBySenderIdAndReceiverId(senderId, receiverId) From 2129b55dafd512db8b6743a13e6b862781d591cd Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 13:09:07 +0900 Subject: [PATCH 575/770] =?UTF-8?q?refactor:=20null=20=EC=B2=B4=ED=81=AC?= =?UTF-8?q?=20=ED=98=95=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChattingRedisService.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java index 19e9f1f0..5f0f59f4 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRedisService.java @@ -5,6 +5,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import java.util.Optional; + @Service @RequiredArgsConstructor public class ChattingRedisService { @@ -45,13 +47,9 @@ public long getSubscriberCount(long roomId) { public String getProfilePicture(long roomId, long senderId) { String key = getKey(roomId); - Object profileImageUrl = chatRoomRedisTemplate.opsForHash().get(key, String.valueOf(senderId)); - - if (profileImageUrl == null) { - return null; - } - - return profileImageUrl.toString(); + return Optional.ofNullable(chatRoomRedisTemplate.opsForHash().get(key, String.valueOf(senderId))) + .map(Object::toString) + .orElse(null); } private String getKey(long roomId) { From 4c3010695aa8a8632a7ed7b334756d1964dcbed9 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 13:24:24 +0900 Subject: [PATCH 576/770] =?UTF-8?q?refactor:=20default=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/stomp/strategy/DefaultCommandStrategy.java | 5 ----- .../domain/chat/stomp/strategy/StompCommandStrategy.java | 4 +++- .../domain/chat/stomp/strategy/StompConnectStrategy.java | 5 ----- .../domain/chat/stomp/strategy/StompSendStrategy.java | 5 ----- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java index a7e47d64..5b9b2f72 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/DefaultCommandStrategy.java @@ -20,9 +20,4 @@ public boolean supports(StompCommand command) { public Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel) { return message; } - - @Override - public void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { - - } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java index 9152a1d0..0f22f15c 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompCommandStrategy.java @@ -11,5 +11,7 @@ public interface StompCommandStrategy { Message preSend(Message message, StompHeaderAccessor accessor, MessageChannel channel); - void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent); + default void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { + + } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java index e7d7fe46..4543bb5c 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompConnectStrategy.java @@ -40,9 +40,4 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess return message; } - - @Override - public void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { - - } } diff --git a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java index 112d9849..dad9674d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java +++ b/src/main/java/com/gachtaxi/domain/chat/stomp/strategy/StompSendStrategy.java @@ -28,9 +28,4 @@ public Message preSend(Message message, StompHeaderAccessor accessor, Mess return message; } - - @Override - public void postSend(Message message, StompHeaderAccessor accessor, MessageChannel channel, boolean sent) { - - } } From 52199a75ed9504296818cb87226f6bebe8d496d2 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 15:55:27 +0900 Subject: [PATCH 577/770] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=ED=98=95?= =?UTF-8?q?=EC=8B=9D=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EB=8B=A4=ED=98=95?= =?UTF-8?q?=EC=84=B1=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/entity/Notification.java | 47 +++++++++---------- .../entity/payload/FriendRequestPayload.java | 16 +++++++ .../entity/payload/MatchingPayload.java | 15 ++++++ .../entity/payload/NotificationPayload.java | 11 +++++ 4 files changed, 65 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java create mode 100644 src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingPayload.java create mode 100644 src/main/java/com/gachtaxi/domain/notification/entity/payload/NotificationPayload.java diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/Notification.java b/src/main/java/com/gachtaxi/domain/notification/entity/Notification.java index e4717452..c78fe8ee 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/Notification.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/Notification.java @@ -2,61 +2,51 @@ import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; import com.gachtaxi.domain.notification.entity.enums.NotificationType; -import com.gachtaxi.global.common.entity.BaseEntity; +import com.gachtaxi.domain.notification.entity.payload.NotificationPayload; import jakarta.persistence.Column; -import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; +import jakarta.persistence.Id; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.mongodb.core.mapping.Document; import java.time.LocalDateTime; import static com.gachtaxi.domain.notification.entity.enums.NotificationStatus.*; @Getter -@Entity +@Document(collection = "notifications") @SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Notification extends BaseEntity { +public class Notification { - private Long senderId; + @Id + private String id; private Long receiverId; @Enumerated(EnumType.STRING) private NotificationType type; - private String title; - @Column(columnDefinition = "text") private String content; + private NotificationPayload payload; + @Builder.Default @Enumerated(EnumType.STRING) private NotificationStatus status = UNREAD; - private LocalDateTime readAt; - - public static Notification of(Long senderId, Long receiverId, NotificationType type, String content) { - return Notification.builder() - .senderId(senderId) - .receiverId(receiverId) - .type(type) - .content(content) - .build(); - } + @CreatedDate + @Column(updatable = false) + private LocalDateTime createDate; - public static Notification of(Long receiverId, NotificationType type, String content) { - return Notification.builder() - .receiverId(receiverId) - .type(type) - .content(content) - .build(); - } + private LocalDateTime readAt; public void read() { this.status = READ; @@ -66,4 +56,13 @@ public void read() { public void failToSend() { this.status = UNSENT; } + + public static Notification of(Long receiverId, NotificationType type, String content, NotificationPayload payload) { + return Notification.builder() + .receiverId(receiverId) + .type(type) + .content(content) + .payload(payload) + .build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java new file mode 100644 index 00000000..b3a3dfd8 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java @@ -0,0 +1,16 @@ +package com.gachtaxi.domain.notification.entity.payload; + +import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; +import lombok.*; +import lombok.experimental.SuperBuilder; + +@Getter +@SuperBuilder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class FriendRequestPayload extends NotificationPayload { + + @Builder.Default + private NotificationStatus notificationStatus = NotificationStatus.PENDING; + + private Long senderId; +} diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingPayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingPayload.java new file mode 100644 index 00000000..a946cf47 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingPayload.java @@ -0,0 +1,15 @@ +package com.gachtaxi.domain.notification.entity.payload; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +@Getter +@SuperBuilder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class MatchingPayload extends NotificationPayload { + private String startLocationName; + + private String endLocationName; +} diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/NotificationPayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/NotificationPayload.java new file mode 100644 index 00000000..cf2e9a4e --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/NotificationPayload.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.notification.entity.payload; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +@SuperBuilder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public abstract class NotificationPayload { + +} From 5c3fd7eb318639647a777102edc62f0693ca1112 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 15:56:11 +0900 Subject: [PATCH 578/770] =?UTF-8?q?feat:=20=EB=AA=BD=EA=B3=A0=EB=94=94?= =?UTF-8?q?=EB=B9=84=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/repository/NotificationRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java index 754571f2..8c6e8575 100644 --- a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java +++ b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java @@ -4,9 +4,9 @@ import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.mongodb.repository.MongoRepository; -public interface NotificationRepository extends JpaRepository { +public interface NotificationRepository extends MongoRepository { Integer countAllByReceiverIdAndStatus(Long receiverId, NotificationStatus status); From 782a88bda21f629d98076c43f76a01836c00f8b6 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 15:56:20 +0900 Subject: [PATCH 579/770] =?UTF-8?q?feat:=20dto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/dto/response/NotificationResponse.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java index 64ee1b0e..b0ed55c4 100644 --- a/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java +++ b/src/main/java/com/gachtaxi/domain/notification/dto/response/NotificationResponse.java @@ -2,28 +2,27 @@ import com.gachtaxi.domain.notification.entity.Notification; import com.gachtaxi.domain.notification.entity.enums.NotificationType; +import com.gachtaxi.domain.notification.entity.payload.NotificationPayload; import lombok.Builder; import java.time.LocalDateTime; @Builder public record NotificationResponse( - long notificationId, - long senderId, + String notificationId, long receiverId, NotificationType type, - String title, String content, + NotificationPayload payload, LocalDateTime createdAt ) { public static NotificationResponse from(Notification notification) { return NotificationResponse.builder() .notificationId(notification.getId()) - .senderId(notification.getSenderId()) .receiverId(notification.getReceiverId()) .type(notification.getType()) - .title(notification.getTitle()) .content(notification.getContent()) + .payload(notification.getPayload()) .createdAt(notification.getCreateDate()) .build(); } From 78a169a81e03f00abc150bd43e0f60c4747f3d50 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 15:56:33 +0900 Subject: [PATCH 580/770] =?UTF-8?q?feat:=20payload=EB=A5=BC=20=EB=B0=9B?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/NotificationService.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java index c79326e7..ae12ae81 100644 --- a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -7,6 +7,7 @@ import com.gachtaxi.domain.notification.dto.response.NotificationResponse; import com.gachtaxi.domain.notification.entity.Notification; import com.gachtaxi.domain.notification.entity.enums.NotificationType; +import com.gachtaxi.domain.notification.entity.payload.NotificationPayload; import com.gachtaxi.domain.notification.exception.MemberNotMatchException; import com.gachtaxi.domain.notification.exception.NotificationNotFoundException; import com.gachtaxi.domain.notification.repository.NotificationRepository; @@ -17,7 +18,6 @@ import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -31,7 +31,6 @@ public class NotificationService { private final NotificationRepository notificationRepository; private final FcmService fcmService; - @Transactional public NotificationListResponse getNotifications(Long receiverId, int pageNum, int pageSize) { Pageable pageable = PageRequest.of(pageNum, pageSize, Sort.by(Sort.Direction.DESC, "createDate")); @@ -41,6 +40,8 @@ public NotificationListResponse getNotifications(Long receiverId, int pageNum, i .filter(notification -> notification.getStatus() == UNREAD) .forEach(Notification::read); + notificationRepository.saveAll(notifications); + List responses = notifications.stream() .map(NotificationResponse::from) .toList(); @@ -60,22 +61,19 @@ public NotificationInfoResponse getInfo(Long receiverId) { return NotificationInfoResponse.of(count, false); } - @Transactional - public void sendWithPush(Long senderId, Members receiver, NotificationType type, String title, String content) { - Notification notification = Notification.of(senderId, receiver.getId(), type, content); + public void sendWithPush(Long senderId, Members receiver, NotificationType type, String title, String content, NotificationPayload payload) { + Notification notification = Notification.of(senderId, type, content, payload); notificationRepository.save(notification); fcmService.sendNotification(receiver.getFcmToken(), title, notification.getContent()); } - @Transactional - public void sendWithOutPush(Long senderId, Members receiver, NotificationType type, String content) { - Notification notification = Notification.of(senderId, receiver.getId(), type, content); + public void sendWithOutPush(Long senderId, Members receiver, NotificationType type, String content, NotificationPayload payload) { + Notification notification = Notification.of(senderId, type, content, payload); notificationRepository.save(notification); } - @Transactional public void delete(Long receiverId, Long notificationId) { validateMember(receiverId, notificationId); From 06a5fd4e84caaf30edd26c9451afc2cb6a93a80e Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 15:57:31 +0900 Subject: [PATCH 581/770] =?UTF-8?q?feat:=20=EC=B9=9C=EA=B5=AC=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/payload/FriendRequestPayload.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java index b3a3dfd8..9ae89f3b 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java @@ -1,7 +1,8 @@ package com.gachtaxi.domain.notification.entity.payload; -import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; -import lombok.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @Getter @@ -9,8 +10,8 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class FriendRequestPayload extends NotificationPayload { - @Builder.Default - private NotificationStatus notificationStatus = NotificationStatus.PENDING; +// @Builder.Default +// private FriendStatus status = FriendStatus.PENDING; private Long senderId; } From 75c6bb4563b0c1bcd47579898f6945ba404a0bf5 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Fri, 31 Jan 2025 15:58:25 +0900 Subject: [PATCH 582/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=20=EA=B4=80=EB=A0=A8=20=EC=A3=BC=EC=84=9D=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20(=EC=95=8C=EB=A6=BC=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=84=A0=20=EB=B0=98=EC=98=81=20=ED=9B=84=20=EC=88=98=EC=A0=95?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/service/FriendService.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index cf514659..54363ae0 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -19,8 +19,6 @@ import java.util.List; -import static com.gachtaxi.domain.notification.entity.enums.NotificationType.FRIEND_REQUEST; - @Slf4j @Service @RequiredArgsConstructor @@ -41,11 +39,11 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { checkDuplicatedFriendShip(senderId, receiver.getId()); friendRepository.save(Friends.of(sender, receiver)); - notificationService.sendWithPush( - sender.getId(), - receiver, - FRIEND_REQUEST, - String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); +// notificationService.sendWithPush( +// sender.getId(), +// receiver, +// FRIEND_REQUEST, +// String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); } public List getFriendsList(Long memberId){ From 485f1396697bf283f6eb0343e6a28db7427ef246 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 16:08:14 +0900 Subject: [PATCH 583/770] =?UTF-8?q?feat:=20=EC=A0=95=EC=A0=81=20=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/entity/payload/FriendRequestPayload.java | 4 ++++ .../notification/entity/payload/MatchingPayload.java | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java index 9ae89f3b..577e67ef 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java @@ -14,4 +14,8 @@ public class FriendRequestPayload extends NotificationPayload { // private FriendStatus status = FriendStatus.PENDING; private Long senderId; + + public static FriendRequestPayload from(Long senderId) { + return FriendRequestPayload.builder().senderId(senderId).build(); + } } diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingPayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingPayload.java index a946cf47..d8b24ff7 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingPayload.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingPayload.java @@ -12,4 +12,11 @@ public class MatchingPayload extends NotificationPayload { private String startLocationName; private String endLocationName; + + public static MatchingPayload of(String startLocationName, String endLocationName) { + return MatchingPayload.builder() + .startLocationName(startLocationName) + .endLocationName(endLocationName) + .build(); + } } From 784d494a0a84fddd5fd9fc2a078a321c487c7641 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 19:52:08 +0900 Subject: [PATCH 584/770] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=B0=A9=20=EC=83=9D=EC=84=B1=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ManualMatchingController.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java new file mode 100644 index 00000000..ddfe3ed4 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -0,0 +1,34 @@ +package com.gachtaxi.domain.matching.common.controller; + +import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.CREATE_MANUAL_MATCHING_ROOM_SUCCESS; +import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; +import com.gachtaxi.domain.matching.common.service.ManualMatchingService; +import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "MANUAL", description = "수동매칭 API") +@Slf4j +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/matching/manual") +public class ManualMatchingController { + + private final ManualMatchingService manualMatchingService; + + @Operation(summary = "수동 매칭방 생성") + @PostMapping("/create") + public ApiResponse createManualMatchingRoom(@Valid @RequestBody ManualMatchingRequest request) { + Long roomId = manualMatchingService.createManualMatchingRoom(request); + return ApiResponse.response(HttpStatus.OK, CREATE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage(), roomId); + } + +} From c3417103f6536a02acc2b7f16969bf82a36da84d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 19:52:25 +0900 Subject: [PATCH 585/770] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=B0=A9=20=EC=84=B1=EA=B3=B5=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/controller/ResponseMessage.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java index 859df93d..02e2214e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java @@ -13,7 +13,14 @@ public enum ResponseMessage { // auto matching AUTO_MATCHING_REQUEST_ACCEPTED("자동 매칭 요청 전송에 성공했습니다."), NOT_SUBSCRIBED_SSE("SSE 구독 후 자동 매칭을 요청할 수 있습니다."), - AUTO_MATCHING_REQUEST_CANCELLED("자동 매칭 취소 요청 전송에 성공했습니다."); + AUTO_MATCHING_REQUEST_CANCELLED("자동 매칭 취소 요청 전송에 성공했습니다."), + + // manual matching + CREATE_MANUAL_MATCHING_ROOM_SUCCESS("수동 매칭방 생성에 성공했습니다."), + JOIN_MANUAL_MATCHING_ROOM_SUCCESS("수동 매칭방 참여에 성공했습니다."), + LEAVE_MANUAL_MATCHING_ROOM_SUCCESS("매칭방 퇴장이 완료되었습니다."), + CONVERT_TO_AUTO_MATCHING_SUCCESS("자동 매칭으로 전환되었습니다."); + private final String message; } From 1e278ad4a67d7818d2c2cb1790dcaa2b7f0405e5 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 19:53:06 +0900 Subject: [PATCH 586/770] =?UTF-8?q?feat:=20=EB=A6=AC=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EA=B0=80=20=EC=95=84=EB=8B=8C=20=ED=98=84=EC=9E=AC=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=B0=A9=20=EA=B2=B0=EC=A0=9C=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MemberMatchingRoomChargingInfoRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java index 2a76f9f1..2b150c8b 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java @@ -14,4 +14,6 @@ public interface MemberMatchingRoomChargingInfoRepository extends JpaRepository< List findByMatchingRoomAndPaymentStatus(MatchingRoom matchingRoom, PaymentStatus paymentStatus); Optional findByMembersAndMatchingRoom(Members members, MatchingRoom matchingRoom); + + int countByMatchingRoomAndPaymentStatus(MatchingRoom matchingRoom, PaymentStatus paymentStatus); } From 97510ed1d2140aed407a8b4bda622d3ef6a86244 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 19:53:21 +0900 Subject: [PATCH 587/770] =?UTF-8?q?feat:=20MatchingRoomType=20enum=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/entity/enums/MatchingRoomType.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomType.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomType.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomType.java new file mode 100644 index 00000000..f08a588a --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingRoomType.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.matching.common.entity.enums; + +public enum MatchingRoomType { + AUTO, MANUAL +} From bee442373eb4c3815bd28c837b6251de6964d7c7 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 19:54:05 +0900 Subject: [PATCH 588/770] =?UTF-8?q?feat:=20=EC=9E=90=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=EC=99=80=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=EB=90=9C=20=EC=88=98=EB=8F=99=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/MatchingRoomService.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index e75e7494..2091df7f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -83,15 +83,26 @@ private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { .build(); return this.routeRepository.save(route); } + public Route saveRoute(String departure, String destination) { + Route route = Route.builder() + .startLocationName(departure) + .endLocationName(destination) + .build(); + return this.routeRepository.save(route); + } private void saveMatchingRoomTagInfo(MatchingRoom matchingRoom, List tags) { tags.forEach(tag -> this.matchingRoomTagInfoRepository.save(MatchingRoomTagInfo.of(matchingRoom, tag))); } - + public void saveMatchingRoomTagInfoForManual(MatchingRoom matchingRoom, List tags) { + tags.forEach(tag -> this.matchingRoomTagInfoRepository.save(MatchingRoomTagInfo.of(matchingRoom, tag))); + } private void saveRoomMasterChargingInfo(MatchingRoom matchingRoom, Members members) { this.memberMatchingRoomChargingInfoRepository.save(MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, members)); } - + public void saveRoomMasterChargingInfoForManual(MatchingRoom matchingRoom, Members members) { + this.memberMatchingRoomChargingInfoRepository.save(MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, members)); + } public void joinMemberToMatchingRoom(MatchMemberJoinedEvent matchMemberJoinedEvent) { Members members = this.memberService.findById(matchMemberJoinedEvent.memberId()); MatchingRoom matchingRoom = this.matchingRoomRepository.findById(matchMemberJoinedEvent.roomId()).orElseThrow(NoSuchMatchingRoomException::new); @@ -134,7 +145,12 @@ private void updateExistMembersCharge(List exist } this.memberMatchingRoomChargingInfoRepository.saveAll(existMembers); } - + public void updateExistMembersChargeForManual(List existMembers, int charge) { + for (MemberMatchingRoomChargingInfo memberMatchingRoomChargingInfo : existMembers) { + memberMatchingRoomChargingInfo.setCharge(charge); + } + this.memberMatchingRoomChargingInfoRepository.saveAll(existMembers); + } public void leaveMemberFromMatchingRoom(MatchMemberCancelledEvent matchMemberCancelledEvent) { Members members = this.memberService.findById(matchMemberCancelledEvent.memberId()); MatchingRoom matchingRoom = this.matchingRoomRepository.findById(matchMemberCancelledEvent.roomId()).orElseThrow(NoSuchMatchingRoomException::new); From 3bd2cf6171ef7046ef050b51941cbbf65e3627c2 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 19:54:32 +0900 Subject: [PATCH 589/770] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/ManualMatchingService.java | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java new file mode 100644 index 00000000..cad8b5c3 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -0,0 +1,154 @@ +package com.gachtaxi.domain.matching.common.service; + +import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; +import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import com.gachtaxi.domain.matching.common.entity.Route; +import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; +import com.gachtaxi.domain.matching.common.exception.MemberAlreadyLeftMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.MemberNotInMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.NotActiveMatchingRoomException; +import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; +import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.service.MemberService; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ManualMatchingService { + + private final MemberService memberService; + private final MatchingRoomService matchingRoomService; + private final MatchingRoomRepository matchingRoomRepository; + private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; + + /* + 수동 매칭 방 생성 + */ + public Long createManualMatchingRoom(ManualMatchingRequest request) { + Members roomMaster = memberService.findById(request.userId()); + + Route route = matchingRoomService.saveRoute(request.departure(), request.destination()); + + MatchingRoom matchingRoom = MatchingRoom.manualOf( + roomMaster, + route, + request.title(), + request.description(), + 4, + request.totalCharge(), + request.departureTime() + ); + + MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); + + matchingRoomService.saveMatchingRoomTagInfoForManual(savedMatchingRoom, request.getCriteria()); + matchingRoomService.saveRoomMasterChargingInfoForManual(savedMatchingRoom, roomMaster); + + return savedMatchingRoom.getId(); + } + + /* + 수동 매칭방 참여 + */ + public void joinManualMatchingRoom(Long userId, Long roomId) { + Members user = memberService.findById(userId); + + MatchingRoom matchingRoom = this.matchingRoomRepository.findById(roomId) + .orElseThrow(NoSuchMatchingRoomException::new); + + if (!matchingRoom.isActive()) { + throw new NotActiveMatchingRoomException(); + } + + Optional joinedInPast = this.memberMatchingRoomChargingInfoRepository + .findByMembersAndMatchingRoom(user, matchingRoom); + + MemberMatchingRoomChargingInfo memberInfo; + if (joinedInPast.isPresent()) { + memberInfo = joinedInPast.get().joinMatchingRoom(); + } else { + memberInfo = MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, user); + } + + this.memberMatchingRoomChargingInfoRepository.save(memberInfo); + + List existMembers = this.memberMatchingRoomChargingInfoRepository + .findByMatchingRoomAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); + + int distributedCharge = (int) Math.ceil((double) matchingRoom.getTotalCharge() / (existMembers.size() + 1)); + + matchingRoomService.updateExistMembersChargeForManual(existMembers, distributedCharge); + + int nowMemberCount = existMembers.size() + 1; + + if (matchingRoom.isFull(nowMemberCount)) { + matchingRoom.completeMatchingRoom(); + this.matchingRoomRepository.save(matchingRoom); + } + } + /* + todo 수동 매칭 → 자동 매칭 전환 : 추후 고도화시, 10분전에 유저에게 알림을 주고 자동 매칭으로 전환 + */ + public void convertToAutoMatching(Long roomId) { + MatchingRoom matchingRoom = this.matchingRoomRepository.findById(roomId) + .orElseThrow(NoSuchMatchingRoomException::new); + + if (!matchingRoom.isActive()) { + throw new NotActiveMatchingRoomException(); + } + + if (LocalDateTime.now().isAfter(matchingRoom.getDepartureTime().minusMinutes(10))) { + + int currentMembers = this.memberMatchingRoomChargingInfoRepository + .countByMatchingRoomAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); + + if (matchingRoom.isAutoConvertible(currentMembers)) { + matchingRoom.convertToAutoMatching(); + matchingRoomRepository.save(matchingRoom); + } + } + } + + /* + 방장 취소 + 방 삭제 + */ + public void leaveManualMatchingRoom(Long userId, Long roomId) { + Members user = this.memberService.findById(userId); + MatchingRoom matchingRoom = this.matchingRoomRepository.findById(roomId) + .orElseThrow(NoSuchMatchingRoomException::new); + + MemberMatchingRoomChargingInfo memberMatchingRoomChargingInfo = + this.memberMatchingRoomChargingInfoRepository.findByMembersAndMatchingRoom(user, matchingRoom) + .orElseThrow(MemberNotInMatchingRoomException::new); + + if (memberMatchingRoomChargingInfo.isAlreadyLeft()) { + throw new MemberAlreadyLeftMatchingRoomException(); + } + + memberMatchingRoomChargingInfo.leftMatchingRoom(); + this.memberMatchingRoomChargingInfoRepository.save(memberMatchingRoomChargingInfo); + + if (user.isRoomMaster(matchingRoom)) { + List remainingMembers = + this.memberMatchingRoomChargingInfoRepository.findByMatchingRoomAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); + + if (remainingMembers.isEmpty()) { + this.matchingRoomRepository.delete(matchingRoom); + } else { + Members newRoomMaster = remainingMembers.get(0).getMembers(); + matchingRoom.changeRoomMaster(newRoomMaster); + this.matchingRoomRepository.save(matchingRoom); + } + } + } +} + From 38547a6510b7f11401be77b43ac465a932c93208 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 19:56:24 +0900 Subject: [PATCH 590/770] =?UTF-8?q?feat:=20departureTime,=20MatchingRoomTy?= =?UTF-8?q?pe=20=EC=88=98=EB=8F=99=EB=A7=A4=EC=B9=AD=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/entity/MatchingRoom.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 0afef65e..eff90cde 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; +import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.members.entity.Members; @@ -15,6 +16,7 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import java.time.LocalDateTime; import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -59,9 +61,16 @@ public class MatchingRoom extends BaseEntity { @Getter private Integer totalCharge; + @Column(name = "departure_time") + @Getter + private LocalDateTime departureTime; + @Enumerated(EnumType.STRING) private MatchingRoomStatus matchingRoomStatus; + @Enumerated(EnumType.STRING) + private MatchingRoomType matchingRoomType; + public boolean isActive() { return this.matchingRoomStatus == MatchingRoomStatus.ACTIVE; } @@ -82,6 +91,10 @@ public boolean isFull(int size) { return size == totalCharge; } + public void convertToAutoMatching() { this.matchingRoomType = MatchingRoomType.AUTO; } + + public boolean isAutoConvertible(int currentMembers) { return currentMembers < this.capacity; } + public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route) { return MatchingRoom.builder() .capacity(matchRoomCreatedEvent.maxCapacity()) @@ -93,6 +106,20 @@ public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, .matchingRoomStatus(MatchingRoomStatus.ACTIVE) .build(); } + + public static MatchingRoom manualOf(Members roomMaster, Route route, String title, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { + return MatchingRoom.builder() + .capacity(4) + .roomMaster(roomMaster) + .title(title) + .description(description) + .route(route) + .totalCharge(totalCharge) + .departureTime(departureTime) + .matchingRoomType(MatchingRoomType.MANUAL) + .matchingRoomStatus(MatchingRoomStatus.ACTIVE) + .build(); + } public boolean containsTag(Tags tag) { return this.matchingRoomTagInfo.stream() .anyMatch(tagInfo -> tagInfo.matchesTag(tag)); From 733295b51dab04e3efbdaf9344fe7a93a544376d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 19:56:47 +0900 Subject: [PATCH 591/770] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=83=9D=EC=84=B1=20dto=20=EC=9A=94=EC=B2=AD=20dto?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/ManualMatchingRequest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java new file mode 100644 index 00000000..376885d9 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java @@ -0,0 +1,41 @@ +package com.gachtaxi.domain.matching.common.dto.request; + +import com.gachtaxi.domain.matching.common.entity.enums.Tags; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import java.time.LocalDateTime; +import java.util.List; + +public record ManualMatchingRequest( + @NotNull + Long userId, + + @NotBlank + String title, + + String description, + + @NotBlank + String departure, + + @NotBlank + String destination, + + @NotNull + LocalDateTime departureTime, + + @Schema(description = "예상 요금") + @Min(value = 0) + int totalCharge, + + @Schema(description = "매칭 태그") + List criteria +) { + public List getCriteria() { + return this.criteria.stream() + .map(Tags::valueOf) + .toList(); + } +} From 0d16ed3330de01b76a18a5c0fab2649693f09210 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 20:04:09 +0900 Subject: [PATCH 592/770] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=83=9D=EC=84=B1=EC=8B=9C=20=EC=A4=91=EB=B3=B5=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/ManualMatchingService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index cad8b5c3..1bb59864 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -5,6 +5,7 @@ import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; +import com.gachtaxi.domain.matching.common.exception.AlreadyInMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.MemberAlreadyLeftMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.MemberNotInMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; @@ -36,6 +37,10 @@ public class ManualMatchingService { public Long createManualMatchingRoom(ManualMatchingRequest request) { Members roomMaster = memberService.findById(request.userId()); + if (matchingRoomRepository.existsByMemberInMatchingRoom(roomMaster)) { + throw new AlreadyInMatchingRoomException(); + } + Route route = matchingRoomService.saveRoute(request.departure(), request.destination()); MatchingRoom matchingRoom = MatchingRoom.manualOf( From c87607fcfa168506f1aa3e8dc0715d5e57e2005c Mon Sep 17 00:00:00 2001 From: hyxklee Date: Fri, 31 Jan 2025 20:11:54 +0900 Subject: [PATCH 593/770] =?UTF-8?q?refactor:=20firebase=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/global/config/FirebaseConfig.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/FirebaseConfig.java b/src/main/java/com/gachtaxi/global/config/FirebaseConfig.java index e736d27d..bf7e9daf 100644 --- a/src/main/java/com/gachtaxi/global/config/FirebaseConfig.java +++ b/src/main/java/com/gachtaxi/global/config/FirebaseConfig.java @@ -9,6 +9,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -23,9 +25,7 @@ public class FirebaseConfig { public void initialize() { try { - ClassPathResource resource = new ClassPathResource(adminSdkPath); - - InputStream inputStream = resource.getInputStream(); + InputStream inputStream = getInputStream(adminSdkPath); FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(inputStream)) @@ -40,4 +40,12 @@ public void initialize() { log.warn("Firebase 설정 중 예외 발생", e); } } + + private InputStream getInputStream(String path) throws IOException { + if (new File(path).exists()) { + return new FileInputStream(path); + } else { + return new ClassPathResource(path).getInputStream(); + } + } } From 59163f03c21cf77f2d6911552a824d17e507b90c Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 20:29:32 +0900 Subject: [PATCH 594/770] =?UTF-8?q?refactor:=20=EC=98=AC=EB=B0=94=EB=A5=B8?= =?UTF-8?q?=20=EC=A4=91=EB=B3=B5=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/ManualMatchingService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 1bb59864..8475ed4b 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -5,7 +5,7 @@ import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; -import com.gachtaxi.domain.matching.common.exception.AlreadyInMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.DuplicatedMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.MemberAlreadyLeftMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.MemberNotInMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; @@ -38,7 +38,7 @@ public Long createManualMatchingRoom(ManualMatchingRequest request) { Members roomMaster = memberService.findById(request.userId()); if (matchingRoomRepository.existsByMemberInMatchingRoom(roomMaster)) { - throw new AlreadyInMatchingRoomException(); + throw new DuplicatedMatchingRoomException(); } Route route = matchingRoomService.saveRoute(request.departure(), request.destination()); From 1f1dcd38ca547e3f71e200bf708a193d2b898b3a Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 21:39:51 +0900 Subject: [PATCH 595/770] =?UTF-8?q?feat:=20=EC=9E=90=EC=8B=A0=EC=9D=B4=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A0=20=EB=B0=A9=20=EC=B0=B8=EC=97=AC=EB=B6=88?= =?UTF-8?q?=EA=B0=80=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/exception/ErrorMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index 3febd48f..0d7353ce 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -16,7 +16,8 @@ public enum ErrorMessage { NOT_DEFINED_KAFKA_TEMPLATE("해당 이벤트와 맞는 KafkaTemplate이 정의되지 않았습니다."), DUPLICATED_MATCHING_ROOM("이미 존재하는 매칭 방입니다."), NOT_FOUND_PAGE("페이지 번호는 0 이상이어야 합니다."), - ALREADY_IN_MATCHING_ROOM("이미 매칭 방에 참가한 멤버입니다."); + ALREADY_IN_MATCHING_ROOM("이미 매칭 방에 참가한 멤버입니다."), + MATCHING_ROOM_NOT_JOIN_OWN("자신이 만든 매칭 방에는 참가할 수 없습니다."); private final String message; } From 2e117ca0b01c8a29cadc5d4938cf4ceeecd92418 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 21:40:11 +0900 Subject: [PATCH 596/770] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=B0=A9=20=EC=B0=B8=EC=97=AC=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/ManualMatchingController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index ddfe3ed4..5afbe4a7 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -1,6 +1,9 @@ package com.gachtaxi.domain.matching.common.controller; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.CREATE_MANUAL_MATCHING_ROOM_SUCCESS; +import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.JOIN_MANUAL_MATCHING_ROOM_SUCCESS; + +import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingJoinRequest; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; import com.gachtaxi.domain.matching.common.service.ManualMatchingService; import com.gachtaxi.global.common.response.ApiResponse; @@ -31,4 +34,10 @@ public ApiResponse createManualMatchingRoom(@Valid @RequestBody ManualMatc return ApiResponse.response(HttpStatus.OK, CREATE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage(), roomId); } + @Operation(summary = "수동 매칭방 참여") + @PostMapping("/join") + public ApiResponse joinManualMatchingRoom(@Valid @RequestBody ManualMatchingJoinRequest request) { + manualMatchingService.joinManualMatchingRoom(request.userId(), request.roomId()); + return ApiResponse.response(HttpStatus.OK, JOIN_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); + } } From 073ebf406008a1d24d2cb7164992f8ca314277bc Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 21:40:26 +0900 Subject: [PATCH 597/770] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=B0=A9=20=EC=9A=94=EC=B2=AD=20dto=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dto/request/ManualMatchingJoinRequest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingJoinRequest.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingJoinRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingJoinRequest.java new file mode 100644 index 00000000..2cd46717 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingJoinRequest.java @@ -0,0 +1,11 @@ +package com.gachtaxi.domain.matching.common.dto.request; + +import jakarta.validation.constraints.NotNull; + +public record ManualMatchingJoinRequest( + @NotNull + Long userId, + @NotNull + Long roomId +) { +} From 25723a11c599edc1342055b65d2e44dda4961825 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 21:41:38 +0900 Subject: [PATCH 598/770] =?UTF-8?q?feat:=20=EC=9E=90=EA=B8=B0=EC=9E=90?= =?UTF-8?q?=EC=8B=A0=EC=9D=B4=20=EC=83=9D=EC=84=B1=ED=95=9C=20=EB=B0=A9=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9D=B4=EB=AF=B8=20=EC=B0=B8=EC=97=AC=ED=95=9C=20?= =?UTF-8?q?=EB=B0=A9=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=EB=8B=A8=EC=97=90=EC=84=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/ManualMatchingService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 8475ed4b..eb2f079e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -6,6 +6,8 @@ import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; import com.gachtaxi.domain.matching.common.exception.DuplicatedMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.MatchingRoomNotJoinOwnException; +import com.gachtaxi.domain.matching.common.exception.MemberAlreadyJoinedException; import com.gachtaxi.domain.matching.common.exception.MemberAlreadyLeftMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.MemberNotInMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; @@ -74,6 +76,14 @@ public void joinManualMatchingRoom(Long userId, Long roomId) { throw new NotActiveMatchingRoomException(); } + if (matchingRoom.getRoomMaster().equals(user)) { + throw new MatchingRoomNotJoinOwnException(); + } + + if (this.memberMatchingRoomChargingInfoRepository.existsByMembersAndMatchingRoom(user, matchingRoom)) { + throw new MemberAlreadyJoinedException(); + } + Optional joinedInPast = this.memberMatchingRoomChargingInfoRepository .findByMembersAndMatchingRoom(user, matchingRoom); From 40cf0dd12f1a563873c29f805bfdc40a1c008583 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 21:42:06 +0900 Subject: [PATCH 599/770] =?UTF-8?q?feat:=20=EC=9E=90=EA=B8=B0=EC=9E=90?= =?UTF-8?q?=EC=8B=A0=EC=9D=B4=20=EC=83=9D=EC=84=B1=ED=95=9C=20=EB=B0=A9=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=20=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/MatchingRoomNotJoinOwnException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomNotJoinOwnException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomNotJoinOwnException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomNotJoinOwnException.java new file mode 100644 index 00000000..87919eca --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomNotJoinOwnException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.MATCHING_ROOM_NOT_JOIN_OWN; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +import com.gachtaxi.global.common.exception.BaseException; + +public class MatchingRoomNotJoinOwnException extends BaseException { + public MatchingRoomNotJoinOwnException() { + super(BAD_REQUEST, MATCHING_ROOM_NOT_JOIN_OWN.getMessage()); + } +} From 27edbd948ed8ad70ac9b393b1810da104347acc7 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 21:42:53 +0900 Subject: [PATCH 600/770] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC=ED=95=9C=20=EB=B0=A9=EC=9D=B8=EC=A7=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=ED=95=98=EB=8A=94=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MemberMatchingRoomChargingInfoRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java index 2b150c8b..9a83f416 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MemberMatchingRoomChargingInfoRepository.java @@ -16,4 +16,6 @@ public interface MemberMatchingRoomChargingInfoRepository extends JpaRepository< Optional findByMembersAndMatchingRoom(Members members, MatchingRoom matchingRoom); int countByMatchingRoomAndPaymentStatus(MatchingRoom matchingRoom, PaymentStatus paymentStatus); + + boolean existsByMembersAndMatchingRoom(Members members, MatchingRoom matchingRoom); } From 38af4977c0fa841d19f5a0e94f3cac9500e5fd52 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 22:37:17 +0900 Subject: [PATCH 601/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EB=B0=A9=20?= =?UTF-8?q?=ED=87=B4=EC=9E=A5=20=EB=B0=8F=20=EB=B0=A9=20=EC=86=8C=ED=94=84?= =?UTF-8?q?=ED=8A=B8=20=EC=82=AD=EC=A0=9C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/ManualMatchingController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index 5afbe4a7..1a24de3c 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -2,8 +2,10 @@ import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.CREATE_MANUAL_MATCHING_ROOM_SUCCESS; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.JOIN_MANUAL_MATCHING_ROOM_SUCCESS; +import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.LEAVE_MANUAL_MATCHING_ROOM_SUCCESS; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingJoinRequest; +import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingLeaveRequest; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; import com.gachtaxi.domain.matching.common.service.ManualMatchingService; import com.gachtaxi.global.common.response.ApiResponse; @@ -40,4 +42,11 @@ public ApiResponse joinManualMatchingRoom(@Valid @RequestBody ManualMatchi manualMatchingService.joinManualMatchingRoom(request.userId(), request.roomId()); return ApiResponse.response(HttpStatus.OK, JOIN_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); } + + @Operation(summary = "수동 매칭방 퇴장 (방 삭제 포함)") + @PostMapping("/leave") + public ApiResponse leaveManualMatchingRoom(@Valid @RequestBody ManualMatchingLeaveRequest request) { + manualMatchingService.leaveManualMatchingRoom(request.userId(), request.roomId()); + return ApiResponse.response(HttpStatus.OK, LEAVE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); + } } From 424941b8830c836448952104b455b939767b5549 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 22:38:34 +0900 Subject: [PATCH 602/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EB=B0=A9=20?= =?UTF-8?q?=ED=87=B4=EC=9E=A5=20=EC=9A=94=EC=B2=AD=20dto=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dto/request/ManualMatchingLeaveRequest.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingLeaveRequest.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingLeaveRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingLeaveRequest.java new file mode 100644 index 00000000..9ad79c73 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingLeaveRequest.java @@ -0,0 +1,9 @@ +package com.gachtaxi.domain.matching.common.dto.request; + +import jakarta.validation.constraints.NotNull; + +public record ManualMatchingLeaveRequest( + @NotNull Long userId, + @NotNull Long roomId +) { +} From 82446750fbbfcd7753244457bc14925d09eb5d84 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 22:39:23 +0900 Subject: [PATCH 603/770] =?UTF-8?q?refactor:=20Transactional=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EC=86=8C=ED=94=84=ED=8A=B8=20=EB=94=9C?= =?UTF-8?q?=EB=A6=AC=ED=8A=B8=20=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/ManualMatchingService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index eb2f079e..51609723 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -13,9 +13,11 @@ import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NotActiveMatchingRoomException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; +import com.gachtaxi.domain.matching.common.repository.MatchingRoomTagInfoRepository; import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; +import jakarta.transaction.Transactional; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -31,11 +33,13 @@ public class ManualMatchingService { private final MemberService memberService; private final MatchingRoomService matchingRoomService; private final MatchingRoomRepository matchingRoomRepository; + private final MatchingRoomTagInfoRepository matchingRoomTagInfoRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; /* 수동 매칭 방 생성 */ + @Transactional public Long createManualMatchingRoom(ManualMatchingRequest request) { Members roomMaster = memberService.findById(request.userId()); @@ -66,6 +70,7 @@ public Long createManualMatchingRoom(ManualMatchingRequest request) { /* 수동 매칭방 참여 */ + @Transactional public void joinManualMatchingRoom(Long userId, Long roomId) { Members user = memberService.findById(userId); @@ -113,6 +118,7 @@ public void joinManualMatchingRoom(Long userId, Long roomId) { /* todo 수동 매칭 → 자동 매칭 전환 : 추후 고도화시, 10분전에 유저에게 알림을 주고 자동 매칭으로 전환 */ + @Transactional public void convertToAutoMatching(Long roomId) { MatchingRoom matchingRoom = this.matchingRoomRepository.findById(roomId) .orElseThrow(NoSuchMatchingRoomException::new); @@ -136,6 +142,7 @@ public void convertToAutoMatching(Long roomId) { /* 방장 취소 + 방 삭제 */ + @Transactional public void leaveManualMatchingRoom(Long userId, Long roomId) { Members user = this.memberService.findById(userId); MatchingRoom matchingRoom = this.matchingRoomRepository.findById(roomId) @@ -157,7 +164,8 @@ public void leaveManualMatchingRoom(Long userId, Long roomId) { this.memberMatchingRoomChargingInfoRepository.findByMatchingRoomAndPaymentStatus(matchingRoom, PaymentStatus.NOT_PAYED); if (remainingMembers.isEmpty()) { - this.matchingRoomRepository.delete(matchingRoom); + matchingRoom.cancelMatchingRoom(); + this.matchingRoomRepository.save(matchingRoom); } else { Members newRoomMaster = remainingMembers.get(0).getMembers(); matchingRoom.changeRoomMaster(newRoomMaster); From d7523c170a7b0b3353593e57fb56f5fb9e22aecf Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 23:01:05 +0900 Subject: [PATCH 604/770] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20Dto=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dto/request/ManualMatchingLeaveRequest.java | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingLeaveRequest.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingLeaveRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingLeaveRequest.java deleted file mode 100644 index 9ad79c73..00000000 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingLeaveRequest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gachtaxi.domain.matching.common.dto.request; - -import jakarta.validation.constraints.NotNull; - -public record ManualMatchingLeaveRequest( - @NotNull Long userId, - @NotNull Long roomId -) { -} From 40ec7791949c2b09b3c9a17426e444458ff00eb5 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 23:01:21 +0900 Subject: [PATCH 605/770] =?UTF-8?q?refactor:=20=EC=9A=94=EC=B2=AD=20dto=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/ManualMatchingJoinRequest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingJoinRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingJoinRequest.java index 2cd46717..eee8d24e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingJoinRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingJoinRequest.java @@ -3,8 +3,6 @@ import jakarta.validation.constraints.NotNull; public record ManualMatchingJoinRequest( - @NotNull - Long userId, @NotNull Long roomId ) { From e1eda47a6723df26252066fb97699ae4e6afdcbc Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Fri, 31 Jan 2025 23:02:48 +0900 Subject: [PATCH 606/770] =?UTF-8?q?refactor:=20CurrentMemberId=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EB=B0=8F=20RESTful=20=ED=95=9C=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ManualMatchingController.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index 1a24de3c..4e5ee1f3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -5,9 +5,9 @@ import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.LEAVE_MANUAL_MATCHING_ROOM_SUCCESS; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingJoinRequest; -import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingLeaveRequest; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; import com.gachtaxi.domain.matching.common.service.ManualMatchingService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -15,6 +15,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -30,7 +32,7 @@ public class ManualMatchingController { private final ManualMatchingService manualMatchingService; @Operation(summary = "수동 매칭방 생성") - @PostMapping("/create") + @PostMapping public ApiResponse createManualMatchingRoom(@Valid @RequestBody ManualMatchingRequest request) { Long roomId = manualMatchingService.createManualMatchingRoom(request); return ApiResponse.response(HttpStatus.OK, CREATE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage(), roomId); @@ -38,15 +40,15 @@ public ApiResponse createManualMatchingRoom(@Valid @RequestBody ManualMatc @Operation(summary = "수동 매칭방 참여") @PostMapping("/join") - public ApiResponse joinManualMatchingRoom(@Valid @RequestBody ManualMatchingJoinRequest request) { - manualMatchingService.joinManualMatchingRoom(request.userId(), request.roomId()); + public ApiResponse joinManualMatchingRoom(@CurrentMemberId Long userId, @Valid @RequestBody ManualMatchingJoinRequest request) { + manualMatchingService.joinManualMatchingRoom(userId, request.roomId()); return ApiResponse.response(HttpStatus.OK, JOIN_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); } @Operation(summary = "수동 매칭방 퇴장 (방 삭제 포함)") - @PostMapping("/leave") - public ApiResponse leaveManualMatchingRoom(@Valid @RequestBody ManualMatchingLeaveRequest request) { - manualMatchingService.leaveManualMatchingRoom(request.userId(), request.roomId()); + @PatchMapping("/exit/{roomId}") + public ApiResponse leaveManualMatchingRoom(@CurrentMemberId Long userId, @PathVariable Long roomId) { + manualMatchingService.leaveManualMatchingRoom(userId, roomId); return ApiResponse.response(HttpStatus.OK, LEAVE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); } } From da655676cd7bf5d574587d7a6bf99d244cb62b12 Mon Sep 17 00:00:00 2001 From: senna Date: Fri, 31 Jan 2025 23:31:20 +0900 Subject: [PATCH 607/770] =?UTF-8?q?chore:=20prod=20CICD=20=EA=B5=AC?= =?UTF-8?q?=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- .github/workflows/prod.yml | 71 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/prod.yml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index a5bd736d..aca584e5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -62,7 +62,7 @@ jobs: port: 22 key: ${{ secrets.DEV_SSH_SECRET_PRIVATE_KEY }} script: | - sudo docker pull ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest + sudo docker pull ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:${{ secrets.DEV_DOCKER_TAG }} sudo docker compose up -d --no-deps gachtaxi diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml new file mode 100644 index 00000000..88779fa2 --- /dev/null +++ b/.github/workflows/prod.yml @@ -0,0 +1,71 @@ +name: GachTaxi-BE dev CI/CD + +on: + push: + branches: [ "main"] # develop 브랜치에 push 시 트리거 + pull_request: + branches: [ "main"] # develop 브랜치에 대한 PR 시 트리거 + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Gradle 캐시 설정 + - name: Gradle Caching + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build with Gradle Wrapper + run: ./gradlew build -x test + + # 빌드된 JAR 파일 확인 + - name: List JAR files + run: ls build/libs + + # Docker 이미지 빌드 및 푸시 + - name: Docker build & push + run: | + docker login -u ${{ secrets.DEV_DOCKER_USER_NAME }} -p ${{ secrets.DEV_DOCKER_USER_TOKEN }} + docker buildx create --use + docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest --push . + + deploy: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' + + steps: + # SSH를 사용하여 원격 서버에 배포 + - name: Deploy to server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.PROD_SSH_SECRET_HOST }} + username: ${{ secrets.PROD_SSH_SECRET_USER }} + port: 22 + key: ${{ secrets.PROD_SSH_SECRET_PRIVATE_KEY }} + script: | + sudo docker pull ${{ secrets.PROD_DOCKER_USER_NAME }}/gachtaxi:${{ secrets.PROD_DOCKER_TAG }} + + sudo docker compose up -d --no-deps gachtaxi + + # 사용하지 않는 이미지 정리 + echo "** 사용하지 않는 Docker 이미지 정리" + sudo docker image prune -f \ No newline at end of file From 37ff4a1d9f0f143d41797b5faa2ba37a5634b51d Mon Sep 17 00:00:00 2001 From: senna Date: Fri, 31 Jan 2025 23:33:32 +0900 Subject: [PATCH 608/770] =?UTF-8?q?rename:=20Prod=20CICD=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 88779fa2..e97018e6 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -1,4 +1,4 @@ -name: GachTaxi-BE dev CI/CD +name: GachTaxi-BE prod CI/CD on: push: From 6dc8d7bb4fa23a44481bbbe932ea274ec7311fcb Mon Sep 17 00:00:00 2001 From: senna Date: Fri, 31 Jan 2025 23:34:34 +0900 Subject: [PATCH 609/770] =?UTF-8?q?docs:=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index e97018e6..1439378a 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -2,9 +2,9 @@ name: GachTaxi-BE prod CI/CD on: push: - branches: [ "main"] # develop 브랜치에 push 시 트리거 + branches: [ "main"] pull_request: - branches: [ "main"] # develop 브랜치에 대한 PR 시 트리거 + branches: [ "main"] types: [opened, synchronize, reopened] jobs: From 113b847b5b73d1546ad91d67544a3921d891415d Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 1 Feb 2025 03:33:50 +0900 Subject: [PATCH 610/770] =?UTF-8?q?feat:=20FetchJoin=20+=20Slice=EB=A1=9C?= =?UTF-8?q?=20=EC=B9=9C=EA=B5=AC=20=EB=AA=A9=EB=A1=9D=20=EB=AC=B4=ED=95=9C?= =?UTF-8?q?=20=EC=8A=A4=ED=81=AC=EB=A1=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/controller/FriendController.java | 12 +++++------ .../friend/repository/FriendRepository.java | 20 ++++++++----------- .../domain/friend/service/FriendService.java | 14 +++++++++---- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 8fe76404..b77b1965 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -7,10 +7,9 @@ import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Slice; import org.springframework.web.bind.annotation.*; -import java.util.List; - import static com.gachtaxi.domain.friend.controller.ResponseMessage.*; import static org.springframework.http.HttpStatus.OK; @@ -32,11 +31,12 @@ public ApiResponse sendFriendRequest( // 나의 친구를 반환하는 API @GetMapping - public ApiResponse> getFriendsList( - @CurrentMemberId Long memberId + public ApiResponse> getFriendsList( + @CurrentMemberId Long memberId, + @RequestParam int page, + @RequestParam int size ){ - - List response = friendService.getFriendsList(memberId); + Slice response = friendService.findFriendsListByMemberId(memberId, page, size); return ApiResponse.response(OK, FRIEND_LIST_SUCCESS.getMessage(), response); } diff --git a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java index f986c774..bd83f939 100644 --- a/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java +++ b/src/main/java/com/gachtaxi/domain/friend/repository/FriendRepository.java @@ -1,28 +1,24 @@ package com.gachtaxi.domain.friend.repository; -import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.entity.Friends; import io.lettuce.core.dynamic.annotation.Param; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import java.util.List; import java.util.Optional; @Repository public interface FriendRepository extends JpaRepository { - @Query("SELECT new com.gachtaxi.domain.friend.dto.response.FriendsResponseDto( " + - "CASE WHEN f.sender.id = :memberId THEN f.receiver.id ELSE f.sender.id END, " + - "CASE WHEN f.sender.id = :memberId THEN f.receiver.nickname ELSE f.sender.nickname END, " + - "CASE WHEN f.sender.id = :memberId THEN f.receiver.profilePicture ELSE f.sender.profilePicture END, " + - "CASE WHEN f.sender.id = :memberId THEN f.receiver.gender ELSE f.sender.gender END " + - ") FROM Friends f " + - "WHERE f.status = 'ACCEPTED' " + - "AND (f.sender.id = :memberId OR f.receiver.id = :memberId)") - List findAcceptedFriendsByMemberId(@Param("memberId") Long memberId); - + @Query("SELECT f FROM Friends f " + + "JOIN FETCH f.sender s " + + "JOIN FETCH f.receiver r " + + "WHERE (s.id = :memberId OR r.id = :memberId) " + + "AND f.status = 'ACCEPTED'") + Slice findFriendsListByMemberId(@Param("memberId") Long memberId, Pageable pageable); @Query("SELECT f FROM Friends f WHERE" + "(f.sender.id = :member1Id AND f.receiver.id = :member2Id) OR" + diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 54363ae0..99e25962 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -8,6 +8,7 @@ import com.gachtaxi.domain.friend.exception.FriendShipDoesNotSendMySelfException; import com.gachtaxi.domain.friend.exception.FriendShipExistsException; import com.gachtaxi.domain.friend.exception.FriendShipPendingException; +import com.gachtaxi.domain.friend.mapper.FriendsMapper; import com.gachtaxi.domain.friend.repository.FriendRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; @@ -15,10 +16,11 @@ import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; import org.springframework.stereotype.Service; -import java.util.List; - @Slf4j @Service @RequiredArgsConstructor @@ -46,8 +48,12 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { // String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); } - public List getFriendsList(Long memberId){ - return friendRepository.findAcceptedFriendsByMemberId(memberId); + public Slice findFriendsListByMemberId(Long memberId, int page, int size) { + Pageable pageable = PageRequest.of(page, size); + + Slice friendsList = friendRepository.findFriendsListByMemberId(memberId, pageable); + + return friendsList.map(f -> FriendsMapper.toResponseDto(f, memberId)); } @Transactional From d5b08cace0b4a99180e7346cd0cb7f6cf18c3c7c Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 1 Feb 2025 03:36:53 +0900 Subject: [PATCH 611/770] =?UTF-8?q?fix:=20=EA=B0=95=ED=98=81=EB=8B=98=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EC=88=98=EC=A0=95=20=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gachtaxi/domain/friend/service/FriendService.java | 3 ++- src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 99e25962..c1ce7894 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -62,6 +62,7 @@ public void updateFriendStatus(Long senderId, Long receiverId) { friendShip.updateStatus(); } + @Transactional public void deleteFriend(Long currentId, Long memberId) { Friends friendShip = getFriendShip(currentId, memberId); friendRepository.delete(friendShip); @@ -71,7 +72,7 @@ public void deleteFriend(Long currentId, Long memberId) { * refactoring * */ - public void checkDuplicatedFriendShip(Long senderId, Long receiverId) { + private void checkDuplicatedFriendShip(Long senderId, Long receiverId) { if(senderId.equals(receiverId)) { // 자기 자신한테 친구 요청을 보낼 경우 throw new FriendShipDoesNotSendMySelfException(); } diff --git a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java index b41f0c5c..a40c5347 100644 --- a/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java +++ b/src/main/java/com/gachtaxi/global/config/PermitUrlConfig.java @@ -22,7 +22,6 @@ public String[] getPublicUrl(){ public String[] getMemberUrl(){ return new String[]{ "/auth/code/**", - "/api/friends", "/api/friends/**" }; } From 1127613a99c2458e8ec7f9291401244520254ba2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 1 Feb 2025 03:38:31 +0900 Subject: [PATCH 612/770] =?UTF-8?q?fix:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/friend/controller/FriendController.java | 6 +++--- .../com/gachtaxi/domain/friend/service/FriendService.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index b77b1965..91cd89d5 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -33,10 +33,10 @@ public ApiResponse sendFriendRequest( @GetMapping public ApiResponse> getFriendsList( @CurrentMemberId Long memberId, - @RequestParam int page, - @RequestParam int size + @RequestParam int pageNum, + @RequestParam int pageSize ){ - Slice response = friendService.findFriendsListByMemberId(memberId, page, size); + Slice response = friendService.findFriendsListByMemberId(memberId, pageNum, pageSize); return ApiResponse.response(OK, FRIEND_LIST_SUCCESS.getMessage(), response); } diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index c1ce7894..886d903c 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -48,8 +48,8 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { // String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); } - public Slice findFriendsListByMemberId(Long memberId, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + public Slice findFriendsListByMemberId(Long memberId, int pageNum, int pageSize) { + Pageable pageable = PageRequest.of(pageNum, pageSize); Slice friendsList = friendRepository.findFriendsListByMemberId(memberId, pageable); From 45d9880a9a679283e7843bcb047dedc29c8c507a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sat, 1 Feb 2025 12:57:11 +0900 Subject: [PATCH 613/770] =?UTF-8?q?refactor:=20sockJs=20=EC=A3=BC=EC=84=9D?= =?UTF-8?q?=20=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index 797132ed..41def4ab 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -25,8 +25,8 @@ public void registerStompEndpoints(StompEndpointRegistry registry) { registry .setErrorHandler(stompExceptionHandler) .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3000"); -// .withSockJS(); + .setAllowedOriginPatterns("http://localhost:3000") + .withSockJS(); } @Override From ad6cedf6358c437e2bc9dbdfbbe49324b7d0f4e4 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 14:02:29 +0900 Subject: [PATCH 614/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=EB=A3=B8?= =?UTF-8?q?=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EA=B0=84=20=EA=B0=9C=ED=96=89=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index eff90cde..8c36408a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -120,10 +120,12 @@ public static MatchingRoom manualOf(Members roomMaster, Route route, String titl .matchingRoomStatus(MatchingRoomStatus.ACTIVE) .build(); } + public boolean containsTag(Tags tag) { return this.matchingRoomTagInfo.stream() .anyMatch(tagInfo -> tagInfo.matchesTag(tag)); } + public FindRoomResult toFindRoomResult() { return FindRoomResult.builder() .roomId(this.getId()) From c9956b9b39755f48c69b3fd2c5d94492389bf068 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 14:04:17 +0900 Subject: [PATCH 615/770] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/controller/ManualMatchingController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index 4e5ee1f3..99be4e3d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -13,7 +13,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -23,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController; @Tag(name = "MANUAL", description = "수동매칭 API") -@Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/api/matching/manual") From 86af61e50b8fa3f16f60fa78779ca1862a093480 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 1 Feb 2025 14:34:24 +0900 Subject: [PATCH 616/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EB=B0=98=ED=99=98=20=EC=8B=9C?= =?UTF-8?q?=20Pageable=20=EA=B0=84=EC=86=8C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/controller/FriendController.java | 7 +++--- .../dto/response/FriendsPageableResponse.java | 22 +++++++++++++++++++ .../dto/response/FriendsSliceResponse.java | 18 +++++++++++++++ .../domain/friend/service/FriendService.java | 14 ++++++++++-- 4 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java create mode 100644 src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsSliceResponse.java diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 91cd89d5..455d6cdf 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -2,12 +2,11 @@ import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; import com.gachtaxi.domain.friend.dto.request.FriendUpdateDto; -import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; +import com.gachtaxi.domain.friend.dto.response.FriendsSliceResponse; import com.gachtaxi.domain.friend.service.FriendService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Slice; import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.friend.controller.ResponseMessage.*; @@ -31,12 +30,12 @@ public ApiResponse sendFriendRequest( // 나의 친구를 반환하는 API @GetMapping - public ApiResponse> getFriendsList( + public ApiResponse getFriendsList( @CurrentMemberId Long memberId, @RequestParam int pageNum, @RequestParam int pageSize ){ - Slice response = friendService.findFriendsListByMemberId(memberId, pageNum, pageSize); + FriendsSliceResponse response = friendService.findFriendsListByMemberId(memberId, pageNum, pageSize); return ApiResponse.response(OK, FRIEND_LIST_SUCCESS.getMessage(), response); } diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java new file mode 100644 index 00000000..a3cb77f2 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java @@ -0,0 +1,22 @@ +package com.gachtaxi.domain.friend.dto.response; + +import com.gachtaxi.domain.friend.entity.Friends; +import lombok.Builder; +import org.springframework.data.domain.Slice; + +@Builder +public record FriendsPageableResponse( + int pageNum, + int pageSize, + int numberOfElements, + boolean isLast +) { + public static FriendsPageableResponse from(Slice slice) { + return FriendsPageableResponse.builder() + .pageNum(slice.getNumber()) + .pageSize(slice.getSize()) + .numberOfElements(slice.getNumberOfElements()) + .isLast(slice.isLast()) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsSliceResponse.java b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsSliceResponse.java new file mode 100644 index 00000000..8b07798c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsSliceResponse.java @@ -0,0 +1,18 @@ +package com.gachtaxi.domain.friend.dto.response; + +import lombok.Builder; + +import java.util.List; + +@Builder +public record FriendsSliceResponse( + List response, + FriendsPageableResponse pageable +) { + public static FriendsSliceResponse of(List response, FriendsPageableResponse pageable) { + return FriendsSliceResponse.builder() + .response(response) + .pageable(pageable) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 886d903c..e9fdd7ae 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -1,7 +1,9 @@ package com.gachtaxi.domain.friend.service; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.dto.response.FriendsPageableResponse; import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; +import com.gachtaxi.domain.friend.dto.response.FriendsSliceResponse; import com.gachtaxi.domain.friend.entity.Friends; import com.gachtaxi.domain.friend.entity.enums.FriendStatus; import com.gachtaxi.domain.friend.exception.FriendNotExistsException; @@ -21,6 +23,8 @@ import org.springframework.data.domain.Slice; import org.springframework.stereotype.Service; +import java.util.List; + @Slf4j @Service @RequiredArgsConstructor @@ -48,12 +52,18 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { // String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); } - public Slice findFriendsListByMemberId(Long memberId, int pageNum, int pageSize) { + public FriendsSliceResponse findFriendsListByMemberId(Long memberId, int pageNum, int pageSize) { Pageable pageable = PageRequest.of(pageNum, pageSize); Slice friendsList = friendRepository.findFriendsListByMemberId(memberId, pageable); - return friendsList.map(f -> FriendsMapper.toResponseDto(f, memberId)); + List friendsListDto = friendsList + .map(f -> FriendsMapper.toResponseDto(f, memberId)) + .toList(); + + FriendsPageableResponse pageableResponse = FriendsPageableResponse.from(friendsList); + + return FriendsSliceResponse.of(friendsListDto, pageableResponse); } @Transactional From 85fb846d39b547f69590e5fb5c2168452f72bbf3 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 14:41:59 +0900 Subject: [PATCH 617/770] =?UTF-8?q?refactor:=20=EB=B0=A9=EC=9E=A5=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EB=B0=A9=20=EC=B0=B8=EC=97=AC=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=A7=81=EA=B4=80=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=84=A4=EC=9D=B4=EB=B0=8D=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...JoinOwnException.java => RoomMasterCantJoinException.java} | 4 ++-- .../domain/matching/common/service/ManualMatchingService.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/com/gachtaxi/domain/matching/common/exception/{MatchingRoomNotJoinOwnException.java => RoomMasterCantJoinException.java} (75%) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomNotJoinOwnException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/RoomMasterCantJoinException.java similarity index 75% rename from src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomNotJoinOwnException.java rename to src/main/java/com/gachtaxi/domain/matching/common/exception/RoomMasterCantJoinException.java index 87919eca..07b7e1ad 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomNotJoinOwnException.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/RoomMasterCantJoinException.java @@ -5,8 +5,8 @@ import com.gachtaxi.global.common.exception.BaseException; -public class MatchingRoomNotJoinOwnException extends BaseException { - public MatchingRoomNotJoinOwnException() { +public class RoomMasterCantJoinException extends BaseException { + public RoomMasterCantJoinException() { super(BAD_REQUEST, MATCHING_ROOM_NOT_JOIN_OWN.getMessage()); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 51609723..31ee8c2d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -6,7 +6,7 @@ import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; import com.gachtaxi.domain.matching.common.exception.DuplicatedMatchingRoomException; -import com.gachtaxi.domain.matching.common.exception.MatchingRoomNotJoinOwnException; +import com.gachtaxi.domain.matching.common.exception.RoomMasterCantJoinException; import com.gachtaxi.domain.matching.common.exception.MemberAlreadyJoinedException; import com.gachtaxi.domain.matching.common.exception.MemberAlreadyLeftMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.MemberNotInMatchingRoomException; @@ -82,7 +82,7 @@ public void joinManualMatchingRoom(Long userId, Long roomId) { } if (matchingRoom.getRoomMaster().equals(user)) { - throw new MatchingRoomNotJoinOwnException(); + throw new RoomMasterCantJoinException(); } if (this.memberMatchingRoomChargingInfoRepository.existsByMembersAndMatchingRoom(user, matchingRoom)) { From 760128dd9a3482327d815e6005dad3012c45c744 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 14:43:20 +0900 Subject: [PATCH 618/770] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=84=A0=EC=96=B8=20=EB=B0=8F=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/ManualMatchingService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 31ee8c2d..01b8fd03 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -13,7 +13,6 @@ import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.NotActiveMatchingRoomException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; -import com.gachtaxi.domain.matching.common.repository.MatchingRoomTagInfoRepository; import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; @@ -33,7 +32,6 @@ public class ManualMatchingService { private final MemberService memberService; private final MatchingRoomService matchingRoomService; private final MatchingRoomRepository matchingRoomRepository; - private final MatchingRoomTagInfoRepository matchingRoomTagInfoRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; /* From 0b0ddef8ed89860f932425dd741234bac3371969 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 16:40:29 +0900 Subject: [PATCH 619/770] =?UTF-8?q?fix:=20push=ED=95=A0=EB=95=8C=20?= =?UTF-8?q?=ED=83=9C=EA=B7=B8=20=EB=AA=85=EC=8B=9C=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- .github/workflows/prod.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index aca584e5..4782f3c8 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -45,7 +45,7 @@ jobs: run: | docker login -u ${{ secrets.DEV_DOCKER_USER_NAME }} -p ${{ secrets.DEV_DOCKER_USER_TOKEN }} docker buildx create --use - docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest --push . + docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:${{ secrets.DEV_DOCKER_TAG }} --push . deploy: runs-on: ubuntu-latest diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 1439378a..50672a9e 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -4,7 +4,7 @@ on: push: branches: [ "main"] pull_request: - branches: [ "main"] + branches: [ "main"] types: [opened, synchronize, reopened] jobs: @@ -45,7 +45,7 @@ jobs: run: | docker login -u ${{ secrets.DEV_DOCKER_USER_NAME }} -p ${{ secrets.DEV_DOCKER_USER_TOKEN }} docker buildx create --use - docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:latest --push . + docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-dev -t ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi:${{ secrets.PROD_DOCKER_TAG }} --push . deploy: runs-on: ubuntu-latest From bc8ae14a2111ce6caca0750fd700b9b4263db52f Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 17:43:57 +0900 Subject: [PATCH 620/770] =?UTF-8?q?feat:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B4=80=EB=A0=A8=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/BlacklistAlreadyExistsException.java | 13 +++++++++++++ .../exception/BlacklistNotFoundException.java | 13 +++++++++++++ .../domain/members/exception/ErrorMessage.java | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/BlacklistAlreadyExistsException.java create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/BlacklistNotFoundException.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/BlacklistAlreadyExistsException.java b/src/main/java/com/gachtaxi/domain/members/exception/BlacklistAlreadyExistsException.java new file mode 100644 index 00000000..030a8bbf --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/BlacklistAlreadyExistsException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.members.exception; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.BLACKLIST_ALREADY_EXISTS; +import static org.springframework.http.HttpStatus.CONFLICT; + +import com.gachtaxi.global.common.exception.BaseException; + +public class BlacklistAlreadyExistsException extends BaseException { + + public BlacklistAlreadyExistsException() { + super(CONFLICT, BLACKLIST_ALREADY_EXISTS.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/exception/BlacklistNotFoundException.java b/src/main/java/com/gachtaxi/domain/members/exception/BlacklistNotFoundException.java new file mode 100644 index 00000000..fa103615 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/BlacklistNotFoundException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.members.exception; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.BLACKLIST_NOT_FOUND; +import static org.springframework.http.HttpStatus.NOT_FOUND; + +import com.gachtaxi.global.common.exception.BaseException; + +public class BlacklistNotFoundException extends BaseException { + + public BlacklistNotFoundException() { + super(NOT_FOUND, BLACKLIST_NOT_FOUND.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index 8a71cd13..28d8353d 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -11,7 +11,9 @@ public enum ErrorMessage { DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."), DUPLICATED_EMAIL("이미 가입된 이메일이에요!"), - EMAIL_FROM_INVALID("가천대학교 이메일이 아니에요!"); + EMAIL_FROM_INVALID("가천대학교 이메일이 아니에요!"), + BLACKLIST_ALREADY_EXISTS("이미 등록된 블랙리스트입니다."), + BLACKLIST_NOT_FOUND("블랙리스트를 찾을 수 없습니다."); private final String message; } From b845dd5df893a93746220a04dc36ae75ae1dd8e1 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 17:44:04 +0900 Subject: [PATCH 621/770] =?UTF-8?q?feat:=20=EB=B8=94=EB=9E=99=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/entity/Blacklists.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/entity/Blacklists.java diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Blacklists.java b/src/main/java/com/gachtaxi/domain/members/entity/Blacklists.java new file mode 100644 index 00000000..3ccfd0a8 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/entity/Blacklists.java @@ -0,0 +1,37 @@ +package com.gachtaxi.domain.members.entity; + +import com.gachtaxi.global.common.entity.BaseEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +@Getter +@Entity +@SuperBuilder +@Table(name="blacklists", + uniqueConstraints = { + @UniqueConstraint(columnNames = {"member_id", "blacklist_member_id"}) + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Blacklists extends BaseEntity { + + @ManyToOne(fetch = FetchType.LAZY) + private Members requester; + + @ManyToOne(fetch = FetchType.LAZY) + private Members receiver; + + public static Blacklists create(Members requester, Members receiver) { + return Blacklists.builder() + .requester(requester) + .receiver(receiver) + .build(); + } +} From cc4e93880f1ac99221d9686a271e823a23700849 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 17:44:15 +0900 Subject: [PATCH 622/770] =?UTF-8?q?feat:=20=EB=B8=94=EB=9E=99=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20repository=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/repository/BlacklistsRepository.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java diff --git a/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java new file mode 100644 index 00000000..97f453b1 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java @@ -0,0 +1,14 @@ +package com.gachtaxi.domain.members.repository; + +import com.gachtaxi.domain.members.entity.Blacklists; +import com.gachtaxi.domain.members.entity.Members; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface BlacklistsRepository extends JpaRepository { + + Optional findByRequesterAndReceiver(Members requester, Members receiver); + boolean existsByRequesterAndReceiver(Members requester, Members receiver); +} From ca67f19a6721238c6b8845e16ac5af0c8086dc54 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 17:44:28 +0900 Subject: [PATCH 623/770] =?UTF-8?q?feat:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=9D=91=EB=8B=B5=20DTO=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/ResponseMessage.java | 7 ++- .../dto/response/BlacklistGetResponse.java | 44 +++++++++++++++++++ .../dto/response/BlacklistPostResponse.java | 18 ++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistPostResponse.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index b53d1e62..79316f67 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -14,7 +14,12 @@ public enum ResponseMessage { ALREADY_SIGN_UP("이미 가입된 이메일 입니다!"), REFRESH_TOKEN_REISSUE("토큰 재발급에 성공했습니다."), LOGIN_SUCCESS("로그인 성공에 성공했습니다."), - UN_REGISTER("회원가입을 진행해주세요"); + UN_REGISTER("회원가입을 진행해주세요"), + + // BlacklistController + BLACKLIST_SAVE_SUCCESS("블랙리스트 등록에 성공했습니다."), + BLACKLIST_DELETE_SUCCESS("블랙리스트 삭제에 성공했습니다."), + BLACKLIST_FIND_ALL_SUCCESS("블랙리스트 조회에 성공했습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java new file mode 100644 index 00000000..9698456a --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java @@ -0,0 +1,44 @@ +package com.gachtaxi.domain.members.dto.response; + +import com.gachtaxi.domain.members.entity.Blacklists; +import java.util.List; +import lombok.Builder; +import org.springframework.data.domain.Page; + +@Builder +public record BlacklistGetResponse( + List blacklists, + Integer pageNumber, + Integer pageSize, + Integer numberOfElements, + Boolean last +) { + + public static BlacklistGetResponse of(Page blacklistsPage) { + List responseList = blacklistsPage.stream() + .map(BlacklistInfo::of) + .toList(); + + return BlacklistGetResponse.builder() + .blacklists(responseList) + .pageNumber(blacklistsPage.getNumber()) + .pageSize(blacklistsPage.getSize()) + .numberOfElements(blacklistsPage.getNumberOfElements()) + .last(blacklistsPage.isLast()) + .build(); + } + + record BlacklistInfo( + Long receiverId, + String receiverNickname, + String gender + ) { + public static BlacklistInfo of(Blacklists blacklists) { + return new BlacklistInfo( + blacklists.getReceiver().getId(), + blacklists.getReceiver().getNickname(), + blacklists.getReceiver().getGender().name() + ); + } + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistPostResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistPostResponse.java new file mode 100644 index 00000000..ef3e712c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistPostResponse.java @@ -0,0 +1,18 @@ +package com.gachtaxi.domain.members.dto.response; + +import com.gachtaxi.domain.members.entity.Blacklists; + +public record BlacklistPostResponse( + Long requesterId, + Long receiverId, + Long blacklistId +) { + + public static BlacklistPostResponse of (Blacklists blacklists) { + return new BlacklistPostResponse( + blacklists.getRequester().getId(), + blacklists.getReceiver().getId(), + blacklists.getId() + ); + } +} From cbffb3304f673023f92678aecd2f295edd6df245 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 17:44:40 +0900 Subject: [PATCH 624/770] =?UTF-8?q?feat:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20CRD=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BlacklistController.java | 63 +++++++++++++++++++ .../members/service/BlacklistService.java | 58 +++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java create mode 100644 src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java b/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java new file mode 100644 index 00000000..4bb8a6fd --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java @@ -0,0 +1,63 @@ +package com.gachtaxi.domain.members.controller; + +import static com.gachtaxi.domain.members.controller.ResponseMessage.BLACKLIST_DELETE_SUCCESS; +import static com.gachtaxi.domain.members.controller.ResponseMessage.BLACKLIST_FIND_ALL_SUCCESS; +import static com.gachtaxi.domain.members.controller.ResponseMessage.BLACKLIST_SAVE_SUCCESS; +import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.OK; + +import com.gachtaxi.domain.members.dto.response.BlacklistGetResponse; +import com.gachtaxi.domain.members.dto.response.BlacklistPostResponse; +import com.gachtaxi.domain.members.service.BlacklistService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "BLACKLIST") +@RestController +@RequestMapping("/api/blacklists") +@RequiredArgsConstructor +public class BlacklistController { + + private final BlacklistService blacklistService; + + @Operation(summary = "블랙리스트 등록 API") + @PostMapping("/{receiverId}") + public ApiResponse postBlacklist( + @CurrentMemberId Long memberId, + @RequestParam Long receiverId) { + + return ApiResponse.response(CREATED, BLACKLIST_SAVE_SUCCESS.getMessage(), + this.blacklistService.save(memberId, receiverId)); + } + + @Operation(summary = "블랙리스트 삭제 API") + @DeleteMapping("/{receiverId}") + public ApiResponse deleteBlacklist( + @CurrentMemberId Long memberId, + @PathVariable Long receiverId) { + this.blacklistService.delete(memberId, receiverId); + + return ApiResponse.response(OK, BLACKLIST_DELETE_SUCCESS.getMessage()); + } + + @Operation(summary = "블랙리스트 조회 API") + @GetMapping("/{pageNum}") + public ApiResponse getAllBlacklist( + @CurrentMemberId Long requesterId, + @PathVariable int pageNum) { + BlacklistGetResponse blacklistPage = this.blacklistService.findBlacklistPage(requesterId, + pageNum); + + return ApiResponse.response(OK, BLACKLIST_FIND_ALL_SUCCESS.getMessage(), blacklistPage); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java new file mode 100644 index 00000000..704d3f9a --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java @@ -0,0 +1,58 @@ +package com.gachtaxi.domain.members.service; + +import com.gachtaxi.domain.members.dto.response.BlacklistGetResponse; +import com.gachtaxi.domain.members.dto.response.BlacklistPostResponse; +import com.gachtaxi.domain.members.entity.Blacklists; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.exception.BlacklistAlreadyExistsException; +import com.gachtaxi.domain.members.exception.BlacklistNotFoundException; +import com.gachtaxi.domain.members.repository.BlacklistsRepository; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class BlacklistService { + + private static final int PAGE_SIZE = 10; + + private final BlacklistsRepository blacklistsRepository; + private final MemberService memberService; + + public BlacklistPostResponse save(Long requesterId, Long receiverId) { + Members requester = this.memberService.findById(requesterId); + Members receiver = this.memberService.findById(receiverId); + + if (this.blacklistsRepository.existsByRequesterAndReceiver(requester, receiver)) { + throw new BlacklistAlreadyExistsException(); + } + + Blacklists blacklists = this.blacklistsRepository.save(Blacklists.create(requester, receiver)); + return BlacklistPostResponse.of(blacklists); + } + + public void delete(Long requesterId, Long receiverId) { + Members requester = this.memberService.findById(requesterId); + Members receiver = this.memberService.findById(receiverId); + + Blacklists blacklists = this.blacklistsRepository.findByRequesterAndReceiver(requester, + receiver) + .orElseThrow(BlacklistNotFoundException::new); + + this.blacklistsRepository.delete(blacklists); + } + + public BlacklistGetResponse findBlacklistPage(Long requesterId, int pageNum) { + Pageable pageRequest = PageRequest.of(pageNum, PAGE_SIZE, Sort.by(Direction.ASC, "receiver.nickname")); + + Page blacklistsPage = this.blacklistsRepository.findAll(pageRequest); + + return BlacklistGetResponse.of(blacklistsPage); + } +} From 5c7951ef1cc56181fe31d47aa0ab2684e2bc0981 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 18:11:12 +0900 Subject: [PATCH 625/770] =?UTF-8?q?fix:=20=EC=9E=90=EA=B8=B0=EC=9E=90?= =?UTF-8?q?=EC=8B=A0=EC=9D=84=20=EB=B8=94=EB=9E=99=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=97=90=20=EC=B6=94=EA=B0=80=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EB=AA=BB=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/BlacklistController.java | 6 +++--- ...lacklistRequesterEqualsReceiverException.java | 14 ++++++++++++++ .../domain/members/exception/ErrorMessage.java | 3 ++- .../members/repository/BlacklistsRepository.java | 3 +++ .../domain/members/service/BlacklistService.java | 16 ++++++++++++++-- 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/BlacklistRequesterEqualsReceiverException.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java b/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java index 4bb8a6fd..33ed814e 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java @@ -31,7 +31,7 @@ public class BlacklistController { private final BlacklistService blacklistService; @Operation(summary = "블랙리스트 등록 API") - @PostMapping("/{receiverId}") + @PostMapping public ApiResponse postBlacklist( @CurrentMemberId Long memberId, @RequestParam Long receiverId) { @@ -51,10 +51,10 @@ public ApiResponse deleteBlacklist( } @Operation(summary = "블랙리스트 조회 API") - @GetMapping("/{pageNum}") + @GetMapping public ApiResponse getAllBlacklist( @CurrentMemberId Long requesterId, - @PathVariable int pageNum) { + @RequestParam int pageNum) { BlacklistGetResponse blacklistPage = this.blacklistService.findBlacklistPage(requesterId, pageNum); diff --git a/src/main/java/com/gachtaxi/domain/members/exception/BlacklistRequesterEqualsReceiverException.java b/src/main/java/com/gachtaxi/domain/members/exception/BlacklistRequesterEqualsReceiverException.java new file mode 100644 index 00000000..c58d44c4 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/BlacklistRequesterEqualsReceiverException.java @@ -0,0 +1,14 @@ +package com.gachtaxi.domain.members.exception; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.BLACKLIST_REQUESTER_EQUALS_RECEIVER; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +import com.gachtaxi.global.common.exception.BaseException; + +public class BlacklistRequesterEqualsReceiverException extends BaseException { + + public BlacklistRequesterEqualsReceiverException() { + super(BAD_REQUEST, BLACKLIST_REQUESTER_EQUALS_RECEIVER.getMessage()); + } + +} diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index 28d8353d..7207ee92 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -13,7 +13,8 @@ public enum ErrorMessage { DUPLICATED_EMAIL("이미 가입된 이메일이에요!"), EMAIL_FROM_INVALID("가천대학교 이메일이 아니에요!"), BLACKLIST_ALREADY_EXISTS("이미 등록된 블랙리스트입니다."), - BLACKLIST_NOT_FOUND("블랙리스트를 찾을 수 없습니다."); + BLACKLIST_NOT_FOUND("블랙리스트를 찾을 수 없습니다."), + BLACKLIST_REQUESTER_EQUALS_RECEIVER("본인을 블랙리스트에 추가할 수 없습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java index 97f453b1..9501496e 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java @@ -3,6 +3,8 @@ import com.gachtaxi.domain.members.entity.Blacklists; import com.gachtaxi.domain.members.entity.Members; import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -11,4 +13,5 @@ public interface BlacklistsRepository extends JpaRepository { Optional findByRequesterAndReceiver(Members requester, Members receiver); boolean existsByRequesterAndReceiver(Members requester, Members receiver); + Page findAllByRequester(Members requester, Pageable pageable); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java index 704d3f9a..7340139d 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java @@ -6,8 +6,8 @@ import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.BlacklistAlreadyExistsException; import com.gachtaxi.domain.members.exception.BlacklistNotFoundException; +import com.gachtaxi.domain.members.exception.BlacklistRequesterEqualsReceiverException; import com.gachtaxi.domain.members.repository.BlacklistsRepository; -import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -29,6 +29,8 @@ public BlacklistPostResponse save(Long requesterId, Long receiverId) { Members requester = this.memberService.findById(requesterId); Members receiver = this.memberService.findById(receiverId); + this.checkRequesterAndReceiver(requester, receiver); + if (this.blacklistsRepository.existsByRequesterAndReceiver(requester, receiver)) { throw new BlacklistAlreadyExistsException(); } @@ -41,6 +43,8 @@ public void delete(Long requesterId, Long receiverId) { Members requester = this.memberService.findById(requesterId); Members receiver = this.memberService.findById(receiverId); + this.checkRequesterAndReceiver(requester, receiver); + Blacklists blacklists = this.blacklistsRepository.findByRequesterAndReceiver(requester, receiver) .orElseThrow(BlacklistNotFoundException::new); @@ -49,10 +53,18 @@ public void delete(Long requesterId, Long receiverId) { } public BlacklistGetResponse findBlacklistPage(Long requesterId, int pageNum) { + Members requester = this.memberService.findById(requesterId); + Pageable pageRequest = PageRequest.of(pageNum, PAGE_SIZE, Sort.by(Direction.ASC, "receiver.nickname")); - Page blacklistsPage = this.blacklistsRepository.findAll(pageRequest); + Page blacklistsPage = this.blacklistsRepository.findAllByRequester(requester, pageRequest); return BlacklistGetResponse.of(blacklistsPage); } + + private void checkRequesterAndReceiver(Members requester, Members receiver) { + if (requester.equals(receiver)) { + throw new BlacklistRequesterEqualsReceiverException(); + } + } } From 1e02dda8aaa4367da0ffb7c2ad3c0837823f54c9 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sat, 1 Feb 2025 18:22:56 +0900 Subject: [PATCH 626/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=95=8C=EB=A6=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/service/FriendService.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index e9fdd7ae..87fac1f9 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -14,6 +14,7 @@ import com.gachtaxi.domain.friend.repository.FriendRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.domain.notification.entity.payload.FriendRequestPayload; import com.gachtaxi.domain.notification.service.NotificationService; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; @@ -25,6 +26,8 @@ import java.util.List; +import static com.gachtaxi.domain.notification.entity.enums.NotificationType.FRIEND_REQUEST; + @Slf4j @Service @RequiredArgsConstructor @@ -34,7 +37,8 @@ public class FriendService { private final NotificationService notificationService; private final MemberService memberService; - public static final String FRIEND_REQUEST_MESSAGE = "%s 님이 친구 요청을 보냈어요."; + public static final String FRIEND_REQUEST_CONTENT = "%s 님이 친구 요청을 보냈어요."; + public static final String FRIEND_REQUEST_TITLE = "친구 요청"; @Transactional public void sendFriendRequest(Long senderId, FriendRequestDto dto) { @@ -45,11 +49,13 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { checkDuplicatedFriendShip(senderId, receiver.getId()); friendRepository.save(Friends.of(sender, receiver)); -// notificationService.sendWithPush( -// sender.getId(), -// receiver, -// FRIEND_REQUEST, -// String.format(FRIEND_REQUEST_MESSAGE, sender.getNickname())); + notificationService.sendWithPush( + sender.getId(), + receiver, + FRIEND_REQUEST, + FRIEND_REQUEST_TITLE, + String.format(FRIEND_REQUEST_CONTENT, sender.getNickname()), + FriendRequestPayload.from(senderId)); } public FriendsSliceResponse findFriendsListByMemberId(Long memberId, int pageNum, int pageSize) { From 123bcfae35cc8489805f37b7f039384ad3d5785e Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 18:34:51 +0900 Subject: [PATCH 627/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=95=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=EC=A6=98=EC=97=90=EC=84=9C=20=EB=B8=94?= =?UTF-8?q?=EB=9E=99=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=ED=99=95=EC=9D=B8?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingAlgorithmServiceImpl.java | 34 +++++++++++-------- .../matching/common/entity/MatchingRoom.java | 1 + .../members/service/BlacklistService.java | 11 ++++++ 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java index 6951b54e..2df43981 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java @@ -7,6 +7,7 @@ import com.gachtaxi.domain.matching.common.exception.PageNotFoundException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.service.BlacklistService; import com.gachtaxi.domain.members.service.MemberService; import java.util.List; import java.util.Optional; @@ -22,12 +23,14 @@ public class MatchingAlgorithmServiceImpl implements MatchingAlgorithmService { private final MatchingRoomRepository matchingRoomRepository; private final MemberService memberService; + private final BlacklistService blacklistService; private static final double SEARCH_RADIUS = 300.0; @Override - public Optional findRoom(Long userId, double startLongitude, double startLatitude, double destinationLongitude, double destinationLatitude, - List criteria) { + public Optional findRoom(Long userId, double startLongitude, double startLatitude, + double destinationLongitude, double destinationLatitude, + List criteria) { /* 사용자 ID로 사용자 정보 조회(이미 방에 참여하고 있는지 중복체크) */ @@ -37,28 +40,30 @@ public Optional findRoom(Long userId, double startLongitude, dou throw new AlreadyInMatchingRoomException(); // * 추후 논의 후 리팩토링 필요 * 똑같은 조건으로 방 생성시 예외 던져주기 } /* - 위치 정보를 이용한 방 검색(300M 이내) + 위치 정보를 이용한 방 검색(300M 이내)ø */ List matchingRooms = matchingRoomRepository.findRoomsByStartAndDestination( - startLongitude, - startLatitude, - destinationLongitude, - destinationLatitude, - SEARCH_RADIUS - ); + startLongitude, + startLatitude, + destinationLongitude, + destinationLatitude, + SEARCH_RADIUS + ); /* - ACTIVE 상태인 방만 필터링 + ACTIVE 상태인 방 && 블랙리스트가 없는 방만 필터링 */ matchingRooms = matchingRooms.stream() - .filter(MatchingRoom::isActive) - .toList(); + .filter(MatchingRoom::isActive) + .filter(room -> !this.blacklistService.isBlacklistInMatchingRoom(userId, room)) + .toList(); + /* 태그 조건이 있는 경우에 태그정보까지 필터링 */ if (criteria != null && !criteria.isEmpty()) { matchingRooms = matchingRooms.stream() - .filter(room -> criteria.stream().anyMatch(room::containsTag)) - .toList(); + .filter(room -> criteria.stream().anyMatch(room::containsTag)) + .toList(); } /* 조건에 맞는 방이 있으면 첫 번째 방의 상세 정보 반환 @@ -72,6 +77,7 @@ public Optional findRoom(Long userId, double startLongitude, dou */ return Optional.empty(); } + @Override public Page findMatchingRooms(int pageNumber, int pageSize) { diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 0afef65e..c11cd65d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -39,6 +39,7 @@ public class MatchingRoom extends BaseEntity { // 팀원들 정보 @OneToMany(mappedBy = "matchingRoom", fetch = FetchType.LAZY) + @Getter private List memberMatchingRoomChargingInfo; @ManyToOne(cascade = CascadeType.PERSIST, optional = false) diff --git a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java index 7340139d..ff923397 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.members.dto.response.BlacklistGetResponse; import com.gachtaxi.domain.members.dto.response.BlacklistPostResponse; import com.gachtaxi.domain.members.entity.Blacklists; @@ -62,6 +63,16 @@ public BlacklistGetResponse findBlacklistPage(Long requesterId, int pageNum) { return BlacklistGetResponse.of(blacklistsPage); } + public boolean isBlacklistInMatchingRoom(Long requesterId, MatchingRoom matchingRoom) { + Members requester = this.memberService.findById(requesterId); + + boolean existBlacklist = matchingRoom.getMemberMatchingRoomChargingInfo().stream() + .anyMatch(memberMatchingRoomChargingInfo -> this.blacklistsRepository.existsByRequesterAndReceiver( + requester, memberMatchingRoomChargingInfo.getMembers())); + + return existBlacklist; + } + private void checkRequesterAndReceiver(Members requester, Members receiver) { if (requester.equals(receiver)) { throw new BlacklistRequesterEqualsReceiverException(); From 91890ef8697bea1c8a35688a94de13ab4cd03608 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 18:54:15 +0900 Subject: [PATCH 628/770] =?UTF-8?q?feat:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A0=80=EC=9E=A5,=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=EC=97=90=20transactional=20?= =?UTF-8?q?=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/BlacklistService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java index ff923397..13390af5 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java @@ -9,6 +9,7 @@ import com.gachtaxi.domain.members.exception.BlacklistNotFoundException; import com.gachtaxi.domain.members.exception.BlacklistRequesterEqualsReceiverException; import com.gachtaxi.domain.members.repository.BlacklistsRepository; +import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -26,6 +27,7 @@ public class BlacklistService { private final BlacklistsRepository blacklistsRepository; private final MemberService memberService; + @Transactional public BlacklistPostResponse save(Long requesterId, Long receiverId) { Members requester = this.memberService.findById(requesterId); Members receiver = this.memberService.findById(receiverId); @@ -40,6 +42,7 @@ public BlacklistPostResponse save(Long requesterId, Long receiverId) { return BlacklistPostResponse.of(blacklists); } + @Transactional public void delete(Long requesterId, Long receiverId) { Members requester = this.memberService.findById(requesterId); Members receiver = this.memberService.findById(receiverId); From dbd2756a9d7ef3068ece3de6c9d5205246fbb4c3 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 19:00:59 +0900 Subject: [PATCH 629/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=EC=B1=84=ED=8C=85=20?= =?UTF-8?q?=EB=B0=A9=EB=8F=84=20=EC=83=9D=EC=84=B1=EB=90=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 채팅 방에 자동으로 매칭 방을 만든 멤버도 참가하도록 구현 --- .../domain/chat/controller/ChattingController.java | 8 -------- .../gachtaxi/domain/chat/service/ChattingRoomService.java | 6 +++--- .../domain/matching/common/entity/MatchingRoom.java | 8 +++++++- .../matching/common/service/MatchingRoomService.java | 7 ++++++- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java index 19512136..33f6bdcc 100644 --- a/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java +++ b/src/main/java/com/gachtaxi/domain/chat/controller/ChattingController.java @@ -29,14 +29,6 @@ public class ChattingController { private final ChattingService chattingService; private final ChattingRoomService chattingRoomService; - @PostMapping("/api/chat/room") - @Operation(summary = "채팅방을 생성하기 위한 API입니다. 임시 구현으로 차후 제거될 수 있습니다.") - public ApiResponse createChattingRoom() { - ChattingRoomResponse response = chattingRoomService.save(); - - return ApiResponse.response(OK, CREATE_CHATTING_ROOM_SUCCESS.getMessage(), response); - } - @GetMapping("/api/chat/{roomId}") @Operation(summary = "채팅방 재입장시 이전 메시지를 조회하기 위한 API입니다.") public ApiResponse getChattingMessages(@PathVariable Long roomId, diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index e5fa8eca..ce6c5f0d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -43,11 +43,11 @@ public class ChattingRoomService { public String chatTopic; @Transactional - public ChattingRoomResponse save() { + public ChattingRoom create(Members roomMaster) { ChattingRoom chattingRoom = ChattingRoom.builder().build(); + chattingParticipantService.save(ChattingParticipant.of(chattingRoom, roomMaster)); - chattingRoomRepository.save(chattingRoom); - return ChattingRoomResponse.from(chattingRoom); + return chattingRoomRepository.save(chattingRoom); } @Transactional diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 0afef65e..9d5c16d3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.matching.common.entity; +import com.gachtaxi.domain.chat.entity.ChattingRoom; import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; @@ -14,6 +15,7 @@ import jakarta.persistence.FetchType; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; +import jakarta.persistence.OneToOne; import jakarta.persistence.Table; import java.util.List; import lombok.AccessLevel; @@ -62,6 +64,9 @@ public class MatchingRoom extends BaseEntity { @Enumerated(EnumType.STRING) private MatchingRoomStatus matchingRoomStatus; + @OneToOne + private ChattingRoom chattingRoom; + public boolean isActive() { return this.matchingRoomStatus == MatchingRoomStatus.ACTIVE; } @@ -82,7 +87,7 @@ public boolean isFull(int size) { return size == totalCharge; } - public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route) { + public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route, ChattingRoom chattingRoom) { return MatchingRoom.builder() .capacity(matchRoomCreatedEvent.maxCapacity()) .roomMaster(members) @@ -91,6 +96,7 @@ public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, .route(route) .totalCharge(matchRoomCreatedEvent.expectedTotalCharge()) .matchingRoomStatus(MatchingRoomStatus.ACTIVE) + .chattingRoom(chattingRoom) .build(); } public boolean containsTag(Tags tag) { diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index e75e7494..0bc2b495 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -1,5 +1,7 @@ package com.gachtaxi.domain.matching.common.service; +import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.service.ChattingRoomService; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MatchingRoomTagInfo; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; @@ -39,6 +41,7 @@ public class MatchingRoomService { // service private final MemberService memberService; private final AutoMatchingProducer autoMatchingProducer; + private final ChattingRoomService chattingRoomService; // repository private final MatchingRoomRepository matchingRoomRepository; @@ -54,7 +57,9 @@ public Long createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { Route route = this.saveRoute(matchRoomCreatedEvent); - MatchingRoom matchingRoom = MatchingRoom.activeOf(matchRoomCreatedEvent, members, route); + ChattingRoom chattingRoom = this.chattingRoomService.create(members); + + MatchingRoom matchingRoom = MatchingRoom.activeOf(matchRoomCreatedEvent, members, route, chattingRoom); this.saveMatchingRoomTagInfo(matchingRoom, matchRoomCreatedEvent.criteria()); this.saveRoomMasterChargingInfo(matchingRoom, members); From ceff64d7bffb2dc5f186f37311014d4e6bb23abe Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 19:05:18 +0900 Subject: [PATCH 630/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=B0=9C?= =?UTF-8?q?=ED=96=89=20=EC=8B=9C=20=EC=B1=84=ED=8C=85=EB=B0=A9=20id?= =?UTF-8?q?=EB=8F=84=20=EA=B0=99=EC=9D=B4=20=EB=B0=98=ED=99=94=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 1 + .../domain/matching/common/service/MatchingRoomService.java | 4 ++-- .../matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java | 4 +++- .../matching/event/service/kafka/AutoMatchingConsumer.java | 4 +--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 9d5c16d3..f1e8c1e5 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -65,6 +65,7 @@ public class MatchingRoom extends BaseEntity { private MatchingRoomStatus matchingRoomStatus; @OneToOne + @Getter private ChattingRoom chattingRoom; public boolean isActive() { diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 0bc2b495..b02338cb 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -52,7 +52,7 @@ public class MatchingRoomService { // event factory private final MatchingEventFactory matchingEventFactory; - public Long createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { + public MatchRoomCreatedEvent createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { Members members = this.memberService.findById(matchRoomCreatedEvent.roomMasterId()); Route route = this.saveRoute(matchRoomCreatedEvent); @@ -66,7 +66,7 @@ public Long createMatchingRoom(MatchRoomCreatedEvent matchRoomCreatedEvent) { MatchingRoom savedMatchingRoom = this.matchingRoomRepository.save(matchingRoom); - return savedMatchingRoom.getId(); + return MatchRoomCreatedEvent.of(matchRoomCreatedEvent, savedMatchingRoom.getId(), savedMatchingRoom.getChattingRoom().getId()); } private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java index 358d0183..8d09c9d5 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchRoomCreatedEvent.java @@ -24,6 +24,7 @@ public record MatchRoomCreatedEvent( List criteria, Integer expectedTotalCharge, Long roomId, + Long chattingRoomId, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime createdAt, @@ -41,7 +42,7 @@ public String getTopic() { return this.topic; } - public static MatchRoomCreatedEvent of(MatchRoomCreatedEvent event, Long roomId) { + public static MatchRoomCreatedEvent of(MatchRoomCreatedEvent event, Long roomId, Long chattingRoomId) { return MatchRoomCreatedEvent.builder() .roomMasterId(event.roomMasterId()) .maxCapacity(event.maxCapacity()) @@ -56,6 +57,7 @@ public static MatchRoomCreatedEvent of(MatchRoomCreatedEvent event, Long roomId) .roomId(roomId) .createdAt(event.createdAt()) .topic(event.topic()) + .chattingRoomId(chattingRoomId) .build(); } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index d18c55ff..3ff71aca 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -32,12 +32,10 @@ public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) try { log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event); - Long roomId = this.matchingRoomService.createMatchingRoom(event); - this.sseService.sendToClient( event.roomMasterId(), "MATCH_ROOM_CREATED", - MatchRoomCreatedEvent.of(event, roomId) + this.matchingRoomService.createMatchingRoom(event) ); ack.acknowledge(); From b1e92300e7bf6c1281112edff8fce74fe4506024 Mon Sep 17 00:00:00 2001 From: senna Date: Sat, 1 Feb 2025 19:14:58 +0900 Subject: [PATCH 631/770] =?UTF-8?q?feat:=20=EB=B0=A9=20=EC=B0=B8=EA=B0=80?= =?UTF-8?q?=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=B0=9C=ED=96=89=20=EC=8B=9C?= =?UTF-8?q?=20=EC=B1=84=ED=8C=85=20=EB=B0=A9=20=EC=95=84=EC=9D=B4=EB=94=94?= =?UTF-8?q?=EB=8F=84=20=EA=B0=99=EC=9D=B4=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/algorithm/dto/FindRoomResult.java | 3 ++- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 1 + .../domain/matching/common/service/AutoMatchingService.java | 2 +- .../gachtaxi/domain/matching/event/MatchingEventFactory.java | 4 ++-- .../event/dto/kafka_topic/MatchMemberJoinedEvent.java | 4 +++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java index 3d059f14..b2d1a6da 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/dto/FindRoomResult.java @@ -6,7 +6,8 @@ public record FindRoomResult( Long roomId, Integer currentMembers, - Integer maxCapacity + Integer maxCapacity, + Long chattingRoomId ) { } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index f1e8c1e5..ad966ac9 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -108,6 +108,7 @@ public FindRoomResult toFindRoomResult() { return FindRoomResult.builder() .roomId(this.getId()) .maxCapacity(this.getCapacity()) + .chattingRoomId(this.getChattingRoom().getId()) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 735ba687..ce124e1f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -68,7 +68,7 @@ private void sendMatchRoomCreatedEvent(Long memberId, private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult) { Long roomId = roomResult.roomId(); - this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchMemberJoinedEvent(roomId, memberId)); + this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchMemberJoinedEvent(roomId, memberId, roomResult.chattingRoomId())); } public AutoMatchingPostResponse handlerAutoCancelMatching(Long memberId, diff --git a/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java b/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java index d44bf9bb..b23ec787 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java @@ -37,8 +37,8 @@ public MatchMemberCancelledEvent createMatchMemberCancelledEvent(Long roomId, Lo return MatchMemberCancelledEvent.of(roomId, memberId, this.matchMemberCancelledTopic); } - public MatchMemberJoinedEvent createMatchMemberJoinedEvent(Long roomId, Long memberId) { - return MatchMemberJoinedEvent.of(roomId, memberId, this.matchMemberJoinedTopic); + public MatchMemberJoinedEvent createMatchMemberJoinedEvent(Long roomId, Long memberId, Long chattingRoomId) { + return MatchMemberJoinedEvent.of(roomId, memberId, this.matchMemberJoinedTopic, chattingRoomId); } public MatchRoomCancelledEvent createMatchRoomCancelledEvent(Long roomId) { diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java index 22d1f395..a727ed34 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java @@ -10,6 +10,7 @@ public record MatchMemberJoinedEvent( Long roomId, Long memberId, + Long chattingRoomId, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime joinedAt, @@ -27,11 +28,12 @@ public String getTopic() { return this.topic; } - public static MatchMemberJoinedEvent of(Long roomId, Long memberId, String topic) { + public static MatchMemberJoinedEvent of(Long roomId, Long memberId, String topic, Long chattingRoomId) { return MatchMemberJoinedEvent.builder() .roomId(roomId) .memberId(memberId) .topic(topic) + .chattingRoomId(chattingRoomId) .build(); } } From 32db37c3e5a26cc5d4cb6c8bbc45c1f2757e3626 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 19:18:37 +0900 Subject: [PATCH 632/770] =?UTF-8?q?refactor:=20=EA=B8=B0=EC=A1=B4=EC=97=90?= =?UTF-8?q?=20=EC=9E=88=EB=8D=98=20isRoomMaster=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/ManualMatchingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 01b8fd03..18c53f47 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -79,7 +79,7 @@ public void joinManualMatchingRoom(Long userId, Long roomId) { throw new NotActiveMatchingRoomException(); } - if (matchingRoom.getRoomMaster().equals(user)) { + if (user.isRoomMaster(matchingRoom)) { throw new RoomMasterCantJoinException(); } From 39a2e7b2fcc022578c74ddfeb60ba488c156404a Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 23:01:39 +0900 Subject: [PATCH 633/770] =?UTF-8?q?refactor:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=B0=A9=20=EC=83=9D=EC=84=B1=20api=20=EC=A0=95?= =?UTF-8?q?=EC=A0=81=20=EA=B2=BD=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/controller/ManualMatchingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index 99be4e3d..7b04410a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -30,7 +30,7 @@ public class ManualMatchingController { private final ManualMatchingService manualMatchingService; @Operation(summary = "수동 매칭방 생성") - @PostMapping + @PostMapping("/creation") public ApiResponse createManualMatchingRoom(@Valid @RequestBody ManualMatchingRequest request) { Long roomId = manualMatchingService.createManualMatchingRoom(request); return ApiResponse.response(HttpStatus.OK, CREATE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage(), roomId); From c1c544ec2a8baeecbba0511bb9c290cd84b9a554 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 23:09:32 +0900 Subject: [PATCH 634/770] =?UTF-8?q?refactor:=20CurrentMemberId=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EB=8B=A8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/controller/ManualMatchingController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index 7b04410a..f56a097e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -31,8 +31,8 @@ public class ManualMatchingController { @Operation(summary = "수동 매칭방 생성") @PostMapping("/creation") - public ApiResponse createManualMatchingRoom(@Valid @RequestBody ManualMatchingRequest request) { - Long roomId = manualMatchingService.createManualMatchingRoom(request); + public ApiResponse createManualMatchingRoom(@CurrentMemberId Long userId, @Valid @RequestBody ManualMatchingRequest request) { + Long roomId = manualMatchingService.createManualMatchingRoom(userId, request); return ApiResponse.response(HttpStatus.OK, CREATE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage(), roomId); } From 515326ab9dc90820bd0c97168ad661c13dd1e7b9 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 23:09:55 +0900 Subject: [PATCH 635/770] =?UTF-8?q?refactor:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=83=9D=EC=84=B1=20dto=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/ManualMatchingRequest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java index 376885d9..0fb44b48 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java @@ -9,9 +9,6 @@ import java.util.List; public record ManualMatchingRequest( - @NotNull - Long userId, - @NotBlank String title, From 9af0bcf1b4c54fdfa56d9ee9557bfade8b3950a8 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sat, 1 Feb 2025 23:10:22 +0900 Subject: [PATCH 636/770] =?UTF-8?q?refactor:=20CurrentMemberId=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EB=8B=A8=EC=97=90=EC=84=9C=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/ManualMatchingService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 18c53f47..ccde113a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -38,8 +38,8 @@ public class ManualMatchingService { 수동 매칭 방 생성 */ @Transactional - public Long createManualMatchingRoom(ManualMatchingRequest request) { - Members roomMaster = memberService.findById(request.userId()); + public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) { + Members roomMaster = memberService.findById(userId); if (matchingRoomRepository.existsByMemberInMatchingRoom(roomMaster)) { throw new DuplicatedMatchingRoomException(); From dacbd6be284722186db7d4c4ed3a03440170d187 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 01:06:34 +0900 Subject: [PATCH 637/770] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99,=20=EB=82=98?= =?UTF-8?q?=EC=9D=98=20=EB=A7=A4=EC=B9=AD=EB=B0=A9=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ManualMatchingController.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index f56a097e..644a661b 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -1,19 +1,24 @@ package com.gachtaxi.domain.matching.common.controller; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.CREATE_MANUAL_MATCHING_ROOM_SUCCESS; +import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.GET_MANUAL_MATCHING_LIST_SUCCESS; +import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.GET_MY_MATCHING_LIST_SUCCESS; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.JOIN_MANUAL_MATCHING_ROOM_SUCCESS; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.LEAVE_MANUAL_MATCHING_ROOM_SUCCESS; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingJoinRequest; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; +import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.service.ManualMatchingService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -49,4 +54,18 @@ public ApiResponse leaveManualMatchingRoom(@CurrentMemberId Long userId, @ manualMatchingService.leaveManualMatchingRoom(userId, roomId); return ApiResponse.response(HttpStatus.OK, LEAVE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); } + + @Operation(summary = "수동 매칭방 조회") + @GetMapping("/list") + public ApiResponse> getManualMatchingList() { + List rooms = manualMatchingService.getManualMatchingList(); + return ApiResponse.response(HttpStatus.OK, GET_MANUAL_MATCHING_LIST_SUCCESS.getMessage(), rooms); + } + + @Operation(summary = "나의 매칭(수동) 조회") + @GetMapping("/my-list") + public ApiResponse> getMyMatchingList(@CurrentMemberId Long userId) { + List rooms = manualMatchingService.getMyMatchingList(userId); + return ApiResponse.response(HttpStatus.OK, GET_MY_MATCHING_LIST_SUCCESS.getMessage(), rooms); + } } From 292343d578c5ddf2747399eeacef71347129b1c1 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 01:07:18 +0900 Subject: [PATCH 638/770] =?UTF-8?q?feat:=20getManualMatchingList,=20getMyM?= =?UTF-8?q?atchingList=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EB=8B=A8=EC=97=90=EC=84=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/ManualMatchingService.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index ccde113a..b52bfe88 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -1,9 +1,12 @@ package com.gachtaxi.domain.matching.common.service; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; +import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; import com.gachtaxi.domain.matching.common.entity.Route; +import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; +import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; import com.gachtaxi.domain.matching.common.exception.DuplicatedMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.RoomMasterCantJoinException; @@ -171,5 +174,29 @@ public void leaveManualMatchingRoom(Long userId, Long roomId) { } } } + /* + 수동 매칭 방 리스트 조회 + */ + @Transactional + public List getManualMatchingList() { + List rooms = matchingRoomRepository.findByMatchingRoomTypeAndMatchingRoomStatus( + MatchingRoomType.MANUAL, MatchingRoomStatus.ACTIVE); + + return rooms.stream() + .map(MatchingRoomResponse::from) + .toList(); + } + /* + 나의 매칭방 리스트 조회 + */ + @Transactional + public List getMyMatchingList(Long userId) { + Members user = memberService.findById(userId); + List rooms = matchingRoomRepository.findByMemberInMatchingRoom(user); + + return rooms.stream() + .map(MatchingRoomResponse::from) + .toList(); + } } From af4be765d11c84d2e038fc6caf266afe9be7b3b9 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 01:10:21 +0900 Subject: [PATCH 639/770] =?UTF-8?q?feat:=20=ED=98=84=EC=9E=AC=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=EC=88=98=20=EA=B3=84=EC=82=B0,=20=ED=83=9C=EA=B7=B8?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/entity/MatchingRoom.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 8c36408a..7a625382 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -49,6 +49,7 @@ public class MatchingRoom extends BaseEntity { private Members roomMaster; @Column(name = "title", nullable = false) + @Getter private String title; @Column(name = "description", nullable = false) @@ -65,6 +66,14 @@ public class MatchingRoom extends BaseEntity { @Getter private LocalDateTime departureTime; + @Column(name = "departure") + @Getter + private String departure; + + @Column(name = "destination") + @Getter + private String destination; + @Enumerated(EnumType.STRING) private MatchingRoomStatus matchingRoomStatus; @@ -132,4 +141,15 @@ public FindRoomResult toFindRoomResult() { .maxCapacity(this.getCapacity()) .build(); } + public int getCurrentMemberCount() { + return (int) memberMatchingRoomChargingInfo.stream() + .filter(info -> !info.isAlreadyLeft()) + .count(); + } + + public List getTags() { + return this.matchingRoomTagInfo.stream() + .map(tagInfo -> tagInfo.getTags().name()) + .toList(); + } } From c8b3df5141d01248d266508f890729f2614f6859 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 01:11:52 +0900 Subject: [PATCH 640/770] =?UTF-8?q?feat:=20=ED=98=84=EC=9E=AC=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=B0=A9=20=EB=A9=A4=EB=B2=84=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=B0=8F=20=EC=88=98=EB=8F=99=20=EB=A7=A4=EC=B9=AD?= =?UTF-8?q?=EB=B0=A9=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=A0=88=ED=8F=AC=EC=A7=80?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=EC=97=90=EC=84=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/repository/MatchingRoomRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index 11d69ea7..5bc3173d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -1,6 +1,8 @@ package com.gachtaxi.domain.matching.common.repository; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; +import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; +import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.members.entity.Members; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; @@ -27,4 +29,9 @@ List findRoomsByStartAndDestination( "AND r.matchingRoomStatus = 'ACTIVE' "+ "AND m.paymentStatus != 'LEFT'") boolean existsByMemberInMatchingRoom(@Param("user") Members user); + + List findByMatchingRoomTypeAndMatchingRoomStatus(MatchingRoomType type, MatchingRoomStatus status); + + @Query("SELECT m.matchingRoom FROM MemberMatchingRoomChargingInfo m WHERE m.members = :user") + List findByMemberInMatchingRoom(@Param("user") Members user); } From b0263e701227fc9b20184766aee0b85c1645ac5d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 01:12:11 +0900 Subject: [PATCH 641/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EB=A3=B8=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=9D=91=EB=8B=B5=20dto=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/MatchingRoomResponse.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java new file mode 100644 index 00000000..f5a31523 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java @@ -0,0 +1,29 @@ +package com.gachtaxi.domain.matching.common.dto.response; + +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; +import java.time.LocalDateTime; +import java.util.List; + +public record MatchingRoomResponse( + Long roomId, + String title, + String departure, + String destination, + LocalDateTime departureTime, + int maxCapacity, + int currentMembers, + List tags +) { + public static MatchingRoomResponse from(MatchingRoom matchingRoom) { + return new MatchingRoomResponse( + matchingRoom.getId(), + matchingRoom.getTitle(), + matchingRoom.getDeparture(), + matchingRoom.getDestination(), + matchingRoom.getDepartureTime(), + matchingRoom.getCapacity(), + matchingRoom.getCurrentMemberCount(), + matchingRoom.getTags() + ); + } +} From 1c2912daca43c66b4adb7495f8e35356883b2cbb Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 01:14:00 +0900 Subject: [PATCH 642/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EB=B0=A9=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EB=B0=98=ED=99=98=20=EC=84=B1?= =?UTF-8?q?=EA=B3=B5=20=EC=9D=91=EB=8B=B5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/controller/ResponseMessage.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java index 02e2214e..6aef743a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java @@ -19,8 +19,9 @@ public enum ResponseMessage { CREATE_MANUAL_MATCHING_ROOM_SUCCESS("수동 매칭방 생성에 성공했습니다."), JOIN_MANUAL_MATCHING_ROOM_SUCCESS("수동 매칭방 참여에 성공했습니다."), LEAVE_MANUAL_MATCHING_ROOM_SUCCESS("매칭방 퇴장이 완료되었습니다."), - CONVERT_TO_AUTO_MATCHING_SUCCESS("자동 매칭으로 전환되었습니다."); - + CONVERT_TO_AUTO_MATCHING_SUCCESS("자동 매칭으로 전환되었습니다."), + GET_MANUAL_MATCHING_LIST_SUCCESS("수동 매칭방 조회에 성공했습니다."), + GET_MY_MATCHING_LIST_SUCCESS("내 매칭방 조회에 성공했습니다."); private final String message; } From cd3d56efe1a1668cdd73cfb106dce7f54b26c66e Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 01:14:27 +0900 Subject: [PATCH 643/770] =?UTF-8?q?feat:=20Tags=EC=97=90=20@Getter=20?= =?UTF-8?q?=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoomTagInfo.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java index 9e85496c..e0abd5d7 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoomTagInfo.java @@ -10,6 +10,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Getter; import lombok.NoArgsConstructor; @Entity @@ -23,6 +24,7 @@ public class MatchingRoomTagInfo extends BaseEntity { private MatchingRoom matchingRoom; @Enumerated(EnumType.STRING) + @Getter private Tags tags; public static MatchingRoomTagInfo of(MatchingRoom matchingRoom, Tags tag) { From 7449cedae2844b0da803b0159487ef03fb87a951 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 02:10:40 +0900 Subject: [PATCH 644/770] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingAlgorithmService.java | 11 ----------- .../service/MatchingAlgorithmServiceImpl.java | 16 ---------------- 2 files changed, 27 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java index 449548f5..3bfb9247 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmService.java @@ -1,11 +1,9 @@ package com.gachtaxi.domain.matching.algorithm.service; import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; -import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import java.util.List; import java.util.Optional; -import org.springframework.data.domain.Page; public interface MatchingAlgorithmService { @@ -21,13 +19,4 @@ public interface MatchingAlgorithmService { * @return Optional - 매칭 가능한 방 정보가 있으면 값이 있고, 없으면 empty */ Optional findRoom(Long userId, double startLongitude, double startLatitude, double destinationLongitude, double destinationLatitude, List criteria); - - /** - * 전체 매칭 방을 페이지 단위로 조회 - * - * @param pageNumber 페이지 번호 (0부터 시작) - * @param pageSize 한 페이지에 포함될 매칭 방의 개수 - * @return Page - 페이지별 매칭 방 정보 - */ - Page findMatchingRooms(int pageNumber, int pageSize); } diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java index 6951b54e..e3f1228d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java @@ -4,16 +4,12 @@ import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.matching.common.exception.AlreadyInMatchingRoomException; -import com.gachtaxi.domain.matching.common.exception.PageNotFoundException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; @Service @@ -72,16 +68,4 @@ public Optional findRoom(Long userId, double startLongitude, dou */ return Optional.empty(); } - @Override - public Page findMatchingRooms(int pageNumber, int pageSize) { - - if (pageNumber < 0) { - throw new PageNotFoundException(); - } - - PageRequest pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "id")); - - return matchingRoomRepository.findAll(pageable); - } - } From a2839fae494fb46e222a1cae7aa95c8f64c1328c Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 02:50:05 +0900 Subject: [PATCH 645/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EB=AC=B4?= =?UTF-8?q?=ED=95=9C=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ManualMatchingController.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index 644a661b..ece71cbb 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -8,6 +8,7 @@ import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingJoinRequest; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; +import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomListResponse; import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.service.ManualMatchingService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; @@ -15,8 +16,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; -import java.util.List; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; @@ -57,15 +58,15 @@ public ApiResponse leaveManualMatchingRoom(@CurrentMemberId Long userId, @ @Operation(summary = "수동 매칭방 조회") @GetMapping("/list") - public ApiResponse> getManualMatchingList() { - List rooms = manualMatchingService.getManualMatchingList(); - return ApiResponse.response(HttpStatus.OK, GET_MANUAL_MATCHING_LIST_SUCCESS.getMessage(), rooms); + public ApiResponse getManualMatchingList(int pageNumber, int pageSize) { + Page rooms = manualMatchingService.getManualMatchingList(pageNumber, pageSize); + return ApiResponse.response(HttpStatus.OK, GET_MANUAL_MATCHING_LIST_SUCCESS.getMessage(), MatchingRoomListResponse.of(rooms)); } @Operation(summary = "나의 매칭(수동) 조회") @GetMapping("/my-list") - public ApiResponse> getMyMatchingList(@CurrentMemberId Long userId) { - List rooms = manualMatchingService.getMyMatchingList(userId); - return ApiResponse.response(HttpStatus.OK, GET_MY_MATCHING_LIST_SUCCESS.getMessage(), rooms); + public ApiResponse getMyMatchingList(@CurrentMemberId Long userId, int pageNumber, int pageSize) { + Page rooms = manualMatchingService.getMyMatchingList(userId, pageNumber, pageSize); + return ApiResponse.response(HttpStatus.OK, GET_MY_MATCHING_LIST_SUCCESS.getMessage(), MatchingRoomListResponse.of(rooms)); } } From 6defd1452d4710b51d9462eefbb23f0d513aa011 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 02:50:39 +0900 Subject: [PATCH 646/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EB=AC=B4=ED=95=9C=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A1=A4=EB=A1=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=EB=8B=A8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/ManualMatchingService.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index b52bfe88..a4a25ecd 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -9,6 +9,7 @@ import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; import com.gachtaxi.domain.matching.common.exception.DuplicatedMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.PageNotFoundException; import com.gachtaxi.domain.matching.common.exception.RoomMasterCantJoinException; import com.gachtaxi.domain.matching.common.exception.MemberAlreadyJoinedException; import com.gachtaxi.domain.matching.common.exception.MemberAlreadyLeftMatchingRoomException; @@ -25,6 +26,10 @@ import java.util.Optional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; @Slf4j @@ -178,25 +183,31 @@ public void leaveManualMatchingRoom(Long userId, Long roomId) { 수동 매칭 방 리스트 조회 */ @Transactional - public List getManualMatchingList() { - List rooms = matchingRoomRepository.findByMatchingRoomTypeAndMatchingRoomStatus( - MatchingRoomType.MANUAL, MatchingRoomStatus.ACTIVE); + public Page getManualMatchingList(int pageNumber, int pageSize) { + if (pageNumber < 0) { + throw new PageNotFoundException(); + } + + Pageable pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "id")); + Page rooms = matchingRoomRepository.findByMatchingRoomTypeAndMatchingRoomStatus( + MatchingRoomType.MANUAL, MatchingRoomStatus.ACTIVE, pageable); - return rooms.stream() - .map(MatchingRoomResponse::from) - .toList(); + return rooms.map(MatchingRoomResponse::from); } /* 나의 매칭방 리스트 조회 */ @Transactional - public List getMyMatchingList(Long userId) { + public Page getMyMatchingList(Long userId, int pageNumber, int pageSize) { + if (pageNumber < 0) { + throw new PageNotFoundException(); + } + Members user = memberService.findById(userId); - List rooms = matchingRoomRepository.findByMemberInMatchingRoom(user); + Pageable pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "id")); + Page rooms = matchingRoomRepository.findByMemberInMatchingRoom(user, pageable); - return rooms.stream() - .map(MatchingRoomResponse::from) - .toList(); + return rooms.map(MatchingRoomResponse::from); } } From 39f371ec4a8349e16050f9105118b3552663e3d6 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 02:51:09 +0900 Subject: [PATCH 647/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20dto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/MatchingPageableResponse.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java new file mode 100644 index 00000000..1f469857 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java @@ -0,0 +1,22 @@ +package com.gachtaxi.domain.matching.common.dto.response; + +import lombok.Builder; +import org.springframework.data.domain.Page; + + +@Builder +public record MatchingPageableResponse( + int pageNumber, + int pageSize, + int numberOfElements, + boolean last +) { + public static MatchingPageableResponse of(Page page) { + return MatchingPageableResponse.builder() + .pageNumber(page.getNumber()) + .pageSize(page.getSize()) + .numberOfElements(page.getNumberOfElements()) + .last(page.isLast()) + .build(); + } +} From 361baed7298778a56c7c923388dffb45e498ca3d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 02:51:21 +0900 Subject: [PATCH 648/770] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=9D=91=EB=8B=B5=20dto=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/MatchingRoomListResponse.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java new file mode 100644 index 00000000..4b954bf5 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java @@ -0,0 +1,18 @@ +package com.gachtaxi.domain.matching.common.dto.response; + +import java.util.List; +import lombok.Builder; +import org.springframework.data.domain.Page; + +@Builder +public record MatchingRoomListResponse( + List rooms, + MatchingPageableResponse pageable +) { + public static MatchingRoomListResponse of(Page page) { + return MatchingRoomListResponse.builder() + .rooms(page.getContent()) + .pageable(MatchingPageableResponse.of(page)) + .build(); + } +} From 3c423c2fff891ca64c307f92f93d1d6b93d6f04c Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 02:52:12 +0900 Subject: [PATCH 649/770] =?UTF-8?q?refactor:=20Page=EB=A1=9C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=A0=88=ED=8F=AC=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/repository/MatchingRoomRepository.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index 5bc3173d..bb6c8cab 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -5,6 +5,8 @@ import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.members.entity.Members; import java.util.List; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -30,8 +32,8 @@ List findRoomsByStartAndDestination( "AND m.paymentStatus != 'LEFT'") boolean existsByMemberInMatchingRoom(@Param("user") Members user); - List findByMatchingRoomTypeAndMatchingRoomStatus(MatchingRoomType type, MatchingRoomStatus status); + Page findByMatchingRoomTypeAndMatchingRoomStatus(MatchingRoomType type, MatchingRoomStatus status, Pageable pageable); - @Query("SELECT m.matchingRoom FROM MemberMatchingRoomChargingInfo m WHERE m.members = :user") - List findByMemberInMatchingRoom(@Param("user") Members user); + @Query("SELECT m.matchingRoom FROM MemberMatchingRoomChargingInfo m WHERE m.members = :user ORDER BY m.matchingRoom.id DESC") + Page findByMemberInMatchingRoom(@Param("user") Members user, Pageable pageable); } From 9e4c2add65f9dbc4ae34ddf735f73bb2afaf9efc Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:03:46 +0900 Subject: [PATCH 650/770] =?UTF-8?q?refactor:=20=EC=B6=9C=EB=B0=9C=EC=A7=80?= =?UTF-8?q?=20=EB=8F=84=EC=B0=A9=EC=A7=80=20=EA=B0=99=EC=9D=80=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F,=20=EA=B8=B0=EC=A1=B4=20=EA=B0=92?= =?UTF-8?q?=EC=9D=B4=20=EC=A1=B4=EC=9E=AC=ED=95=A0=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/ManualMatchingService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index a4a25ecd..bf7497d3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -9,6 +9,7 @@ import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; import com.gachtaxi.domain.matching.common.exception.DuplicatedMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.NotEqualStartAndDestinationException; import com.gachtaxi.domain.matching.common.exception.PageNotFoundException; import com.gachtaxi.domain.matching.common.exception.RoomMasterCantJoinException; import com.gachtaxi.domain.matching.common.exception.MemberAlreadyJoinedException; @@ -18,6 +19,7 @@ import com.gachtaxi.domain.matching.common.exception.NotActiveMatchingRoomException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; +import com.gachtaxi.domain.matching.common.repository.RouteRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; import jakarta.transaction.Transactional; @@ -41,6 +43,7 @@ public class ManualMatchingService { private final MatchingRoomService matchingRoomService; private final MatchingRoomRepository matchingRoomRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; + private final RouteRepository routeRepository; /* 수동 매칭 방 생성 @@ -53,7 +56,12 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) throw new DuplicatedMatchingRoomException(); } - Route route = matchingRoomService.saveRoute(request.departure(), request.destination()); + if (request.departure().equals(request.destination())) { + throw new NotEqualStartAndDestinationException(); + } + + Route route = routeRepository.findByStartLocationNameAndEndLocationName(request.departure(), request.destination()) + .orElseGet(() -> routeRepository.save(Route.of(request.departure(), request.destination()))); MatchingRoom matchingRoom = MatchingRoom.manualOf( roomMaster, From 7d7168636d19fee8e768a9328b68fe2b31919e73 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:04:32 +0900 Subject: [PATCH 651/770] =?UTF-8?q?feat=20:=20=EC=B6=9C=EB=B0=9C=EC=A7=80?= =?UTF-8?q?=20=EB=8F=84=EC=B0=A9=EC=A7=80=20=EA=B0=99=EC=9D=80=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotEqualStartAndDestinationException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/NotEqualStartAndDestinationException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/NotEqualStartAndDestinationException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotEqualStartAndDestinationException.java new file mode 100644 index 00000000..096c7385 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/NotEqualStartAndDestinationException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.NOT_EQUAL_START_DESTINATION; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +import com.gachtaxi.global.common.exception.BaseException; + +public class NotEqualStartAndDestinationException extends BaseException { + public NotEqualStartAndDestinationException() { + super(BAD_REQUEST, NOT_EQUAL_START_DESTINATION.getMessage()); + } +} From 8dae553351d67924afb737fe2c124655f0184beb Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:04:44 +0900 Subject: [PATCH 652/770] =?UTF-8?q?feat=20:=20=EC=B6=9C=EB=B0=9C=EC=A7=80?= =?UTF-8?q?=20=EB=8F=84=EC=B0=A9=EC=A7=80=20=EA=B0=99=EC=9D=80=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/exception/ErrorMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index 0d7353ce..f33483a8 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -17,7 +17,8 @@ public enum ErrorMessage { DUPLICATED_MATCHING_ROOM("이미 존재하는 매칭 방입니다."), NOT_FOUND_PAGE("페이지 번호는 0 이상이어야 합니다."), ALREADY_IN_MATCHING_ROOM("이미 매칭 방에 참가한 멤버입니다."), - MATCHING_ROOM_NOT_JOIN_OWN("자신이 만든 매칭 방에는 참가할 수 없습니다."); + MATCHING_ROOM_NOT_JOIN_OWN("자신이 만든 매칭 방에는 참가할 수 없습니다."), + NOT_EQUAL_START_DESTINATION("출발지와 도착지는 같을 수 없습니다."); private final String message; } From 8358a74932175fcac92a41a4dc783c8b1ea5c4fc Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:05:16 +0900 Subject: [PATCH 653/770] =?UTF-8?q?feat=20:=20=EC=A0=95=EC=A0=81=20?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/matching/common/entity/Route.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java index 2b7f5260..6a26000d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java @@ -1,6 +1,5 @@ package com.gachtaxi.domain.matching.common.entity; -import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.global.common.entity.BaseEntity; import jakarta.persistence.Entity; import jakarta.persistence.Table; @@ -23,4 +22,11 @@ public class Route extends BaseEntity { private double endLongitude; private double endLatitude; private String endLocationName; + + public static Route of(String startLocation, String endLocation) { + return Route.builder() + .startLocationName(startLocation) + .endLocationName(endLocation) + .build(); + } } From e7db0338cefcb49f4714cc29719c08b5d3b79b89 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:05:28 +0900 Subject: [PATCH 654/770] =?UTF-8?q?feat=20:=20findByStartLocationNameAndEn?= =?UTF-8?q?dLocationName=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=A0=88?= =?UTF-8?q?=ED=8F=AC=EC=97=90=EC=84=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/repository/RouteRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java index 617e4e75..1c5f9c3f 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java @@ -1,10 +1,11 @@ package com.gachtaxi.domain.matching.common.repository; import com.gachtaxi.domain.matching.common.entity.Route; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface RouteRepository extends JpaRepository { - + Optional findByStartLocationNameAndEndLocationName(String startLocation, String endLocation); } From 0927b38f334e5b39905bd7c7bd80660d50876e60 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:11:48 +0900 Subject: [PATCH 655/770] =?UTF-8?q?refactor=20:=20=EC=98=AC=EB=B0=94?= =?UTF-8?q?=EB=A5=B8=20=EB=B3=80=EC=88=98=EB=AA=85=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/repository/RouteRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java index 1c5f9c3f..71516d41 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java @@ -7,5 +7,5 @@ @Repository public interface RouteRepository extends JpaRepository { - Optional findByStartLocationNameAndEndLocationName(String startLocation, String endLocation); + Optional findByStartLocationNameAndEndLocationName(String departure, String destination); } From cf1a10e078fd99f690526b3bbcfaee0253a64860 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:28:39 +0900 Subject: [PATCH 656/770] =?UTF-8?q?refactor=20:=20=EC=88=98=EB=8F=99?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=83=9D=EC=84=B1=EC=8B=9C=EC=97=90?= =?UTF-8?q?=EB=8A=94=20route=20=EC=83=9D=EC=84=B1=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=ED=95=98=EC=97=AC=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=20=EB=A7=A4=EC=B9=AD=EA=B3=BC=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 7a625382..f156b377 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -116,13 +116,12 @@ public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, .build(); } - public static MatchingRoom manualOf(Members roomMaster, Route route, String title, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { + public static MatchingRoom manualOf(Members roomMaster, String title, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { return MatchingRoom.builder() .capacity(4) .roomMaster(roomMaster) .title(title) .description(description) - .route(route) .totalCharge(totalCharge) .departureTime(departureTime) .matchingRoomType(MatchingRoomType.MANUAL) From 5558007246d09c07d24d17a01bf29d67d4e738f8 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:29:08 +0900 Subject: [PATCH 657/770] =?UTF-8?q?feat=20:=20=EA=B8=B0=EC=A1=B4=EC=97=90?= =?UTF-8?q?=20=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20=EC=B6=9C=EB=B0=9C?= =?UTF-8?q?=EC=A7=80=20=EB=8F=84=EC=B0=A9=EC=A7=80=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=EC=9D=B8=EC=A7=80=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/repository/MatchingRoomRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index bb6c8cab..b5a8ebae 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -5,6 +5,7 @@ import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.members.entity.Members; import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -36,4 +37,6 @@ List findRoomsByStartAndDestination( @Query("SELECT m.matchingRoom FROM MemberMatchingRoomChargingInfo m WHERE m.members = :user ORDER BY m.matchingRoom.id DESC") Page findByMemberInMatchingRoom(@Param("user") Members user, Pageable pageable); + + Optional findByDepartureAndDestination(String departure, String destination); } From 861fd17fadd56844e6027a089d40fbff929a3b16 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:29:24 +0900 Subject: [PATCH 658/770] =?UTF-8?q?refactor=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/matching/common/entity/Route.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java index 6a26000d..1a942627 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/Route.java @@ -22,11 +22,4 @@ public class Route extends BaseEntity { private double endLongitude; private double endLatitude; private String endLocationName; - - public static Route of(String startLocation, String endLocation) { - return Route.builder() - .startLocationName(startLocation) - .endLocationName(endLocation) - .build(); - } } From f344dc57cd83dad1dc711ed903af4c04b5b81b1d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:29:35 +0900 Subject: [PATCH 659/770] =?UTF-8?q?refactor=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/repository/RouteRepository.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java index 71516d41..83a45fdc 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java @@ -1,11 +1,9 @@ package com.gachtaxi.domain.matching.common.repository; import com.gachtaxi.domain.matching.common.entity.Route; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface RouteRepository extends JpaRepository { - Optional findByStartLocationNameAndEndLocationName(String departure, String destination); } From b60a59ec4910b745b70d5d909d4f36d5beeed0c5 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 17:30:36 +0900 Subject: [PATCH 660/770] =?UTF-8?q?refactor=20:=20=EC=88=98=EB=8F=99?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EC=97=90=EC=84=9C=EB=A7=8C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8A=94=20=EC=A0=95=EB=B3=B4=EB=93=A4?= =?UTF-8?q?=EB=A1=9C=20=EC=A1=B0=ED=9A=8C=ED=95=B4=EC=84=9C=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=EC=A0=95=EB=B3=B4=EA=B0=80=20=EC=A1=B4=EC=9E=AC?= =?UTF-8?q?=ED=95=98=EB=A9=B4=20=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D,=20=EC=97=86=EC=9C=BC=EB=A9=B4=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/ManualMatchingService.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index bf7497d3..de36e0fb 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -4,7 +4,6 @@ import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; -import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; @@ -19,7 +18,6 @@ import com.gachtaxi.domain.matching.common.exception.NotActiveMatchingRoomException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; -import com.gachtaxi.domain.matching.common.repository.RouteRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; import jakarta.transaction.Transactional; @@ -43,7 +41,6 @@ public class ManualMatchingService { private final MatchingRoomService matchingRoomService; private final MatchingRoomRepository matchingRoomRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; - private final RouteRepository routeRepository; /* 수동 매칭 방 생성 @@ -60,20 +57,17 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) throw new NotEqualStartAndDestinationException(); } - Route route = routeRepository.findByStartLocationNameAndEndLocationName(request.departure(), request.destination()) - .orElseGet(() -> routeRepository.save(Route.of(request.departure(), request.destination()))); - - MatchingRoom matchingRoom = MatchingRoom.manualOf( + MatchingRoom existingRoom = matchingRoomRepository.findByDepartureAndDestination(request.departure(), request.destination()) + .orElseGet(() -> MatchingRoom.manualOf( roomMaster, - route, request.title(), request.description(), 4, request.totalCharge(), request.departureTime() - ); + )); - MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); + MatchingRoom savedMatchingRoom = matchingRoomRepository.save(existingRoom); matchingRoomService.saveMatchingRoomTagInfoForManual(savedMatchingRoom, request.getCriteria()); matchingRoomService.saveRoomMasterChargingInfoForManual(savedMatchingRoom, roomMaster); From 9d4f58dad64574a9d0a861d53616293a08a30346 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 18:05:58 +0900 Subject: [PATCH 661/770] =?UTF-8?q?refactor=20:=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20=EB=A7=A4=EC=B9=AD?= =?UTF-8?q?=EB=B0=A9=EC=9D=B8=EC=A7=80=20=EC=97=AC=EB=B6=80=EB=8A=94=20Mat?= =?UTF-8?q?chingRoomService=20=EC=97=90=EC=84=9C=20=EC=B2=98=EB=A6=AC?= =?UTF-8?q?=ED=95=B4=EC=A3=BC=EB=8F=84=EB=A1=9D=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/ManualMatchingService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index de36e0fb..2d5cca45 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -4,6 +4,7 @@ import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; @@ -57,17 +58,19 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) throw new NotEqualStartAndDestinationException(); } - MatchingRoom existingRoom = matchingRoomRepository.findByDepartureAndDestination(request.departure(), request.destination()) - .orElseGet(() -> MatchingRoom.manualOf( + Route route = matchingRoomService.saveRoute(request.departure(), request.destination()); + + MatchingRoom matchingRoom = MatchingRoom.manualOf( roomMaster, + route, request.title(), request.description(), 4, request.totalCharge(), request.departureTime() - )); + ); - MatchingRoom savedMatchingRoom = matchingRoomRepository.save(existingRoom); + MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); matchingRoomService.saveMatchingRoomTagInfoForManual(savedMatchingRoom, request.getCriteria()); matchingRoomService.saveRoomMasterChargingInfoForManual(savedMatchingRoom, roomMaster); From 197d66bc0bb88affa473814a8a0936d428a234ed Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 18:06:34 +0900 Subject: [PATCH 662/770] =?UTF-8?q?refactor=20:=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=EC=97=90=20=EA=B4=80=ED=95=9C=20=EC=A0=95=EB=B3=B4=EB=8A=94=20?= =?UTF-8?q?=EC=9D=B4=EC=A0=84=EA=B3=BC=20=EB=8F=99=EC=9D=BC=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20route=20=EA=B0=9D=EC=B2=B4=EC=97=90=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index f156b377..7a625382 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -116,12 +116,13 @@ public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, .build(); } - public static MatchingRoom manualOf(Members roomMaster, String title, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { + public static MatchingRoom manualOf(Members roomMaster, Route route, String title, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { return MatchingRoom.builder() .capacity(4) .roomMaster(roomMaster) .title(title) .description(description) + .route(route) .totalCharge(totalCharge) .departureTime(departureTime) .matchingRoomType(MatchingRoomType.MANUAL) From d04054085996e0d813248d42434ee9e9dd0071c8 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 18:07:51 +0900 Subject: [PATCH 663/770] =?UTF-8?q?refactor=20:=20=EB=A7=8C=EC=95=BD=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=EB=9D=BC=EB=A9=B4=20=EC=83=88=EB=A1=9C=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=97=86=EC=9D=B4=20=EC=B2=AB=EB=B2=88?= =?UTF-8?q?=EC=A7=B8=20=EA=B0=92=EC=9D=84=20=EB=B9=88=ED=99=98=ED=95=B4?= =?UTF-8?q?=EC=A4=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/MatchingRoomService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 2091df7f..f213e678 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -84,6 +84,13 @@ private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { return this.routeRepository.save(route); } public Route saveRoute(String departure, String destination) { + + List existingRoutes = routeRepository.findByStartLocationNameAndEndLocationName(departure, destination); + + if (!existingRoutes.isEmpty()) { + return existingRoutes.get(0); + } + Route route = Route.builder() .startLocationName(departure) .endLocationName(destination) From ea5a92f138318ffeb935bbe6b4d594423c919111 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 18:08:35 +0900 Subject: [PATCH 664/770] =?UTF-8?q?feat=20:=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20=EC=B6=9C=EB=B0=9C?= =?UTF-8?q?=EC=A7=80,=20=EB=8F=84=EC=B0=A9=EC=A7=80=EC=9D=B8=EC=A7=80=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/repository/RouteRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java index 83a45fdc..b6419c03 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java @@ -1,9 +1,11 @@ package com.gachtaxi.domain.matching.common.repository; import com.gachtaxi.domain.matching.common.entity.Route; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface RouteRepository extends JpaRepository { + List findByStartLocationNameAndEndLocationName(String departure, String destination); } From af9726229cb353c3fceb3704d8735c5784a057b0 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 18:28:26 +0900 Subject: [PATCH 665/770] =?UTF-8?q?fix=20:=20=EC=9E=90=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EB=A1=9C=EC=A7=81=EA=B3=BC=20=EB=B6=84=EB=A6=AC=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4=EC=84=9C=20route=EA=B0=80=20=EC=95=84?= =?UTF-8?q?=EB=8B=8C=20=EB=B3=84=EB=8F=84=EC=9D=98=20MatchingRoom=EC=97=90?= =?UTF-8?q?=20=EC=A0=80=EC=9E=A5=EB=90=98=EB=8F=84=EB=A1=9D=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MatchingRoomRepository.java | 3 +-- .../common/service/ManualMatchingService.java | 8 +++----- .../common/service/MatchingRoomService.java | 18 ++++++++---------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index b5a8ebae..9dcd4e93 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -5,7 +5,6 @@ import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.members.entity.Members; import java.util.List; -import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -38,5 +37,5 @@ List findRoomsByStartAndDestination( @Query("SELECT m.matchingRoom FROM MemberMatchingRoomChargingInfo m WHERE m.members = :user ORDER BY m.matchingRoom.id DESC") Page findByMemberInMatchingRoom(@Param("user") Members user, Pageable pageable); - Optional findByDepartureAndDestination(String departure, String destination); + List findByDepartureAndDestination(String departure, String destination); } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 2d5cca45..8444c522 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -4,7 +4,6 @@ import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; -import com.gachtaxi.domain.matching.common.entity.Route; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.matching.common.entity.enums.PaymentStatus; @@ -58,11 +57,10 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) throw new NotEqualStartAndDestinationException(); } - Route route = matchingRoomService.saveRoute(request.departure(), request.destination()); - MatchingRoom matchingRoom = MatchingRoom.manualOf( roomMaster, - route, + request.departure(), + request.destination(), request.title(), request.description(), 4, @@ -70,7 +68,7 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) request.departureTime() ); - MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); + MatchingRoom savedMatchingRoom = matchingRoomService.saveRoute(matchingRoom); matchingRoomService.saveMatchingRoomTagInfoForManual(savedMatchingRoom, request.getCriteria()); matchingRoomService.saveRoomMasterChargingInfoForManual(savedMatchingRoom, roomMaster); diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index f213e678..7b3ebaba 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -83,20 +83,18 @@ private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { .build(); return this.routeRepository.save(route); } - public Route saveRoute(String departure, String destination) { + public MatchingRoom saveRoute(MatchingRoom matchingRoom) { - List existingRoutes = routeRepository.findByStartLocationNameAndEndLocationName(departure, destination); + String departure = matchingRoom.getDeparture(); + String destination = matchingRoom.getDestination(); - if (!existingRoutes.isEmpty()) { - return existingRoutes.get(0); - } + List existingRooms = matchingRoomRepository.findByDepartureAndDestination(departure, destination); - Route route = Route.builder() - .startLocationName(departure) - .endLocationName(destination) - .build(); + if (!existingRooms.isEmpty()) { + return existingRooms.get(0); + } - return this.routeRepository.save(route); + return matchingRoomRepository.save(matchingRoom); } private void saveMatchingRoomTagInfo(MatchingRoom matchingRoom, List tags) { tags.forEach(tag -> this.matchingRoomTagInfoRepository.save(MatchingRoomTagInfo.of(matchingRoom, tag))); From 9977b4947e9d54f07c3dce92651c8498fb09f2ea Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 18:28:54 +0900 Subject: [PATCH 666/770] =?UTF-8?q?fix=20:=20=EC=98=AC=EB=B0=94=EB=A5=B8?= =?UTF-8?q?=20=ED=95=84=EB=93=9C=EB=A1=9C=20=EC=A0=95=EC=A0=81=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 7a625382..47eb4fd6 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -116,13 +116,14 @@ public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, .build(); } - public static MatchingRoom manualOf(Members roomMaster, Route route, String title, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { + public static MatchingRoom manualOf(Members roomMaster, String departure, String destination, String title, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { return MatchingRoom.builder() .capacity(4) .roomMaster(roomMaster) .title(title) .description(description) - .route(route) + .departure(departure) + .destination(destination) .totalCharge(totalCharge) .departureTime(departureTime) .matchingRoomType(MatchingRoomType.MANUAL) From c2e1695f1146d67acc2a11f30c8d4a37114465b7 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 18:29:13 +0900 Subject: [PATCH 667/770] =?UTF-8?q?refactor=20:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=EC=95=8A=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/repository/RouteRepository.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java index b6419c03..83a45fdc 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/RouteRepository.java @@ -1,11 +1,9 @@ package com.gachtaxi.domain.matching.common.repository; import com.gachtaxi.domain.matching.common.entity.Route; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface RouteRepository extends JpaRepository { - List findByStartLocationNameAndEndLocationName(String departure, String destination); } From 3b896e0e794967470b7a0ba46b8ead3863419a1d Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 2 Feb 2025 20:07:03 +0900 Subject: [PATCH 668/770] =?UTF-8?q?refactor:=20FriendStatus=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/entity/payload/FriendRequestPayload.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java index 577e67ef..e65c462e 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java @@ -1,6 +1,8 @@ package com.gachtaxi.domain.notification.entity.payload; +import com.gachtaxi.domain.friend.entity.enums.FriendStatus; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -10,8 +12,8 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class FriendRequestPayload extends NotificationPayload { -// @Builder.Default -// private FriendStatus status = FriendStatus.PENDING; + @Builder.Default + private FriendStatus friendStatus = FriendStatus.PENDING; private Long senderId; From 1fd325f4c16449879ee48edfbe7525ce72f58846 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 2 Feb 2025 20:07:19 +0900 Subject: [PATCH 669/770] =?UTF-8?q?refactor:=20=EC=95=8C=EB=A6=BC=20id=20l?= =?UTF-8?q?ong->String=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/controller/NotificationController.java | 2 +- .../notification/repository/NotificationRepository.java | 2 +- .../domain/notification/service/NotificationService.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java b/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java index 2878aa2e..a31bb2e0 100644 --- a/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java +++ b/src/main/java/com/gachtaxi/domain/notification/controller/NotificationController.java @@ -43,7 +43,7 @@ public ApiResponse getInfo(@CurrentMemberId Long membe @DeleteMapping("/{notificationId}") @Operation(summary = "알림을 개별 삭제하는 API입니다.") public ApiResponse delete(@CurrentMemberId Long memberId, - @PathVariable Long notificationId) { + @PathVariable String notificationId) { notificationService.delete(memberId, notificationId); return ApiResponse.response(OK, NOTIFICATION_DELETE_SUCCESS.getMessage()); diff --git a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java index 8c6e8575..19b781b7 100644 --- a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java +++ b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java @@ -6,7 +6,7 @@ import org.springframework.data.domain.Slice; import org.springframework.data.mongodb.repository.MongoRepository; -public interface NotificationRepository extends MongoRepository { +public interface NotificationRepository extends MongoRepository { Integer countAllByReceiverIdAndStatus(Long receiverId, NotificationStatus status); diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java index ae12ae81..8c328462 100644 --- a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -74,18 +74,18 @@ public void sendWithOutPush(Long senderId, Members receiver, NotificationType ty notificationRepository.save(notification); } - public void delete(Long receiverId, Long notificationId) { + public void delete(Long receiverId, String notificationId) { validateMember(receiverId, notificationId); notificationRepository.deleteById(notificationId); } - private Notification find(Long notificationId) { + private Notification find(String notificationId) { return notificationRepository.findById(notificationId) .orElseThrow(NotificationNotFoundException::new); } - private void validateMember(long receiverId, long notificationId) { + private void validateMember(long receiverId, String notificationId) { Notification notification = find(notificationId); if (!notification.getReceiverId().equals(receiverId)) { From 9068833e5d7145aff946a86148d61b8f871db47a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Sun, 2 Feb 2025 20:14:09 +0900 Subject: [PATCH 670/770] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/entity/payload/FriendRequestPayload.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java index e65c462e..235a9540 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/FriendRequestPayload.java @@ -13,7 +13,7 @@ public class FriendRequestPayload extends NotificationPayload { @Builder.Default - private FriendStatus friendStatus = FriendStatus.PENDING; + private FriendStatus status = FriendStatus.PENDING; private Long senderId; From 8386b40fba950eb15918624ccb56fbcb86643c96 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 20:21:34 +0900 Subject: [PATCH 671/770] =?UTF-8?q?refactor=20:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=EC=95=8A=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/repository/MatchingRoomRepository.java | 2 -- .../matching/common/service/MatchingRoomService.java | 12 ------------ 2 files changed, 14 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index 9dcd4e93..bb6c8cab 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -36,6 +36,4 @@ List findRoomsByStartAndDestination( @Query("SELECT m.matchingRoom FROM MemberMatchingRoomChargingInfo m WHERE m.members = :user ORDER BY m.matchingRoom.id DESC") Page findByMemberInMatchingRoom(@Param("user") Members user, Pageable pageable); - - List findByDepartureAndDestination(String departure, String destination); } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 7b3ebaba..ec1cf9f1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -83,19 +83,7 @@ private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { .build(); return this.routeRepository.save(route); } - public MatchingRoom saveRoute(MatchingRoom matchingRoom) { - String departure = matchingRoom.getDeparture(); - String destination = matchingRoom.getDestination(); - - List existingRooms = matchingRoomRepository.findByDepartureAndDestination(departure, destination); - - if (!existingRooms.isEmpty()) { - return existingRooms.get(0); - } - - return matchingRoomRepository.save(matchingRoom); - } private void saveMatchingRoomTagInfo(MatchingRoom matchingRoom, List tags) { tags.forEach(tag -> this.matchingRoomTagInfoRepository.save(MatchingRoomTagInfo.of(matchingRoom, tag))); } From 2ca6e912074e67bcb77fdc26aaafe3967aaa7bdd Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Sun, 2 Feb 2025 20:22:43 +0900 Subject: [PATCH 672/770] =?UTF-8?q?refactor=20:=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EA=B7=B8=EB=8C=80=EB=A1=9C=20MatchingRoom?= =?UTF-8?q?=20=EA=B0=9D=EC=B2=B4=20=EC=A0=80=EC=9E=A5=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/ManualMatchingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 8444c522..73d251b6 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -68,7 +68,7 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) request.departureTime() ); - MatchingRoom savedMatchingRoom = matchingRoomService.saveRoute(matchingRoom); + MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); matchingRoomService.saveMatchingRoomTagInfoForManual(savedMatchingRoom, request.getCriteria()); matchingRoomService.saveRoomMasterChargingInfoForManual(savedMatchingRoom, roomMaster); From 3e31a7d6cdc00025fc4dd43b911569a11ee28409 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 2 Feb 2025 21:22:02 +0900 Subject: [PATCH 673/770] =?UTF-8?q?fix:=20FriendsPageableResponse=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/dto/response/FriendsPageableResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java index a3cb77f2..f420e04f 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java @@ -9,14 +9,14 @@ public record FriendsPageableResponse( int pageNum, int pageSize, int numberOfElements, - boolean isLast + boolean last ) { public static FriendsPageableResponse from(Slice slice) { return FriendsPageableResponse.builder() .pageNum(slice.getNumber()) .pageSize(slice.getSize()) .numberOfElements(slice.getNumberOfElements()) - .isLast(slice.isLast()) + .last(slice.isLast()) .build(); } } From e92125bda727f06ad4dc87e5ad970834ea7c3afb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Sun, 2 Feb 2025 21:37:09 +0900 Subject: [PATCH 674/770] =?UTF-8?q?docs:=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20?= =?UTF-8?q?=EB=AA=85=EC=84=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/friend/controller/FriendController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 455d6cdf..6618da95 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -6,6 +6,7 @@ import com.gachtaxi.domain.friend.service.FriendService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @@ -20,6 +21,7 @@ public class FriendController { private final FriendService friendService; @PostMapping + @Operation(summary = "친구 요청을 보내는 API 받는 이의 nickName을 입력해주세요") public ApiResponse sendFriendRequest( @CurrentMemberId Long senderId, @RequestBody FriendRequestDto dto @@ -30,6 +32,7 @@ public ApiResponse sendFriendRequest( // 나의 친구를 반환하는 API @GetMapping + @Operation(summary = "친구 목록을 반환하는 API입니다. (무한스크롤)") public ApiResponse getFriendsList( @CurrentMemberId Long memberId, @RequestParam int pageNum, @@ -40,6 +43,7 @@ public ApiResponse getFriendsList( } @PatchMapping + @Operation(summary = "친구 요청을 수락하는 API입니다.") public ApiResponse acceptFriendRequest( @CurrentMemberId Long currentId, @RequestBody FriendUpdateDto dto @@ -49,6 +53,7 @@ public ApiResponse acceptFriendRequest( } @DeleteMapping("/{memberId}") + @Operation(summary = "친구 요청 거절 및 친구를 삭제하는 API입니다.") public ApiResponse deleteFriend( @CurrentMemberId Long currentId, @PathVariable Long memberId From 0125ce2e327709b387d81aee0d9c80159edb0d7b Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:13:43 +0900 Subject: [PATCH 675/770] =?UTF-8?q?feat=20:=20=EC=88=98=EB=8F=8B=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=B9=9C=EA=B5=AC=20=EC=B4=88=EB=8C=80=EC=8B=9C=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/exception/ErrorMessage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java index f33483a8..5fab8bbf 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/ErrorMessage.java @@ -18,7 +18,9 @@ public enum ErrorMessage { NOT_FOUND_PAGE("페이지 번호는 0 이상이어야 합니다."), ALREADY_IN_MATCHING_ROOM("이미 매칭 방에 참가한 멤버입니다."), MATCHING_ROOM_NOT_JOIN_OWN("자신이 만든 매칭 방에는 참가할 수 없습니다."), - NOT_EQUAL_START_DESTINATION("출발지와 도착지는 같을 수 없습니다."); + NOT_EQUAL_START_DESTINATION("출발지와 도착지는 같을 수 없습니다."), + NO_SUCH_INVITATION("해당 수동매칭 초대가 존재하지 않습니다."), + MATCHING_ALREADY_ROOM_FULL("매칭 방이 이미 꽉 찼습니다."); private final String message; } From f10d5244f4ce50346951bb83fdc1b3fb5a455b10 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:14:33 +0900 Subject: [PATCH 676/770] =?UTF-8?q?feat=20:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=B9=9C=EA=B5=AC=20=EC=B4=88=EB=8C=80=20=EC=88=98?= =?UTF-8?q?=EB=9D=BD=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/ManualMatchingController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index ece71cbb..70378eac 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.matching.common.controller; +import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.ACCEPT_MATCHING_INVITE_SUCCESS; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.CREATE_MANUAL_MATCHING_ROOM_SUCCESS; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.GET_MANUAL_MATCHING_LIST_SUCCESS; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.GET_MY_MATCHING_LIST_SUCCESS; @@ -11,6 +12,7 @@ import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomListResponse; import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.service.ManualMatchingService; +import com.gachtaxi.domain.matching.common.service.MatchingInvitationService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.Operation; @@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @Tag(name = "MANUAL", description = "수동매칭 API") @@ -34,6 +37,7 @@ public class ManualMatchingController { private final ManualMatchingService manualMatchingService; + private final MatchingInvitationService matchingInvitationService; @Operation(summary = "수동 매칭방 생성") @PostMapping("/creation") @@ -49,6 +53,14 @@ public ApiResponse joinManualMatchingRoom(@CurrentMemberId Long userId, @V return ApiResponse.response(HttpStatus.OK, JOIN_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); } + @Operation(summary = "수동 매칭 초대 수락") + @PostMapping("/invite/accept") + public ApiResponse acceptInvitation(@CurrentMemberId Long userId, @RequestParam Long matchingRoomId + ) { + matchingInvitationService.acceptInvitation(userId, matchingRoomId); + return ApiResponse.response(HttpStatus.OK, ACCEPT_MATCHING_INVITE_SUCCESS.getMessage()); + } + @Operation(summary = "수동 매칭방 퇴장 (방 삭제 포함)") @PatchMapping("/exit/{roomId}") public ApiResponse leaveManualMatchingRoom(@CurrentMemberId Long userId, @PathVariable Long roomId) { From 79050cfd2a02098ab4a1f51c481d42b3ddca3777 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:14:58 +0900 Subject: [PATCH 677/770] =?UTF-8?q?feat=20:=20friendNicknames=EB=A1=9C=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/ManualMatchingRequest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java index 0fb44b48..5c56ee83 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java @@ -28,7 +28,10 @@ public record ManualMatchingRequest( int totalCharge, @Schema(description = "매칭 태그") - List criteria + List criteria, + + @Schema(description = "초대할 친구 닉네임 리스트") + List friendNicknames ) { public List getCriteria() { return this.criteria.stream() From 617d283b2c59e29ae50e9ecf23ee55d9b7f69cc0 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:16:39 +0900 Subject: [PATCH 678/770] =?UTF-8?q?refactor=20:=20=EC=88=98=EB=8F=99?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=83=9D=EC=84=B1=EC=8B=9C=20=EC=B9=9C?= =?UTF-8?q?=EA=B5=AC=EC=B4=88=EB=8C=80=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/ManualMatchingService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 73d251b6..6aff06f2 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -39,6 +39,7 @@ public class ManualMatchingService { private final MemberService memberService; private final MatchingRoomService matchingRoomService; + private final MatchingInvitationService matchingInvitationService; private final MatchingRoomRepository matchingRoomRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; @@ -70,6 +71,8 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); + matchingInvitationService.sendMatchingInvitation(roomMaster, request.friendNicknames()); + matchingRoomService.saveMatchingRoomTagInfoForManual(savedMatchingRoom, request.getCriteria()); matchingRoomService.saveRoomMasterChargingInfoForManual(savedMatchingRoom, roomMaster); From 2fdb26aa94d53a9d7824b8065dfd83d03917a966 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:17:23 +0900 Subject: [PATCH 679/770] =?UTF-8?q?feat=20:=20=EC=88=98=EB=8F=99=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=B9=9C=EA=B5=AC=EC=B4=88=EB=8C=80=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingInvitationService.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java new file mode 100644 index 00000000..a4f39607 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java @@ -0,0 +1,69 @@ +package com.gachtaxi.domain.matching.common.service; + +import static com.gachtaxi.domain.notification.entity.enums.NotificationType.MATCH_INVITE; + +import com.gachtaxi.domain.matching.common.entity.MatchingRoom; +import com.gachtaxi.domain.matching.common.exception.NoSuchInvitationException; +import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; +import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.repository.MemberRepository; +import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.domain.notification.entity.payload.MatchingInvitePayload; +import com.gachtaxi.domain.notification.service.NotificationService; +import jakarta.transaction.Transactional; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +@Transactional +public class MatchingInvitationService { + private final NotificationService notificationService; + private final MemberService memberService; + private final MemberRepository memberRepository; + private final MatchingRoomRepository matchingRoomRepository; + + /* + 수동 매칭시 친구 초대 + */ + public static final String MATCHING_INVITE_TITLE = "수동 매칭 초대"; + public static final String MATCHING_INVITE_CONTENT = "%s 님이 수동 매칭 초대를 보냈습니다."; + + public void sendMatchingInvitation(Members sender, List friendNicknames) { + if (friendNicknames == null || friendNicknames.isEmpty()) { + return; + } + + List friends = memberRepository.findByNicknameIn(friendNicknames); + + for (Members friend : friends) { + notificationService.sendWithPush( + sender.getId(), + friend, + MATCH_INVITE, + MATCHING_INVITE_TITLE, + String.format(MATCHING_INVITE_CONTENT, sender.getNickname()), + MatchingInvitePayload.from(sender.getNickname()) + ); + } + } + + /* + 수동 매칭시 친구 초대 수락 + */ + @Transactional + public void acceptInvitation(Long userId, Long matchingRoomId) { + Members member = memberService.findById(userId); + MatchingRoom matchingRoom = matchingRoomRepository.findById(matchingRoomId) + .orElseThrow(NoSuchMatchingRoomException::new); + + if (!notificationService.hasReceivedMatchingInvite(userId)) { + throw new NoSuchInvitationException(); + } + + matchingRoom.addMember(member); + matchingRoomRepository.save(matchingRoom); + } +} From 496a0ae8fcfc7044ea85ef8db0f8b1e269514e4b Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:17:48 +0900 Subject: [PATCH 680/770] =?UTF-8?q?feat=20:=20=EC=B9=9C=EA=B5=AC=20?= =?UTF-8?q?=EC=B4=88=EB=8C=80=EC=8B=9C=20=EB=B0=98=ED=99=98=20Payload=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/payload/MatchingInvitePayload.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingInvitePayload.java diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingInvitePayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingInvitePayload.java new file mode 100644 index 00000000..a181227c --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingInvitePayload.java @@ -0,0 +1,19 @@ +package com.gachtaxi.domain.notification.entity.payload; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +@Getter +@SuperBuilder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class MatchingInvitePayload extends NotificationPayload { + private String senderNickname; + + public static MatchingInvitePayload from(String senderNickname) { + return MatchingInvitePayload.builder() + .senderNickname(senderNickname) + .build(); + } +} From 0522375ef40ff66bb635f73cf9d7192f9c313d29 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:18:20 +0900 Subject: [PATCH 681/770] =?UTF-8?q?refactor=20:=20NotificationType?= =?UTF-8?q?=EC=97=90=20MATCH=5FINVITE=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notification/entity/enums/NotificationType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java b/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java index e0bedb39..22c00063 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/enums/NotificationType.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.notification.entity.enums; public enum NotificationType { - MATCH_START, MATCH_FINISH, FRIEND_REQUEST + MATCH_START, MATCH_FINISH, FRIEND_REQUEST, MATCH_INVITE } From 84ee2c1dc622c56b3cc678ea45a56b599dc211cc Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:18:46 +0900 Subject: [PATCH 682/770] =?UTF-8?q?feat=20:=20=EB=A7=A4=EC=B9=AD=EB=B0=A9?= =?UTF-8?q?=20=EC=B4=88=EB=8C=80=20=EC=88=98=EB=9D=BD=20=EC=84=B1=EA=B3=B5?= =?UTF-8?q?=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/controller/ResponseMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java index 6aef743a..3b9a4b79 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java @@ -21,7 +21,8 @@ public enum ResponseMessage { LEAVE_MANUAL_MATCHING_ROOM_SUCCESS("매칭방 퇴장이 완료되었습니다."), CONVERT_TO_AUTO_MATCHING_SUCCESS("자동 매칭으로 전환되었습니다."), GET_MANUAL_MATCHING_LIST_SUCCESS("수동 매칭방 조회에 성공했습니다."), - GET_MY_MATCHING_LIST_SUCCESS("내 매칭방 조회에 성공했습니다."); + GET_MY_MATCHING_LIST_SUCCESS("내 매칭방 조회에 성공했습니다."), + ACCEPT_MATCHING_INVITE_SUCCESS("매칭방 초대 수락에 성공했습니다"); private final String message; } From a20dcee54d0d8c24f342294177d7fb382ffd170e Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:19:37 +0900 Subject: [PATCH 683/770] =?UTF-8?q?feat=20:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=B4=88=EB=8C=80=EB=A5=BC=20=EB=B0=9B=EC=9D=80=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EC=9D=B8=EC=A7=80=20=ED=99=95=EC=9D=B8=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=83=9D=EC=84=B1=EC=9E=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notification/service/NotificationService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java index ae12ae81..3257b788 100644 --- a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -92,4 +92,10 @@ private void validateMember(long receiverId, long notificationId) { throw new MemberNotMatchException(); } } + + public boolean hasReceivedMatchingInvite(Long userId) { + return notificationRepository.existsByReceiverIdAndType( + userId, NotificationType.MATCH_INVITE + ); + } } From 69c72c01d1ee8becc7e2f7e7a601d22984a92234 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:19:57 +0900 Subject: [PATCH 684/770] =?UTF-8?q?feat=20:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=B4=88=EB=8C=80=EB=A5=BC=20=EB=B0=9B=EC=9D=80=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EC=9D=B8=EC=A7=80=20=ED=99=95=EC=9D=B8=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notification/repository/NotificationRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java index 8c6e8575..e13322b3 100644 --- a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java +++ b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.notification.entity.Notification; import com.gachtaxi.domain.notification.entity.enums.NotificationStatus; +import com.gachtaxi.domain.notification.entity.enums.NotificationType; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.mongodb.repository.MongoRepository; @@ -11,4 +12,6 @@ public interface NotificationRepository extends MongoRepository findAllByReceiverId(Long receiverId, Pageable pageable); + + boolean existsByReceiverIdAndType(Long receiverId, NotificationType type); } From 6a9ca1b686f0a91c5c9a0243e45e60fa0bde8b47 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:20:11 +0900 Subject: [PATCH 685/770] =?UTF-8?q?feat=20:=20=EC=B4=88=EB=8C=80=20?= =?UTF-8?q?=EB=B0=9B=EC=A7=80=EC=95=8A=EC=9D=80=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/NoSuchInvitationException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchInvitationException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchInvitationException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchInvitationException.java new file mode 100644 index 00000000..797e8fac --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/NoSuchInvitationException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.NO_SUCH_INVITATION; +import static org.springframework.http.HttpStatus.NOT_FOUND; + +import com.gachtaxi.global.common.exception.BaseException; + +public class NoSuchInvitationException extends BaseException { + public NoSuchInvitationException() { + super(NOT_FOUND, NO_SUCH_INVITATION.getMessage()); + } +} From bb2702c5b8cd51f688af64fa6d82008bbcff364c Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:20:26 +0900 Subject: [PATCH 686/770] =?UTF-8?q?feat=20:=20=EB=B0=A9=EC=9D=B4=20?= =?UTF-8?q?=EB=8B=A4=20=EC=B0=AC=20=EC=83=81=ED=83=9C=EC=9D=BC=EB=96=84=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/MatchingRoomAlreadyFullException.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomAlreadyFullException.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomAlreadyFullException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomAlreadyFullException.java new file mode 100644 index 00000000..ffa569b6 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/MatchingRoomAlreadyFullException.java @@ -0,0 +1,13 @@ +package com.gachtaxi.domain.matching.common.exception; + +import static com.gachtaxi.domain.matching.common.exception.ErrorMessage.MATCHING_ALREADY_ROOM_FULL; +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +import com.gachtaxi.global.common.exception.BaseException; + +public class MatchingRoomAlreadyFullException extends BaseException { + + public MatchingRoomAlreadyFullException() { + super(BAD_REQUEST, MATCHING_ALREADY_ROOM_FULL.getMessage()); + } +} From bac1a2d48ab8e10990a8834e2a072445d5834cb7 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:20:48 +0900 Subject: [PATCH 687/770] =?UTF-8?q?feat=20:=20findByNicknameIn=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=8B=89=EB=84=A4=EC=9E=84=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/repository/MemberRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 74134ff4..5514fc45 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.entity.enums.UserStatus; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -23,4 +24,6 @@ public interface MemberRepository extends JpaRepository { Optional findByNicknameAndStatus(String nickname, UserStatus status); Optional findByEmailAndStatus(String email, UserStatus status); + + List findByNicknameIn(List nicknames); } From 00e7fdea5ea799672b55b2154351bc45cbc3c2c5 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 05:21:25 +0900 Subject: [PATCH 688/770] =?UTF-8?q?feat=20:=20=EC=88=98=EB=9D=BD=ED=95=9C?= =?UTF-8?q?=20=EC=9C=A0=EC=A0=80=EA=B0=80=20=EB=B0=A9=EC=97=90=20=EC=B0=B8?= =?UTF-8?q?=EA=B0=80=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?addMember=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoom.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 47eb4fd6..4122ab44 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; +import com.gachtaxi.domain.matching.common.exception.MatchingRoomAlreadyFullException; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.members.entity.Members; @@ -153,4 +154,12 @@ public List getTags() { .map(tagInfo -> tagInfo.getTags().name()) .toList(); } + + public void addMember(Members member) { + if (this.getCurrentMemberCount() >= this.capacity) { + throw new MatchingRoomAlreadyFullException(); + } + MemberMatchingRoomChargingInfo memberInfo = MemberMatchingRoomChargingInfo.notPayedOf(this, member); + this.memberMatchingRoomChargingInfo.add(memberInfo); + } } From 4382ae003a2c89021d8ecc5aa755e57dc1027aee Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 3 Feb 2025 14:33:26 +0900 Subject: [PATCH 689/770] =?UTF-8?q?refactor:=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B0=9C=ED=96=89=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/response/BlacklistGetResponse.java | 1 - .../domain/members/dto/response/BlacklistPostResponse.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java index 9698456a..1a5d48c2 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java @@ -13,7 +13,6 @@ public record BlacklistGetResponse( Integer numberOfElements, Boolean last ) { - public static BlacklistGetResponse of(Page blacklistsPage) { List responseList = blacklistsPage.stream() .map(BlacklistInfo::of) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistPostResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistPostResponse.java index ef3e712c..dc9c3d78 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistPostResponse.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistPostResponse.java @@ -7,7 +7,6 @@ public record BlacklistPostResponse( Long receiverId, Long blacklistId ) { - public static BlacklistPostResponse of (Blacklists blacklists) { return new BlacklistPostResponse( blacklists.getRequester().getId(), From 15d79646544226f35dc2bad6cb13e4c12de36c25 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 3 Feb 2025 14:34:57 +0900 Subject: [PATCH 690/770] =?UTF-8?q?refactor:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20=ED=81=AC=EA=B8=B0=EB=8F=84=20=EC=BF=BC=EB=A6=AC=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=A1=9C=20=EB=B0=9B=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/controller/BlacklistController.java | 6 ++++-- .../gachtaxi/domain/members/service/BlacklistService.java | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java b/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java index 33ed814e..84c3e26c 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/BlacklistController.java @@ -54,9 +54,11 @@ public ApiResponse deleteBlacklist( @GetMapping public ApiResponse getAllBlacklist( @CurrentMemberId Long requesterId, - @RequestParam int pageNum) { + @RequestParam int pageNum, + @RequestParam int pageSize + ) { BlacklistGetResponse blacklistPage = this.blacklistService.findBlacklistPage(requesterId, - pageNum); + pageNum, pageSize); return ApiResponse.response(OK, BLACKLIST_FIND_ALL_SUCCESS.getMessage(), blacklistPage); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java index 13390af5..32d6666c 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java @@ -22,8 +22,6 @@ @RequiredArgsConstructor public class BlacklistService { - private static final int PAGE_SIZE = 10; - private final BlacklistsRepository blacklistsRepository; private final MemberService memberService; @@ -56,10 +54,10 @@ public void delete(Long requesterId, Long receiverId) { this.blacklistsRepository.delete(blacklists); } - public BlacklistGetResponse findBlacklistPage(Long requesterId, int pageNum) { + public BlacklistGetResponse findBlacklistPage(Long requesterId, int pageNum, int pageSize) { Members requester = this.memberService.findById(requesterId); - Pageable pageRequest = PageRequest.of(pageNum, PAGE_SIZE, Sort.by(Direction.ASC, "receiver.nickname")); + Pageable pageRequest = PageRequest.of(pageNum, pageSize, Sort.by(Direction.ASC, "receiver.nickname")); Page blacklistsPage = this.blacklistsRepository.findAllByRequester(requester, pageRequest); From b496593d53879b226567744efb0b198352af8141 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 3 Feb 2025 14:36:12 +0900 Subject: [PATCH 691/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=B8=94=EB=9E=99=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=8B=9C=20=EB=A9=A4=EB=B2=84=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=EB=A5=BC=20=EC=A7=81=EC=A0=91=20=EB=84=98=EA=B8=B0?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/service/MatchingAlgorithmServiceImpl.java | 2 +- .../com/gachtaxi/domain/members/service/BlacklistService.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java index 2df43981..5c246d69 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java @@ -54,7 +54,7 @@ public Optional findRoom(Long userId, double startLongitude, dou */ matchingRooms = matchingRooms.stream() .filter(MatchingRoom::isActive) - .filter(room -> !this.blacklistService.isBlacklistInMatchingRoom(userId, room)) + .filter(room -> !this.blacklistService.isBlacklistInMatchingRoom(user, room)) .toList(); /* diff --git a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java index 32d6666c..1ab91f6f 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java @@ -64,9 +64,7 @@ public BlacklistGetResponse findBlacklistPage(Long requesterId, int pageNum, int return BlacklistGetResponse.of(blacklistsPage); } - public boolean isBlacklistInMatchingRoom(Long requesterId, MatchingRoom matchingRoom) { - Members requester = this.memberService.findById(requesterId); - + public boolean isBlacklistInMatchingRoom(Members requester, MatchingRoom matchingRoom) { boolean existBlacklist = matchingRoom.getMemberMatchingRoomChargingInfo().stream() .anyMatch(memberMatchingRoomChargingInfo -> this.blacklistsRepository.existsByRequesterAndReceiver( requester, memberMatchingRoomChargingInfo.getMembers())); From 99277fe4dbdaf311dc42ca8ba49676d300601e23 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 3 Feb 2025 14:36:58 +0900 Subject: [PATCH 692/770] =?UTF-8?q?refactor:=20Page=20->=20Slice=EB=A1=9C?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/response/BlacklistGetResponse.java | 3 ++- .../domain/members/repository/BlacklistsRepository.java | 3 ++- .../com/gachtaxi/domain/members/service/BlacklistService.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java index 1a5d48c2..dfaf5047 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java @@ -4,6 +4,7 @@ import java.util.List; import lombok.Builder; import org.springframework.data.domain.Page; +import org.springframework.data.domain.Slice; @Builder public record BlacklistGetResponse( @@ -13,7 +14,7 @@ public record BlacklistGetResponse( Integer numberOfElements, Boolean last ) { - public static BlacklistGetResponse of(Page blacklistsPage) { + public static BlacklistGetResponse of(Slice blacklistsPage) { List responseList = blacklistsPage.stream() .map(BlacklistInfo::of) .toList(); diff --git a/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java index 9501496e..85474d97 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/BlacklistsRepository.java @@ -5,6 +5,7 @@ import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -13,5 +14,5 @@ public interface BlacklistsRepository extends JpaRepository { Optional findByRequesterAndReceiver(Members requester, Members receiver); boolean existsByRequesterAndReceiver(Members requester, Members receiver); - Page findAllByRequester(Members requester, Pageable pageable); + Slice findAllByRequester(Members requester, Pageable pageable); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java index 1ab91f6f..f7a28b7b 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java @@ -14,6 +14,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; import org.springframework.stereotype.Service; @@ -59,7 +60,7 @@ public BlacklistGetResponse findBlacklistPage(Long requesterId, int pageNum, int Pageable pageRequest = PageRequest.of(pageNum, pageSize, Sort.by(Direction.ASC, "receiver.nickname")); - Page blacklistsPage = this.blacklistsRepository.findAllByRequester(requester, pageRequest); + Slice blacklistsPage = this.blacklistsRepository.findAllByRequester(requester, pageRequest); return BlacklistGetResponse.of(blacklistsPage); } From fbceb0ef3def5a4f8fcf82ba5aec0ff783fab763 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 3 Feb 2025 14:45:21 +0900 Subject: [PATCH 693/770] =?UTF-8?q?fix:=20=EB=B9=8C=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingAlgorithmServiceImpl.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java index 474b23c3..ce689b57 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java @@ -73,16 +73,4 @@ public Optional findRoom(Long userId, double startLongitude, dou */ return Optional.empty(); } - - @Override - public Page findMatchingRooms(int pageNumber, int pageSize) { - - if (pageNumber < 0) { - throw new PageNotFoundException(); - } - - PageRequest pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "id")); - - return matchingRoomRepository.findAll(pageable); - } } From b34f4ea1ed666b1ee5c96019ffdf6c29a4bca089 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 3 Feb 2025 14:59:52 +0900 Subject: [PATCH 694/770] =?UTF-8?q?refactor:=20=EC=B9=9C=EA=B5=AC=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20isL?= =?UTF-8?q?ast=20->=20last=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/dto/response/FriendsPageableResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java index a3cb77f2..f420e04f 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java @@ -9,14 +9,14 @@ public record FriendsPageableResponse( int pageNum, int pageSize, int numberOfElements, - boolean isLast + boolean last ) { public static FriendsPageableResponse from(Slice slice) { return FriendsPageableResponse.builder() .pageNum(slice.getNumber()) .pageSize(slice.getSize()) .numberOfElements(slice.getNumberOfElements()) - .isLast(slice.isLast()) + .last(slice.isLast()) .build(); } } From 52dc5b46b21b2f058c6f1cc2a7c32bbbca93d60d Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 3 Feb 2025 15:32:19 +0900 Subject: [PATCH 695/770] =?UTF-8?q?fix:=20FriendsUpdateDto=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/friend/dto/request/FriendUpdateDto.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java index 06172f53..9842fbee 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java @@ -3,6 +3,7 @@ import jakarta.validation.constraints.NotNull; public record FriendUpdateDto( - @NotNull Long memberId + @NotNull Long memberId, + @NotNull String notificationId ) { } From 6a8222dfde18aa5f99b90e342fc2edb50572b645 Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 3 Feb 2025 16:46:31 +0900 Subject: [PATCH 696/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jwt/filter/JwtAuthenticationFilter.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index 24ed0bc4..80f5a949 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -1,25 +1,24 @@ package com.gachtaxi.global.auth.jwt.filter; +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_EXPIRED; +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_INVALID; +import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.JWT_TOKEN_NOT_FOUND; + import com.gachtaxi.global.auth.jwt.user.JwtUserDetails; import com.gachtaxi.global.auth.jwt.util.JwtExtractor; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Optional; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.web.filter.OncePerRequestFilter; -import java.io.IOException; -import java.util.Optional; - -import static com.gachtaxi.global.auth.jwt.exception.JwtErrorMessage.*; - -@Slf4j @RequiredArgsConstructor public class JwtAuthenticationFilter extends OncePerRequestFilter { @@ -52,14 +51,15 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse } saveAuthentcation(accessToken); + filterChain.doFilter(request, response); } private void saveAuthentcation(String token) { Long id = jwtExtractor.getId(token); String email = jwtExtractor.getEmail(token); - String role = jwtExtractor.getRole(token); - + String role = new StringBuilder().append("ROLE_").append(jwtExtractor.getRole(token)).toString(); + UserDetails userDetails = JwtUserDetails.of(id, email, role); Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); From 17647466272f2e20c1d27d425125c36dcd1d8a4d Mon Sep 17 00:00:00 2001 From: senna Date: Mon, 3 Feb 2025 16:54:28 +0900 Subject: [PATCH 697/770] =?UTF-8?q?fix:=20=EB=A7=A4=EC=B9=AD=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=8B=9C=20=EA=B2=BD=EB=8F=84,=20=EC=9C=84?= =?UTF-8?q?=EB=8F=84=20=EC=88=9C=EC=84=9C=EB=A1=9C=20=EB=B0=9B=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20SQL=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/repository/MatchingRoomRepository.java | 4 ++-- .../global/auth/jwt/filter/JwtAuthenticationFilter.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index bb6c8cab..29914787 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -16,8 +16,8 @@ public interface MatchingRoomRepository extends JpaRepository { @Query("SELECT r FROM MatchingRoom r " + "WHERE " + - "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLatitude, :startLongitude), FUNCTION('POINT', r.route.startLatitude, r.route.startLongitude)) <= :radius " + - "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLatitude, :destinationLongitude), FUNCTION('POINT', r.route.endLatitude, r.route.endLongitude)) <= :radius ") + "FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :startLongitude, :startLatitude), FUNCTION('POINT', r.route.startLongitude, r.route.startLatitude)) <= :radius " + + "AND FUNCTION('ST_Distance_Sphere', FUNCTION('POINT', :destinationLongitude, :destinationLatitude), FUNCTION('POINT', r.route.endLongitude, r.route.endLatitude)) <= :radius ") List findRoomsByStartAndDestination( @Param("startLongitude") double startLongitude, @Param("startLatitude") double startLatitude, diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index 80f5a949..4bc194d5 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -59,7 +59,7 @@ private void saveAuthentcation(String token) { Long id = jwtExtractor.getId(token); String email = jwtExtractor.getEmail(token); String role = new StringBuilder().append("ROLE_").append(jwtExtractor.getRole(token)).toString(); - + UserDetails userDetails = JwtUserDetails.of(id, email, role); Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); From ad65cfdddfc7c8038090b34ba974e7e9e79ff1d0 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 19:13:19 +0900 Subject: [PATCH 698/770] =?UTF-8?q?fix=20:=20receiver=20ID=20=EB=B0=94?= =?UTF-8?q?=EA=BF=94=EC=84=9C=20=EB=82=98=EC=98=A4=EB=8A=94=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/service/FriendService.java | 1 - .../service/NotificationService.java | 17 ++++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 87fac1f9..21c90edd 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -50,7 +50,6 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { friendRepository.save(Friends.of(sender, receiver)); notificationService.sendWithPush( - sender.getId(), receiver, FRIEND_REQUEST, FRIEND_REQUEST_TITLE, diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java index 3257b788..218c0efb 100644 --- a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -61,15 +61,16 @@ public NotificationInfoResponse getInfo(Long receiverId) { return NotificationInfoResponse.of(count, false); } - public void sendWithPush(Long senderId, Members receiver, NotificationType type, String title, String content, NotificationPayload payload) { - Notification notification = Notification.of(senderId, type, content, payload); + public void sendWithPush(Members receiver, NotificationType type, String title, String content, NotificationPayload payload) { + Notification notification = Notification.of(receiver.getId(), type, content, payload); notificationRepository.save(notification); - fcmService.sendNotification(receiver.getFcmToken(), title, notification.getContent()); + // todo : 앱으로 마이그레이션 후 주석 해제 +// fcmService.sendNotification(receiver.getFcmToken(), title, notification.getContent()); } - public void sendWithOutPush(Long senderId, Members receiver, NotificationType type, String content, NotificationPayload payload) { - Notification notification = Notification.of(senderId, type, content, payload); + public void sendWithOutPush(Members receiver, NotificationType type, String content, NotificationPayload payload) { + Notification notification = Notification.of(receiver.getId(), type, content, payload); notificationRepository.save(notification); } @@ -92,10 +93,4 @@ private void validateMember(long receiverId, long notificationId) { throw new MemberNotMatchException(); } } - - public boolean hasReceivedMatchingInvite(Long userId) { - return notificationRepository.existsByReceiverIdAndType( - userId, NotificationType.MATCH_INVITE - ); - } } From 82e67dd08ffdb9bed13955bf9655a6a2dcef459d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 19:13:53 +0900 Subject: [PATCH 699/770] =?UTF-8?q?refactor=20:=20=EB=B3=B4=EB=82=B8?= =?UTF-8?q?=EC=82=AC=EB=9E=8C=20ID=EB=A1=9C=20=EC=88=98=EB=8F=99=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=88=98=EB=9D=BD=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/controller/ManualMatchingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index 70378eac..cfd93e6d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -55,7 +55,7 @@ public ApiResponse joinManualMatchingRoom(@CurrentMemberId Long userId, @V @Operation(summary = "수동 매칭 초대 수락") @PostMapping("/invite/accept") - public ApiResponse acceptInvitation(@CurrentMemberId Long userId, @RequestParam Long matchingRoomId + public ApiResponse acceptInvitation(@RequestParam Long userId, @RequestParam Long matchingRoomId ) { matchingInvitationService.acceptInvitation(userId, matchingRoomId); return ApiResponse.response(HttpStatus.OK, ACCEPT_MATCHING_INVITE_SUCCESS.getMessage()); From 727bf75fab4c96ef9411edd3ecfd92101cfc48ca Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 19:14:50 +0900 Subject: [PATCH 700/770] =?UTF-8?q?fix=20:=20=EC=B4=88=EB=8C=80=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=ED=95=98=EC=A7=80=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=EC=8B=9C=20=EB=AA=BD?= =?UTF-8?q?=EA=B3=A0DB=20=ED=98=95=EC=8B=9D=EC=97=90=20=EB=A7=9E=EA=B2=8C?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=ED=95=B4=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/MatchingInvitationService.java | 6 ++++-- .../notification/repository/NotificationRepository.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java index a4f39607..193b2d48 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java @@ -9,7 +9,9 @@ import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.domain.notification.entity.enums.NotificationType; import com.gachtaxi.domain.notification.entity.payload.MatchingInvitePayload; +import com.gachtaxi.domain.notification.repository.NotificationRepository; import com.gachtaxi.domain.notification.service.NotificationService; import jakarta.transaction.Transactional; import java.util.List; @@ -24,6 +26,7 @@ public class MatchingInvitationService { private final MemberService memberService; private final MemberRepository memberRepository; private final MatchingRoomRepository matchingRoomRepository; + private final NotificationRepository notificationRepository; /* 수동 매칭시 친구 초대 @@ -40,7 +43,6 @@ public void sendMatchingInvitation(Members sender, List friendNicknames) for (Members friend : friends) { notificationService.sendWithPush( - sender.getId(), friend, MATCH_INVITE, MATCHING_INVITE_TITLE, @@ -59,7 +61,7 @@ public void acceptInvitation(Long userId, Long matchingRoomId) { MatchingRoom matchingRoom = matchingRoomRepository.findById(matchingRoomId) .orElseThrow(NoSuchMatchingRoomException::new); - if (!notificationService.hasReceivedMatchingInvite(userId)) { + if (notificationRepository.countByReceiverIdAndType(userId, NotificationType.MATCH_INVITE) == 0) { throw new NoSuchInvitationException(); } diff --git a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java index e13322b3..8e789ad3 100644 --- a/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java +++ b/src/main/java/com/gachtaxi/domain/notification/repository/NotificationRepository.java @@ -13,5 +13,5 @@ public interface NotificationRepository extends MongoRepository findAllByReceiverId(Long receiverId, Pageable pageable); - boolean existsByReceiverIdAndType(Long receiverId, NotificationType type); + int countByReceiverIdAndType(Long receiverId, NotificationType type); } From 57d10363485918c6e422d73da7a5476078573a58 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 20:16:41 +0900 Subject: [PATCH 701/770] =?UTF-8?q?refactor=20:=20=ED=94=84=EB=A1=A0?= =?UTF-8?q?=ED=8A=B8=20=EC=9A=94=EA=B5=AC=EC=82=AC=ED=95=AD=EC=97=90=20?= =?UTF-8?q?=EB=A7=9E=EC=B6=B0=EC=84=9C=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20DTO=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/ManualMatchingRequest.java | 2 -- .../matching/common/dto/response/MatchingRoomResponse.java | 4 ++-- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 4 ++-- .../domain/matching/common/service/ManualMatchingService.java | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java index 5c56ee83..57bdf30c 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java @@ -9,8 +9,6 @@ import java.util.List; public record ManualMatchingRequest( - @NotBlank - String title, String description, diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java index f5a31523..c5ec997a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java @@ -6,7 +6,7 @@ public record MatchingRoomResponse( Long roomId, - String title, + String description, String departure, String destination, LocalDateTime departureTime, @@ -17,7 +17,7 @@ public record MatchingRoomResponse( public static MatchingRoomResponse from(MatchingRoom matchingRoom) { return new MatchingRoomResponse( matchingRoom.getId(), - matchingRoom.getTitle(), + matchingRoom.getDescription(), matchingRoom.getDeparture(), matchingRoom.getDestination(), matchingRoom.getDepartureTime(), diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 4122ab44..29a9dc20 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -54,6 +54,7 @@ public class MatchingRoom extends BaseEntity { private String title; @Column(name = "description", nullable = false) + @Getter private String description; @ManyToOne(fetch = FetchType.LAZY) @@ -117,11 +118,10 @@ public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, .build(); } - public static MatchingRoom manualOf(Members roomMaster, String departure, String destination, String title, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { + public static MatchingRoom manualOf(Members roomMaster, String departure, String destination, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { return MatchingRoom.builder() .capacity(4) .roomMaster(roomMaster) - .title(title) .description(description) .departure(departure) .destination(destination) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 6aff06f2..fe3011b1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -62,7 +62,6 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) roomMaster, request.departure(), request.destination(), - request.title(), request.description(), 4, request.totalCharge(), From 27764917ea334a92ef57e6bc73c343d2163a88bc Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 20:23:39 +0900 Subject: [PATCH 702/770] =?UTF-8?q?refactor=20:=20=EC=A0=95=EC=A0=81=20imp?= =?UTF-8?q?ort=EB=A5=BC=20=ED=99=9C=EC=9A=A9=ED=95=B4=EC=84=9C=20=EC=84=B1?= =?UTF-8?q?=EA=B3=B5=20=EC=9D=91=EB=8B=B5=EC=BD=94=EB=93=9C=20=ED=98=95?= =?UTF-8?q?=ED=83=9C=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ManualMatchingController.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index cfd93e6d..c223e80a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -6,6 +6,7 @@ import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.GET_MY_MATCHING_LIST_SUCCESS; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.JOIN_MANUAL_MATCHING_ROOM_SUCCESS; import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.LEAVE_MANUAL_MATCHING_ROOM_SUCCESS; +import static org.springframework.http.HttpStatus.OK; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingJoinRequest; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; @@ -20,7 +21,6 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; -import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -43,14 +43,14 @@ public class ManualMatchingController { @PostMapping("/creation") public ApiResponse createManualMatchingRoom(@CurrentMemberId Long userId, @Valid @RequestBody ManualMatchingRequest request) { Long roomId = manualMatchingService.createManualMatchingRoom(userId, request); - return ApiResponse.response(HttpStatus.OK, CREATE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage(), roomId); + return ApiResponse.response(OK, CREATE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage(), roomId); } @Operation(summary = "수동 매칭방 참여") @PostMapping("/join") public ApiResponse joinManualMatchingRoom(@CurrentMemberId Long userId, @Valid @RequestBody ManualMatchingJoinRequest request) { manualMatchingService.joinManualMatchingRoom(userId, request.roomId()); - return ApiResponse.response(HttpStatus.OK, JOIN_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); + return ApiResponse.response(OK, JOIN_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); } @Operation(summary = "수동 매칭 초대 수락") @@ -58,27 +58,27 @@ public ApiResponse joinManualMatchingRoom(@CurrentMemberId Long userId, @V public ApiResponse acceptInvitation(@RequestParam Long userId, @RequestParam Long matchingRoomId ) { matchingInvitationService.acceptInvitation(userId, matchingRoomId); - return ApiResponse.response(HttpStatus.OK, ACCEPT_MATCHING_INVITE_SUCCESS.getMessage()); + return ApiResponse.response(OK, ACCEPT_MATCHING_INVITE_SUCCESS.getMessage()); } @Operation(summary = "수동 매칭방 퇴장 (방 삭제 포함)") @PatchMapping("/exit/{roomId}") public ApiResponse leaveManualMatchingRoom(@CurrentMemberId Long userId, @PathVariable Long roomId) { manualMatchingService.leaveManualMatchingRoom(userId, roomId); - return ApiResponse.response(HttpStatus.OK, LEAVE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); + return ApiResponse.response(OK, LEAVE_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); } @Operation(summary = "수동 매칭방 조회") @GetMapping("/list") public ApiResponse getManualMatchingList(int pageNumber, int pageSize) { Page rooms = manualMatchingService.getManualMatchingList(pageNumber, pageSize); - return ApiResponse.response(HttpStatus.OK, GET_MANUAL_MATCHING_LIST_SUCCESS.getMessage(), MatchingRoomListResponse.of(rooms)); + return ApiResponse.response(OK, GET_MANUAL_MATCHING_LIST_SUCCESS.getMessage(), MatchingRoomListResponse.of(rooms)); } @Operation(summary = "나의 매칭(수동) 조회") @GetMapping("/my-list") public ApiResponse getMyMatchingList(@CurrentMemberId Long userId, int pageNumber, int pageSize) { Page rooms = manualMatchingService.getMyMatchingList(userId, pageNumber, pageSize); - return ApiResponse.response(HttpStatus.OK, GET_MY_MATCHING_LIST_SUCCESS.getMessage(), MatchingRoomListResponse.of(rooms)); + return ApiResponse.response(OK, GET_MY_MATCHING_LIST_SUCCESS.getMessage(), MatchingRoomListResponse.of(rooms)); } } From 490f2deded4f2b48aad760f822484777bcbd5dbc Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 3 Feb 2025 21:30:12 +0900 Subject: [PATCH 703/770] =?UTF-8?q?HOTFIX:=20Role=20Claims=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A1=A4=EB=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/jwt/filter/JwtAuthenticationFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java index 4bc194d5..28b68644 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/filter/JwtAuthenticationFilter.java @@ -58,7 +58,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse private void saveAuthentcation(String token) { Long id = jwtExtractor.getId(token); String email = jwtExtractor.getEmail(token); - String role = new StringBuilder().append("ROLE_").append(jwtExtractor.getRole(token)).toString(); + String role = jwtExtractor.getRole(token); UserDetails userDetails = JwtUserDetails.of(id, email, role); Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); From 1978175a028d1c5a4c7f3f418b0f668f8c3f7372 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 21:32:49 +0900 Subject: [PATCH 704/770] =?UTF-8?q?refactor=20:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=EC=95=8A=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoom.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 29a9dc20..a36ea9ee 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -3,7 +3,6 @@ import com.gachtaxi.domain.matching.algorithm.dto.FindRoomResult; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomStatus; import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; -import com.gachtaxi.domain.matching.common.exception.MatchingRoomAlreadyFullException; import com.gachtaxi.domain.matching.event.dto.kafka_topic.MatchRoomCreatedEvent; import com.gachtaxi.domain.matching.common.entity.enums.Tags; import com.gachtaxi.domain.members.entity.Members; @@ -49,7 +48,7 @@ public class MatchingRoom extends BaseEntity { @Setter private Members roomMaster; - @Column(name = "title", nullable = false) + @Column(name = "title") @Getter private String title; @@ -154,12 +153,4 @@ public List getTags() { .map(tagInfo -> tagInfo.getTags().name()) .toList(); } - - public void addMember(Members member) { - if (this.getCurrentMemberCount() >= this.capacity) { - throw new MatchingRoomAlreadyFullException(); - } - MemberMatchingRoomChargingInfo memberInfo = MemberMatchingRoomChargingInfo.notPayedOf(this, member); - this.memberMatchingRoomChargingInfo.add(memberInfo); - } } From 69a911743b2a86a8076359e0f16973e7a298cf84 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 21:42:49 +0900 Subject: [PATCH 705/770] =?UTF-8?q?fix=20:=20=EC=B9=9C=EA=B5=AC=EC=B4=88?= =?UTF-8?q?=EB=8C=80=EC=8B=9C=20MatchingInvitationService=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EA=B2=80=EC=A6=9D=20=ED=9B=84=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingInvitationService.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java index 193b2d48..874b63ef 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java @@ -3,9 +3,13 @@ import static com.gachtaxi.domain.notification.entity.enums.NotificationType.MATCH_INVITE; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; +import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import com.gachtaxi.domain.matching.common.exception.AlreadyInMatchingRoomException; +import com.gachtaxi.domain.matching.common.exception.MatchingRoomAlreadyFullException; import com.gachtaxi.domain.matching.common.exception.NoSuchInvitationException; import com.gachtaxi.domain.matching.common.exception.NoSuchMatchingRoomException; import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; +import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.domain.members.service.MemberService; @@ -26,6 +30,7 @@ public class MatchingInvitationService { private final MemberService memberService; private final MemberRepository memberRepository; private final MatchingRoomRepository matchingRoomRepository; + private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; private final NotificationRepository notificationRepository; /* @@ -65,7 +70,15 @@ public void acceptInvitation(Long userId, Long matchingRoomId) { throw new NoSuchInvitationException(); } - matchingRoom.addMember(member); - matchingRoomRepository.save(matchingRoom); + if (matchingRoom.getCurrentMemberCount() >= matchingRoom.getCapacity()) { + throw new MatchingRoomAlreadyFullException(); + } + + if (matchingRoomRepository.existsByMemberInMatchingRoom(member)) { + throw new AlreadyInMatchingRoomException(); + } + + MemberMatchingRoomChargingInfo memberInfo = MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, member); + memberMatchingRoomChargingInfoRepository.save(memberInfo); } } From 40cba071430dde5d01ea6fccad9e7e066a235bdb Mon Sep 17 00:00:00 2001 From: koreaioi Date: Mon, 3 Feb 2025 21:43:22 +0900 Subject: [PATCH 706/770] =?UTF-8?q?HOTFIX:=20nickname=20=EC=9C=A0=EB=8B=88?= =?UTF-8?q?=ED=81=AC=20=EC=A0=9C=EC=95=BD=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 2cb916f0..1d24876b 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -30,7 +30,7 @@ public class Members extends BaseEntity { @Column(name = "profile_picture") private String profilePicture; - @Column(name = "nickname") + @Column(name = "nickname", unique = true) private String nickname; @Column(name = "real_name") From 4440accd071e9bd0a3d3f358c8cac772dc1e5003 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Mon, 3 Feb 2025 22:31:20 +0900 Subject: [PATCH 707/770] =?UTF-8?q?refactor=20:=20=ED=94=84=EB=A1=A0?= =?UTF-8?q?=ED=8A=B8=20=EC=9A=94=EA=B5=AC=EC=82=AC=ED=95=AD=20=EB=A7=9E?= =?UTF-8?q?=EC=B6=B0=EC=84=9C=20=EC=9A=94=EC=B2=AD=20DTO=20=EA=B0=92=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/ManualMatchingRequest.java | 24 +++++++++++++++---- .../common/service/ManualMatchingService.java | 10 ++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java index 57bdf30c..3728585e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java @@ -13,27 +13,43 @@ public record ManualMatchingRequest( String description, @NotBlank - String departure, + String startName, @NotBlank - String destination, + String destinationName, @NotNull LocalDateTime departureTime, @Schema(description = "예상 요금") @Min(value = 0) - int totalCharge, + int expectedTotalCharge, @Schema(description = "매칭 태그") List criteria, @Schema(description = "초대할 친구 닉네임 리스트") - List friendNicknames + List members ) { public List getCriteria() { return this.criteria.stream() .map(Tags::valueOf) .toList(); } + + public List getFriendNicknames() { + return members; + } + + public int getTotalCharge() { + return expectedTotalCharge; + } + + public String getDeparture() { + return startName; + } + + public String getDestination() { + return destinationName; + } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index fe3011b1..2a17cb2c 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -54,23 +54,23 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) throw new DuplicatedMatchingRoomException(); } - if (request.departure().equals(request.destination())) { + if (request.getDeparture().equals(request.getDestination())) { throw new NotEqualStartAndDestinationException(); } MatchingRoom matchingRoom = MatchingRoom.manualOf( roomMaster, - request.departure(), - request.destination(), + request.getDeparture(), + request.getDestination(), request.description(), 4, - request.totalCharge(), + request.getTotalCharge(), request.departureTime() ); MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); - matchingInvitationService.sendMatchingInvitation(roomMaster, request.friendNicknames()); + matchingInvitationService.sendMatchingInvitation(roomMaster, request.getFriendNicknames()); matchingRoomService.saveMatchingRoomTagInfoForManual(savedMatchingRoom, request.getCriteria()); matchingRoomService.saveRoomMasterChargingInfoForManual(savedMatchingRoom, roomMaster); From ef8b645720a21f65ba0d149b3201dec5ac8ac192 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 01:48:32 +0900 Subject: [PATCH 708/770] =?UTF-8?q?refactor=20:=20=EB=A7=A4=EC=B9=AD?= =?UTF-8?q?=EB=A3=B8=20=EC=95=84=EC=9D=B4=EB=94=94=20=EA=B0=99=EC=9D=B4=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20ManualMatchingS?= =?UTF-8?q?ervice=20=EC=97=90=EC=84=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/ManualMatchingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 2a17cb2c..ebc82c57 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -70,7 +70,7 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); - matchingInvitationService.sendMatchingInvitation(roomMaster, request.getFriendNicknames()); + matchingInvitationService.sendMatchingInvitation(roomMaster, request.getFriendNicknames(), savedMatchingRoom.getId()); matchingRoomService.saveMatchingRoomTagInfoForManual(savedMatchingRoom, request.getCriteria()); matchingRoomService.saveRoomMasterChargingInfoForManual(savedMatchingRoom, roomMaster); From ca6b14f9cc660bb45bde95b2dcf8bf2bd9df5de6 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 01:51:52 +0900 Subject: [PATCH 709/770] =?UTF-8?q?refactor=20:=20=EC=88=98=EB=8F=99?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=B4=88=EB=8C=80=20=EC=88=98=EB=9D=BD?= =?UTF-8?q?=EC=8B=9C=20notificationId=20=ED=8C=8C=EB=9D=BC=EB=AF=B8?= =?UTF-8?q?=ED=84=B0=EB=A1=9C=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/controller/ManualMatchingController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index c223e80a..df0f32ec 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -55,9 +55,9 @@ public ApiResponse joinManualMatchingRoom(@CurrentMemberId Long userId, @V @Operation(summary = "수동 매칭 초대 수락") @PostMapping("/invite/accept") - public ApiResponse acceptInvitation(@RequestParam Long userId, @RequestParam Long matchingRoomId + public ApiResponse acceptInvitation(@RequestParam Long userId, @RequestParam Long matchingRoomId, @RequestParam String notificationId ) { - matchingInvitationService.acceptInvitation(userId, matchingRoomId); + matchingInvitationService.acceptInvitation(userId, matchingRoomId, notificationId); return ApiResponse.response(OK, ACCEPT_MATCHING_INVITE_SUCCESS.getMessage()); } From a091c5be06931025c30bb624d85f35e80101a3fa Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 01:54:21 +0900 Subject: [PATCH 710/770] =?UTF-8?q?refactor=20:=20notificationId=EB=A1=9C?= =?UTF-8?q?=20=EC=A1=B4=EC=9E=AC=ED=95=98=EC=A7=80=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EC=B4=88=EB=8C=80=EC=9D=B8=EC=A7=80=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingInvitationService.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java index 874b63ef..b38fee51 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java @@ -13,6 +13,7 @@ import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.repository.MemberRepository; import com.gachtaxi.domain.members.service.MemberService; +import com.gachtaxi.domain.notification.entity.Notification; import com.gachtaxi.domain.notification.entity.enums.NotificationType; import com.gachtaxi.domain.notification.entity.payload.MatchingInvitePayload; import com.gachtaxi.domain.notification.repository.NotificationRepository; @@ -39,7 +40,7 @@ public class MatchingInvitationService { public static final String MATCHING_INVITE_TITLE = "수동 매칭 초대"; public static final String MATCHING_INVITE_CONTENT = "%s 님이 수동 매칭 초대를 보냈습니다."; - public void sendMatchingInvitation(Members sender, List friendNicknames) { + public void sendMatchingInvitation(Members sender, List friendNicknames, Long matchingRoomId) { if (friendNicknames == null || friendNicknames.isEmpty()) { return; } @@ -52,7 +53,7 @@ public void sendMatchingInvitation(Members sender, List friendNicknames) MATCH_INVITE, MATCHING_INVITE_TITLE, String.format(MATCHING_INVITE_CONTENT, sender.getNickname()), - MatchingInvitePayload.from(sender.getNickname()) + MatchingInvitePayload.from(sender.getNickname(), matchingRoomId) ); } } @@ -61,11 +62,20 @@ public void sendMatchingInvitation(Members sender, List friendNicknames) 수동 매칭시 친구 초대 수락 */ @Transactional - public void acceptInvitation(Long userId, Long matchingRoomId) { + public void acceptInvitation(Long userId, Long matchingRoomId, String notificationId) { Members member = memberService.findById(userId); MatchingRoom matchingRoom = matchingRoomRepository.findById(matchingRoomId) .orElseThrow(NoSuchMatchingRoomException::new); + Notification notification = notificationService.find(notificationId); + + MatchingInvitePayload payload = (MatchingInvitePayload) notification.getPayload(); + if (!payload.getMatchingRoomId().equals(matchingRoomId)) { + throw new NoSuchInvitationException(); + } + + notificationRepository.save(notification); + if (notificationRepository.countByReceiverIdAndType(userId, NotificationType.MATCH_INVITE) == 0) { throw new NoSuchInvitationException(); } From b70e14c91c2da7c5698608de601ab795c59decb5 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 01:54:40 +0900 Subject: [PATCH 711/770] =?UTF-8?q?refactor=20:=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=EC=97=90=20matchingRoomId=20=EB=8B=B4?= =?UTF-8?q?=EC=95=84=EC=84=9C=20=EB=B3=B4=EB=82=B4=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/entity/payload/MatchingInvitePayload.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingInvitePayload.java b/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingInvitePayload.java index a181227c..09a9cffc 100644 --- a/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingInvitePayload.java +++ b/src/main/java/com/gachtaxi/domain/notification/entity/payload/MatchingInvitePayload.java @@ -10,10 +10,12 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class MatchingInvitePayload extends NotificationPayload { private String senderNickname; + private Long matchingRoomId; - public static MatchingInvitePayload from(String senderNickname) { + public static MatchingInvitePayload from(String senderNickname, Long matchingRoomId) { return MatchingInvitePayload.builder() .senderNickname(senderNickname) + .matchingRoomId(matchingRoomId) .build(); } } From d3374c701145799928e48ae1bfca237e2d4b3f67 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 01:55:12 +0900 Subject: [PATCH 712/770] =?UTF-8?q?refactor=20:=20public=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20find=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notification/service/NotificationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java index a931aa72..51d4088a 100644 --- a/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java +++ b/src/main/java/com/gachtaxi/domain/notification/service/NotificationService.java @@ -81,7 +81,7 @@ public void delete(Long receiverId, String notificationId) { notificationRepository.deleteById(notificationId); } - private Notification find(String notificationId) { + public Notification find(String notificationId) { return notificationRepository.findById(notificationId) .orElseThrow(NotificationNotFoundException::new); } From 7b9ec1e4fbc6bf0d9dfdab335c1a99c2cc1ada36 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 02:09:03 +0900 Subject: [PATCH 713/770] =?UTF-8?q?refactor=20:=20=EB=AA=A8=EB=93=A0=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=99=84=EB=A3=8C=20=ED=9B=84=20?= =?UTF-8?q?CurrentMemberId=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=9E=AC?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/controller/ManualMatchingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index df0f32ec..2ec861bf 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -55,7 +55,7 @@ public ApiResponse joinManualMatchingRoom(@CurrentMemberId Long userId, @V @Operation(summary = "수동 매칭 초대 수락") @PostMapping("/invite/accept") - public ApiResponse acceptInvitation(@RequestParam Long userId, @RequestParam Long matchingRoomId, @RequestParam String notificationId + public ApiResponse acceptInvitation(@CurrentMemberId Long userId, @RequestParam Long matchingRoomId, @RequestParam String notificationId ) { matchingInvitationService.acceptInvitation(userId, matchingRoomId, notificationId); return ApiResponse.response(OK, ACCEPT_MATCHING_INVITE_SUCCESS.getMessage()); From 83fba19dda4073c8e6d53bbecdaf564ac193e33b Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 04:23:17 +0900 Subject: [PATCH 714/770] =?UTF-8?q?feat=20:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=93=B1=EB=A1=9D=EB=90=9C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20=EB=B0=A9=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/exception/ErrorMessage.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index 7207ee92..199a733b 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -6,15 +6,18 @@ @Getter @AllArgsConstructor public enum ErrorMessage { - + // Member DUPLICATED_NICKNAME("중복되는 닉네임입니다."), DUPLICATED_STUDENT_NUMBER("이미 가입된 학번입니다."), MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."), DUPLICATED_EMAIL("이미 가입된 이메일이에요!"), EMAIL_FROM_INVALID("가천대학교 이메일이 아니에요!"), + + // Blacklist BLACKLIST_ALREADY_EXISTS("이미 등록된 블랙리스트입니다."), BLACKLIST_NOT_FOUND("블랙리스트를 찾을 수 없습니다."), - BLACKLIST_REQUESTER_EQUALS_RECEIVER("본인을 블랙리스트에 추가할 수 없습니다."); + BLACKLIST_REQUESTER_EQUALS_RECEIVER("본인을 블랙리스트에 추가할 수 없습니다."), + BLACKLISTED_USER_CANNOT_JOIN("블랙리스트로 등록된 사용자의 방은 입장할 수 없습니다."); private final String message; } From 847be126f107cb9a19fc59080b5ed4d65fa47f97 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 04:23:52 +0900 Subject: [PATCH 715/770] =?UTF-8?q?feat=20:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=EB=8B=A8=EC=97=90=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/ManualMatchingService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index ebc82c57..9d1ab15e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -19,6 +19,8 @@ import com.gachtaxi.domain.matching.common.repository.MatchingRoomRepository; import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.exception.BlacklistedUserCannotJoinException; +import com.gachtaxi.domain.members.service.BlacklistService; import com.gachtaxi.domain.members.service.MemberService; import jakarta.transaction.Transactional; import java.time.LocalDateTime; @@ -40,6 +42,7 @@ public class ManualMatchingService { private final MemberService memberService; private final MatchingRoomService matchingRoomService; private final MatchingInvitationService matchingInvitationService; + private final BlacklistService blacklistService; private final MatchingRoomRepository matchingRoomRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; @@ -100,6 +103,11 @@ public void joinManualMatchingRoom(Long userId, Long roomId) { throw new MemberAlreadyJoinedException(); } + boolean isBlacklisted = blacklistService.isUserBlacklistedInRoom(user, matchingRoom); + if (isBlacklisted) { + throw new BlacklistedUserCannotJoinException(); + } + Optional joinedInPast = this.memberMatchingRoomChargingInfoRepository .findByMembersAndMatchingRoom(user, matchingRoom); From 82707353a83ba47680aff4cf398ef14c39fa5b1b Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 04:24:38 +0900 Subject: [PATCH 716/770] =?UTF-8?q?feat=20:=20isUserBlacklistedInRoom=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=84=9C=EB=B9=84=EC=8A=A4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/service/BlacklistService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java index f7a28b7b..a70cc84e 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/BlacklistService.java @@ -11,7 +11,6 @@ import com.gachtaxi.domain.members.repository.BlacklistsRepository; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -78,4 +77,9 @@ private void checkRequesterAndReceiver(Members requester, Members receiver) { throw new BlacklistRequesterEqualsReceiverException(); } } + + public boolean isUserBlacklistedInRoom(Members requester, MatchingRoom matchingRoom) { + return matchingRoom.getMemberMatchingRoomChargingInfo().stream() + .anyMatch(info -> this.blacklistsRepository.existsByRequesterAndReceiver(requester, info.getMembers())); + } } From 9bda0e563a02c27762bd74c0bb4f20f27e85b0fb Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 04:25:01 +0900 Subject: [PATCH 717/770] =?UTF-8?q?feat=20:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EB=93=B1=EB=A1=9D=EB=90=9C=20?= =?UTF-8?q?=EB=B0=A9=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlacklistedUserCannotJoinException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/BlacklistedUserCannotJoinException.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/BlacklistedUserCannotJoinException.java b/src/main/java/com/gachtaxi/domain/members/exception/BlacklistedUserCannotJoinException.java new file mode 100644 index 00000000..c6a12815 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/BlacklistedUserCannotJoinException.java @@ -0,0 +1,12 @@ +package com.gachtaxi.domain.members.exception; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.BLACKLISTED_USER_CANNOT_JOIN; +import static org.springframework.http.HttpStatus.FORBIDDEN; + +import com.gachtaxi.global.common.exception.BaseException; + +public class BlacklistedUserCannotJoinException extends BaseException { + public BlacklistedUserCannotJoinException() { + super(FORBIDDEN, BLACKLISTED_USER_CANNOT_JOIN.getMessage()); + } +} From 1cadf3ff2c067b60050d0b6020dfa038273c8a24 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 04:50:35 +0900 Subject: [PATCH 718/770] =?UTF-8?q?feat=20:=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20=EC=B0=B8=EA=B0=80=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/service/ChattingRoomService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index 086dcb48..fd642dcf 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -11,6 +11,7 @@ import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; +import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; import com.gachtaxi.domain.chat.repository.ChattingRoomRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; @@ -34,6 +35,7 @@ public class ChattingRoomService { private final ChattingRoomRepository chattingRoomRepository; private final ChattingMessageRepository chattingMessageRepository; + private final ChattingParticipantRepository chattingParticipantRepository; private final ChattingParticipantService chattingParticipantService; private final MemberService memberService; private final RedisChatPublisher redisChatPublisher; @@ -116,4 +118,15 @@ private void publishMessage(long roomId, long senderId, String senderName, Strin redisChatPublisher.publish(topic, chatMessage); } + @Transactional + public ChattingRoom create(Members roomMaster) { + + ChattingRoom chattingRoom = ChattingRoom.builder().build(); + ChattingRoom savedChattingRoom = chattingRoomRepository.save(chattingRoom); + + ChattingParticipant chattingParticipant = ChattingParticipant.of(savedChattingRoom, roomMaster); + chattingParticipantRepository.save(chattingParticipant); + + return savedChattingRoom; + } } From c47abe0f568c4d5637da5fd63e587168dc12b78d Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 04:51:12 +0900 Subject: [PATCH 719/770] =?UTF-8?q?feat=20:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=84=9C=EB=B9=84=EC=8A=A4=EB=8B=A8=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=B1=84=ED=8C=85=EB=B0=A9=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EB=B0=8F=20=EC=B0=B8=EC=97=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/ManualMatchingService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 9d1ab15e..219b48d6 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -1,5 +1,7 @@ package com.gachtaxi.domain.matching.common.service; +import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.service.ChattingRoomService; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; @@ -43,6 +45,7 @@ public class ManualMatchingService { private final MatchingRoomService matchingRoomService; private final MatchingInvitationService matchingInvitationService; private final BlacklistService blacklistService; + private final ChattingRoomService chattingRoomService; private final MatchingRoomRepository matchingRoomRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; @@ -71,6 +74,10 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) request.departureTime() ); + ChattingRoom chattingRoom = chattingRoomService.create(roomMaster); + + matchingRoom.setChattingRoomId(chattingRoom.getId()); + MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); matchingInvitationService.sendMatchingInvitation(roomMaster, request.getFriendNicknames(), savedMatchingRoom.getId()); From e8ad42ae922276c4ab345db90a4d44a14b4bb8c5 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 04:52:32 +0900 Subject: [PATCH 720/770] =?UTF-8?q?feat=20:=20=EB=A7=A4=EC=B9=AD=EB=A3=B8?= =?UTF-8?q?=20=EC=97=94=ED=8B=B0=ED=8B=B0=EC=97=90=20chattingRoomId=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoom.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 18986b4b..a0d15be3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -76,6 +76,10 @@ public class MatchingRoom extends BaseEntity { @Getter private String destination; + @Column(name = "chatting_room_id") + @Getter + private Long chattingRoomId; + @Enumerated(EnumType.STRING) private MatchingRoomStatus matchingRoomStatus; @@ -154,4 +158,8 @@ public List getTags() { .map(tagInfo -> tagInfo.getTags().name()) .toList(); } + + public void setChattingRoomId(Long chattingRoomId) { + this.chattingRoomId = chattingRoomId; + } } From 718969605d871c391add12618e6022f01e9865d7 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 05:12:29 +0900 Subject: [PATCH 721/770] =?UTF-8?q?feat=20:=20=EC=B1=84=ED=8C=85=EB=A3=B8?= =?UTF-8?q?=EC=97=90=20=EC=9E=85=EC=9E=A5=EC=8B=9C=ED=82=A4=EB=8A=94=20joi?= =?UTF-8?q?nChattingRoom=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ChattingParticipantService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index c0c8ca85..eb59d911 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -6,11 +6,14 @@ import com.gachtaxi.domain.chat.entity.ChattingRoom; import com.gachtaxi.domain.chat.entity.enums.MessageType; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; +import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageMongoRepository; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; +import com.gachtaxi.domain.chat.repository.ChattingRoomRepository; import com.gachtaxi.domain.members.entity.Members; +import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.listener.ChannelTopic; @@ -25,8 +28,10 @@ public class ChattingParticipantService { private final ChattingParticipantRepository chattingParticipantRepository; private final ChattingMessageMongoRepository chattingMessageMongoRepository; + private final ChattingRoomRepository chattingRoomRepository; private final ChattingRedisService chattingRedisService; private final RedisChatPublisher redisChatPublisher; + private final ChattingRoomService chattingRoomService; @Value("${chat.topic}") public String chatTopic; @@ -85,4 +90,17 @@ private void reEnterEvent(long roomId, long senderId, String senderName, ReadMes redisChatPublisher.publish(topic, chatMessage); } + + @Transactional + public void joinChattingRoom(Members user, Long chattingRoomId) { + ChattingRoom chattingRoom = chattingRoomRepository.findById(chattingRoomId) + .orElseThrow(ChattingRoomNotFoundException::new); + + if (chattingParticipantRepository.findByChattingRoomAndMembers(chattingRoom, user).isPresent()) { + return; + } + + ChattingParticipant chattingParticipant = ChattingParticipant.of(chattingRoom, user); + chattingParticipantRepository.save(chattingParticipant); + } } From dc549fcaaeb8bddfcd3a44ec264804831ec923a3 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 05:13:06 +0900 Subject: [PATCH 722/770] =?UTF-8?q?feat=20:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=B0=B8=EC=97=AC=EC=8B=9C=EC=97=90=EB=8F=84=20?= =?UTF-8?q?=EC=B1=84=ED=8C=85=EB=B0=A9=20=EC=9E=85=EC=9E=A5=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/service/ManualMatchingService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 219b48d6..e9c9512d 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.matching.common.service; import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.service.ChattingParticipantService; import com.gachtaxi.domain.chat.service.ChattingRoomService; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; @@ -46,6 +47,7 @@ public class ManualMatchingService { private final MatchingInvitationService matchingInvitationService; private final BlacklistService blacklistService; private final ChattingRoomService chattingRoomService; + private final ChattingParticipantService chattingParticipantService; private final MatchingRoomRepository matchingRoomRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; @@ -140,6 +142,8 @@ public void joinManualMatchingRoom(Long userId, Long roomId) { matchingRoom.completeMatchingRoom(); this.matchingRoomRepository.save(matchingRoom); } + + chattingParticipantService.joinChattingRoom(user, matchingRoom.getChattingRoomId()); } /* todo 수동 매칭 → 자동 매칭 전환 : 추후 고도화시, 10분전에 유저에게 알림을 주고 자동 매칭으로 전환 From c1a1505b3a7dbbd754998aeccf9a6b9ee35edfd0 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 05:19:19 +0900 Subject: [PATCH 723/770] =?UTF-8?q?refactor=20:=20=EC=88=98=EB=8F=99?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=EC=97=90=20chattingRoomId=20=ED=8F=AC=ED=95=A8?= =?UTF-8?q?=EC=8B=9C=EC=BC=9C=EC=84=9C=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/response/MatchingRoomResponse.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java index c5ec997a..f44771f9 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java @@ -12,7 +12,8 @@ public record MatchingRoomResponse( LocalDateTime departureTime, int maxCapacity, int currentMembers, - List tags + List tags, + Long chattingRoomId ) { public static MatchingRoomResponse from(MatchingRoom matchingRoom) { return new MatchingRoomResponse( @@ -23,7 +24,8 @@ public static MatchingRoomResponse from(MatchingRoom matchingRoom) { matchingRoom.getDepartureTime(), matchingRoom.getCapacity(), matchingRoom.getCurrentMemberCount(), - matchingRoom.getTags() + matchingRoom.getTags(), + matchingRoom.getChattingRoomId() ); } } From f027d98df163b8f616acb6f2d630b1788990d885 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 4 Feb 2025 10:02:21 +0900 Subject: [PATCH 724/770] =?UTF-8?q?refactor:=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/{SesClinetConfig.java => SesClientConfig.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/com/gachtaxi/global/config/{SesClinetConfig.java => SesClientConfig.java} (97%) diff --git a/src/main/java/com/gachtaxi/global/config/SesClinetConfig.java b/src/main/java/com/gachtaxi/global/config/SesClientConfig.java similarity index 97% rename from src/main/java/com/gachtaxi/global/config/SesClinetConfig.java rename to src/main/java/com/gachtaxi/global/config/SesClientConfig.java index de60f62c..b7274ab0 100644 --- a/src/main/java/com/gachtaxi/global/config/SesClinetConfig.java +++ b/src/main/java/com/gachtaxi/global/config/SesClientConfig.java @@ -10,7 +10,7 @@ import software.amazon.awssdk.services.ses.SesClient; @Configuration -public class SesClinetConfig { +public class SesClientConfig { @Value("${aws.ses.accessKey}") private String accessKey; From 1763749946d970a5678deb44e3b3f43d9db950c5 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 4 Feb 2025 10:03:53 +0900 Subject: [PATCH 725/770] =?UTF-8?q?refactor:=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=EC=8B=9C=20=EC=B1=84=ED=8C=85=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=ED=95=A8=EA=BB=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChattingMessageMongoRepository.java | 20 +++++++++++++++---- .../domain/members/service/MemberService.java | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageMongoRepository.java b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageMongoRepository.java index b2a47f93..84b6e2da 100644 --- a/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageMongoRepository.java +++ b/src/main/java/com/gachtaxi/domain/chat/repository/ChattingMessageMongoRepository.java @@ -1,8 +1,8 @@ package com.gachtaxi.domain.chat.repository; import com.gachtaxi.domain.chat.entity.ChattingMessage; +import com.gachtaxi.domain.members.entity.Members; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; @@ -13,12 +13,12 @@ import java.time.LocalDateTime; -@Slf4j @Repository @RequiredArgsConstructor public class ChattingMessageMongoRepository { private static final String COLLECTION = "chatting_messages"; + private static final String EMPTY_READ_MESSAGE = "NO_MESSAGES"; private final MongoTemplate mongoTemplate; public Pair updateUnreadCount(Long roomId, LocalDateTime lastReadAt, Long senderId) { @@ -32,6 +32,18 @@ public Pair updateUnreadCount(Long roomId, LocalDateTime lastRea return range; } + public void updateMemberInfo(Members member) { + Query query = new Query(); + query.addCriteria(Criteria.where("senderId").is(member.getId())); + + Update update = new Update() + .set("profilePicture", member.getProfilePicture()) + .set("senderName", member.getNickname()) + .set("updatedAt", LocalDateTime.now()); + + mongoTemplate.updateMulti(query, update, ChattingMessage.class); + } + private Pair getUpdatedMessageRange(Long roomId, LocalDateTime lastReadAt, Long senderId) { Query minQuery = new Query().addCriteria(buildCommonCriteria(roomId, lastReadAt, senderId)) .with(Sort.by(Sort.Direction.ASC, "_id")).limit(1); @@ -42,8 +54,8 @@ private Pair getUpdatedMessageRange(Long roomId, LocalDateTime l ChattingMessage minMessage = mongoTemplate.findOne(minQuery, ChattingMessage.class, COLLECTION); ChattingMessage maxMessage = mongoTemplate.findOne(maxQuery, ChattingMessage.class, COLLECTION); - String minId = (minMessage != null) ? minMessage.getId() : "NO_MESSAGES"; - String maxId = (maxMessage != null) ? maxMessage.getId() : "NO_MESSAGES"; + String minId = (minMessage != null) ? minMessage.getId() : EMPTY_READ_MESSAGE; + String maxId = (maxMessage != null) ? maxMessage.getId() : EMPTY_READ_MESSAGE; return Pair.of(minId, maxId); } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 0a9781e7..9f647762 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.chat.repository.ChattingMessageMongoRepository; import com.gachtaxi.domain.members.dto.request.*; import com.gachtaxi.domain.members.dto.response.MemberResponseDto; import com.gachtaxi.domain.members.entity.Members; @@ -20,6 +21,7 @@ public class MemberService { private final MemberRepository memberRepository; + private final ChattingMessageMongoRepository chattingMessageMongoRepository; @Transactional public InactiveMemberDto saveTmpKakaoMember(Long kakaoId){ @@ -38,6 +40,8 @@ public MemberResponseDto updateMemberInfo(Long currentId, MemberInfoRequestDto d Members member = findById(currentId); member.updateMemberInfo(dto); + chattingMessageMongoRepository.updateMemberInfo(member); + return MemberResponseDto.from(member); } From 4f6a5e22e8aeffa74b0a8da7346d35e9ab20041b Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 16:23:38 +0900 Subject: [PATCH 726/770] =?UTF-8?q?fix=20:=20=EC=88=9C=ED=99=98=EC=B0=B8?= =?UTF-8?q?=EC=A1=B0=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ChattingParticipantService.java | 18 ------------------ .../chat/service/ChattingRoomService.java | 14 -------------- .../dto/response/MatchingRoomResponse.java | 6 ++---- .../matching/common/entity/MatchingRoom.java | 4 ---- .../common/service/ManualMatchingService.java | 11 ----------- 5 files changed, 2 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java index eb59d911..c0c8ca85 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingParticipantService.java @@ -6,14 +6,11 @@ import com.gachtaxi.domain.chat.entity.ChattingRoom; import com.gachtaxi.domain.chat.entity.enums.MessageType; import com.gachtaxi.domain.chat.exception.ChattingParticipantNotFoundException; -import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.exception.DuplicateSubscribeException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageMongoRepository; import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; -import com.gachtaxi.domain.chat.repository.ChattingRoomRepository; import com.gachtaxi.domain.members.entity.Members; -import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.listener.ChannelTopic; @@ -28,10 +25,8 @@ public class ChattingParticipantService { private final ChattingParticipantRepository chattingParticipantRepository; private final ChattingMessageMongoRepository chattingMessageMongoRepository; - private final ChattingRoomRepository chattingRoomRepository; private final ChattingRedisService chattingRedisService; private final RedisChatPublisher redisChatPublisher; - private final ChattingRoomService chattingRoomService; @Value("${chat.topic}") public String chatTopic; @@ -90,17 +85,4 @@ private void reEnterEvent(long roomId, long senderId, String senderName, ReadMes redisChatPublisher.publish(topic, chatMessage); } - - @Transactional - public void joinChattingRoom(Members user, Long chattingRoomId) { - ChattingRoom chattingRoom = chattingRoomRepository.findById(chattingRoomId) - .orElseThrow(ChattingRoomNotFoundException::new); - - if (chattingParticipantRepository.findByChattingRoomAndMembers(chattingRoom, user).isPresent()) { - return; - } - - ChattingParticipant chattingParticipant = ChattingParticipant.of(chattingRoom, user); - chattingParticipantRepository.save(chattingParticipant); - } } diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index fd642dcf..21954a4d 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -11,7 +11,6 @@ import com.gachtaxi.domain.chat.exception.ChattingRoomNotFoundException; import com.gachtaxi.domain.chat.redis.RedisChatPublisher; import com.gachtaxi.domain.chat.repository.ChattingMessageRepository; -import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; import com.gachtaxi.domain.chat.repository.ChattingRoomRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.service.MemberService; @@ -35,7 +34,6 @@ public class ChattingRoomService { private final ChattingRoomRepository chattingRoomRepository; private final ChattingMessageRepository chattingMessageRepository; - private final ChattingParticipantRepository chattingParticipantRepository; private final ChattingParticipantService chattingParticipantService; private final MemberService memberService; private final RedisChatPublisher redisChatPublisher; @@ -117,16 +115,4 @@ private void publishMessage(long roomId, long senderId, String senderName, Strin redisChatPublisher.publish(topic, chatMessage); } - - @Transactional - public ChattingRoom create(Members roomMaster) { - - ChattingRoom chattingRoom = ChattingRoom.builder().build(); - ChattingRoom savedChattingRoom = chattingRoomRepository.save(chattingRoom); - - ChattingParticipant chattingParticipant = ChattingParticipant.of(savedChattingRoom, roomMaster); - chattingParticipantRepository.save(chattingParticipant); - - return savedChattingRoom; - } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java index f44771f9..c5ec997a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java @@ -12,8 +12,7 @@ public record MatchingRoomResponse( LocalDateTime departureTime, int maxCapacity, int currentMembers, - List tags, - Long chattingRoomId + List tags ) { public static MatchingRoomResponse from(MatchingRoom matchingRoom) { return new MatchingRoomResponse( @@ -24,8 +23,7 @@ public static MatchingRoomResponse from(MatchingRoom matchingRoom) { matchingRoom.getDepartureTime(), matchingRoom.getCapacity(), matchingRoom.getCurrentMemberCount(), - matchingRoom.getTags(), - matchingRoom.getChattingRoomId() + matchingRoom.getTags() ); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index a0d15be3..dd5f1a80 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -158,8 +158,4 @@ public List getTags() { .map(tagInfo -> tagInfo.getTags().name()) .toList(); } - - public void setChattingRoomId(Long chattingRoomId) { - this.chattingRoomId = chattingRoomId; - } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index e9c9512d..9d1ab15e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -1,8 +1,5 @@ package com.gachtaxi.domain.matching.common.service; -import com.gachtaxi.domain.chat.entity.ChattingRoom; -import com.gachtaxi.domain.chat.service.ChattingParticipantService; -import com.gachtaxi.domain.chat.service.ChattingRoomService; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; @@ -46,8 +43,6 @@ public class ManualMatchingService { private final MatchingRoomService matchingRoomService; private final MatchingInvitationService matchingInvitationService; private final BlacklistService blacklistService; - private final ChattingRoomService chattingRoomService; - private final ChattingParticipantService chattingParticipantService; private final MatchingRoomRepository matchingRoomRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; @@ -76,10 +71,6 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) request.departureTime() ); - ChattingRoom chattingRoom = chattingRoomService.create(roomMaster); - - matchingRoom.setChattingRoomId(chattingRoom.getId()); - MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); matchingInvitationService.sendMatchingInvitation(roomMaster, request.getFriendNicknames(), savedMatchingRoom.getId()); @@ -142,8 +133,6 @@ public void joinManualMatchingRoom(Long userId, Long roomId) { matchingRoom.completeMatchingRoom(); this.matchingRoomRepository.save(matchingRoom); } - - chattingParticipantService.joinChattingRoom(user, matchingRoom.getChattingRoomId()); } /* todo 수동 매칭 → 자동 매칭 전환 : 추후 고도화시, 10분전에 유저에게 알림을 주고 자동 매칭으로 전환 From da15e4df63d21b5b46f0d1c919e5b34c58d5d8e9 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 16:57:22 +0900 Subject: [PATCH 727/770] =?UTF-8?q?refactor=20:=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=98=ED=99=98=20DTO=EC=97=90=EC=84=9C=20chatti?= =?UTF-8?q?ngRoomId=20=ED=95=A8=EA=BB=98=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/response/MatchingRoomResponse.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java index c5ec997a..f6f02547 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomResponse.java @@ -6,6 +6,7 @@ public record MatchingRoomResponse( Long roomId, + Long chattingRoomId, String description, String departure, String destination, @@ -17,6 +18,7 @@ public record MatchingRoomResponse( public static MatchingRoomResponse from(MatchingRoom matchingRoom) { return new MatchingRoomResponse( matchingRoom.getId(), + matchingRoom.getChattingRoomId(), matchingRoom.getDescription(), matchingRoom.getDeparture(), matchingRoom.getDestination(), From bbbb255b6cf702d8eb0f2f5b3aa41d1b31e53d41 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 16:59:15 +0900 Subject: [PATCH 728/770] =?UTF-8?q?refactor=20:=20=EC=88=98=EB=8F=99?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EC=83=9D=EC=84=B1=EC=8B=9C=20manualOf=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=EB=A1=9C=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=EB=8F=84=20=EA=B0=99=EC=9D=B4=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index dd5f1a80..4478a681 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -122,7 +122,7 @@ public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, .build(); } - public static MatchingRoom manualOf(Members roomMaster, String departure, String destination, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime) { + public static MatchingRoom manualOf(Members roomMaster, String departure, String destination, String description, int maxCapacity, int totalCharge, LocalDateTime departureTime, Long chattingRoomId) { return MatchingRoom.builder() .capacity(4) .roomMaster(roomMaster) @@ -131,6 +131,7 @@ public static MatchingRoom manualOf(Members roomMaster, String departure, String .destination(destination) .totalCharge(totalCharge) .departureTime(departureTime) + .chattingRoomId(chattingRoomId) .matchingRoomType(MatchingRoomType.MANUAL) .matchingRoomStatus(MatchingRoomStatus.ACTIVE) .build(); From 429d1f70acba16a878ab3f7fe02327bb8ddddf99 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 17:00:11 +0900 Subject: [PATCH 729/770] =?UTF-8?q?refactor=20:=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=A3=B8id=20=EB=B0=98=ED=99=98=20=EC=84=9C=EB=B9=84=EC=8A=A4?= =?UTF-8?q?=EB=8B=A8=EC=97=90=EC=84=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/ManualMatchingService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index 9d1ab15e..c92be4f1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -1,5 +1,7 @@ package com.gachtaxi.domain.matching.common.service; +import com.gachtaxi.domain.chat.entity.ChattingRoom; +import com.gachtaxi.domain.chat.repository.ChattingRoomRepository; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomResponse; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; @@ -45,6 +47,7 @@ public class ManualMatchingService { private final BlacklistService blacklistService; private final MatchingRoomRepository matchingRoomRepository; private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; + private final ChattingRoomRepository chattingRoomRepository; /* 수동 매칭 방 생성 @@ -61,6 +64,10 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) throw new NotEqualStartAndDestinationException(); } + ChattingRoom chattingRoom = ChattingRoom.builder() + .build(); + chattingRoomRepository.save(chattingRoom); + MatchingRoom matchingRoom = MatchingRoom.manualOf( roomMaster, request.getDeparture(), @@ -68,7 +75,8 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) request.description(), 4, request.getTotalCharge(), - request.departureTime() + request.departureTime(), + chattingRoom.getId() ); MatchingRoom savedMatchingRoom = matchingRoomRepository.save(matchingRoom); From a1b74a03b2d60f874c47c5e57350036e85b23024 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 17:25:39 +0900 Subject: [PATCH 730/770] =?UTF-8?q?refactor=20:=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=B0=98=ED=99=98=20Slice=20=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20=EB=AC=B4=ED=95=9C=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A1=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ManualMatchingController.java | 6 +++--- .../dto/response/MatchingPageableResponse.java | 14 +++++++------- .../dto/response/MatchingRoomListResponse.java | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index 2ec861bf..b5370914 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -20,7 +20,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; +import org.springframework.data.domain.Slice; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -71,14 +71,14 @@ public ApiResponse leaveManualMatchingRoom(@CurrentMemberId Long userId, @ @Operation(summary = "수동 매칭방 조회") @GetMapping("/list") public ApiResponse getManualMatchingList(int pageNumber, int pageSize) { - Page rooms = manualMatchingService.getManualMatchingList(pageNumber, pageSize); + Slice rooms = manualMatchingService.getManualMatchingList(pageNumber, pageSize); return ApiResponse.response(OK, GET_MANUAL_MATCHING_LIST_SUCCESS.getMessage(), MatchingRoomListResponse.of(rooms)); } @Operation(summary = "나의 매칭(수동) 조회") @GetMapping("/my-list") public ApiResponse getMyMatchingList(@CurrentMemberId Long userId, int pageNumber, int pageSize) { - Page rooms = manualMatchingService.getMyMatchingList(userId, pageNumber, pageSize); + Slice rooms = manualMatchingService.getMyMatchingList(userId, pageNumber, pageSize); return ApiResponse.response(OK, GET_MY_MATCHING_LIST_SUCCESS.getMessage(), MatchingRoomListResponse.of(rooms)); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java index 1f469857..05700960 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java @@ -1,7 +1,7 @@ package com.gachtaxi.domain.matching.common.dto.response; import lombok.Builder; -import org.springframework.data.domain.Page; +import org.springframework.data.domain.Slice; @Builder @@ -9,14 +9,14 @@ public record MatchingPageableResponse( int pageNumber, int pageSize, int numberOfElements, - boolean last + boolean hasNext ) { - public static MatchingPageableResponse of(Page page) { + public static MatchingPageableResponse of(Slice Slice) { return MatchingPageableResponse.builder() - .pageNumber(page.getNumber()) - .pageSize(page.getSize()) - .numberOfElements(page.getNumberOfElements()) - .last(page.isLast()) + .pageNumber(Slice.getNumber()) + .pageSize(Slice.getSize()) + .numberOfElements(Slice.getNumberOfElements()) + .hasNext(Slice.hasNext()) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java index 4b954bf5..ad6a01c6 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java @@ -2,17 +2,17 @@ import java.util.List; import lombok.Builder; -import org.springframework.data.domain.Page; +import org.springframework.data.domain.Slice; @Builder public record MatchingRoomListResponse( List rooms, MatchingPageableResponse pageable ) { - public static MatchingRoomListResponse of(Page page) { + public static MatchingRoomListResponse of(Slice Slice) { return MatchingRoomListResponse.builder() - .rooms(page.getContent()) - .pageable(MatchingPageableResponse.of(page)) + .rooms(Slice.getContent()) + .pageable(MatchingPageableResponse.of(Slice)) .build(); } } From cd1771095b556338027b0da38fa24221b28e8c00 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Tue, 4 Feb 2025 17:28:05 +0900 Subject: [PATCH 731/770] =?UTF-8?q?refactor=20:=20isLast=EB=A1=9C=20?= =?UTF-8?q?=EB=A7=88=EC=A7=80=EB=A7=89=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dto/response/MatchingPageableResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java index 05700960..f13c34e7 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java @@ -9,14 +9,14 @@ public record MatchingPageableResponse( int pageNumber, int pageSize, int numberOfElements, - boolean hasNext + boolean isLast ) { public static MatchingPageableResponse of(Slice Slice) { return MatchingPageableResponse.builder() .pageNumber(Slice.getNumber()) .pageSize(Slice.getSize()) .numberOfElements(Slice.getNumberOfElements()) - .hasNext(Slice.hasNext()) + .isLast(Slice.isLast()) .build(); } } From 360da41fec8cbc9f059339ed81d4fc8343a11b68 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 4 Feb 2025 17:33:56 +0900 Subject: [PATCH 732/770] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=A0=ED=8A=B8=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=84=9C=EB=B2=84=20cors=20=ED=95=B4?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index 41def4ab..cc5ae2fe 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -25,7 +25,7 @@ public void registerStompEndpoints(StompEndpointRegistry registry) { registry .setErrorHandler(stompExceptionHandler) .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3000") + .setAllowedOriginPatterns("http://localhost:3000", "https://*.amplifyapp.com") .withSockJS(); } From 98b649700d6585bd08525c0e2f834389c95d683b Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 17:40:38 +0900 Subject: [PATCH 733/770] =?UTF-8?q?refactor:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=EC=97=90=20pageable=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/BlacklistGetResponse.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java index dfaf5047..9bf594e0 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java @@ -9,10 +9,7 @@ @Builder public record BlacklistGetResponse( List blacklists, - Integer pageNumber, - Integer pageSize, - Integer numberOfElements, - Boolean last + BlacklistPageable pageable ) { public static BlacklistGetResponse of(Slice blacklistsPage) { List responseList = blacklistsPage.stream() @@ -21,10 +18,7 @@ public static BlacklistGetResponse of(Slice blacklistsPage) { return BlacklistGetResponse.builder() .blacklists(responseList) - .pageNumber(blacklistsPage.getNumber()) - .pageSize(blacklistsPage.getSize()) - .numberOfElements(blacklistsPage.getNumberOfElements()) - .last(blacklistsPage.isLast()) + .pageable(BlacklistPageable.of(blacklistsPage)) .build(); } @@ -41,4 +35,21 @@ public static BlacklistInfo of(Blacklists blacklists) { ); } } + + record BlacklistPageable( + Integer pageNumber, + Integer pageSize, + Integer numberOfElements, + Boolean last + ) { + + public static BlacklistPageable of (Slice blacklistsPage) { + return new BlacklistPageable( + blacklistsPage.getNumber(), + blacklistsPage.getSize(), + blacklistsPage.getNumberOfElements(), + blacklistsPage.isLast() + ); + } + } } From 817d8426b9231cdec05be77162a727bd80c3771e Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 17:41:59 +0900 Subject: [PATCH 734/770] =?UTF-8?q?refactor:=20=EB=B8=94=EB=9E=99=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=9D=91=EB=8B=B5=EC=97=90=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/response/BlacklistGetResponse.java | 4 +++- .../java/com/gachtaxi/domain/members/entity/Blacklists.java | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java index 9bf594e0..6c88d37a 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/BlacklistGetResponse.java @@ -25,13 +25,15 @@ public static BlacklistGetResponse of(Slice blacklistsPage) { record BlacklistInfo( Long receiverId, String receiverNickname, + String receiverProfilePicture, String gender ) { public static BlacklistInfo of(Blacklists blacklists) { return new BlacklistInfo( blacklists.getReceiver().getId(), blacklists.getReceiver().getNickname(), - blacklists.getReceiver().getGender().name() + blacklists.getReceiver().getGender().name(), + blacklists.getReceiverProfilePicture() ); } } diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Blacklists.java b/src/main/java/com/gachtaxi/domain/members/entity/Blacklists.java index 3ccfd0a8..ade33cec 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Blacklists.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Blacklists.java @@ -28,6 +28,10 @@ public class Blacklists extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) private Members receiver; + public String getReceiverProfilePicture() { + return receiver.getProfilePicture(); + } + public static Blacklists create(Members requester, Members receiver) { return Blacklists.builder() .requester(requester) From 2c74a30e7b6ab18fc1d168a6a440b2d87052d1c7 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 18:11:33 +0900 Subject: [PATCH 735/770] =?UTF-8?q?refactor:=20=EC=9E=90=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EC=97=90=EC=84=9C=20=EC=9D=B4=EB=AF=B8=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EB=8A=94=20=EB=B0=A9=EC=97=90=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EC=9A=94=EC=B2=AD=EC=8B=9C=20409=EC=99=80=20?= =?UTF-8?q?=ED=95=A8=EA=BB=98=20=EC=B1=84=ED=8C=85=EB=B0=A9=20id=20?= =?UTF-8?q?=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingAlgorithmServiceImpl.java | 14 +++++++++++--- .../exception/AlreadyInMatchingRoomException.java | 5 +++++ .../common/repository/MatchingRoomRepository.java | 10 +++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java index ce689b57..884cdf09 100644 --- a/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java +++ b/src/main/java/com/gachtaxi/domain/matching/algorithm/service/MatchingAlgorithmServiceImpl.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service @@ -21,6 +22,9 @@ public class MatchingAlgorithmServiceImpl implements MatchingAlgorithmService { private final MemberService memberService; private final BlacklistService blacklistService; + @Value("${gachtaxi.matching.auto-matching-description}") + private String autoMatchingDescription; + private static final double SEARCH_RADIUS = 300.0; @Override @@ -32,9 +36,13 @@ public Optional findRoom(Long userId, double startLongitude, dou */ Members user = memberService.findById(userId); - if (matchingRoomRepository.existsByMemberInMatchingRoom(user)) { - throw new AlreadyInMatchingRoomException(); // * 추후 논의 후 리팩토링 필요 * 똑같은 조건으로 방 생성시 예외 던져주기 - } + matchingRoomRepository.findByMemberInMatchingRoom(user) + .forEach(room -> { + if (room.getDescription().equals(autoMatchingDescription)) { + throw new AlreadyInMatchingRoomException(room.getChattingRoomId()); + } + }); + /* 위치 정보를 이용한 방 검색(300M 이내)ø */ diff --git a/src/main/java/com/gachtaxi/domain/matching/common/exception/AlreadyInMatchingRoomException.java b/src/main/java/com/gachtaxi/domain/matching/common/exception/AlreadyInMatchingRoomException.java index a2b2cb44..6d048baa 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/exception/AlreadyInMatchingRoomException.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/exception/AlreadyInMatchingRoomException.java @@ -4,8 +4,13 @@ import static org.springframework.http.HttpStatus.CONFLICT; import com.gachtaxi.global.common.exception.BaseException; +import java.util.Map; public class AlreadyInMatchingRoomException extends BaseException { + public AlreadyInMatchingRoomException(Long chattingRoomId) { + super(CONFLICT, Map.of("chattingRoomId", chattingRoomId, "message", ALREADY_IN_MATCHING_ROOM.getMessage()).toString()); + } + public AlreadyInMatchingRoomException() { super(CONFLICT, ALREADY_IN_MATCHING_ROOM.getMessage()); } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index 29914787..e0f01d61 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -5,6 +5,7 @@ import com.gachtaxi.domain.matching.common.entity.enums.MatchingRoomType; import com.gachtaxi.domain.members.entity.Members; import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -25,11 +26,18 @@ List findRoomsByStartAndDestination( @Param("destinationLatitude") double destinationLatitude, @Param("radius") double radius ); - @Query("SELECT CASE WHEN COUNT(m) > 0 THEN true ELSE false END " + + @Query("SELECT r " + "FROM MatchingRoom r JOIN r.memberMatchingRoomChargingInfo m " + "WHERE m.members = :user "+ "AND r.matchingRoomStatus = 'ACTIVE' "+ "AND m.paymentStatus != 'LEFT'") + List findByMemberInMatchingRoom(@Param("user") Members user); + + @Query("SELECT CASE WHEN COUNT(m) > 0 THEN true ELSE false END" + + "FROM MatchingRoom r JOIN r.memberMatchingRoomChargingInfo m " + + "WHERE m.members = :user "+ + "AND r.matchingRoomStatus = 'ACTIVE' "+ + "AND m.paymentStatus != 'LEFT'") boolean existsByMemberInMatchingRoom(@Param("user") Members user); Page findByMatchingRoomTypeAndMatchingRoomStatus(MatchingRoomType type, MatchingRoomStatus status, Pageable pageable); From 023caae112cd34d52160367f5f0ca5e8bd18485d Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 18:36:03 +0900 Subject: [PATCH 736/770] =?UTF-8?q?fix:=20MatchingRoomRepository=20?= =?UTF-8?q?=EB=B9=8C=EB=93=9C=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/repository/MatchingRoomRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java index e0f01d61..d2f6ee77 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/repository/MatchingRoomRepository.java @@ -33,7 +33,7 @@ List findRoomsByStartAndDestination( "AND m.paymentStatus != 'LEFT'") List findByMemberInMatchingRoom(@Param("user") Members user); - @Query("SELECT CASE WHEN COUNT(m) > 0 THEN true ELSE false END" + + @Query("SELECT CASE WHEN COUNT(m) > 0 THEN true ELSE false END " + "FROM MatchingRoom r JOIN r.memberMatchingRoomChargingInfo m " + "WHERE m.members = :user "+ "AND r.matchingRoomStatus = 'ACTIVE' "+ From 041ecd14b738e3a142aff81ef7add117bd8d459f Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 18:38:19 +0900 Subject: [PATCH 737/770] =?UTF-8?q?hotfix:=20CI=20=EC=99=80=20CD=20?= =?UTF-8?q?=EA=B0=80=20=EA=B0=99=EC=9D=B4=20=EB=8F=99=EC=9E=91=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 4782f3c8..1f273a76 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -50,7 +50,7 @@ jobs: deploy: runs-on: ubuntu-latest needs: build -# if: github.event_name == 'push' + if: github.event_name == 'push' steps: # SSH를 사용하여 원격 서버에 배포 From 861c8241674a2635848765a205dc12734268726b Mon Sep 17 00:00:00 2001 From: hyxklee Date: Tue, 4 Feb 2025 21:30:10 +0900 Subject: [PATCH 738/770] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=A0=ED=8A=B8=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=84=9C=EB=B2=84=20cors=20=ED=95=B4?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/global/config/WebSocketConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java index cc5ae2fe..ead72f35 100644 --- a/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java +++ b/src/main/java/com/gachtaxi/global/config/WebSocketConfig.java @@ -25,7 +25,7 @@ public void registerStompEndpoints(StompEndpointRegistry registry) { registry .setErrorHandler(stompExceptionHandler) .addEndpoint("/ws") - .setAllowedOriginPatterns("http://localhost:3000", "https://*.amplifyapp.com") + .setAllowedOriginPatterns("http://localhost:3000", "https://*.amplifyapp.com", "https://gachtaxi.site") .withSockJS(); } From 7b4e01cd00fee96fc7ab4b6dd274add7247556f6 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:03:13 +0900 Subject: [PATCH 739/770] =?UTF-8?q?refactor:=20=EB=A7=A4=EC=B9=AD=EB=B0=A9?= =?UTF-8?q?=EA=B3=BC=20=EC=B1=84=ED=8C=85=EB=B0=A9=20=EC=97=B0=EA=B4=80?= =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/entity/MatchingRoom.java | 8 ++++---- .../matching/common/service/MatchingRoomService.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index ad966ac9..c4116321 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -64,9 +64,9 @@ public class MatchingRoom extends BaseEntity { @Enumerated(EnumType.STRING) private MatchingRoomStatus matchingRoomStatus; - @OneToOne + @Column(name = "chatting_room_id") @Getter - private ChattingRoom chattingRoom; + private Long chattingRoomId; public boolean isActive() { return this.matchingRoomStatus == MatchingRoomStatus.ACTIVE; @@ -97,7 +97,7 @@ public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, .route(route) .totalCharge(matchRoomCreatedEvent.expectedTotalCharge()) .matchingRoomStatus(MatchingRoomStatus.ACTIVE) - .chattingRoom(chattingRoom) + .chattingRoomId(chattingRoom.getId()) .build(); } public boolean containsTag(Tags tag) { @@ -108,7 +108,7 @@ public FindRoomResult toFindRoomResult() { return FindRoomResult.builder() .roomId(this.getId()) .maxCapacity(this.getCapacity()) - .chattingRoomId(this.getChattingRoom().getId()) + .chattingRoomId(this.chattingRoomId) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index b02338cb..82918752 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -66,7 +66,7 @@ public MatchRoomCreatedEvent createMatchingRoom(MatchRoomCreatedEvent matchRoomC MatchingRoom savedMatchingRoom = this.matchingRoomRepository.save(matchingRoom); - return MatchRoomCreatedEvent.of(matchRoomCreatedEvent, savedMatchingRoom.getId(), savedMatchingRoom.getChattingRoom().getId()); + return MatchRoomCreatedEvent.of(matchRoomCreatedEvent, savedMatchingRoom.getId(), savedMatchingRoom.getChattingRoomId()); } private Route saveRoute(MatchRoomCreatedEvent matchRoomCreatedEvent) { From e6b8ff8915b71c85c09dc89dcc52f2e9a52861fc Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:23:41 +0900 Subject: [PATCH 740/770] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=EC=8B=9C=20=EB=B0=94=EB=A1=9C=20=EB=B0=A9?= =?UTF-8?q?=EC=9E=A5=20=EC=B0=B8=EA=B0=80=ED=95=98=EB=8A=94=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/chat/service/ChattingRoomService.java | 3 +-- .../domain/matching/common/service/MatchingRoomService.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java index ce6c5f0d..67798292 100644 --- a/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/chat/service/ChattingRoomService.java @@ -43,9 +43,8 @@ public class ChattingRoomService { public String chatTopic; @Transactional - public ChattingRoom create(Members roomMaster) { + public ChattingRoom create() { ChattingRoom chattingRoom = ChattingRoom.builder().build(); - chattingParticipantService.save(ChattingParticipant.of(chattingRoom, roomMaster)); return chattingRoomRepository.save(chattingRoom); } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java index 82918752..dad029b8 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingRoomService.java @@ -57,7 +57,7 @@ public MatchRoomCreatedEvent createMatchingRoom(MatchRoomCreatedEvent matchRoomC Route route = this.saveRoute(matchRoomCreatedEvent); - ChattingRoom chattingRoom = this.chattingRoomService.create(members); + ChattingRoom chattingRoom = this.chattingRoomService.create(); MatchingRoom matchingRoom = MatchingRoom.activeOf(matchRoomCreatedEvent, members, route, chattingRoom); From a725bba0fec8be989318526195d9f5c70aef2df6 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:38:07 +0900 Subject: [PATCH 741/770] =?UTF-8?q?feat:=20=EA=B3=84=EC=A2=8C=20API=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20DTO=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/request/AccountPostRequest.java | 10 ++++++++++ .../members/dto/response/AccountGetResponse.java | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/request/AccountPostRequest.java create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/AccountPostRequest.java b/src/main/java/com/gachtaxi/domain/members/dto/request/AccountPostRequest.java new file mode 100644 index 00000000..36ea2628 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/AccountPostRequest.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.members.dto.request; + +import jakarta.validation.constraints.NotBlank; + +public record AccountPostRequest( + @NotBlank + String accountNumber +) { + +} diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java new file mode 100644 index 00000000..a01b1887 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java @@ -0,0 +1,10 @@ +package com.gachtaxi.domain.members.dto.response; + +public record AccountGetResponse( + String accountNumber +) { + + public static AccountGetResponse of(String accountNumber) { + return new AccountGetResponse(accountNumber); + } +} From d2a164a8d150f21e5554255cf13c430960f7627d Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:38:17 +0900 Subject: [PATCH 742/770] =?UTF-8?q?refactor:=20Member=EC=9D=98=20account?= =?UTF-8?q?=EC=97=90=20setter=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 29fa0ef9..ce1e5d99 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -13,6 +13,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import lombok.experimental.SuperBuilder; import org.hibernate.annotations.ColumnDefault; @@ -44,6 +45,7 @@ public class Members extends BaseEntity { private String phoneNumber; @Column(name = "account_number", unique = true) + @Setter private String accountNumber; @Column(name = "kakao_id", unique = true) From 82f45bb4b0bad153bcfd3152ba35de24e006a83c Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:38:26 +0900 Subject: [PATCH 743/770] =?UTF-8?q?feat:=20=EA=B3=84=EC=A2=8C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C,=20=EC=88=98=EC=A0=95=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AccountController.java | 41 +++++++++++++++++++ .../members/controller/ResponseMessage.java | 6 ++- .../members/service/AccountService.java | 26 ++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/controller/AccountController.java create mode 100644 src/main/java/com/gachtaxi/domain/members/service/AccountService.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java b/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java new file mode 100644 index 00000000..4786401b --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java @@ -0,0 +1,41 @@ +package com.gachtaxi.domain.members.controller; + +import static com.gachtaxi.domain.members.controller.ResponseMessage.ACCOUNT_GET_SUCCESS; +import static com.gachtaxi.domain.members.controller.ResponseMessage.ACCOUNT_UPDATE_SUCCESS; +import static org.springframework.http.HttpStatus.OK; + +import com.gachtaxi.domain.members.dto.request.AccountPostRequest; +import com.gachtaxi.domain.members.dto.response.AccountGetResponse; +import com.gachtaxi.domain.members.service.AccountService; +import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; +import com.gachtaxi.global.common.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/accounts") +@RequiredArgsConstructor +public class AccountController { + + private final AccountService accountService; + + @GetMapping + public ApiResponse getAccount( + @CurrentMemberId Long memberId + ) { + return ApiResponse.response(OK, ACCOUNT_GET_SUCCESS.getMessage(), AccountGetResponse.of(this.accountService.getAccount(memberId))); + } + + @PostMapping + public ApiResponse updateAccount( + @CurrentMemberId Long memberId, + @RequestBody AccountPostRequest accountPostRequest + ) { + this.accountService.updateAccount(memberId, accountPostRequest.accountNumber()); + return ApiResponse.response(OK, ACCOUNT_UPDATE_SUCCESS.getMessage()); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 5ff0272a..786f5fbf 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -21,7 +21,11 @@ public enum ResponseMessage { // BlacklistController BLACKLIST_SAVE_SUCCESS("블랙리스트 등록에 성공했습니다."), BLACKLIST_DELETE_SUCCESS("블랙리스트 삭제에 성공했습니다."), - BLACKLIST_FIND_ALL_SUCCESS("블랙리스트 조회에 성공했습니다."); + BLACKLIST_FIND_ALL_SUCCESS("블랙리스트 조회에 성공했습니다."), + + // AccountController + ACCOUNT_GET_SUCCESS("계좌 정보를 성공적으로 가져왔습니다."), + ACCOUNT_UPDATE_SUCCESS("계좌 정보를 성공적으로 수정했습니다."); private final String message; } diff --git a/src/main/java/com/gachtaxi/domain/members/service/AccountService.java b/src/main/java/com/gachtaxi/domain/members/service/AccountService.java new file mode 100644 index 00000000..974136c6 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/service/AccountService.java @@ -0,0 +1,26 @@ +package com.gachtaxi.domain.members.service; + +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.repository.MemberRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class AccountService { + + private final MemberService memberService; + + private final MemberRepository memberRepository; + + public String getAccount(Long memberId) { + return this.memberService.findById(memberId).getAccountNumber(); + } + + public void updateAccount(Long memberId, String accountNumber) { + Members member = this.memberService.findById(memberId); + + member.setAccountNumber(accountNumber); + this.memberRepository.save(member); + } +} From 61244045748f599e9f843d614bc96f9d63f0f891 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:40:54 +0900 Subject: [PATCH 744/770] =?UTF-8?q?feat:=20request=20body=EC=97=90=20valid?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/controller/AccountController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java b/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java index 4786401b..c6addabe 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java @@ -9,6 +9,7 @@ import com.gachtaxi.domain.members.service.AccountService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -33,7 +34,7 @@ public ApiResponse getAccount( @PostMapping public ApiResponse updateAccount( @CurrentMemberId Long memberId, - @RequestBody AccountPostRequest accountPostRequest + @RequestBody @Valid AccountPostRequest accountPostRequest ) { this.accountService.updateAccount(memberId, accountPostRequest.accountNumber()); return ApiResponse.response(OK, ACCOUNT_UPDATE_SUCCESS.getMessage()); From fd2547d4eff3470f4d004b245a6c08510cac87bc Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:42:16 +0900 Subject: [PATCH 745/770] =?UTF-8?q?fix:=20=EB=B9=8C=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index cb5413a8..4039fad9 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -85,10 +85,6 @@ public class MatchingRoom extends BaseEntity { @Enumerated(EnumType.STRING) private MatchingRoomStatus matchingRoomStatus; - @Column(name = "chatting_room_id") - @Getter - private Long chattingRoomId; - @Enumerated(EnumType.STRING) private MatchingRoomType matchingRoomType; From c6e1b54855668ec5f94c79a85ffe429754b2f260 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:43:37 +0900 Subject: [PATCH 746/770] =?UTF-8?q?fix:=20=EB=B9=8C=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/matching/common/entity/MatchingRoom.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 4039fad9..6a086794 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -108,13 +108,11 @@ public boolean isFull(int size) { return size == totalCharge; } - public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route, ChattingRoom chattingRoom) { - public void convertToAutoMatching() { this.matchingRoomType = MatchingRoomType.AUTO; } public boolean isAutoConvertible(int currentMembers) { return currentMembers < this.capacity; } - public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route) { + public static MatchingRoom activeOf(MatchRoomCreatedEvent matchRoomCreatedEvent, Members members, Route route, ChattingRoom chattingRoom) { return MatchingRoom.builder() .capacity(matchRoomCreatedEvent.maxCapacity()) .roomMaster(members) From ea47105953a9b2c503a307cadf5073318aec0e3a Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:44:27 +0900 Subject: [PATCH 747/770] =?UTF-8?q?feat:=20=ED=8A=B8=EB=9E=9C=EC=9E=AD?= =?UTF-8?q?=EC=85=94=EB=84=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/members/service/AccountService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/members/service/AccountService.java b/src/main/java/com/gachtaxi/domain/members/service/AccountService.java index 974136c6..d180122c 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AccountService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AccountService.java @@ -2,6 +2,7 @@ import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.repository.MemberRepository; +import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -17,6 +18,7 @@ public String getAccount(Long memberId) { return this.memberService.findById(memberId).getAccountNumber(); } + @Transactional public void updateAccount(Long memberId, String accountNumber) { Members member = this.memberService.findById(memberId); From 29f395f8da3ef681a51ac15cec6119fe22a167d1 Mon Sep 17 00:00:00 2001 From: senna Date: Tue, 4 Feb 2025 23:53:28 +0900 Subject: [PATCH 748/770] =?UTF-8?q?refactor:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EB=93=B1=EB=A1=9D=20=EC=8B=9C=20=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=20String=EC=9C=BC=EB=A1=9C=20=EB=B0=9B=EC=95=84=20=ED=8C=8C?= =?UTF-8?q?=EC=8B=B1=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/ManualMatchingRequest.java | 2 +- .../matching/common/service/ManualMatchingService.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java index 3728585e..31508d6c 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingRequest.java @@ -19,7 +19,7 @@ public record ManualMatchingRequest( String destinationName, @NotNull - LocalDateTime departureTime, + String departureTime, @Schema(description = "예상 요금") @Min(value = 0) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java index c92be4f1..ceade367 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/ManualMatchingService.java @@ -26,6 +26,7 @@ import com.gachtaxi.domain.members.service.MemberService; import jakarta.transaction.Transactional; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; @@ -68,6 +69,9 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) .build(); chattingRoomRepository.save(chattingRoom); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime departureTime = LocalDateTime.parse(request.getDeparture(), formatter); + MatchingRoom matchingRoom = MatchingRoom.manualOf( roomMaster, request.getDeparture(), @@ -75,7 +79,7 @@ public Long createManualMatchingRoom(Long userId, ManualMatchingRequest request) request.description(), 4, request.getTotalCharge(), - request.departureTime(), + departureTime, chattingRoom.getId() ); From fe85e79b59642d817699199a25da6b8c3bd0218a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 5 Feb 2025 00:08:21 +0900 Subject: [PATCH 749/770] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EC=86=8C=ED=94=84=ED=8A=B8=20=EB=94=9C=EB=A6=AC?= =?UTF-8?q?=ED=8A=B8=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/MemberController.java | 10 ++++ .../members/controller/ResponseMessage.java | 1 + .../domain/members/entity/Members.java | 4 ++ .../members/entity/enums/UserStatus.java | 2 +- .../members/service/MemberDeleteService.java | 50 +++++++++++++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/service/MemberDeleteService.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java index c0c63770..c29107af 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/MemberController.java @@ -3,6 +3,7 @@ import com.gachtaxi.domain.members.dto.request.FcmTokenRequest; import com.gachtaxi.domain.members.dto.request.MemberInfoRequestDto; import com.gachtaxi.domain.members.dto.response.MemberResponseDto; +import com.gachtaxi.domain.members.service.MemberDeleteService; import com.gachtaxi.domain.members.service.MemberService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; @@ -22,6 +23,7 @@ public class MemberController { private final MemberService memberService; + private final MemberDeleteService memberDeleteService; @PatchMapping("/firebase") @Operation(summary = "fcm 토큰을 저장하기 위한 API입니다. 매 로그인 혹은 토큰 리프레시가 발생할 때 저장해주세요") @@ -46,4 +48,12 @@ public ApiResponse memberInfoModify( MemberResponseDto response = memberService.updateMemberInfo(currentId, dto); return ApiResponse.response(OK, MEMBER_INFO_UPDATE.getMessage(), response); } + + @DeleteMapping + @Operation(summary = "회원 탈퇴 API입니다. 관련 정보가 모두 삭제됩니다.") + public ApiResponse delete(@CurrentMemberId Long currentId) { + memberDeleteService.softDelete(currentId); + + return ApiResponse.response(OK, MEMBER_DELETE_SUCCESS.getMessage()); + } } diff --git a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java index 5ff0272a..35341987 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/ResponseMessage.java @@ -11,6 +11,7 @@ public enum ResponseMessage { MEMBER_INFO_UPDATE("유저 정보를 성공적으로 수정했습니다!"), MEMBER_INFO_RESPONSE("유저 정보를 반환합니다."), FCM_TOKEN_UPDATE_SUCCESS("FCM 토큰 업데이트에 성공했습니다."), + MEMBER_DELETE_SUCCESS("회원 탈퇴에 성공했습니다."), // AuthController ALREADY_SIGN_UP("이미 가입된 이메일 입니다!"), diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index 29fa0ef9..6ccb20ab 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -152,6 +152,10 @@ public boolean isRoomMaster(MatchingRoom matchingRoom){ return this.equals(matchingRoom.getRoomMaster()); } + public void delete() { + this.status = UserStatus.DELETED; + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/src/main/java/com/gachtaxi/domain/members/entity/enums/UserStatus.java b/src/main/java/com/gachtaxi/domain/members/entity/enums/UserStatus.java index 306e5999..2b7a5070 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/enums/UserStatus.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/enums/UserStatus.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.members.entity.enums; public enum UserStatus { - ACTIVE, INACTIVE + ACTIVE, INACTIVE, DELETED } diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberDeleteService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberDeleteService.java new file mode 100644 index 00000000..96d5ab70 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberDeleteService.java @@ -0,0 +1,50 @@ +package com.gachtaxi.domain.members.service; + +import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; +import com.gachtaxi.domain.friend.repository.FriendRepository; +import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; +import com.gachtaxi.domain.members.entity.Members; +import com.gachtaxi.domain.members.exception.MemberNotFoundException; +import com.gachtaxi.domain.members.repository.MemberRepository; +import com.gachtaxi.domain.notification.repository.NotificationRepository; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class MemberDeleteService { + + private final MemberRepository memberRepository; + private final FriendRepository friendRepository; + private final ChattingParticipantRepository chattingParticipantRepository; + private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; + private final NotificationRepository notificationRepository; + + /* + todo 채팅 메시지 수정 PR 머지 되면 (알수없음)으로 바꾸고 프사 삭제하기 + */ + + // 하드 딜리트 +// @Transactional +// public void delete(Long memberId) { +// Members member = memberRepository.findById(memberId) +// .orElseThrow(MemberNotFoundException::new); +// +// chattingParticipantRepository.deleteAllByMembers(member); +// friendRepository.deleteBySenderOrReceiver(member, member); +// memberMatchingRoomChargingInfoRepository.deleteAllByMembers(member); +// +// notificationRepository.deleteByReceiverId(memberId); +// memberRepository.deleteById(memberId); +// } + + // 소프트 딜리트 + @Transactional + public void softDelete(Long memberId) { + Members member = memberRepository.findById(memberId) + .orElseThrow(MemberNotFoundException::new); + + member.delete(); + } +} From 4c85167590b776cbb4dbf9af1eff72b6f1fa73aa Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 5 Feb 2025 00:08:36 +0900 Subject: [PATCH 750/770] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C=20ACTIVE=EC=9D=B8=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EB=A7=8C=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/members/repository/MemberRepository.java | 4 +++- .../com/gachtaxi/domain/members/service/MemberService.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java index 5514fc45..f6e82124 100644 --- a/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java +++ b/src/main/java/com/gachtaxi/domain/members/repository/MemberRepository.java @@ -2,10 +2,10 @@ import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.entity.enums.UserStatus; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.Optional; @Repository @@ -13,6 +13,8 @@ public interface MemberRepository extends JpaRepository { Optional findByEmail(String email); + Optional findByIdAndStatus(Long id, UserStatus status); + Optional findByStudentNumber(Long studentNumber); Optional findByKakaoId(Long kakaoId); diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index 0a9781e7..db46931e 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -87,7 +87,7 @@ public void updateFcmToken(Long userId, FcmTokenRequest request) { * */ public Members findById(Long id) { - return memberRepository.findById(id) + return memberRepository.findByIdAndStatus(id, ACTIVE) .orElseThrow(MemberNotFoundException::new); } From e2487ab6955a779fb9df1b53785a8951b5352e4a Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 5 Feb 2025 00:16:18 +0900 Subject: [PATCH 751/770] =?UTF-8?q?feat:=20=EC=9E=84=EC=8B=9C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/service/MemberService.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java index db46931e..c2e5fca3 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberService.java @@ -50,13 +50,13 @@ public InactiveMemberDto saveTmpGoogleMember(String googleId){ @Transactional public void updateMemberEmail(String email, Long userId) { - Members members = findById(userId); + Members members = findTempUserById(userId); members.updateEmail(email); } @Transactional public void updateMemberAgreement(MemberAgreementRequestDto dto, Long userId) { - Members members = findById(userId); + Members members = findTempUserById(userId); members.updateAgreement(dto); } @@ -65,7 +65,7 @@ public MemberResponseDto updateMemberSupplement(MemberSupplmentRequestDto dto, L checkDuplicatedNickName(dto.nickname()); checkDuplicatedStudentNumber(dto.studentNumber()); - Members members = findById(userId); + Members members = findTempUserById(userId); members.updateSupplment(dto); return MemberResponseDto.from(members); @@ -91,6 +91,11 @@ public Members findById(Long id) { .orElseThrow(MemberNotFoundException::new); } + public Members findTempUserById(Long id) { + return memberRepository.findById(id) + .orElseThrow(MemberNotFoundException::new); + } + public Members findActiveByEmail(String email) { return memberRepository.findByEmailAndStatus(email, ACTIVE) .orElseThrow(MemberNotFoundException::new); From 5944c919f8b20d1ade7d6caa411b4536f9099300 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 5 Feb 2025 00:22:00 +0900 Subject: [PATCH 752/770] =?UTF-8?q?feat=20:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=B4=88=EB=8C=80=EC=9D=91=EB=8B=B5=20api=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=82=AC=EC=9A=A9=ED=95=A0=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?dto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/ManualMatchingInviteReplyRequest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingInviteReplyRequest.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingInviteReplyRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingInviteReplyRequest.java new file mode 100644 index 00000000..09581de5 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/ManualMatchingInviteReplyRequest.java @@ -0,0 +1,14 @@ +package com.gachtaxi.domain.matching.common.dto.request; + +import com.gachtaxi.domain.matching.common.entity.enums.MatchingInviteStatus; +import jakarta.validation.constraints.NotNull; + +public record ManualMatchingInviteReplyRequest( + @NotNull + Long matchingRoomId, + @NotNull + String notificationId, + @NotNull + MatchingInviteStatus status + ) { +} From 4575a2625a2a90b42f02e8ab4c005fc55d471f46 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 5 Feb 2025 00:22:45 +0900 Subject: [PATCH 753/770] =?UTF-8?q?refactor=20:=20=EC=88=98=EB=8F=99?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=B4=88=EB=8C=80=20=EA=B1=B0=EC=A0=88?= =?UTF-8?q?=EC=8B=9C=EC=97=90=EB=8F=84=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MatchingInvitationService.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java index b38fee51..51c4c0b2 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java @@ -1,9 +1,10 @@ package com.gachtaxi.domain.matching.common.service; import static com.gachtaxi.domain.notification.entity.enums.NotificationType.MATCH_INVITE; - +import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingInviteReplyRequest; import com.gachtaxi.domain.matching.common.entity.MatchingRoom; import com.gachtaxi.domain.matching.common.entity.MemberMatchingRoomChargingInfo; +import com.gachtaxi.domain.matching.common.entity.enums.MatchingInviteStatus; import com.gachtaxi.domain.matching.common.exception.AlreadyInMatchingRoomException; import com.gachtaxi.domain.matching.common.exception.MatchingRoomAlreadyFullException; import com.gachtaxi.domain.matching.common.exception.NoSuchInvitationException; @@ -62,18 +63,23 @@ public void sendMatchingInvitation(Members sender, List friendNicknames, 수동 매칭시 친구 초대 수락 */ @Transactional - public void acceptInvitation(Long userId, Long matchingRoomId, String notificationId) { + public void acceptInvitation(Long userId, ManualMatchingInviteReplyRequest request) { Members member = memberService.findById(userId); - MatchingRoom matchingRoom = matchingRoomRepository.findById(matchingRoomId) + MatchingRoom matchingRoom = matchingRoomRepository.findById(request.matchingRoomId()) .orElseThrow(NoSuchMatchingRoomException::new); - Notification notification = notificationService.find(notificationId); + Notification notification = notificationService.find(request.notificationId()); MatchingInvitePayload payload = (MatchingInvitePayload) notification.getPayload(); - if (!payload.getMatchingRoomId().equals(matchingRoomId)) { + if (!payload.getMatchingRoomId().equals(request.matchingRoomId())) { throw new NoSuchInvitationException(); } + if (request.status() == MatchingInviteStatus.REJECT) { + notificationRepository.save(notification); + return; + } + notificationRepository.save(notification); if (notificationRepository.countByReceiverIdAndType(userId, NotificationType.MATCH_INVITE) == 0) { From 11953f2f58f487b4a242afbbfac27269f9ebcf23 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 5 Feb 2025 00:23:02 +0900 Subject: [PATCH 754/770] =?UTF-8?q?refactor:=20=ED=95=98=EB=93=9C=20?= =?UTF-8?q?=EB=94=9C=EB=A6=AC=ED=8A=B8=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/service/MemberDeleteService.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/service/MemberDeleteService.java b/src/main/java/com/gachtaxi/domain/members/service/MemberDeleteService.java index 96d5ab70..24e09287 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/MemberDeleteService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/MemberDeleteService.java @@ -1,12 +1,8 @@ package com.gachtaxi.domain.members.service; -import com.gachtaxi.domain.chat.repository.ChattingParticipantRepository; -import com.gachtaxi.domain.friend.repository.FriendRepository; -import com.gachtaxi.domain.matching.common.repository.MemberMatchingRoomChargingInfoRepository; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.exception.MemberNotFoundException; import com.gachtaxi.domain.members.repository.MemberRepository; -import com.gachtaxi.domain.notification.repository.NotificationRepository; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -16,30 +12,10 @@ public class MemberDeleteService { private final MemberRepository memberRepository; - private final FriendRepository friendRepository; - private final ChattingParticipantRepository chattingParticipantRepository; - private final MemberMatchingRoomChargingInfoRepository memberMatchingRoomChargingInfoRepository; - private final NotificationRepository notificationRepository; /* todo 채팅 메시지 수정 PR 머지 되면 (알수없음)으로 바꾸고 프사 삭제하기 */ - - // 하드 딜리트 -// @Transactional -// public void delete(Long memberId) { -// Members member = memberRepository.findById(memberId) -// .orElseThrow(MemberNotFoundException::new); -// -// chattingParticipantRepository.deleteAllByMembers(member); -// friendRepository.deleteBySenderOrReceiver(member, member); -// memberMatchingRoomChargingInfoRepository.deleteAllByMembers(member); -// -// notificationRepository.deleteByReceiverId(memberId); -// memberRepository.deleteById(memberId); -// } - - // 소프트 딜리트 @Transactional public void softDelete(Long memberId) { Members member = memberRepository.findById(memberId) From a7a926ba8000ae77c6a527f66165e748d30e4647 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 5 Feb 2025 00:23:06 +0900 Subject: [PATCH 755/770] =?UTF-8?q?feat=20:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=B4=88=EB=8C=80=20=EC=83=81=ED=83=9C=20enum?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/entity/enums/MatchingInviteStatus.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingInviteStatus.java diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingInviteStatus.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingInviteStatus.java new file mode 100644 index 00000000..38088735 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/enums/MatchingInviteStatus.java @@ -0,0 +1,5 @@ +package com.gachtaxi.domain.matching.common.entity.enums; + +public enum MatchingInviteStatus { + ACCEPT, REJECT +} From f42f18f11b3a3abbec0aa090a0a7c99fa7470fc8 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 5 Feb 2025 00:24:20 +0900 Subject: [PATCH 756/770] =?UTF-8?q?refactor=20:=20=EC=88=98=EB=8F=99?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=B4=88=EB=8C=80=20=EC=88=98=EB=9D=BD/?= =?UTF-8?q?=EA=B1=B0=EC=A0=88=20api=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC?= =?UTF-8?q?=EB=8B=A8=EC=97=90=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/ManualMatchingController.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java index b5370914..e85ba87e 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ManualMatchingController.java @@ -8,6 +8,7 @@ import static com.gachtaxi.domain.matching.common.controller.ResponseMessage.LEAVE_MANUAL_MATCHING_ROOM_SUCCESS; import static org.springframework.http.HttpStatus.OK; +import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingInviteReplyRequest; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingJoinRequest; import com.gachtaxi.domain.matching.common.dto.request.ManualMatchingRequest; import com.gachtaxi.domain.matching.common.dto.response.MatchingRoomListResponse; @@ -27,7 +28,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @Tag(name = "MANUAL", description = "수동매칭 API") @@ -53,11 +53,10 @@ public ApiResponse joinManualMatchingRoom(@CurrentMemberId Long userId, @V return ApiResponse.response(OK, JOIN_MANUAL_MATCHING_ROOM_SUCCESS.getMessage()); } - @Operation(summary = "수동 매칭 초대 수락") - @PostMapping("/invite/accept") - public ApiResponse acceptInvitation(@CurrentMemberId Long userId, @RequestParam Long matchingRoomId, @RequestParam String notificationId - ) { - matchingInvitationService.acceptInvitation(userId, matchingRoomId, notificationId); + @Operation(summary = "수동 매칭 초대 수락/거절") + @PostMapping("/invite/reply") + public ApiResponse acceptInvitation(@CurrentMemberId Long userId, @Valid @RequestBody ManualMatchingInviteReplyRequest request) { + matchingInvitationService.acceptInvitation(userId, request); return ApiResponse.response(OK, ACCEPT_MATCHING_INVITE_SUCCESS.getMessage()); } From e5f3e1405f61ab51b22cbc9048b5f9cde44d4d7a Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 5 Feb 2025 00:24:57 +0900 Subject: [PATCH 757/770] =?UTF-8?q?refactor=20:=20=EB=A7=A4=EC=B9=AD?= =?UTF-8?q?=EB=B0=A9=20=EC=B4=88=EB=8C=80/=EC=88=98=EB=9D=BD=20Api=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20=EB=A9=94=EC=84=B8=EC=A7=80=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/common/controller/ResponseMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java index 3b9a4b79..ffad9479 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/controller/ResponseMessage.java @@ -22,7 +22,7 @@ public enum ResponseMessage { CONVERT_TO_AUTO_MATCHING_SUCCESS("자동 매칭으로 전환되었습니다."), GET_MANUAL_MATCHING_LIST_SUCCESS("수동 매칭방 조회에 성공했습니다."), GET_MY_MATCHING_LIST_SUCCESS("내 매칭방 조회에 성공했습니다."), - ACCEPT_MATCHING_INVITE_SUCCESS("매칭방 초대 수락에 성공했습니다"); + ACCEPT_MATCHING_INVITE_SUCCESS("매칭방 초대를 수락/거절이 완료되었습니다"); private final String message; } From 9f6d153fda1e06e1c4421d83d0417f98ed3bbe04 Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 5 Feb 2025 00:25:36 +0900 Subject: [PATCH 758/770] =?UTF-8?q?refactor:=20=EA=B3=84=EC=A2=8C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=9D=91=EB=8B=B5=20=ED=98=95=EC=8B=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AccountController.java | 2 +- .../dto/response/AccountGetResponse.java | 38 ++++++++++++++++++- .../members/service/AccountService.java | 7 +++- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java b/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java index c6addabe..ea056ab3 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java @@ -28,7 +28,7 @@ public class AccountController { public ApiResponse getAccount( @CurrentMemberId Long memberId ) { - return ApiResponse.response(OK, ACCOUNT_GET_SUCCESS.getMessage(), AccountGetResponse.of(this.accountService.getAccount(memberId))); + return ApiResponse.response(OK, ACCOUNT_GET_SUCCESS.getMessage(), this.accountService.getAccount(memberId)); } @PostMapping diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java index a01b1887..a5ec94ed 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java @@ -1,10 +1,44 @@ package com.gachtaxi.domain.members.dto.response; +import com.gachtaxi.domain.members.entity.Members; +import lombok.Builder; + +/** + * "userId": 0, + * "studentNumber": 0, + * "nickName": "string", + * "realName": "string", + * "profilePicture": "string", + * "email": "string", + * "role": "string", + * "gender": "MALE", + * "accountNumber": "string" + * @param accountNumber + */ +@Builder public record AccountGetResponse( + Long userId, + Long studentNumber, + String nickName, + String realName, + String profilePicture, + String email, + String role, + String gender, String accountNumber ) { - public static AccountGetResponse of(String accountNumber) { - return new AccountGetResponse(accountNumber); + public static AccountGetResponse of(Members members) { + return AccountGetResponse.builder() + .userId(members.getId()) + .studentNumber(members.getStudentNumber()) + .nickName(members.getNickname()) + .realName(members.getRealName()) + .profilePicture(members.getProfilePicture()) + .email(members.getEmail()) + .role(members.getRole().name()) + .gender(members.getGender().name()) + .accountNumber(members.getAccountNumber()) + .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/members/service/AccountService.java b/src/main/java/com/gachtaxi/domain/members/service/AccountService.java index d180122c..c60a00bf 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AccountService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AccountService.java @@ -1,5 +1,6 @@ package com.gachtaxi.domain.members.service; +import com.gachtaxi.domain.members.dto.response.AccountGetResponse; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.repository.MemberRepository; import jakarta.transaction.Transactional; @@ -14,8 +15,10 @@ public class AccountService { private final MemberRepository memberRepository; - public String getAccount(Long memberId) { - return this.memberService.findById(memberId).getAccountNumber(); + public AccountGetResponse getAccount(Long memberId) { + Members members = this.memberService.findById(memberId); + + return AccountGetResponse.of(members); } @Transactional From 8381dd208011ac46dea5eea8f93b75ca85035c9e Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 5 Feb 2025 00:27:03 +0900 Subject: [PATCH 759/770] =?UTF-8?q?refactor:=20=EA=B3=84=EC=A2=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=9D=91=EB=8B=B5=20=ED=98=95=EC=8B=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../members/controller/AccountController.java | 7 ++-- .../dto/response/AccountGetResponse.java | 12 ------- .../dto/response/AccountPostResponse.java | 32 +++++++++++++++++++ .../members/service/AccountService.java | 6 +++- 4 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/dto/response/AccountPostResponse.java diff --git a/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java b/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java index ea056ab3..997350c8 100644 --- a/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java +++ b/src/main/java/com/gachtaxi/domain/members/controller/AccountController.java @@ -6,6 +6,7 @@ import com.gachtaxi.domain.members.dto.request.AccountPostRequest; import com.gachtaxi.domain.members.dto.response.AccountGetResponse; +import com.gachtaxi.domain.members.dto.response.AccountPostResponse; import com.gachtaxi.domain.members.service.AccountService; import com.gachtaxi.global.auth.jwt.annotation.CurrentMemberId; import com.gachtaxi.global.common.response.ApiResponse; @@ -32,11 +33,11 @@ public ApiResponse getAccount( } @PostMapping - public ApiResponse updateAccount( + public ApiResponse updateAccount( @CurrentMemberId Long memberId, @RequestBody @Valid AccountPostRequest accountPostRequest ) { - this.accountService.updateAccount(memberId, accountPostRequest.accountNumber()); - return ApiResponse.response(OK, ACCOUNT_UPDATE_SUCCESS.getMessage()); + return ApiResponse.response(OK, ACCOUNT_UPDATE_SUCCESS.getMessage(), + this.accountService.updateAccount(memberId, accountPostRequest.accountNumber())); } } diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java index a5ec94ed..c3267825 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/AccountGetResponse.java @@ -3,18 +3,6 @@ import com.gachtaxi.domain.members.entity.Members; import lombok.Builder; -/** - * "userId": 0, - * "studentNumber": 0, - * "nickName": "string", - * "realName": "string", - * "profilePicture": "string", - * "email": "string", - * "role": "string", - * "gender": "MALE", - * "accountNumber": "string" - * @param accountNumber - */ @Builder public record AccountGetResponse( Long userId, diff --git a/src/main/java/com/gachtaxi/domain/members/dto/response/AccountPostResponse.java b/src/main/java/com/gachtaxi/domain/members/dto/response/AccountPostResponse.java new file mode 100644 index 00000000..cce58df5 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/dto/response/AccountPostResponse.java @@ -0,0 +1,32 @@ +package com.gachtaxi.domain.members.dto.response; + +import com.gachtaxi.domain.members.entity.Members; +import lombok.Builder; + +@Builder +public record AccountPostResponse( + Long userId, + Long studentNumber, + String nickName, + String realName, + String profilePicture, + String email, + String role, + String gender, + String accountNumber +) { + + public static AccountPostResponse of(Members members) { + return AccountPostResponse.builder() + .userId(members.getId()) + .studentNumber(members.getStudentNumber()) + .nickName(members.getNickname()) + .realName(members.getRealName()) + .profilePicture(members.getProfilePicture()) + .email(members.getEmail()) + .role(members.getRole().name()) + .gender(members.getGender().name()) + .accountNumber(members.getAccountNumber()) + .build(); + } +} diff --git a/src/main/java/com/gachtaxi/domain/members/service/AccountService.java b/src/main/java/com/gachtaxi/domain/members/service/AccountService.java index c60a00bf..05adf170 100644 --- a/src/main/java/com/gachtaxi/domain/members/service/AccountService.java +++ b/src/main/java/com/gachtaxi/domain/members/service/AccountService.java @@ -1,10 +1,12 @@ package com.gachtaxi.domain.members.service; import com.gachtaxi.domain.members.dto.response.AccountGetResponse; +import com.gachtaxi.domain.members.dto.response.AccountPostResponse; import com.gachtaxi.domain.members.entity.Members; import com.gachtaxi.domain.members.repository.MemberRepository; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; +import org.checkerframework.checker.units.qual.A; import org.springframework.stereotype.Service; @Service @@ -22,10 +24,12 @@ public AccountGetResponse getAccount(Long memberId) { } @Transactional - public void updateAccount(Long memberId, String accountNumber) { + public AccountPostResponse updateAccount(Long memberId, String accountNumber) { Members member = this.memberService.findById(memberId); member.setAccountNumber(accountNumber); this.memberRepository.save(member); + + return AccountPostResponse.of(member); } } From 09244eeda7bd46148d4dc835b25c61306af1768c Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 5 Feb 2025 00:38:29 +0900 Subject: [PATCH 760/770] =?UTF-8?q?refactor=20:=20=ED=94=84=EB=A1=A0?= =?UTF-8?q?=ED=8A=B8=20=EC=9A=94=EC=B2=AD=EC=82=AC=ED=95=AD=20=EB=A7=9E?= =?UTF-8?q?=EC=B6=B0=EC=84=9C=20last=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/MatchingPageableResponse.java | 12 ++++++------ .../dto/response/MatchingRoomListResponse.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java index f13c34e7..0a9f6e26 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingPageableResponse.java @@ -9,14 +9,14 @@ public record MatchingPageableResponse( int pageNumber, int pageSize, int numberOfElements, - boolean isLast + boolean last ) { - public static MatchingPageableResponse of(Slice Slice) { + public static MatchingPageableResponse of(Slice slice) { return MatchingPageableResponse.builder() - .pageNumber(Slice.getNumber()) - .pageSize(Slice.getSize()) - .numberOfElements(Slice.getNumberOfElements()) - .isLast(Slice.isLast()) + .pageNumber(slice.getNumber()) + .pageSize(slice.getSize()) + .numberOfElements(slice.getNumberOfElements()) + .last(slice.isLast()) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java index ad6a01c6..1af3fa45 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/response/MatchingRoomListResponse.java @@ -9,10 +9,10 @@ public record MatchingRoomListResponse( List rooms, MatchingPageableResponse pageable ) { - public static MatchingRoomListResponse of(Slice Slice) { + public static MatchingRoomListResponse of(Slice slice) { return MatchingRoomListResponse.builder() - .rooms(Slice.getContent()) - .pageable(MatchingPageableResponse.of(Slice)) + .rooms(slice.getContent().stream().toList()) + .pageable(MatchingPageableResponse.of(slice)) .build(); } } From 4ece73a17d67cb086f3bad993a51079ef7fd73f6 Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 5 Feb 2025 00:51:17 +0900 Subject: [PATCH 761/770] =?UTF-8?q?refactor=20:=20REJECT=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EA=B1=B0=EC=A0=88=EC=8B=9C=20=EC=95=8C=EB=A6=BC=EC=9D=B4=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/MatchingInvitationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java index 51c4c0b2..67397809 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java @@ -76,7 +76,7 @@ public void acceptInvitation(Long userId, ManualMatchingInviteReplyRequest reque } if (request.status() == MatchingInviteStatus.REJECT) { - notificationRepository.save(notification); + notificationRepository.delete(notification); return; } From aee125c030250572d1d50b6329067d1afeb06334 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 5 Feb 2025 00:58:04 +0900 Subject: [PATCH 762/770] =?UTF-8?q?refactor:=20accountNumber=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/dto/request/MemberInfoRequestDto.java | 3 +-- src/main/java/com/gachtaxi/domain/members/entity/Members.java | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java index 23de4656..d0bea53f 100644 --- a/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java +++ b/src/main/java/com/gachtaxi/domain/members/dto/request/MemberInfoRequestDto.java @@ -4,7 +4,6 @@ public record MemberInfoRequestDto( @NotNull String profilePicture, - @NotNull String nickName, - @NotNull String accountNumber + @NotNull String nickName ) { } diff --git a/src/main/java/com/gachtaxi/domain/members/entity/Members.java b/src/main/java/com/gachtaxi/domain/members/entity/Members.java index ce1e5d99..751219cc 100644 --- a/src/main/java/com/gachtaxi/domain/members/entity/Members.java +++ b/src/main/java/com/gachtaxi/domain/members/entity/Members.java @@ -122,7 +122,6 @@ public void updateGoogleId(String googleId) { public void updateMemberInfo(MemberInfoRequestDto dto) { this.profilePicture = dto.profilePicture(); this.nickname = dto.nickName(); - this.accountNumber = dto.accountNumber(); } public void updateAgreement(MemberAgreementRequestDto dto) { From 0e8a0008578816d1091f4319a46ac168b7864731 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 5 Feb 2025 01:21:21 +0900 Subject: [PATCH 763/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=88=98=EB=9D=BD=20=EB=B0=8F=20=EA=B1=B0=EC=A0=88?= =?UTF-8?q?=20API=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/controller/FriendController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 6618da95..a841a887 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -42,24 +42,24 @@ public ApiResponse getFriendsList( return ApiResponse.response(OK, FRIEND_LIST_SUCCESS.getMessage(), response); } - @PatchMapping - @Operation(summary = "친구 요청을 수락하는 API입니다.") - public ApiResponse acceptFriendRequest( + @PatchMapping("") + @Operation(summary = "친구 요청을 수락/거절하는 API입니다.") + public ApiResponse updateFriendRequest( @CurrentMemberId Long currentId, @RequestBody FriendUpdateDto dto ){ - friendService.updateFriendStatus(dto.memberId(), currentId); // 친구 요청 보낸 사람(dto), 받은 사람(토큰 추출) + System.out.println("친구요청 수락/ 거절 실행"); + friendService.updateFriendRequest(dto, currentId); // 친구 요청 보낸 사람(dto), 받은 사람(토큰 추출) return ApiResponse.response(OK, FRIEND_STATUS_ACCEPTED.getMessage()); } @DeleteMapping("/{memberId}") - @Operation(summary = "친구 요청 거절 및 친구를 삭제하는 API입니다.") + @Operation(summary = "친구를 삭제하는 API입니다.") public ApiResponse deleteFriend( @CurrentMemberId Long currentId, @PathVariable Long memberId ) { friendService.deleteFriend(currentId, memberId); - return ApiResponse.response(OK, FRIEND_DELETE.getMessage()); } From cfa0e20139daa17c0811905f2188e6643ba43ea7 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 5 Feb 2025 01:21:44 +0900 Subject: [PATCH 764/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20REJECTED=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/friend/entity/enums/FriendStatus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java b/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java index bd382d4a..cc0bc7e7 100644 --- a/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java +++ b/src/main/java/com/gachtaxi/domain/friend/entity/enums/FriendStatus.java @@ -1,5 +1,5 @@ package com.gachtaxi.domain.friend.entity.enums; public enum FriendStatus { - PENDING, ACCEPTED + PENDING, ACCEPTED, REJECTED } From b21570e69e174d1a7e7ebc1d0d177b17842942fa Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 5 Feb 2025 01:22:18 +0900 Subject: [PATCH 765/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EC=88=98?= =?UTF-8?q?=EB=9D=BD=20=EB=B0=8F=20=EA=B1=B0=EC=A0=88=20API=20=ED=86=B5?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/dto/request/FriendUpdateDto.java | 4 +++- .../domain/friend/service/FriendService.java | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java index 9842fbee..37a5d872 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/request/FriendUpdateDto.java @@ -1,9 +1,11 @@ package com.gachtaxi.domain.friend.dto.request; +import com.gachtaxi.domain.friend.entity.enums.FriendStatus; import jakarta.validation.constraints.NotNull; public record FriendUpdateDto( @NotNull Long memberId, - @NotNull String notificationId + @NotNull String notificationId, + @NotNull FriendStatus status ) { } diff --git a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java index 87fac1f9..52482103 100644 --- a/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java +++ b/src/main/java/com/gachtaxi/domain/friend/service/FriendService.java @@ -1,6 +1,7 @@ package com.gachtaxi.domain.friend.service; import com.gachtaxi.domain.friend.dto.request.FriendRequestDto; +import com.gachtaxi.domain.friend.dto.request.FriendUpdateDto; import com.gachtaxi.domain.friend.dto.response.FriendsPageableResponse; import com.gachtaxi.domain.friend.dto.response.FriendsResponseDto; import com.gachtaxi.domain.friend.dto.response.FriendsSliceResponse; @@ -26,6 +27,7 @@ import java.util.List; +import static com.gachtaxi.domain.friend.entity.enums.FriendStatus.REJECTED; import static com.gachtaxi.domain.notification.entity.enums.NotificationType.FRIEND_REQUEST; @Slf4j @@ -45,7 +47,6 @@ public void sendFriendRequest(Long senderId, FriendRequestDto dto) { Members sender = memberService.findById(senderId); Members receiver = memberService.findByNickname(dto.nickName()); - checkDuplicatedFriendShip(senderId, receiver.getId()); friendRepository.save(Friends.of(sender, receiver)); @@ -73,9 +74,15 @@ public FriendsSliceResponse findFriendsListByMemberId(Long memberId, int pageNum } @Transactional - public void updateFriendStatus(Long senderId, Long receiverId) { - Friends friendShip = findBySenderIdAndReceiverId(senderId, receiverId); - friendShip.updateStatus(); + public void updateFriendRequest(FriendUpdateDto dto, Long receiverId) { + Friends friendShip = findBySenderIdAndReceiverId(dto.memberId(), receiverId); + notificationService.delete(receiverId, dto.notificationId()); + + if(dto.status() == REJECTED){ + friendRepository.delete(friendShip); + }else{ + friendShip.updateStatus(); + } } @Transactional From eb5455d22f85a8a0be026e15b7b11c5415ff8fa1 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 5 Feb 2025 01:27:37 +0900 Subject: [PATCH 766/770] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EC=88=98?= =?UTF-8?q?=EB=9D=BD=20=EB=B0=8F=20=EA=B1=B0=EC=A0=88=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/friend/controller/FriendController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index a841a887..f44c11b2 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*; import static com.gachtaxi.domain.friend.controller.ResponseMessage.*; +import static com.gachtaxi.domain.friend.entity.enums.FriendStatus.REJECTED; import static org.springframework.http.HttpStatus.OK; @RestController @@ -48,8 +49,11 @@ public ApiResponse updateFriendRequest( @CurrentMemberId Long currentId, @RequestBody FriendUpdateDto dto ){ - System.out.println("친구요청 수락/ 거절 실행"); friendService.updateFriendRequest(dto, currentId); // 친구 요청 보낸 사람(dto), 받은 사람(토큰 추출) + if(dto.status() == REJECTED){ + return ApiResponse.response(OK, FRIEND_STATUS_REJECTED.getMessage()); + } + return ApiResponse.response(OK, FRIEND_STATUS_ACCEPTED.getMessage()); } From 778cb736a409ffde359c37c46818ce5dffd4e40f Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 5 Feb 2025 01:29:54 +0900 Subject: [PATCH 767/770] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=A0=ED=8A=B8=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=EC=9C=BC=EB=A1=9C=20RequestParam=20String?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/friend/controller/FriendController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index f44c11b2..13342b15 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -36,10 +36,10 @@ public ApiResponse sendFriendRequest( @Operation(summary = "친구 목록을 반환하는 API입니다. (무한스크롤)") public ApiResponse getFriendsList( @CurrentMemberId Long memberId, - @RequestParam int pageNum, - @RequestParam int pageSize + @RequestParam String pageNum, + @RequestParam String pageSize ){ - FriendsSliceResponse response = friendService.findFriendsListByMemberId(memberId, pageNum, pageSize); + FriendsSliceResponse response = friendService.findFriendsListByMemberId(memberId, Integer.parseInt(pageNum), Integer.parseInt(pageSize)); return ApiResponse.response(OK, FRIEND_LIST_SUCCESS.getMessage(), response); } From 36277a9fb7b4bf3e3fd4ed86551da5cdb06d07d2 Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 5 Feb 2025 02:45:03 +0900 Subject: [PATCH 768/770] =?UTF-8?q?HOTFIX:=20RequestParam=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachtaxi/domain/friend/controller/FriendController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java index 13342b15..f44c11b2 100644 --- a/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java +++ b/src/main/java/com/gachtaxi/domain/friend/controller/FriendController.java @@ -36,10 +36,10 @@ public ApiResponse sendFriendRequest( @Operation(summary = "친구 목록을 반환하는 API입니다. (무한스크롤)") public ApiResponse getFriendsList( @CurrentMemberId Long memberId, - @RequestParam String pageNum, - @RequestParam String pageSize + @RequestParam int pageNum, + @RequestParam int pageSize ){ - FriendsSliceResponse response = friendService.findFriendsListByMemberId(memberId, Integer.parseInt(pageNum), Integer.parseInt(pageSize)); + FriendsSliceResponse response = friendService.findFriendsListByMemberId(memberId, pageNum, pageSize); return ApiResponse.response(OK, FRIEND_LIST_SUCCESS.getMessage(), response); } From e9477d3a7793184cec1c751fe23c3c5d21809cca Mon Sep 17 00:00:00 2001 From: koreaioi Date: Wed, 5 Feb 2025 02:57:34 +0900 Subject: [PATCH 769/770] =?UTF-8?q?HOTFIX:=20=EC=B0=BE=EC=95=98=EB=8B=A4?= =?UTF-8?q?=20=EB=B2=94=EC=9D=B8.=20=EC=9D=91=EB=8B=B5=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=EB=AA=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/dto/response/FriendsPageableResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java index f420e04f..ab6fec3c 100644 --- a/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java +++ b/src/main/java/com/gachtaxi/domain/friend/dto/response/FriendsPageableResponse.java @@ -6,14 +6,14 @@ @Builder public record FriendsPageableResponse( - int pageNum, + int pageNumber, int pageSize, int numberOfElements, boolean last ) { public static FriendsPageableResponse from(Slice slice) { return FriendsPageableResponse.builder() - .pageNum(slice.getNumber()) + .pageNumber(slice.getNumber()) .pageSize(slice.getSize()) .numberOfElements(slice.getNumberOfElements()) .last(slice.isLast()) From 8e3be88696b2f6f7bb08ad6b5840f1225d8ab153 Mon Sep 17 00:00:00 2001 From: hyxklee Date: Wed, 5 Feb 2025 12:43:37 +0900 Subject: [PATCH 770/770] =?UTF-8?q?refactor:=20UserDetail=EC=9D=B4=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=20=EB=95=8C=20=EC=98=88=EC=99=B8=20=EB=B0=98?= =?UTF-8?q?=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/members/exception/ErrorMessage.java | 1 + .../exception/MemberIdNotFoundException.java | 16 ++++++++++++++++ .../auth/jwt/annotation/CurrentMemberId.java | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gachtaxi/domain/members/exception/MemberIdNotFoundException.java diff --git a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java index 199a733b..51432554 100644 --- a/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java +++ b/src/main/java/com/gachtaxi/domain/members/exception/ErrorMessage.java @@ -12,6 +12,7 @@ public enum ErrorMessage { MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."), DUPLICATED_EMAIL("이미 가입된 이메일이에요!"), EMAIL_FROM_INVALID("가천대학교 이메일이 아니에요!"), + MEMBER_ID_NOT_FOUND("토큰에서 회원 id를 찾을 수 없습니다."), // Blacklist BLACKLIST_ALREADY_EXISTS("이미 등록된 블랙리스트입니다."), diff --git a/src/main/java/com/gachtaxi/domain/members/exception/MemberIdNotFoundException.java b/src/main/java/com/gachtaxi/domain/members/exception/MemberIdNotFoundException.java new file mode 100644 index 00000000..3808ed39 --- /dev/null +++ b/src/main/java/com/gachtaxi/domain/members/exception/MemberIdNotFoundException.java @@ -0,0 +1,16 @@ +package com.gachtaxi.domain.members.exception; + +import com.gachtaxi.global.common.exception.BaseException; + +import static com.gachtaxi.domain.members.exception.ErrorMessage.*; +import static org.springframework.http.HttpStatus.NOT_FOUND; + +public class MemberIdNotFoundException extends BaseException { + public MemberIdNotFoundException() { + super(NOT_FOUND, MEMBER_ID_NOT_FOUND.getMessage()); + } + + public static void throwException() { + throw new MemberIdNotFoundException(); + } +} diff --git a/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMemberId.java b/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMemberId.java index 43f4330e..31804b4e 100644 --- a/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMemberId.java +++ b/src/main/java/com/gachtaxi/global/auth/jwt/annotation/CurrentMemberId.java @@ -9,7 +9,7 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) -@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : id") +@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? T(com.gachtaxi.domain.members.exception.MemberIdNotFoundException).throwException() : id") public @interface CurrentMemberId { /* * AuthenticationPrincipal의 id 필드를 반환