Skip to content

Commit

Permalink
refactor: (#281) presentation → domain 의존
Browse files Browse the repository at this point in the history
Web Enum Class 제거
  • Loading branch information
khcho0125 committed Jan 10, 2023
1 parent d46034e commit a82a778
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package team.comit.simtong.domain.holiday.usecase

import team.comit.simtong.domain.holiday.dto.QueryEmployeeHolidayResponse
import team.comit.simtong.domain.holiday.model.HolidayQueryType
import team.comit.simtong.domain.holiday.model.value.HolidayQueryType
import team.comit.simtong.domain.holiday.spi.HolidayQueryUserPort
import team.comit.simtong.domain.holiday.spi.HolidaySecurityPort
import team.comit.simtong.domain.holiday.spi.QueryHolidayPort
Expand All @@ -28,14 +28,14 @@ class QueryEmployeeHolidayUseCase(
private val queryUserPort: HolidayQueryUserPort
) {

fun execute(year: Int, month: Int, typeName: String, teamId: UUID?): QueryEmployeeHolidayResponse {
fun execute(year: Int, month: Int, type: HolidayQueryType, teamId: UUID?): QueryEmployeeHolidayResponse {
val currentUserId = securityPort.getCurrentUserId()
val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound()

val holidays = queryHolidayPort.queryHolidaysByYearAndMonthAndTeamId(
year = year,
month = month,
type = HolidayQueryType.valueOf(typeName).toHolidayType(),
type = type.toHolidayType(),
spotId = user.spotId,
teamId = teamId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import team.comit.simtong.domain.notification.spi.SendPushMessagePort
import team.comit.simtong.domain.user.exception.UserExceptions
import team.comit.simtong.global.annotation.UseCase
import java.util.UUID
import kotlin.collections.List

/**
*
Expand All @@ -26,15 +25,15 @@ class SendNotificationUseCase(
private val queryUserPort: NotificationQueryUserPort
) {

fun execute(userId: UUID, title: String, content: String, type: String, identify: UUID?) {
fun execute(userId: UUID, title: String, content: String, type: NotificationType, identify: UUID?) {
val deviceToken = queryUserPort.queryDeviceTokenByUserId(userId)
?: throw UserExceptions.NotFound("디바이스 토큰이 존재하지 않습니다.")

val notification = commandNotificationPort.saveNotification(
Notification(
title = title,
content = content,
type = NotificationType.valueOf(type),
type = type,
identify = identify
)
)
Expand All @@ -46,17 +45,17 @@ class SendNotificationUseCase(
)
)

sendPushMessagePort.sendMessage(deviceToken, title, content, NotificationType.valueOf(type), identify)
sendPushMessagePort.sendMessage(deviceToken, title, content, type, identify)
}

fun execute(userIds: List<UUID>, title: String, content: String, type: String, identify: UUID?) {
fun execute(userIds: List<UUID>, title: String, content: String, type: NotificationType, identify: UUID?) {
val deviceTokens = queryUserPort.queryDeviceTokensByUserIds(userIds)

val notification = commandNotificationPort.saveNotification(
Notification(
title = title,
content = content,
type = NotificationType.valueOf(type),
type = type,
identify = identify
)
)
Expand All @@ -70,6 +69,6 @@ class SendNotificationUseCase(
}
)

sendPushMessagePort.sendMessage(deviceTokens, title, content, NotificationType.valueOf(type), identify)
sendPushMessagePort.sendMessage(deviceTokens, title, content, type, identify)
}
}
1 change: 1 addition & 0 deletions simtong-presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {

dependencies {
// impl project
implementation(project(":simtong-domain"))
implementation(project(":simtong-application"))

// web
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import team.comit.simtong.domain.holiday.dto.request.CancelHolidayWebRequest
import team.comit.simtong.domain.holiday.dto.request.ChangeEmployeeHolidayWebRequest
import team.comit.simtong.domain.holiday.dto.request.ShareHolidayWebRequest
import team.comit.simtong.domain.holiday.dto.response.QueryRemainAnnualWebResponse
import team.comit.simtong.domain.holiday.model.value.HolidayQueryType
import team.comit.simtong.domain.holiday.model.value.HolidayStatus
import team.comit.simtong.domain.holiday.usecase.AppointAnnualUseCase
import team.comit.simtong.domain.holiday.usecase.AppointHolidayPeriodUseCase
import team.comit.simtong.domain.holiday.usecase.AppointHolidayUseCase
Expand All @@ -32,8 +34,6 @@ import team.comit.simtong.domain.holiday.usecase.QueryIndividualHolidayUseCase
import team.comit.simtong.domain.holiday.usecase.QueryMonthHolidayPeriodUseCase
import team.comit.simtong.domain.holiday.usecase.QueryRemainAnnualUseCase
import team.comit.simtong.domain.holiday.usecase.ShareHolidayUseCase
import team.comit.simtong.domain.holiday.value.WebHolidayQueryType
import team.comit.simtong.domain.holiday.value.WebHolidayStatus
import java.time.LocalDate
import java.util.UUID
import javax.validation.Valid
Expand All @@ -45,7 +45,7 @@ import javax.validation.Valid
* @author Chokyunghyeon
* @author kimbeomjin
* @date 2022/12/03
* @version 1.2.3
* @version 1.2.5
**/
@RestController
@RequestMapping("/holidays")
Expand Down Expand Up @@ -91,7 +91,7 @@ class WebHolidayAdapter(
fun queryIndividualHolidays(
@RequestParam("start_at") startAt: LocalDate,
@RequestParam("end_at") endAt: LocalDate,
@RequestParam status: WebHolidayStatus
@RequestParam status: HolidayStatus
): QueryIndividualHolidaysResponse {
return queryIndividualHolidayUseCase.execute(
QueryIndividualRequest(
Expand Down Expand Up @@ -120,13 +120,13 @@ class WebHolidayAdapter(
fun queryEmployeeHolidays(
@RequestParam year: Int,
@RequestParam month: Int,
@RequestParam type: WebHolidayQueryType,
@RequestParam type: HolidayQueryType,
@RequestParam("team_id", required = false) teamId: UUID?
): QueryEmployeeHolidayResponse {
return queryEmployeeHolidayUseCase.execute(
year = year,
month = month,
typeName = type.name,
type = type,
teamId = teamId
)
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package team.comit.simtong.domain.notification.dto

import team.comit.simtong.domain.notification.model.value.NotificationType
import java.util.UUID
import javax.validation.constraints.NotBlank
import javax.validation.constraints.NotNull
Expand All @@ -15,16 +16,16 @@ import javax.validation.constraints.NotNull
data class SendNotificationWebRequest(

@field:NotNull
val userId: UUID?,
val userId: UUID,

@field:NotBlank
val title: String?,
val title: String,

@field:NotBlank
val content: String?,
val content: String,

@field:NotNull
val type: WebNotificationType?,
val type: NotificationType,

val identify: UUID?
)
Expand All @@ -41,13 +42,13 @@ data class SendMultiNotificationWebRequest(
val userIds: List<UUID>,

@field:NotBlank
val title: String?,
val title: String,

@field:NotBlank
val content: String?,
val content: String,

@field:NotNull
val type: WebNotificationType?,
val type: NotificationType,

val identify: UUID?
)

This file was deleted.

0 comments on commit a82a778

Please sign in to comment.