Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/uoslife/server-meeting into…
Browse files Browse the repository at this point in the history
… fix/match
  • Loading branch information
hyunseung-you committed May 27, 2024
2 parents 964824b + 88126a1 commit 01e1225
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package uoslife.servermeeting.match.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import uoslife.servermeeting.meetingteam.dto.response.MeetingTeamInformationGetResponse

class MatchInformationResponse(
@Schema(description = "본인 이름", example = "호랑이") val myName: String,
@Schema(description = "매칭된 상대 정보")
val opponnentUserInformation: MeetingTeamInformationGetResponse
val opponnentUserInformation: MatchedMeetingTeamInformationGetResponse
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package uoslife.servermeeting.match.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotNull
import uoslife.servermeeting.meetingteam.dto.response.UserProfile
import uoslife.servermeeting.meetingteam.entity.enums.TeamType
import uoslife.servermeeting.user.entity.enums.GenderType

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<UserProfile>?,
@Schema(description = "질문 응답값") val information: MatchedInformation?,
@Schema(description = "상대에게 전하는 메세지") val message: String?
)

data class MatchedInformation(
val gender: GenderType? = null,
val questions: List<Int>? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import uoslife.servermeeting.match.dao.MatchedDao
import uoslife.servermeeting.match.dto.response.MatchInformationResponse
import uoslife.servermeeting.match.dto.response.MatchedMeetingTeamInformationGetResponse
import uoslife.servermeeting.match.entity.Match
import uoslife.servermeeting.match.exception.MatchNotFoundException
import uoslife.servermeeting.meetingteam.dto.response.MeetingTeamInformationGetResponse
import uoslife.servermeeting.meetingteam.entity.MeetingTeam
import uoslife.servermeeting.meetingteam.entity.enums.TeamType.SINGLE
import uoslife.servermeeting.meetingteam.entity.enums.TeamType.TRIPLE
Expand Down Expand Up @@ -65,15 +65,17 @@ class MatchingService(
fun getOpponentUserInformationByTeamType(
meetingTeam: MeetingTeam,
opponentUser: User
): MeetingTeamInformationGetResponse {
return when (meetingTeam.type) {
SINGLE -> {
singleMeetingService.getMeetingTeamInformation(opponentUser.id!!)
): MatchedMeetingTeamInformationGetResponse {
val meetingTeamInformationGetResponse =
when (meetingTeam.type) {
SINGLE -> {
singleMeetingService.getMeetingTeamInformation(opponentUser.id!!)
}
TRIPLE -> {
tripleMeetingService.getMeetingTeamInformation(opponentUser.id!!)
}
}
TRIPLE -> {
tripleMeetingService.getMeetingTeamInformation(opponentUser.id!!)
}
}
return meetingTeamInformationGetResponse.toMatchedMeetingTeamInformationGetResponse()
}

private fun isLeader(user: User): Boolean{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package uoslife.servermeeting.meetingteam.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotNull
import uoslife.servermeeting.match.dto.response.MatchedMeetingTeamInformationGetResponse
import uoslife.servermeeting.meetingteam.entity.Information
import uoslife.servermeeting.meetingteam.entity.Preference
import uoslife.servermeeting.meetingteam.entity.enums.TeamType
Expand All @@ -16,7 +17,18 @@ data class MeetingTeamInformationGetResponse(
@Schema(description = "질문 응답값") val information: Information?,
@Schema(description = "상대방 선호 응답값") val preference: Preference?,
@Schema(description = "상대에게 전하는 메세지") val message: String?
)
) {
fun toMatchedMeetingTeamInformationGetResponse(): MatchedMeetingTeamInformationGetResponse {
return MatchedMeetingTeamInformationGetResponse(
teamType = teamType,
teamName = teamName,
gender = gender,
teamUserList = teamUserList,
information = information?.toMatchedInformation(),
message = message
)
}
}

data class UserProfile(
@field:NotNull @Schema(description = "유저 이름", example = "이름") val name: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package uoslife.servermeeting.meetingteam.entity

import java.io.Serializable
import uoslife.servermeeting.match.dto.response.MatchedInformation
import uoslife.servermeeting.user.entity.enums.GenderType

data class Information(
val gender: GenderType? = null,
val questions: Map<Int, Int>? = null,
) : Serializable
) : Serializable {
fun toMatchedInformation(): MatchedInformation {
return MatchedInformation(gender = gender, questions = questions?.values?.toList())
}
}

0 comments on commit 01e1225

Please sign in to comment.