-
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
10 changed files
with
225 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/error/HolidayErrorCode.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,23 @@ | ||
package team.comit.simtong.domain.holiday.error | ||
|
||
import team.comit.simtong.global.error.ErrorProperty | ||
|
||
/** | ||
* | ||
* 휴무일에 관한 Error Code를 관리하는 HolidayErrorCode | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/12/02 | ||
* @version 1.0.0 | ||
**/ | ||
enum class HolidayErrorCode( | ||
private val status: Int, | ||
private val message: String | ||
) : ErrorProperty { | ||
|
||
; | ||
|
||
override fun status(): Int = status | ||
|
||
override fun message(): String = message | ||
} |
25 changes: 25 additions & 0 deletions
25
simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/model/Holiday.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,25 @@ | ||
package team.comit.simtong.domain.holiday.model | ||
|
||
import team.comit.simtong.global.annotation.Aggregate | ||
import java.time.LocalDate | ||
import java.util.UUID | ||
|
||
/** | ||
* | ||
* 휴무일의 Root Aggregate를 담당하는 Holiday | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/12/02 | ||
* @version 1.0.0 | ||
**/ | ||
@Aggregate | ||
data class Holiday( | ||
val date: LocalDate, | ||
|
||
val userId: UUID, | ||
|
||
val type: HolidayType, | ||
|
||
val spotId: UUID | ||
|
||
) |
22 changes: 22 additions & 0 deletions
22
simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/model/HolidayType.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,22 @@ | ||
package team.comit.simtong.domain.holiday.model | ||
|
||
/** | ||
* | ||
* 휴무일 유형를 관리하는 HolidayType | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/12/02 | ||
* @version 1.0.0 | ||
**/ | ||
enum class HolidayType { | ||
|
||
/** | ||
* 휴무일 | ||
*/ | ||
HOLIDAY, | ||
|
||
/** | ||
* 연차 | ||
*/ | ||
ANNUAL | ||
} |
Empty file.
18 changes: 18 additions & 0 deletions
18
...astructure/src/main/kotlin/team/comit/simtong/persistence/holiday/HolidayJpaRepository.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,18 @@ | ||
package team.comit.simtong.persistence.holiday | ||
|
||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.stereotype.Repository | ||
import team.comit.simtong.persistence.holiday.entity.HolidayId | ||
import team.comit.simtong.persistence.holiday.entity.HolidayJpaEntity | ||
|
||
/** | ||
* | ||
* Spring Repository의 기능을 이용하는 HolidayJpaRepository | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/12/02 | ||
* @version 1.0.0 | ||
**/ | ||
@Repository | ||
interface HolidayJpaRepository : CrudRepository<HolidayJpaEntity, HolidayId> { | ||
} |
21 changes: 21 additions & 0 deletions
21
...cture/src/main/kotlin/team/comit/simtong/persistence/holiday/HolidayPersistenceAdapter.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,21 @@ | ||
package team.comit.simtong.persistence.holiday | ||
|
||
import org.springframework.stereotype.Component | ||
import team.comit.simtong.persistence.holiday.mapper.HolidayMapper | ||
|
||
/** | ||
* | ||
* 휴무일의 영속성을 관리하는 HolidayPersistenceAdapter | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/12/02 | ||
* @version 1.0.0 | ||
**/ | ||
@Component | ||
class HolidayPersistenceAdapter( | ||
private val holidayMapper: HolidayMapper, | ||
private val holidayJpaRepository: HolidayJpaRepository | ||
) { | ||
|
||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...infrastructure/src/main/kotlin/team/comit/simtong/persistence/holiday/entity/HolidayId.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,25 @@ | ||
package team.comit.simtong.persistence.holiday.entity | ||
|
||
import java.io.Serializable | ||
import java.time.LocalDate | ||
import java.util.UUID | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
|
||
/** | ||
* | ||
* 휴무일의 기본키를 구성하는 HolidayId | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/12/02 | ||
* @version 1.0.0 | ||
**/ | ||
@Embeddable | ||
data class HolidayId( | ||
|
||
@Column(nullable = false) | ||
val date: LocalDate, | ||
|
||
@Column(nullable = false) | ||
val userId: UUID | ||
) : Serializable |
46 changes: 46 additions & 0 deletions
46
...ructure/src/main/kotlin/team/comit/simtong/persistence/holiday/entity/HolidayJpaEntity.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,46 @@ | ||
package team.comit.simtong.persistence.holiday.entity | ||
|
||
import team.comit.simtong.domain.holiday.model.HolidayType | ||
import team.comit.simtong.persistence.spot.entity.SpotJpaEntity | ||
import team.comit.simtong.persistence.user.entity.UserJpaEntity | ||
import javax.persistence.EmbeddedId | ||
import javax.persistence.Entity | ||
import javax.persistence.EnumType | ||
import javax.persistence.Enumerated | ||
import javax.persistence.FetchType | ||
import javax.persistence.JoinColumn | ||
import javax.persistence.ManyToOne | ||
import javax.persistence.MapsId | ||
import javax.persistence.Table | ||
import javax.validation.constraints.NotNull | ||
|
||
/** | ||
* | ||
* 유저의 휴무일을 관리하는 HolidayJpaEntity | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/12/02 | ||
* @version 1.0.0 | ||
**/ | ||
@Entity | ||
@Table(name = "tbl_holiday") | ||
class HolidayJpaEntity( | ||
|
||
@EmbeddedId | ||
val id: HolidayId, | ||
|
||
@field:NotNull | ||
@Enumerated(EnumType.STRING) | ||
val type: HolidayType, | ||
|
||
@MapsId("userId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id", columnDefinition = "BINARY(16)", nullable = false) | ||
val user: UserJpaEntity, | ||
|
||
@field:NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "spot_id", columnDefinition = "BINARY(16)", nullable = false) | ||
val spot: SpotJpaEntity | ||
|
||
) |
43 changes: 43 additions & 0 deletions
43
...astructure/src/main/kotlin/team/comit/simtong/persistence/holiday/mapper/HolidayMapper.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,43 @@ | ||
package team.comit.simtong.persistence.holiday.mapper | ||
|
||
import org.mapstruct.Mapper | ||
import org.mapstruct.Mapping | ||
import org.mapstruct.Mappings | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import team.comit.simtong.domain.holiday.model.Holiday | ||
import team.comit.simtong.persistence.GenericMapper | ||
import team.comit.simtong.persistence.holiday.entity.HolidayJpaEntity | ||
import team.comit.simtong.persistence.spot.SpotJpaRepository | ||
import team.comit.simtong.persistence.user.repository.UserJpaRepository | ||
|
||
/** | ||
* | ||
* 휴무일 엔티티와 도메인 휴무일 변환을 담당하는 HolidayMapper | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/12/02 | ||
* @version 1.0.0 | ||
**/ | ||
@Mapper | ||
abstract class HolidayMapper : GenericMapper<HolidayJpaEntity, Holiday> { | ||
|
||
@Autowired | ||
protected lateinit var userJpaRepository: UserJpaRepository | ||
|
||
@Autowired | ||
protected lateinit var spotJpaRepository: SpotJpaRepository | ||
|
||
@Mappings( | ||
Mapping(target = "userId", expression = "java(entity.getId().getUserId())"), | ||
Mapping(target = "spotId", expression = "java(entity.getSpot().getId())"), | ||
Mapping(target = "date", expression = "java(entity.getId().getDate())") | ||
) | ||
abstract override fun toDomain(entity: HolidayJpaEntity?): Holiday? | ||
|
||
@Mappings( | ||
Mapping(target = "user", expression = "java(userJpaRepository.findById(model.getUserId()).orElse(null))"), | ||
Mapping(target = "spot", expression = "java(spotJpaRepository.findById(model.getSpotId()).orElse(null))"), | ||
Mapping(target = "id", expression = "java(new HolidayId(model.getDate(), model.getUserId()))") | ||
) | ||
abstract override fun toEntity(model: Holiday): HolidayJpaEntity | ||
} |
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