Skip to content

Commit

Permalink
refactor: 오버로딩 불가로 인한 함수명 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
h-ye-ryoung committed Aug 5, 2024
1 parent 9b693d8 commit 789ab91
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,7 +56,7 @@ public class ShareGroupController {
})
public ResultResponse<ShareGroupResponse.ShareGroupDetailInfo> getShareGroupDetailInfo(@PathVariable(name = "shareGroupId") Long shareGroupId) {
ShareGroup shareGroup = shareGroupService.findShareGroup(shareGroupId);
List<Profile> profileList = shareGroupService.findProfileList(shareGroupId);
List<Profile> profileList = shareGroupService.findProfileListByShareGroupId(shareGroupId);

return ResultResponse.of(ShareGroupResultCode.SHARE_GROUP_INFO,
shareGroupConverter.toShareGroupDetailInfo(shareGroup, profileList));
Expand All @@ -70,7 +69,7 @@ public ResultResponse<ShareGroupResponse.ShareGroupDetailInfo> getShareGroupDeta
})
public ResultResponse<ShareGroupResponse.ShareGroupDetailInfo> getShareGroupByInviteCode(@RequestParam String inviteCode) {
ShareGroup shareGroup = shareGroupService.findShareGroup(inviteCode);
List<Profile> profileList = shareGroupService.findProfileList(shareGroup.getId());
List<Profile> profileList = shareGroupService.findProfileListByShareGroupId(shareGroup.getId());

return ResultResponse.of(ShareGroupResultCode.SHARE_GROUP_INFO,
shareGroupConverter.toShareGroupDetailInfo(shareGroup, profileList));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,5 +13,4 @@ public interface ProfileRepository extends JpaRepository<Profile, Long> {
Optional<Profile> findByShareGroupIdAndMemberId(Long shareGroupId, Long memberId);
List<Profile> findByMemberId(Long memberId);
boolean existsByShareGroupIdAndMemberId(Long shareGroupId, Long memberId);
List<Profile> findByMember(Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import java.util.List;

public interface OpenAiService {
String generateGroupName(String place, List<String> meetingTypes);
String generateGroupName(String place, List<String> meetingTypeList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class OpenAiServiceImpl implements OpenAiService {

private final OpenAiChatModel chatModel;

public String generateGroupName(String place, List<String> meetingTypes) {
public String generateGroupName(String place, List<String> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ShareGroup> getMyShareGroupList(Member member, Pageable pageable);
ShareGroup findShareGroup(Long shareGroupId);
ShareGroup findShareGroup(String inviteCode);
List<Profile> findProfileList(Long shareGroupId);
ShareGroup joinShareGroup(Long shareGroupId, Long profileId, Member member);
List<Profile> findProfileListByShareGroupId(Long shareGroupId);
List<Profile> findProfileListByMemberId(Long memberId);
Profile findProfile(Long profileId);
Profile findProfile(Long shareGroupId, Long memberID);
Page<ShareGroup> getMyShareGroupList(Member member, Pageable pageable);
ShareGroup deleteShareGroup(Long shareGroupId, Member member);
ShareGroup getInviteInfo(Long shareGroupId, Member member);
boolean doesProfileExist(Long shareGroupId, Long memberId);
List<Profile> findProfileList(Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ public ShareGroup findShareGroup(String inviteCode) {
.orElseThrow(() -> new BusinessException(ShareGroupErrorCode.SHARE_GROUP_NOT_FOUND));
}

@Override
public List<Profile> findProfileList(Long shareGroupId) {
return profileRepository.findByShareGroupId(shareGroupId);
}

@Override
public Profile findProfile(Long profileId) {
return profileRepository.findById(profileId)
Expand All @@ -164,7 +159,12 @@ public boolean doesProfileExist(Long shareGroupId, Long memberId) {
}

@Override
public List<Profile> findProfileList(Member member) {
return profileRepository.findByMember(member);
public List<Profile> findProfileListByShareGroupId(Long shareGroupId) {
return profileRepository.findByShareGroupId(shareGroupId);
}

@Override
public List<Profile> findProfileListByMemberId(Long memberId) {
return profileRepository.findByMemberId(memberId);
}
}

0 comments on commit 789ab91

Please sign in to comment.