From 5795ff9a7a55dc9aa19b8190274875f7601060e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=9C=EB=A0=B9?= Date: Mon, 5 Aug 2024 23:18:05 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feature:=20GPT=20=ED=94=84=EB=A1=AC?= =?UTF-8?q?=ED=94=84=ED=8A=B8=EB=A1=9C=20=EA=B3=B5=EC=9C=A0=EA=B7=B8?= =?UTF-8?q?=EB=A3=B9=20=EC=9D=B4=EB=A6=84=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 18 ++++++++++++- .../controller/ShareGroupController.java | 3 +++ .../shareGroup/service/OpenAiService.java | 7 +++++ .../shareGroup/service/OpenAiServiceImpl.java | 26 +++++++++++++++++++ .../service/ShareGroupServiceImpl.java | 5 ++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiService.java create mode 100644 src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java diff --git a/build.gradle b/build.gradle index 32922ead..5ba01d2f 100644 --- a/build.gradle +++ b/build.gradle @@ -22,12 +22,18 @@ configurations { repositories { mavenCentral() maven { url 'https://jitpack.io' } + maven { url 'https://repo.spring.io/milestone' } +} + +ext { + set('springAiVersion', "1.0.0-M1") } dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-web' + developmentOnly 'org.springframework.boot:spring-boot-devtools' // security implementation 'io.jsonwebtoken:jjwt-api:0.12.5' @@ -37,6 +43,10 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' + // GPT 프롬프트 + implementation 'org.springframework.ai:spring-ai-openai-spring-boot-starter' + // implementation 'io.github.flashvayne:chatgpt-spring-boot-starter:1.0.4' + // redis implementation 'org.springframework.boot:spring-boot-starter-data-redis' @@ -66,6 +76,12 @@ dependencies { implementation 'org.springframework.data:spring-data-elasticsearch:' } +dependencyManagement { + imports { + mavenBom "org.springframework.ai:spring-ai-bom:${springAiVersion}" + } +} + tasks.named('test') { useJUnitPlatform() -} +} \ No newline at end of file diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java b/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java index 4387d8b8..0a711ca1 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java @@ -7,6 +7,7 @@ import com.umc.naoman.domain.shareGroup.dto.ShareGroupResponse; import com.umc.naoman.domain.shareGroup.entity.Profile; import com.umc.naoman.domain.shareGroup.entity.ShareGroup; +import com.umc.naoman.domain.shareGroup.service.OpenAiService; import com.umc.naoman.domain.shareGroup.service.ShareGroupService; import com.umc.naoman.global.result.ResultResponse; import com.umc.naoman.global.result.code.ShareGroupResultCode; @@ -37,12 +38,14 @@ public class ShareGroupController { private final ShareGroupService shareGroupService; private final ShareGroupConverter shareGroupConverter; + private final OpenAiService openAiService; @PostMapping @Operation(summary = "공유그룹 생성 API", description = "새로운 공유그룹을 생성하는 API입니다.") public ResultResponse createShareGroup(@Valid @RequestBody createShareGroupRequest request, @LoginMember Member member) { + // OpenAI API를 사용하여 그룹 이름 생성 ShareGroup shareGroup = shareGroupService.createShareGroup(request, member); return ResultResponse.of(ShareGroupResultCode.CREATE_SHARE_GROUP, shareGroupConverter.toShareGroupInfo(shareGroup)); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiService.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiService.java new file mode 100644 index 00000000..d68b735d --- /dev/null +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiService.java @@ -0,0 +1,7 @@ +package com.umc.naoman.domain.shareGroup.service; + +import java.util.List; + +public interface OpenAiService { + String generateGroupName(String place, List meetingTypes); +} diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java new file mode 100644 index 00000000..022dc0c1 --- /dev/null +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java @@ -0,0 +1,26 @@ +package com.umc.naoman.domain.shareGroup.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.ai.openai.OpenAiChatModel; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Transactional(readOnly = true) +@RequiredArgsConstructor +public class OpenAiServiceImpl implements OpenAiService { + + private final OpenAiChatModel chatModel; + + public String generateGroupName(String place, List meetingTypes) { + String prompt = String.format("장소: %s, 모임 종류: %s \n위 키워드를 참고해 재미있는 그룹 이름을 공백 포함 10자~20자 사이로 하나만 지어줘. 큰따옴표는 제외하고 보여줘.", place, String.join(", ", meetingTypes)); + String response = chatModel.call(prompt); + return removeQuotes(response); + } + + private String removeQuotes(String response) { + return response.replace("\"", ""); // 모든 큰따옴표 제거 + } +} \ No newline at end of file diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java index a3574f30..375389cf 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java @@ -29,6 +29,7 @@ public class ShareGroupServiceImpl implements ShareGroupService { private final ShareGroupRepository shareGroupRepository; private final ProfileRepository profileRepository; private final ShareGroupConverter shareGroupConverter; + private final OpenAiService openAiService; @Transactional @Override @@ -36,9 +37,13 @@ public ShareGroup createShareGroup(ShareGroupRequest.createShareGroupRequest req // 초대링크를 위한 고유번호 생성 (UUID) String inviteCode = UUID.randomUUID().toString().replace("-", "").toUpperCase(); + // GPT 프롬프트로 groupName 생성 + String groupName = openAiService.generateGroupName(request.getPlace(), request.getMeetingTypeList()); + // 변환 로직 ShareGroup newShareGroup = shareGroupConverter.toEntity(request); newShareGroup.setInviteCode(inviteCode); + newShareGroup.setName(groupName); // 생성된 공유 그룹 저장 ShareGroup savedShareGroup = shareGroupRepository.save(newShareGroup); From ae98c144b375df1eb7dc0ef18fd9e45235f6e0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=9C=EB=A0=B9?= Date: Mon, 5 Aug 2024 23:49:32 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20=EB=A6=AC=EB=B7=B0=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=EC=BD=94=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 --- .../shareGroup/controller/ShareGroupController.java | 2 -- .../shareGroup/converter/ShareGroupConverter.java | 5 +++-- .../naoman/domain/shareGroup/entity/ShareGroup.java | 1 - .../domain/shareGroup/service/OpenAiServiceImpl.java | 3 ++- .../shareGroup/service/ShareGroupServiceImpl.java | 11 ++++------- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java b/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java index 0a711ca1..fcaef147 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java @@ -38,14 +38,12 @@ public class ShareGroupController { private final ShareGroupService shareGroupService; private final ShareGroupConverter shareGroupConverter; - private final OpenAiService openAiService; @PostMapping @Operation(summary = "공유그룹 생성 API", description = "새로운 공유그룹을 생성하는 API입니다.") public ResultResponse createShareGroup(@Valid @RequestBody createShareGroupRequest request, @LoginMember Member member) { - // OpenAI API를 사용하여 그룹 이름 생성 ShareGroup shareGroup = shareGroupService.createShareGroup(request, member); return ResultResponse.of(ShareGroupResultCode.CREATE_SHARE_GROUP, shareGroupConverter.toShareGroupInfo(shareGroup)); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/converter/ShareGroupConverter.java b/src/main/java/com/umc/naoman/domain/shareGroup/converter/ShareGroupConverter.java index a91fd3d1..06269de8 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/converter/ShareGroupConverter.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/converter/ShareGroupConverter.java @@ -16,10 +16,11 @@ public class ShareGroupConverter { private static final String BASE_URL = "https://naoman/invite/"; //baseUrl 상수 - public ShareGroup toEntity(ShareGroupRequest.createShareGroupRequest request) { + public ShareGroup toEntity(ShareGroupRequest.createShareGroupRequest request, String inviteCode, String groupName) { return ShareGroup.builder() .memberCount(request.getMemberNameList().size()) // 변경 가능성 있음. memberCount 대신 nameList의 size 사용 - .name("임시 공유 그룹 이름") //임시 공유 그룹 이름 + .inviteCode(inviteCode) // 생성된 초대 코드 + .name(groupName) // gpt로 만들어진 공유 그룹 이름 .build(); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/entity/ShareGroup.java b/src/main/java/com/umc/naoman/domain/shareGroup/entity/ShareGroup.java index 6e9464e0..797c5fcf 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/entity/ShareGroup.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/entity/ShareGroup.java @@ -13,7 +13,6 @@ @Table(name = "share_groups") @SQLRestriction("deleted_at is NULL") @Getter -@Setter @Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java index 022dc0c1..c7a2a131 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java @@ -15,7 +15,8 @@ public class OpenAiServiceImpl implements OpenAiService { private final OpenAiChatModel chatModel; public String generateGroupName(String place, List meetingTypes) { - String prompt = String.format("장소: %s, 모임 종류: %s \n위 키워드를 참고해 재미있는 그룹 이름을 공백 포함 10자~20자 사이로 하나만 지어줘. 큰따옴표는 제외하고 보여줘.", place, String.join(", ", meetingTypes)); + String prompt = String.format("장소: %s, 모임 종류: %s \n위 키워드를 참고해 재미있는 그룹 이름을 공백 포함 10자~20자 사이로 하나만 지어줘. 큰따옴표는 제외하고 보여줘.", + place, String.join(", ", meetingTypes)); String response = chatModel.call(prompt); return removeQuotes(response); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java index 43bea068..bfcf968b 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java @@ -9,7 +9,6 @@ import com.umc.naoman.domain.shareGroup.repository.ProfileRepository; import com.umc.naoman.domain.shareGroup.repository.ShareGroupRepository; import com.umc.naoman.global.error.BusinessException; -import com.umc.naoman.global.error.code.MemberErrorCode; import com.umc.naoman.global.error.code.ShareGroupErrorCode; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -36,16 +35,14 @@ public class ShareGroupServiceImpl implements ShareGroupService { @Override public ShareGroup createShareGroup(ShareGroupRequest.createShareGroupRequest request, Member member) { - // 초대링크를 위한 고유번호 생성 (UUID) - String inviteCode = UUID.randomUUID().toString().replace("-", "").toUpperCase(); - // GPT 프롬프트로 groupName 생성 String groupName = openAiService.generateGroupName(request.getPlace(), request.getMeetingTypeList()); + // 초대링크를 위한 고유번호 생성 (UUID) + String inviteCode = UUID.randomUUID().toString().replace("-", "").toUpperCase(); + // 변환 로직 - ShareGroup newShareGroup = shareGroupConverter.toEntity(request); - newShareGroup.setInviteCode(inviteCode); - newShareGroup.setName(groupName); + ShareGroup newShareGroup = shareGroupConverter.toEntity(request, inviteCode, groupName); // 생성된 공유 그룹 저장 ShareGroup savedShareGroup = shareGroupRepository.save(newShareGroup); From 9b693d89b75147fb144189de5e7d4dec9efee806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=9C=EB=A0=B9?= Date: Mon, 5 Aug 2024 23:54:59 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20findProfileList=20=ED=95=A8?= =?UTF-8?q?=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 --- .../domain/shareGroup/repository/ProfileRepository.java | 2 ++ .../naoman/domain/shareGroup/service/ShareGroupService.java | 1 + .../domain/shareGroup/service/ShareGroupServiceImpl.java | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/repository/ProfileRepository.java b/src/main/java/com/umc/naoman/domain/shareGroup/repository/ProfileRepository.java index 01dee1b5..bf0e5037 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/repository/ProfileRepository.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/repository/ProfileRepository.java @@ -1,5 +1,6 @@ package com.umc.naoman.domain.shareGroup.repository; +import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.shareGroup.entity.Profile; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -13,4 +14,5 @@ public interface ProfileRepository extends JpaRepository { Optional findByShareGroupIdAndMemberId(Long shareGroupId, Long memberId); List findByMemberId(Long memberId); boolean existsByShareGroupIdAndMemberId(Long shareGroupId, Long memberId); + List findByMember(Member member); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupService.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupService.java index f05fc26d..2c5b28cd 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupService.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupService.java @@ -21,4 +21,5 @@ public interface ShareGroupService { ShareGroup deleteShareGroup(Long shareGroupId, Member member); ShareGroup getInviteInfo(Long shareGroupId, Member member); boolean doesProfileExist(Long shareGroupId, Long memberId); + List findProfileList(Member member); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java index bfcf968b..a3f72156 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java @@ -163,4 +163,8 @@ public boolean doesProfileExist(Long shareGroupId, Long memberId) { return profileRepository.existsByShareGroupIdAndMemberId(shareGroupId, memberId); } + @Override + public List findProfileList(Member member) { + return profileRepository.findByMember(member); + } } \ No newline at end of file From 789ab91ef1bfda50f99a0af6d911a93712c58d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=9C=EB=A0=B9?= Date: Tue, 6 Aug 2024 00:12:57 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=EC=98=A4=EB=B2=84=EB=A1=9C?= =?UTF-8?q?=EB=94=A9=20=EB=B6=88=EA=B0=80=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=ED=95=A8=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 --- .../controller/ShareGroupController.java | 5 ++--- .../shareGroup/converter/ShareGroupConverter.java | 2 +- .../naoman/domain/shareGroup/entity/Profile.java | 12 +++++++++++- .../domain/shareGroup/entity/ShareGroup.java | 15 ++++++++++++--- .../shareGroup/repository/ProfileRepository.java | 2 -- .../domain/shareGroup/service/OpenAiService.java | 2 +- .../shareGroup/service/OpenAiServiceImpl.java | 4 ++-- .../shareGroup/service/ShareGroupService.java | 12 ++++++------ .../shareGroup/service/ShareGroupServiceImpl.java | 14 +++++++------- 9 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java b/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java index 17c92e05..d38379f8 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/controller/ShareGroupController.java @@ -7,7 +7,6 @@ import com.umc.naoman.domain.shareGroup.dto.ShareGroupResponse; import com.umc.naoman.domain.shareGroup.entity.Profile; import com.umc.naoman.domain.shareGroup.entity.ShareGroup; -import com.umc.naoman.domain.shareGroup.service.OpenAiService; import com.umc.naoman.domain.shareGroup.service.ShareGroupService; import com.umc.naoman.global.result.ResultResponse; import com.umc.naoman.global.result.code.ShareGroupResultCode; @@ -57,7 +56,7 @@ public class ShareGroupController { }) public ResultResponse getShareGroupDetailInfo(@PathVariable(name = "shareGroupId") Long shareGroupId) { ShareGroup shareGroup = shareGroupService.findShareGroup(shareGroupId); - List profileList = shareGroupService.findProfileList(shareGroupId); + List profileList = shareGroupService.findProfileListByShareGroupId(shareGroupId); return ResultResponse.of(ShareGroupResultCode.SHARE_GROUP_INFO, shareGroupConverter.toShareGroupDetailInfo(shareGroup, profileList)); @@ -70,7 +69,7 @@ public ResultResponse getShareGroupDeta }) public ResultResponse getShareGroupByInviteCode(@RequestParam String inviteCode) { ShareGroup shareGroup = shareGroupService.findShareGroup(inviteCode); - List profileList = shareGroupService.findProfileList(shareGroup.getId()); + List profileList = shareGroupService.findProfileListByShareGroupId(shareGroup.getId()); return ResultResponse.of(ShareGroupResultCode.SHARE_GROUP_INFO, shareGroupConverter.toShareGroupDetailInfo(shareGroup, profileList)); diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/converter/ShareGroupConverter.java b/src/main/java/com/umc/naoman/domain/shareGroup/converter/ShareGroupConverter.java index 06269de8..dfe95289 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/converter/ShareGroupConverter.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/converter/ShareGroupConverter.java @@ -18,7 +18,7 @@ public class ShareGroupConverter { public ShareGroup toEntity(ShareGroupRequest.createShareGroupRequest request, String inviteCode, String groupName) { return ShareGroup.builder() - .memberCount(request.getMemberNameList().size()) // 변경 가능성 있음. memberCount 대신 nameList의 size 사용 + .memberCount(request.getMemberNameList().size()) //nameList의 size 사용 .inviteCode(inviteCode) // 생성된 초대 코드 .name(groupName) // gpt로 만들어진 공유 그룹 이름 .build(); diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/entity/Profile.java b/src/main/java/com/umc/naoman/domain/shareGroup/entity/Profile.java index 47a5ff36..9053b458 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/entity/Profile.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/entity/Profile.java @@ -1,7 +1,17 @@ package com.umc.naoman.domain.shareGroup.entity; import com.umc.naoman.domain.member.entity.Member; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/entity/ShareGroup.java b/src/main/java/com/umc/naoman/domain/shareGroup/entity/ShareGroup.java index 797c5fcf..6070729d 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/entity/ShareGroup.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/entity/ShareGroup.java @@ -1,11 +1,20 @@ package com.umc.naoman.domain.shareGroup.entity; import com.umc.naoman.global.entity.BaseTimeEntity; -import jakarta.persistence.*; -import lombok.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; import org.hibernate.annotations.SQLRestriction; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/repository/ProfileRepository.java b/src/main/java/com/umc/naoman/domain/shareGroup/repository/ProfileRepository.java index bf0e5037..01dee1b5 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/repository/ProfileRepository.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/repository/ProfileRepository.java @@ -1,6 +1,5 @@ package com.umc.naoman.domain.shareGroup.repository; -import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.shareGroup.entity.Profile; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -14,5 +13,4 @@ public interface ProfileRepository extends JpaRepository { Optional findByShareGroupIdAndMemberId(Long shareGroupId, Long memberId); List findByMemberId(Long memberId); boolean existsByShareGroupIdAndMemberId(Long shareGroupId, Long memberId); - List findByMember(Member member); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiService.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiService.java index d68b735d..b38700e3 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiService.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiService.java @@ -3,5 +3,5 @@ import java.util.List; public interface OpenAiService { - String generateGroupName(String place, List meetingTypes); + String generateGroupName(String place, List meetingTypeList); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java index c7a2a131..a0b90aa6 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/OpenAiServiceImpl.java @@ -14,9 +14,9 @@ public class OpenAiServiceImpl implements OpenAiService { private final OpenAiChatModel chatModel; - public String generateGroupName(String place, List meetingTypes) { + public String generateGroupName(String place, List meetingTypeList) { String prompt = String.format("장소: %s, 모임 종류: %s \n위 키워드를 참고해 재미있는 그룹 이름을 공백 포함 10자~20자 사이로 하나만 지어줘. 큰따옴표는 제외하고 보여줘.", - place, String.join(", ", meetingTypes)); + place, String.join(", ", meetingTypeList)); String response = chatModel.call(prompt); return removeQuotes(response); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupService.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupService.java index 2c5b28cd..6c968beb 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupService.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupService.java @@ -11,15 +11,15 @@ public interface ShareGroupService { ShareGroup createShareGroup(ShareGroupRequest.createShareGroupRequest request, Member member); + ShareGroup joinShareGroup(Long shareGroupId, Long profileId, Member member); + ShareGroup getInviteInfo(Long shareGroupId, Member member); + ShareGroup deleteShareGroup(Long shareGroupId, Member member); + Page getMyShareGroupList(Member member, Pageable pageable); ShareGroup findShareGroup(Long shareGroupId); ShareGroup findShareGroup(String inviteCode); - List findProfileList(Long shareGroupId); - ShareGroup joinShareGroup(Long shareGroupId, Long profileId, Member member); + List findProfileListByShareGroupId(Long shareGroupId); + List findProfileListByMemberId(Long memberId); Profile findProfile(Long profileId); Profile findProfile(Long shareGroupId, Long memberID); - Page getMyShareGroupList(Member member, Pageable pageable); - ShareGroup deleteShareGroup(Long shareGroupId, Member member); - ShareGroup getInviteInfo(Long shareGroupId, Member member); boolean doesProfileExist(Long shareGroupId, Long memberId); - List findProfileList(Member member); } diff --git a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java index a3f72156..281ddf28 100644 --- a/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/shareGroup/service/ShareGroupServiceImpl.java @@ -141,11 +141,6 @@ public ShareGroup findShareGroup(String inviteCode) { .orElseThrow(() -> new BusinessException(ShareGroupErrorCode.SHARE_GROUP_NOT_FOUND)); } - @Override - public List findProfileList(Long shareGroupId) { - return profileRepository.findByShareGroupId(shareGroupId); - } - @Override public Profile findProfile(Long profileId) { return profileRepository.findById(profileId) @@ -164,7 +159,12 @@ public boolean doesProfileExist(Long shareGroupId, Long memberId) { } @Override - public List findProfileList(Member member) { - return profileRepository.findByMember(member); + public List findProfileListByShareGroupId(Long shareGroupId) { + return profileRepository.findByShareGroupId(shareGroupId); + } + + @Override + public List findProfileListByMemberId(Long memberId) { + return profileRepository.findByMemberId(memberId); } } \ No newline at end of file