Skip to content

Commit

Permalink
Merge pull request #79 from whatever-mentoring/feature/goal-gifticon-…
Browse files Browse the repository at this point in the history
…service-test

Feature/goal gifticon service test
  • Loading branch information
mkSpace authored Jan 20, 2024
2 parents 932e7d8 + 1b0e1a1 commit 70e1d9e
Show file tree
Hide file tree
Showing 13 changed files with 277 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class BettingApplicationService(
val betting = findByIdOrThrowException(request.bettingId)
betting.validateOwnerId(request.userId)
betting.validateStartDate()
return BettingRetrieveResponse.of(bettingService.updatePredictionType(request.bettingId, request.bettingPredictionType))
return BettingRetrieveResponse.of(bettingService.updatePredictionType(request.bettingId,
request.bettingPredictionType))
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class GoalApplicationService(
val gifticon = gifticonService.create(request.userId, request.gifticonUrl)
goalGifticonService.create(
goalId = goal.id,
gifticonId = gifticon.id,
userId = request.userId
gifticonId = gifticon.id
)
}
val hostUser = userService.loadById(request.userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ class GoalGifticonApplicationService(
executionMessage = "기프티콘을 업로드하는 중, 이미 다짐 수행이 시작되어 업로드할 수 없습니다."
)


val gifticon = gifticonService.create(request.userId, request.uploadedURL)
val goalGifticon = goalGifticonService.create(
goalId = request.goalId,
gifticonId = gifticon.id,
userId = request.userId
gifticonId = gifticon.id
)
return GoalGifticonResponse(
goalGifticonId = goalGifticon.id,
Expand All @@ -64,17 +62,13 @@ class GoalGifticonApplicationService(
goalId: Long,
userId: Long
): GifticonResponse {
val user = userService.loadById(userId)
val goal = goalService.findById(goalId)
isBrokenTiming(goal)

val goalGifticon = if (userId != goal.userId) {
null
} else {
goalGifticonService.loadByGoalAndUserEntity(
goal = goal,
userEntity = user.fromDto()
)
goalGifticonService.findByGoalId(goal.id)
}
val winnerGifticonId = winnerService.findByGoalIdAndUserId(goalId, userId)?.gifticonId
val actualGifticonId = goalGifticon?.gifticonId ?: winnerGifticonId ?: throw BaseException.of(
Expand All @@ -94,10 +88,8 @@ class GoalGifticonApplicationService(
fun updateGifticonURLByGoalId(request: GoalGifticonUpdateServiceRequest): GoalGifticonResponse {
val userEntity = userService.loadById(request.userId).fromDto()
val goal = goalService.findById(request.goalId).fromDto(userEntity).toDto()
val goalGifticon = goalGifticonService.loadByGoalAndUserEntity(
goal = goal,
userEntity = userEntity
) ?: throw BaseException.of(ExceptionCode.E404_NOT_FOUND, "다짐에 등록된 기프티콘을 찾을 수 없습니다.")
val goalGifticon = goalGifticonService.findByGoalId(goal.id)
?: throw BaseException.of(ExceptionCode.E404_NOT_FOUND, "다짐에 등록된 기프티콘을 찾을 수 없습니다.")
val gifticon = gifticonService.findById(goalGifticon.gifticonId)

validateIsRequestUserHasUpdateAuthority(goal, request.userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ class TestApplicationService(
loserBettingList.map { betting -> betting.id }.toSet(),
com.whatever.raisedragon.domain.betting.BettingResult.NO_GIFTICON
)
bettingService.updateResult(winnerBetting.id, com.whatever.raisedragon.domain.betting.BettingResult.GET_GIFTICON)
bettingService.updateResult(
bettingId = winnerBetting.id,
bettingResult = com.whatever.raisedragon.domain.betting.BettingResult.GET_GIFTICON
)
winnerService.create(
goalId = goal.id,
userId = winnerBetting.userId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class UserApplicationService(
exceptionCode = ExceptionCode.E400_BAD_REQUEST,
executionMessage = "아직 진행중인 다짐이 있어 회원탈퇴에 실패했습니다."
)
}
else if (bettingService.existsBettingParticipantUser(id)) {
} else if (bettingService.existsBettingParticipantUser(id)) {
throw BaseException.of(
exceptionCode = ExceptionCode.E400_BAD_REQUEST,
executionMessage = "아직 진행중인 다짐에 대한 내기가 있어 회원탈퇴에 실패했습니다."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.whatever.raisedragon.common

import com.whatever.raisedragon.common.exception.BaseException
import com.whatever.raisedragon.common.exception.ExceptionCode
import org.springframework.http.HttpStatus

data class Response<T>(
val isSuccess: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ data class GoalProofUpdateRequest(
val comment: String? = null
)

fun GoalProofUpdateRequest.toServiceRequest(userId: Long, goalProofId: Long): GoalProofUpdateServiceRequest =
GoalProofUpdateServiceRequest(
userId = userId,
goalProofId = goalProofId,
url = url,
comment = comment?.let { Comment(it) }
fun GoalProofUpdateRequest.toServiceRequest(
userId: Long,
goalProofId: Long
): GoalProofUpdateServiceRequest = GoalProofUpdateServiceRequest(
userId = userId,
goalProofId = goalProofId,
url = url,
comment = comment?.let { Comment(it) }
)
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class JwtAgentImpl(

companion object {
const val BEARER_PREFIX = "Bearer"
// private const val ACCESS_TOKEN_EXPIRE_TIME = (1000 * 60 * 30).toLong()

// private const val ACCESS_TOKEN_EXPIRE_TIME = (1000 * 60 * 30).toLong()
private const val ACCESS_TOKEN_EXPIRE_TIME = (1000 * 60 * 60 * 24 * 7).toLong() // 임시 JWT 만료기간
private const val REFRESH_TOKEN_EXPIRE_TIME = (1000 * 60 * 60 * 24 * 7).toLong()
private const val CLAIM_INFO_KEY = "claim-info"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UserInfoArgumentResolver : HandlerMethodArgumentResolver {

override fun supportsParameter(parameter: MethodParameter): Boolean {
return parameter.hasParameterAnnotation(GetAuth::class.java)
&& parameter.parameter.type == UserInfo::class.java
&& parameter.parameter.type == UserInfo::class.java
}

override fun resolveArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package com.whatever.raisedragon.domain.goalgifticon

import com.whatever.raisedragon.common.exception.BaseException
import com.whatever.raisedragon.domain.gifticon.GifticonRepository
import com.whatever.raisedragon.domain.goal.Goal
import com.whatever.raisedragon.domain.goal.GoalRepository
import com.whatever.raisedragon.domain.goal.fromDto
import com.whatever.raisedragon.domain.user.UserEntity
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
Expand All @@ -23,8 +20,7 @@ class GoalGifticonService(
@Transactional
fun create(
goalId: Long,
gifticonId: Long,
userId: Long,
gifticonId: Long
): GoalGifticon {
val goalGifticon = goalGifticonRepository.save(
GoalGifticonEntity(
Expand All @@ -35,18 +31,6 @@ class GoalGifticonService(
return goalGifticon.toDto()
}

fun loadById(id: Long): GoalGifticon {
return goalGifticonRepository.findById(id).orElseThrow(notFoundExceptionSupplier).toDto()
}

fun loadByGoalAndUserEntity(
goal: Goal,
userEntity: UserEntity
): GoalGifticon? {
return goalGifticonRepository.findByGoalEntity(goal.fromDto(userEntity))?.toDto()
?: throw notFoundExceptionSupplier.get()
}

fun findByGoalId(goalId: Long): GoalGifticon? {
val goalEntity = goalRepository.findById(goalId).orElseThrow(notFoundExceptionSupplier)
return goalGifticonRepository.findByGoalEntity(goalEntity)?.toDto()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ package com.whatever.raisedragon.domain.user
object RandomWordsNickname {

internal val adjectives = listOf(
"반장인","청순한","선물사는","미소짓는","달콤한","밤샘하는 ","슬기로운","인기많은","노래하는","귀여운",
"요가하는","라식한","용감한","공부하는","서핑하는","지혜로운","당돌한","산책하는","거울보는","작곡하는",
"돈많은","코딩하는","소원비는","사연있는","결혼한","씨름하는 ","여행하는","당찬","캠핑하는","팀플하는",
"한약먹는","깔끔한","휴가간","배부른","비행중인","기분좋은 ","조깅하는","회의하는","양치하는","고기굽는",
"휴가나온","행복한","알바하는","늦잠잔","면도하는","칼퇴한","요리하는","수줍은","이국적인","순박한",
"상큼한","똑똑한","명랑한","발랄한","활발한","친절한","부지런한","바른","배짱있는","밝은","빼어난",
"부드러운","반듯한","친숙한","차분한","침착한","청초한","착한","쾌활한","편안한","포근한","활달한",
"화끈한","화사한","훌륭한","털털한","튼튼한","강직한","고운","기특한","깜찍한","관대한","다정한",
"당당한","든든한","또렷한","단호한","대담한","놀라운","넉넉한","느긋한","맑은","멋진","어여쁜",
"우아한","위대한","순한","수려한","산뜻한","순수한","섬세한","상냥한","소탈한","기운찬","공손한",
"검소한","겸손한","꾸준한","고요한","솔직한","신중한","싹싹한","지적인","정직한","조용한","재밌는",
"존귀한","성실한","순진한","원만한","유능한","유쾌한",
"반장인", "청순한", "선물사는", "미소짓는", "달콤한", "밤샘하는 ", "슬기로운", "인기많은", "노래하는", "귀여운",
"요가하는", "라식한", "용감한", "공부하는", "서핑하는", "지혜로운", "당돌한", "산책하는", "거울보는", "작곡하는",
"돈많은", "코딩하는", "소원비는", "사연있는", "결혼한", "씨름하는 ", "여행하는", "당찬", "캠핑하는", "팀플하는",
"한약먹는", "깔끔한", "휴가간", "배부른", "비행중인", "기분좋은 ", "조깅하는", "회의하는", "양치하는", "고기굽는",
"휴가나온", "행복한", "알바하는", "늦잠잔", "면도하는", "칼퇴한", "요리하는", "수줍은", "이국적인", "순박한",
"상큼한", "똑똑한", "명랑한", "발랄한", "활발한", "친절한", "부지런한", "바른", "배짱있는", "밝은", "빼어난",
"부드러운", "반듯한", "친숙한", "차분한", "침착한", "청초한", "착한", "쾌활한", "편안한", "포근한", "활달한",
"화끈한", "화사한", "훌륭한", "털털한", "튼튼한", "강직한", "고운", "기특한", "깜찍한", "관대한", "다정한",
"당당한", "든든한", "또렷한", "단호한", "대담한", "놀라운", "넉넉한", "느긋한", "맑은", "멋진", "어여쁜",
"우아한", "위대한", "순한", "수려한", "산뜻한", "순수한", "섬세한", "상냥한", "소탈한", "기운찬", "공손한",
"검소한", "겸손한", "꾸준한", "고요한", "솔직한", "신중한", "싹싹한", "지적인", "정직한", "조용한", "재밌는",
"존귀한", "성실한", "순진한", "원만한", "유능한", "유쾌한",
)

internal val nouns = listOf(
"고양이","강아지","거북이","토끼","사자","호랑이","표범","기린","코끼리","코뿔소","하마","악어",
"펭귄","부엉이","올빼미 ","고릴라","침팬지","원숭이","코알라","캥거루","앵무새","판다","개구리",
"너구리","두더지","당나귀","수달","북극곰","미어캣","기러기","비둘기","돌고래","알파카","다람쥐",
"오소리","청설모","여우","사슴","낙타","비버","치타","문어","생쥐","병아리","물고기","햄스터",
"독수리","도롱뇽","해태","유니콘","그리핀","봉황","","드래곤","방울새","파랑새","봉황새","코요테",
"퓨마","벨루가","고라니","노루","스컹크","암탉","얼룩말","족제비","칠면조","타조","염소","수탉",
"물소","자라","오징어","","","개미","거머리","영양","맘모스","고래","나방","박쥐","올빼미",
"","나비","칼리브","사향소","브롱혼","순록","","","돼지","무스","엘크","와피티","가젤","",
"팬더","상어","도마뱀","","늑대","이리","담비","","솔개","재규어","왈라비","리드벅","리스트",
"리카온","해파리","지렁이","진드기","진딧물","고니","큰고니","살쾡이","공룡","재칼","밍크","비비",
"호저","문차크","에란드","몽구스","파리","강치","","모기","라이거","오카피",
"고양이", "강아지", "거북이", "토끼", "사자", "호랑이", "표범", "기린", "코끼리", "코뿔소", "하마", "악어",
"펭귄", "부엉이", "올빼미 ", "고릴라", "침팬지", "원숭이", "코알라", "캥거루", "앵무새", "판다", "개구리",
"너구리", "두더지", "당나귀", "수달", "북극곰", "미어캣", "기러기", "비둘기", "돌고래", "알파카", "다람쥐",
"오소리", "청설모", "여우", "사슴", "낙타", "비버", "치타", "문어", "생쥐", "병아리", "물고기", "햄스터",
"독수리", "도롱뇽", "해태", "유니콘", "그리핀", "봉황", "", "드래곤", "방울새", "파랑새", "봉황새", "코요테",
"퓨마", "벨루가", "고라니", "노루", "스컹크", "암탉", "얼룩말", "족제비", "칠면조", "타조", "염소", "수탉",
"물소", "자라", "오징어", "", "", "개미", "거머리", "영양", "맘모스", "고래", "나방", "박쥐", "올빼미",
"", "나비", "칼리브", "사향소", "브롱혼", "순록", "", "", "돼지", "무스", "엘크", "와피티", "가젤", "",
"팬더", "상어", "도마뱀", "", "늑대", "이리", "담비", "", "솔개", "재규어", "왈라비", "리드벅", "리스트",
"리카온", "해파리", "지렁이", "진드기", "진딧물", "고니", "큰고니", "살쾡이", "공룡", "재칼", "밍크", "비비",
"호저", "문차크", "에란드", "몽구스", "파리", "강치", "", "모기", "라이거", "오카피",
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.hibernate.annotations.SQLRestriction
@Table(name = "winner")
@Entity
@SQLRestriction("deleted_at IS NULL")
class WinnerEntity (
class WinnerEntity(
@OneToOne
@JoinColumn(name = "goal_id")
val goalEntity: GoalEntity,
Expand All @@ -26,4 +26,4 @@ class WinnerEntity (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long = 0L
): BaseEntity()
) : BaseEntity()
Loading

0 comments on commit 70e1d9e

Please sign in to comment.