diff --git a/src/main/kotlin/uoslife/servermeeting/global/error/exception/ErrorCode.kt b/src/main/kotlin/uoslife/servermeeting/global/error/exception/ErrorCode.kt index 3a2b0cfa..b1d2d945 100644 --- a/src/main/kotlin/uoslife/servermeeting/global/error/exception/ErrorCode.kt +++ b/src/main/kotlin/uoslife/servermeeting/global/error/exception/ErrorCode.kt @@ -73,6 +73,11 @@ enum class ErrorCode(val code: String, val message: String, var status: Int) { ), // Match MATCH_NOT_FOUND("MT01", "Match is not Found.", HttpStatus.BAD_REQUEST.value()), + ONLY_TEAM_LEADER_CAN_GET_MATCH( + "MT02", + "Only Team Leader Can Get Match.", + HttpStatus.BAD_REQUEST.value() + ), // External API EXTERNAL_API_FAILED( diff --git a/src/main/kotlin/uoslife/servermeeting/match/dto/response/MatchedMeetingTeamInformationGetResponse.kt b/src/main/kotlin/uoslife/servermeeting/match/dto/response/MatchedMeetingTeamInformationGetResponse.kt index 4f9f8660..16d1b970 100644 --- a/src/main/kotlin/uoslife/servermeeting/match/dto/response/MatchedMeetingTeamInformationGetResponse.kt +++ b/src/main/kotlin/uoslife/servermeeting/match/dto/response/MatchedMeetingTeamInformationGetResponse.kt @@ -10,7 +10,7 @@ data class MatchedMeetingTeamInformationGetResponse( @field:NotNull @Schema(description = "팀 타입", example = "SINGLE") val teamType: TeamType, @Schema(description = "팀 이름", example = "팀 이름(1:1인 경우 null)") val teamName: String?, @field:NotNull @Schema(description = "성별", example = "MALE") val gender: GenderType, - @Schema(description = "팀에 속한 유저 정보") val teamUserList: List?, + @Schema(description = "팀에 속한 유저 정보") val leaderProfile: UserProfile?, @Schema(description = "질문 응답값") val information: MatchedInformation?, @Schema(description = "상대에게 전하는 메세지") val message: String? ) diff --git a/src/main/kotlin/uoslife/servermeeting/match/service/MatchingService.kt b/src/main/kotlin/uoslife/servermeeting/match/service/MatchingService.kt index 15e6f4a2..1366a537 100644 --- a/src/main/kotlin/uoslife/servermeeting/match/service/MatchingService.kt +++ b/src/main/kotlin/uoslife/servermeeting/match/service/MatchingService.kt @@ -11,6 +11,7 @@ import uoslife.servermeeting.meetingteam.entity.MeetingTeam import uoslife.servermeeting.meetingteam.entity.enums.TeamType.SINGLE import uoslife.servermeeting.meetingteam.entity.enums.TeamType.TRIPLE import uoslife.servermeeting.meetingteam.exception.MeetingTeamNotFoundException +import uoslife.servermeeting.meetingteam.exception.OnlyTeamLeaderCanGetMatchException import uoslife.servermeeting.meetingteam.service.impl.SingleMeetingService import uoslife.servermeeting.meetingteam.service.impl.TripleMeetingService import uoslife.servermeeting.user.dao.UserDao @@ -21,8 +22,8 @@ import uoslife.servermeeting.user.exception.UserNotFoundException @Service @Transactional(readOnly = true) class MatchingService( - private val userDao: UserDao, private val matchedDao: MatchedDao, + private val userDao: UserDao, private val singleMeetingService: SingleMeetingService, private val tripleMeetingService: TripleMeetingService, ) { @@ -31,10 +32,10 @@ class MatchingService( val user = userDao.findUserWithMeetingTeam(userId) ?: throw UserNotFoundException() val meetingTeam = user.team ?: throw MeetingTeamNotFoundException() - val match = getMatchByGender(user, meetingTeam) + if (!isLeader(user)) throw OnlyTeamLeaderCanGetMatchException() + val match = getMatchByGender(user, meetingTeam) val opponentTeam = getOpponentTeamByGender(user, match) - val opponentUser = opponentTeam.leader ?: throw UserNotFoundException() return MatchInformationResponse( @@ -74,4 +75,9 @@ class MatchingService( } return meetingTeamInformationGetResponse.toMatchedMeetingTeamInformationGetResponse() } + + private fun isLeader(user: User): Boolean { + if (user.team!!.leader!!.id == user.id) return true + return false + } } diff --git a/src/main/kotlin/uoslife/servermeeting/meetingteam/dto/response/MeetingTeamInformationGetResponse.kt b/src/main/kotlin/uoslife/servermeeting/meetingteam/dto/response/MeetingTeamInformationGetResponse.kt index 26d170fb..26252cd5 100644 --- a/src/main/kotlin/uoslife/servermeeting/meetingteam/dto/response/MeetingTeamInformationGetResponse.kt +++ b/src/main/kotlin/uoslife/servermeeting/meetingteam/dto/response/MeetingTeamInformationGetResponse.kt @@ -13,7 +13,7 @@ data class MeetingTeamInformationGetResponse( @field:NotNull @Schema(description = "팀 타입", example = "SINGLE") val teamType: TeamType, @Schema(description = "팀 이름", example = "팀 이름(1:1인 경우 null)") val teamName: String?, @field:NotNull @Schema(description = "성별", example = "MALE") val gender: GenderType, - @Schema(description = "팀에 속한 유저 정보") val teamUserList: List?, + @Schema(description = "팀에 속한 유저 정보") val opponentLeaderProfile: UserProfile?, @Schema(description = "질문 응답값") val information: Information?, @Schema(description = "상대방 선호 응답값") val preference: Preference?, @Schema(description = "상대에게 전하는 메세지") val message: String? @@ -23,7 +23,7 @@ data class MeetingTeamInformationGetResponse( teamType = teamType, teamName = teamName, gender = gender, - teamUserList = teamUserList, + leaderProfile = opponentLeaderProfile, information = information?.toMatchedInformation(), message = message ) @@ -32,9 +32,9 @@ data class MeetingTeamInformationGetResponse( data class UserProfile( @field:NotNull @Schema(description = "유저 이름", example = "이름") val name: String, - @Schema(description = "유저 전화번호", example = "01012341234") val phoneNumber: String?, + // @Schema(description = "유저 전화번호", example = "01012341234") val phoneNumber: String?, @field:NotNull @Schema(description = "유저 나이", example = "20") val age: Int, - @Schema(description = "유저 키", example = "180") val height: Int?, + // @Schema(description = "유저 키", example = "180") val height: Int?, @Schema(description = "대학", example = "UOS") val university: University?, @field:NotNull @Schema(description = "학과", example = "경영학부") val department: String, @field:NotNull @@ -42,7 +42,7 @@ data class UserProfile( val studentType: StudentType, @field:NotNull @Schema(description = "카카오톡 ID", example = "kakaoId") val kakaoTalkId: String, @Schema(description = "흡연 여부", example = "TRUE") val smoking: SmokingType?, - @Schema(description = "종교", example = "CHRISTIAN") val religion: ReligionType?, + // @Schema(description = "종교", example = "CHRISTIAN") val religion: ReligionType?, @Schema(description = "한달 최소 음주량", example = "1") val drinkingMin: Int?, @Schema(description = "한달 최대 음주량", example = "10") val drinkingMax: Int?, @Schema(description = "동물상", example = "[\"DOG\", \"CAT\"]") diff --git a/src/main/kotlin/uoslife/servermeeting/meetingteam/exception/OnlyTeamLeaderCanGetMatchException.kt b/src/main/kotlin/uoslife/servermeeting/meetingteam/exception/OnlyTeamLeaderCanGetMatchException.kt new file mode 100644 index 00000000..7c94fc74 --- /dev/null +++ b/src/main/kotlin/uoslife/servermeeting/meetingteam/exception/OnlyTeamLeaderCanGetMatchException.kt @@ -0,0 +1,7 @@ +package uoslife.servermeeting.meetingteam.exception + +import uoslife.servermeeting.global.error.exception.AccessDeniedException +import uoslife.servermeeting.global.error.exception.ErrorCode + +class OnlyTeamLeaderCanGetMatchException : + AccessDeniedException(ErrorCode.ONLY_TEAM_LEADER_CAN_GET_MATCH) diff --git a/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/PortOneService.kt b/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/PortOneService.kt index ace49915..d3ced452 100644 --- a/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/PortOneService.kt +++ b/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/PortOneService.kt @@ -136,7 +136,7 @@ class PortOneService( payment.price ) - payment.status = PaymentStatus.REFUND + paymentRepository.delete(payment) return PaymentResponseDto.PaymentRefundResponse(true, "") } catch (e: ExternalApiFailedException) { payment.status = PaymentStatus.REFUND_FAILED diff --git a/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/SingleMeetingService.kt b/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/SingleMeetingService.kt index 9272aa54..2ab8ab94 100644 --- a/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/SingleMeetingService.kt +++ b/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/SingleMeetingService.kt @@ -117,7 +117,7 @@ class SingleMeetingService( return meetingServiceUtils.toMeetingTeamInformationGetResponse( user.userPersonalInformation.gender, TeamType.SINGLE, - listOf(user), + user, information, preference, null, diff --git a/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/TripleMeetingService.kt b/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/TripleMeetingService.kt index 54ef4468..8e54924d 100644 --- a/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/TripleMeetingService.kt +++ b/src/main/kotlin/uoslife/servermeeting/meetingteam/service/impl/TripleMeetingService.kt @@ -160,7 +160,7 @@ class TripleMeetingService( return meetingServiceUtils.toMeetingTeamInformationGetResponse( user.userPersonalInformation.gender, TeamType.TRIPLE, - userList, + user, information, preference, meetingTeam.name, diff --git a/src/main/kotlin/uoslife/servermeeting/meetingteam/service/util/MeetingServiceUtils.kt b/src/main/kotlin/uoslife/servermeeting/meetingteam/service/util/MeetingServiceUtils.kt index 35bbf029..0c0a7376 100644 --- a/src/main/kotlin/uoslife/servermeeting/meetingteam/service/util/MeetingServiceUtils.kt +++ b/src/main/kotlin/uoslife/servermeeting/meetingteam/service/util/MeetingServiceUtils.kt @@ -17,7 +17,7 @@ class MeetingServiceUtils { fun toMeetingTeamInformationGetResponse( gender: GenderType, teamType: TeamType, - userList: List, + user: User, information: Information, preference: Preference, teamName: String?, @@ -27,26 +27,21 @@ class MeetingServiceUtils { teamType = teamType, teamName = teamName, gender = gender, - teamUserList = - userList.map { - UserProfile( - name = it.name, - phoneNumber = it.phoneNumber, - age = it.userPersonalInformation.age, - height = it.userPersonalInformation.height, - university = it.userPersonalInformation.university, - department = it.userPersonalInformation.department, - studentType = it.userPersonalInformation.studentType, - kakaoTalkId = it.kakaoTalkId, - smoking = it.userPersonalInformation.smoking, - religion = it.userPersonalInformation.religion, - drinkingMin = it.userPersonalInformation.drinkingMin, - drinkingMax = it.userPersonalInformation.drinkingMax, - spiritAnimal = it.userPersonalInformation.spiritAnimal, - mbti = it.userPersonalInformation.mbti, - interest = it.userPersonalInformation.interest - ) - }, + opponentLeaderProfile = + UserProfile( + name = user.name, + age = user.userPersonalInformation.age, + university = user.userPersonalInformation.university, + department = user.userPersonalInformation.department, + studentType = user.userPersonalInformation.studentType, + kakaoTalkId = user.kakaoTalkId, + smoking = user.userPersonalInformation.smoking, + drinkingMin = user.userPersonalInformation.drinkingMin, + drinkingMax = user.userPersonalInformation.drinkingMax, + spiritAnimal = user.userPersonalInformation.spiritAnimal, + mbti = user.userPersonalInformation.mbti, + interest = user.userPersonalInformation.interest + ), information = information, preference = preference, message = message