Skip to content

Commit

Permalink
[DPMBE-119] 약속 init, end Event 호출 누락을 처리한다 (#196)
Browse files Browse the repository at this point in the history
* feat : PromiseUserRegisterEvent 발행 호출

* feat : promise title 수정 및 불필요한 함수 제거

* refactor : 호출부 수정
  • Loading branch information
BlackBean99 authored Jul 15, 2023
1 parent 935c20e commit f4a8f78
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PromiseImageReadUseCase(
)
} ?: listOf()

return PromiseImageResponse(promiseUser.promiseUserType!!, result)
return PromiseImageResponse(promiseUser.promiseUserType, result)
}

fun getImagesByPromiseId(promiseId: Long): List<PromiseImageDto> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class PromiseController(
val promiseRegisterUseCase: PromiseRegisterUseCase,
val promiseReadUseCase: PromiseReadUseCase,
) {
// 나의 약속 전부 조회
@Deprecated("나의 약속 전부 조회", replaceWith = ReplaceWith("findPromiseByStatus"))
@Operation(summary = "나의 약속 전부 조회", description = "유저의 약속 전부 조회 (단, 예정된 약속과 지난 약속을 구분해서 조회")
// view 방식에 따라 구분하게 기능 추가 예정
Expand Down Expand Up @@ -75,14 +74,23 @@ class PromiseController(
return promiseRegisterUseCase.createPromise(promiseRequest)
}

// 1. 약속 장소 변경
@Operation(summary = "약속(promise) 장소 수정", description = "약속 장소를 변경합니다.")
@RequiresMainUser
@PutMapping("/promises/{promise-id}/location")
fun updatePromiseLocation(@PathVariable(value = "promise-id") promiseId: Long, @RequestBody meetPlace: PlaceVo): PromiseDto {
return promiseRegisterUseCase.updatePromiseMeetPlace(promiseId, meetPlace)
}

@Operation(summary = "약속(promise) 제목 수정", description = "약속 제목을 변경합니다.")
@RequiresMainUser
@PutMapping("/promises/{promise-id}/titles")
fun updatePromiseTitle(
@PathVariable(value = "promise-id") promiseId: Long,
@RequestParam title: String,
): PromiseDto {
return promiseRegisterUseCase.updatePromiseTitle(promiseId, title)
}

@Operation(summary = "약속(promise)시간 수정", description = "약속을 수정합니다. (약속 제목, 약속 장소, 약속 시간)")
@RequiresMainUser
@PutMapping("/promises/{promise-id}/end-times")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class PromiseReadUseCase(
.map { InteractionDto.from(it) }
.sortedByDescending { interactionDto -> interactionDto.count }
user?.let {
PromiseUserInfoVo.of(it, promiseUser.promiseUserType!!, interactions)
PromiseUserInfoVo.of(it, promiseUser.promiseUserType, interactions)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class PromiseRegisterUseCase(
return PromiseDto.from(updatePromise)
}

fun updatePromiseTitle(promiseId: Long, title: String): PromiseDto {
val updatePromise = promiseDomainService.updatePromiseTitle(promiseId, title)
return PromiseDto.from(updatePromise)
}

fun updatePromiseEndTime(promiseId: Long, endTime: LocalDateTime): PromiseDto {
val promise = promiseAdaptor.queryPromise(promiseId)
val updatePromise = promiseDomainService.updateEndTime(promise, endTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ data class PromiseLocationDto(
fun from(promiseUser: PromiseUser): PromiseLocationDto {
return PromiseLocationDto(
userId = promiseUser.userId,
userLocation = promiseUser.userLocation!!,
promiseUserType = promiseUser.promiseUserType!!,
userLocation = promiseUser.userLocation,
promiseUserType = promiseUser.promiseUserType,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class PromiseUserDto(
) {
companion object {
fun of(p: PromiseUser, progress: PromiseProgress): PromiseUserDto {
return PromiseUserDto(p.promiseId, p.userId, p.userLocation, p.promiseUserType!!, progress)
return PromiseUserDto(p.promiseId, p.userId, p.userLocation, p.promiseUserType, progress)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import javax.servlet.http.HttpServletResponse
class JwtTokenFilter(
val jwtTokenProvider: JwtTokenHelper,
) : OncePerRequestFilter() {

override fun doFilterInternal(
request: HttpServletRequest,
response: HttpServletResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SlackAsyncErrorSenderTest {

@BeforeEach
fun setup() {
MockitoAnnotations.initMocks(this)
MockitoAnnotations.openMocks(this)
slackAsyncErrorSender = SlackAsyncErrorSender(slackProvider, objectMapper)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.depromeet.whatnow.domains.promise.service

import com.depromeet.whatnow.common.vo.PlaceVo
import com.depromeet.whatnow.domains.progresshistory.domain.PromiseProgressGroup
import com.depromeet.whatnow.domains.promise.adaptor.PromiseAdaptor
import com.depromeet.whatnow.domains.promise.domain.Promise
import com.depromeet.whatnow.domains.promise.domain.PromiseType
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDateTime
Expand All @@ -13,61 +11,13 @@ import java.time.LocalDateTime
class PromiseDomainService(
val promiseAdaptor: PromiseAdaptor,
) {
fun registerPromise(
endTime: LocalDateTime,
title: String,
mainUserId: Long,
meetPlace: PlaceVo?,
promiseType: PromiseType,
): Promise {
val promise = Promise(
endTime = endTime,
title = title,
mainUserId = mainUserId,
meetPlace = meetPlace,
promiseType = promiseType,
)
return promiseAdaptor.save(promise)
}

@Transactional
fun updatePromiseTitle(promiseId: Long, title: String): Promise {
val promise = promiseAdaptor.queryPromise(promiseId)
// dirty checking
promise.updateTitle(title)
return promise
}

@Transactional
fun delayPromise(promiseId: Long, endTime: LocalDateTime): Promise {
val promise = promiseAdaptor.queryPromise(promiseId)
promise.delayPromise(endTime)
return promise
}

// 약속장소 변경
@Transactional
fun movePromisePlace(promiseId: Long, placeVo: PlaceVo): Promise {
val promise = promiseAdaptor.queryPromise(promiseId)
promise.movePlace(placeVo)
return promise
}

// 약속 진행상태(출발 전, 이동 중, 도착, ETC) 변경
@Transactional
fun pendingPromiseProgressType(promiseId: Long, promiseProgressGroup: PromiseProgressGroup): Promise {
val promise = promiseAdaptor.queryPromise(promiseId)
promise.pendingPromise()
return promise
}

@Transactional
fun endPromiseProgressType(promiseId: Long, promiseProgressGroup: PromiseProgressGroup): Promise {
val promise = promiseAdaptor.queryPromise(promiseId)
promise.endPromise()
return promise
}

// 약속 취소 처리
@Transactional
fun deletePromise(promise: Promise) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class PromiseUserDomainService(
* */
@Transactional
fun createPromiseUser(promiseUser: PromiseUser): PromiseUser {
return promiseUserAdaptor.save(promiseUser)
val promiseUser = promiseUserAdaptor.save(promiseUser)
promiseUser.createPromiseUserEvent()
return promiseUser
}

fun findByPromiseId(promiseId: Long): List<PromiseUser> {
Expand Down

0 comments on commit f4a8f78

Please sign in to comment.