-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
208 additions
and
14 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...api/src/main/kotlin/com/whatever/raisedragon/applicationservice/GoalApplicationService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.whatever.raisedragon.applicationservice | ||
|
||
import com.whatever.raisedragon.domain.gifticon.GifticonService | ||
import com.whatever.raisedragon.domain.goal.* | ||
import com.whatever.raisedragon.domain.goalgifticon.GoalGifticonService | ||
import com.whatever.raisedragon.domain.user.User | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
import java.time.LocalDateTime | ||
|
||
@Transactional | ||
@Service | ||
class GoalApplicationService( | ||
private val goalService: GoalService, | ||
private val gifticonService: GifticonService, | ||
private val goalGifticonService: GoalGifticonService | ||
) { | ||
|
||
fun createGoal( | ||
content: Content, | ||
bettingType: BettingType, | ||
threshold: Threshold, | ||
startDate: LocalDateTime, | ||
endDate: LocalDateTime, | ||
user: User, | ||
presignedURL: String | ||
): Goal { | ||
if (bettingType == BettingType.BILLING) { | ||
val goal = goalService.create( | ||
content = content, | ||
bettingType = bettingType, | ||
threshold = threshold, | ||
startDate = startDate, | ||
endDate = endDate | ||
) | ||
val gifticon = gifticonService.create( | ||
user = user, | ||
presignedURL = presignedURL | ||
) | ||
goalGifticonService.create( | ||
goal = goal, | ||
gifticon = gifticon, | ||
user = user | ||
) | ||
return goal | ||
} | ||
|
||
return goalService.create( | ||
content = content, | ||
bettingType = bettingType, | ||
threshold = threshold, | ||
startDate = startDate, | ||
endDate = endDate | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/gifticon/GifticonService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.whatever.raisedragon.domain.gifticon | ||
|
||
import com.whatever.raisedragon.domain.user.User | ||
import com.whatever.raisedragon.domain.user.fromDto | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Transactional | ||
@Service | ||
class GifticonService( | ||
private val gifticonRepository: GifticonRepository, | ||
) { | ||
|
||
fun create( | ||
user: User, | ||
presignedURL: String, | ||
): Gifticon { | ||
val gifticon = gifticonRepository.save( | ||
GifticonEntity( | ||
userEntity = user.fromDto(), | ||
url = URL(presignedURL) | ||
) | ||
) | ||
return gifticon.toDto() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goal/GoalService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.whatever.raisedragon.domain.goal | ||
|
||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
import java.time.LocalDateTime | ||
|
||
@Transactional | ||
@Service | ||
class GoalService( | ||
private val goalRepository: GoalRepository | ||
) { | ||
|
||
fun create( | ||
content: Content, | ||
bettingType: BettingType, | ||
threshold: Threshold, | ||
startDate: LocalDateTime, | ||
endDate: LocalDateTime, | ||
): Goal { | ||
val goal = goalRepository.save( | ||
GoalEntity( | ||
type = bettingType, | ||
content = content, | ||
threshold = threshold, | ||
result = Result.PROCEEDING, | ||
startDate = startDate, | ||
endDate = endDate | ||
) | ||
) | ||
return goal.toDto() | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...-core/src/main/kotlin/com/whatever/raisedragon/domain/goalgifticon/GoalGifticonService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.whatever.raisedragon.domain.goalgifticon | ||
|
||
import com.whatever.raisedragon.domain.gifticon.Gifticon | ||
import com.whatever.raisedragon.domain.gifticon.fromDto | ||
import com.whatever.raisedragon.domain.goal.Goal | ||
import com.whatever.raisedragon.domain.goal.fromDto | ||
import com.whatever.raisedragon.domain.user.User | ||
import com.whatever.raisedragon.domain.user.fromDto | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Transactional | ||
@Service | ||
class GoalGifticonService( | ||
private val goalGifticonRepository: GoalGifticonRepository | ||
) { | ||
|
||
fun create( | ||
goal: Goal, | ||
gifticon: Gifticon, | ||
user: User, | ||
) { | ||
goalGifticonRepository.save( | ||
GoalGifticonEntity( | ||
goal.fromDto(), | ||
gifticon.fromDto(user.fromDto()) | ||
) | ||
) | ||
} | ||
} |