Skip to content

Commit

Permalink
refactor: (#301) 인자 변경 UseCase
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Jan 23, 2023
1 parent dcc89b3 commit e3c8b9f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package team.comit.simtong.domain.auth.usecase

import team.comit.simtong.domain.auth.dto.request.CheckAuthCodeData
import team.comit.simtong.domain.auth.exception.AuthExceptions
import team.comit.simtong.domain.auth.model.AuthCodeLimit
import team.comit.simtong.domain.auth.spi.CommandAuthCodeLimitPort
Expand All @@ -22,16 +21,16 @@ class CheckAuthCodeUseCase(
private val queryAuthCodePort: QueryAuthCodePort
) {

fun execute(request: CheckAuthCodeData) {
val authCode = queryAuthCodePort.queryAuthCodeByEmail(request.email)
fun execute(email: String, code: String) {
val authCode = queryAuthCodePort.queryAuthCodeByEmail(email)
?: throw AuthExceptions.RequiredNewEmailAuthentication()

if (!authCode.code.match(request.code)) {
if (!authCode.code.match(code)) {
throw AuthExceptions.DifferentAuthCode()
}

commandAuthCodeLimitPort.save(
AuthCodeLimit.certified(request.email)
AuthCodeLimit.certified(email)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package team.comit.simtong.domain.menu.usecase

import team.comit.simtong.domain.menu.dto.request.SaveMenuData
import team.comit.simtong.domain.menu.exception.MenuExceptions
import team.comit.simtong.domain.menu.spi.CommandMenuPort
import team.comit.simtong.domain.menu.spi.ParseMenuFilePort
import team.comit.simtong.domain.menu.spi.QueryMenuPort
import team.comit.simtong.global.annotation.UseCase
import java.io.File
import java.time.LocalDate
import java.util.UUID

Expand All @@ -25,11 +25,16 @@ class SaveMenuUseCase(
private val commandMenuPort: CommandMenuPort
) {

fun execute(request: SaveMenuData, spotId: UUID) {
val menu = parseMenuFilePort.importMenu(request.file, request.year, request.month, spotId)
fun execute(file: File, year: Int, month: Int, spotId: UUID) {
val menu = parseMenuFilePort.importMenu(
file = file,
year = year,
month = month,
spotId = spotId
)

if (queryMenuPort.existsMenuByMonthAndSpotId(LocalDate.of(request.year, request.month, 1), spotId)) {
throw MenuExceptions.AlreadyExistsSameMonth("${request.year}${request.month}월 메뉴가 이미 존재합니다.")
if (queryMenuPort.existsMenuByMonthAndSpotId(LocalDate.of(year, month, 1), spotId)) {
throw MenuExceptions.AlreadyExistsSameMonth("${year}${month}월 메뉴가 이미 존재합니다.")
}

commandMenuPort.saveAll(menu)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package team.comit.simtong.domain.user.usecase

import team.comit.simtong.domain.user.dto.request.FindEmployeeNumberData
import team.comit.simtong.domain.user.dto.response.FindEmployeeNumberResponse
import team.comit.simtong.domain.user.exception.UserExceptions
import team.comit.simtong.domain.user.spi.QueryUserPort
import team.comit.simtong.global.annotation.UseCase
import java.util.UUID

/**
*
Expand All @@ -19,8 +19,8 @@ class FindEmployeeNumberUseCase(
private val queryUserPort: QueryUserPort
) {

fun execute(request: FindEmployeeNumberData): FindEmployeeNumberResponse {
val user = queryUserPort.queryUserByNameAndSpotAndEmail(request.name, request.spotId, request.email)
fun execute(name: String, spotId: UUID, email: String): FindEmployeeNumberResponse {
val user = queryUserPort.queryUserByNameAndSpotAndEmail(name, spotId, email)
?: throw UserExceptions.NotFound()

return user.employeeNumber.value
Expand Down

0 comments on commit e3c8b9f

Please sign in to comment.