Skip to content

Commit

Permalink
Merge pull request #103 from mash-up-kr/xonmin/update-userAuthInfo-pa…
Browse files Browse the repository at this point in the history
…ram-api

update : todo user id param / delete unused code / 시트지조회 mock 제거
  • Loading branch information
xonmin authored Aug 17, 2024
2 parents fc6b4a2 + 739db59 commit f8f1154
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 107 deletions.
7 changes: 4 additions & 3 deletions api/src/main/kotlin/com/mashup/dojo/CoinController.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mashup.dojo

import com.mashup.dojo.common.DojoApiResponse
import com.mashup.dojo.domain.MemberId
import com.mashup.dojo.config.security.MemberPrincipalContextHolder
import com.mashup.dojo.dto.CurrentCoinResponse
import com.mashup.dojo.usecase.CoinUseCase
import io.swagger.v3.oas.annotations.Operation
Expand All @@ -25,8 +25,9 @@ class CoinController(
ApiResponse(responseCode = "200", description = "코인 정보 조회")
]
)
fun getCurrentCoin(): DojoApiResponse<CurrentCoinResponse> { // TODO : param UserInfo
val currentCoin = coinUseCase.getCurrentCoin(CoinUseCase.GetCurrentCoinCommand(MemberId("1")))
fun getCurrentCoin(): DojoApiResponse<CurrentCoinResponse> {
val memberId = MemberPrincipalContextHolder.current().id
val currentCoin = coinUseCase.getCurrentCoin(CoinUseCase.GetCurrentCoinCommand(memberId))

return DojoApiResponse.success(
CurrentCoinResponse(
Expand Down
10 changes: 4 additions & 6 deletions api/src/main/kotlin/com/mashup/dojo/PickController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.mashup.dojo

import com.mashup.dojo.common.DojoApiResponse
import com.mashup.dojo.config.security.MemberPrincipalContextHolder
import com.mashup.dojo.domain.MemberId
import com.mashup.dojo.domain.PickId
import com.mashup.dojo.domain.PickOpenItem
import com.mashup.dojo.domain.PickSort
Expand Down Expand Up @@ -164,14 +163,14 @@ class PickController(
fun create(
@RequestBody request: CreatePickRequest,
): DojoApiResponse<PickId> {
// todo : update memberId to AuthInfo
val currentMemberId = MemberPrincipalContextHolder.current().id
val pickId =
pickUseCase.createPick(
PickUseCase.CreatePickCommand(
questionSheetId = request.questionSheetId,
questionSetId = request.questionSetId,
questionId = request.questionId,
pickerId = MemberId("1"),
pickerId = currentMemberId,
pickedId = request.pickedId
)
)
Expand Down Expand Up @@ -201,15 +200,14 @@ class PickController(
]
)
fun openPick(
// todo: add userInfo
@PathVariable id: String,
@Valid @RequestBody request: PickOpenRequest,
): DojoApiResponse<PickOpenResponse> {
// todd: pickedId에 실제 유저 id 전달
val memberId = MemberPrincipalContextHolder.current().id
return pickUseCase.openPick(
PickUseCase.OpenPickCommand(
pickId = PickId(id),
pickedId = MemberId("MOCK_MEMBER_ID"),
pickedId = memberId,
pickOpenItem = PickOpenItem.findByValue(request.pickOpenItemDto.value)
)
).let { DojoApiResponse.success(PickOpenResponse(it.pickId.value, PickOpenItemDto.findByValue(it.pickOpenItem.value), it.value)) }
Expand Down
10 changes: 4 additions & 6 deletions api/src/main/kotlin/com/mashup/dojo/QuestionController.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mashup.dojo

import com.mashup.dojo.domain.MemberId
import com.mashup.dojo.config.security.MemberPrincipalContextHolder
import com.mashup.dojo.dto.QuestionSheetCandidate
import com.mashup.dojo.dto.QuestionSheetResponse
import com.mashup.dojo.dto.QuestionSheetsGetResponse
Expand Down Expand Up @@ -29,11 +29,9 @@ class QuestionController(
ApiResponse(responseCode = "200", description = "OK")
]
)
fun getQuestionSheet(
// todo add auth for memberId
): QuestionSheetsGetResponse {
// todo update to param Member auth info
return questionUseCase.getQuestionSheetList(MemberId("d")).toResponse()
fun getQuestionSheet(): QuestionSheetsGetResponse {
val memberId = MemberPrincipalContextHolder.current().id
return questionUseCase.getQuestionSheetList(memberId).toResponse()
}
}

Expand Down
31 changes: 0 additions & 31 deletions service/src/main/kotlin/com/mashup/dojo/service/MemberService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.mashup.dojo.DojoException
import com.mashup.dojo.DojoExceptionType
import com.mashup.dojo.MemberEntity
import com.mashup.dojo.MemberRepository
import com.mashup.dojo.domain.Candidate
import com.mashup.dojo.domain.ImageId
import com.mashup.dojo.domain.Member
import com.mashup.dojo.domain.MemberGender
Expand All @@ -17,8 +16,6 @@ import java.time.LocalDateTime
import kotlin.jvm.optionals.getOrNull

interface MemberService {
fun getCandidates(currentMemberId: MemberId): List<Candidate>

fun findMemberById(memberId: MemberId): Member?

fun create(command: CreateMember): MemberId
Expand Down Expand Up @@ -67,34 +64,6 @@ class DefaultMemberService(
)
}

override fun getCandidates(currentMemberId: MemberId): List<Candidate> {
val memberRelation1 = mockMemberRelation(currentMemberId, MemberId("20"))
val memberRelation2 = mockMemberRelation(currentMemberId, MemberId("30"))
val memberRelation3 = mockMemberRelation(currentMemberId, MemberId("40"))
val memberRelation4 = mockMemberRelation(currentMemberId, MemberId("50"))
val memberRelation5 = mockMemberRelation(currentMemberId, MemberId("60"))
val memberRelation6 = mockMemberRelation(currentMemberId, MemberId("70"))

/**
* ToDo
* 친구들 중 랜덤 4명 뽑기
* Mock, 랜덤으로 뽑은 4명.
*
*/

val targetMemberId1 = memberRelation1.toId
val targetMemberId2 = memberRelation2.toId
val targetMemberId3 = memberRelation3.toId
val targetMemberId4 = memberRelation4.toId

val candidate1 = Candidate(targetMemberId1, "한씨", ImageId("member-image-id-1"), MemberPlatform.SPRING)
val candidate2 = Candidate(targetMemberId2, "오씨", ImageId("member-image-id-2"), MemberPlatform.SPRING)
val candidate3 = Candidate(targetMemberId3, "박씨", ImageId("member-image-id-3"), MemberPlatform.SPRING)
val candidate4 = Candidate(targetMemberId4, "", ImageId("member-image-id-4"), MemberPlatform.SPRING)

return listOf(candidate1, candidate2, candidate3, candidate4)
}

override fun findMemberById(memberId: MemberId): Member? {
val member = memberRepository.findById(memberId.value)
return member.getOrNull()?.toMember()
Expand Down
62 changes: 3 additions & 59 deletions service/src/main/kotlin/com/mashup/dojo/service/QuestionService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,9 @@ class DefaultQuestionService(
*/

val candidates =
if (questionType == QuestionType.FRIEND) {
candidatesOfFriend
} else if (questionType == QuestionType.ACCOMPANY) {
candidatesOfAccompany
} else {
throw DojoException.of(DojoExceptionType.QUESTION_INVALID_TYPE)
when (questionType) {
QuestionType.FRIEND -> candidatesOfFriend
QuestionType.ACCOMPANY -> candidatesOfAccompany
}

return QuestionSheet.create(
Expand All @@ -279,59 +276,6 @@ class DefaultQuestionService(
return questionRepository.findByIdOrNull(id.value)?.toQuestion()
?: throw DojoException.of(DojoExceptionType.QUESTION_NOT_EXIST)
}

companion object {
private const val DEFAULT_QUESTION_SIZE: Int = 12
val SAMPLE_QUESTION =
Question(
id = QuestionId("1234564"),
content = "세상에서 제일 멋쟁이인 사람",
type = QuestionType.FRIEND,
category = QuestionCategory.DATING,
emojiImageId = ImageId("345678")
)

private val SAMPLE_QUESTION_SET =
QuestionSet(
id = QuestionSetId("1"),
questionIds =
listOf(
QuestionOrder(QuestionId("1"), 1),
QuestionOrder(QuestionId("2"), 2),
QuestionOrder(QuestionId("3"), 3),
QuestionOrder(QuestionId("4"), 4),
QuestionOrder(QuestionId("5"), 5),
QuestionOrder(QuestionId("6"), 6),
QuestionOrder(QuestionId("7"), 7),
QuestionOrder(QuestionId("8"), 8),
QuestionOrder(QuestionId("9"), 9),
QuestionOrder(QuestionId("10"), 10),
QuestionOrder(QuestionId("11"), 11),
QuestionOrder(QuestionId("12"), 12)
),
publishedAt = LocalDateTime.now(),
endAt = LocalDateTime.now().plusHours(12)
)

private val SAMPLE_QUESTION_SHEET =
QuestionSheet(
questionSheetId = QuestionSheetId("1"),
questionSetId = SAMPLE_QUESTION_SET.id,
questionId = QuestionId("1"),
resolverId = MemberId("1"),
candidates =
listOf(
MemberId("2"),
MemberId("3"),
MemberId("4"),
MemberId("5")
)
)

// TODO: Set to 3 sheets initially. Need to modify for all users later.
val LIST_SAMPLE_QUESTION_SHEET =
listOf(SAMPLE_QUESTION_SHEET, SAMPLE_QUESTION_SHEET, SAMPLE_QUESTION_SHEET)
}
}

private fun Question.toEntity(): QuestionEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ class DefaultQuestionUseCase(
}

override fun getQuestionSheetList(memberId: MemberId): QuestionUseCase.GetQuestionSheetsResult {
return TEMP_GET_QUESTION_SHEETS_RESULT
// 운영중인 questionSet 조회 (todo : scheduler 가 최신 QuestionSet 을 발행 시각 2분전에 publishedYn Y 로 변경 예정)
val operatingQSet =
questionService.getOperatingQuestionSet()
?: throw DojoException.of(DojoExceptionType.QUESTION_SET_OPERATING_NOT_EXIST)
Expand Down

0 comments on commit f8f1154

Please sign in to comment.