Skip to content

Commit

Permalink
feat: 사용자 정보 조회 API 개발
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Dec 11, 2024
1 parent 8f7c241 commit 1770b0b
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.official.cufitapi.domain.api.dto

import com.official.cufitapi.domain.enums.MatchMakerCandidateRelationType
import io.swagger.v3.oas.annotations.media.Schema


@Schema(name = "사용자 정보 응답")
data class MemberInfoResponse(
@Schema(name = "이름")
val name: String,
@Schema(name = "email")
val email: String,
@Schema(name = "초대자 이름")
val inviteeName: String,
@Schema(name = "초대한 사람과의 관계")
val relationWithInvitee: MatchMakerCandidateRelationType
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.official.cufitapi.domain.api.dto.connection

data class ConnectionApplyRequest(
val name: String
) {
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.official.cufitapi.domain.application

import com.official.cufitapi.domain.api.dto.connection.ConnectionApplyRequest
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
@Transactional(readOnly = true)
class ConnectionService {

fun apply(memberId: Long, request: ConnectionApplyRequest) {
// 요청 정보 DB에 저장
// 알림
}

fun reject() {
// 연결 요청 제거
// push
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
package com.official.cufitapi.domain.application

import com.official.cufitapi.common.exception.InvalidRequestException
import com.official.cufitapi.domain.api.dto.MemberInfoResponse
import com.official.cufitapi.domain.api.dto.MemberProfileRequest
import com.official.cufitapi.domain.infrastructure.repository.InvitationJpaRepository
import com.official.cufitapi.domain.infrastructure.repository.MemberJpaRepository
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
@Transactional(readOnly = true)
class MemberService(
private val memberJpaRepository: MemberJpaRepository
private val memberJpaRepository: MemberJpaRepository,
private val invitationJpaRepository: InvitationJpaRepository
) {
fun getMemberInfo(memberId: Long): MemberInfoResponse {
val member = memberJpaRepository.findById(memberId)
.orElseThrow { InvalidRequestException("존재하지 않는 사용자 id: $memberId") }
val invitee = memberJpaRepository.findById(member.inviteeId)
.orElseThrow { InvalidRequestException("존재하지 않는 사용자 id: $memberId") }
val invitation = invitationJpaRepository.findByMemberId(memberId) ?: throw InvalidRequestException("존재하지 않는 사용자 id: $memberId")

fun getMemberInfo() : MemberInfoResponse {
return MemberInfoResponse(
name = "",
email = ""
name = member.name,
email = member.email,
inviteeName = invitee.name,
relationWithInvitee = invitation.relationType
)
}

fun updateMemberProfile(memberId: Long, request: MemberProfileRequest) {

// Implementation for updating member profile
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class Invitation(
*/
val code: String,
/*
초대한 사람과의 관계
초대하는 사람과의 관계
*/
val relationType: MatchMakerCandidateRelationType,
/*
초대한 사용자 ID
초대하는 사용자 ID
*/
val memberId: Long,
/*
Expand All @@ -33,7 +33,6 @@ class Invitation(

) : BaseTimeEntity() {

fun deactivate() {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.official.cufitapi.domain.infrastructure.entity

import com.official.cufitapi.domain.enums.MatchMakerCandidateRelationType
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.Id

@Entity
class MakerCandidateRelation(
@Id @GeneratedValue
val id: Long? = null,
val makerId: Long,
val candidateId: Long,
val relationType: MatchMakerCandidateRelationType
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import jakarta.persistence.Id
class MatchCandidate(
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long? = null,
/*
사용자 id
*/
val memberId: Long,


/*
후보자 Table
이상형 정보
*/
val matchMakerId: Long

) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import jakarta.persistence.Id
@Entity
class MatchMaker(
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long? = null
val id: Long? = null,
/*
사용자 id
*/
val memberId: Long
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,14 @@ class Member(
val name: String,

/*
나를 초대한 유저의 id
*/
val inviteeId: Long,

/*
사용자 email
*/
val height: Int,
val email: String,

/*
나이
나를 초대한 유저의 id
*/
val age: Int

val inviteeId: Long,

) : BaseTimeEntity() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ interface InvitationJpaRepository : JpaRepository<Invitation, Long> {

fun existsByMemberIdAndCodeAndActivatedIsTrue(memberId: Long, code: String) : Boolean
fun findByCode(code: String) : Invitation?
fun findByMemberId(memberId: Long) : Invitation?
}

0 comments on commit 1770b0b

Please sign in to comment.