-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #51 user type(일반 유저, 사진작가) 추가 및 사진 작가 entity 설계/구현
- Loading branch information
Showing
21 changed files
with
339 additions
and
7 deletions.
There are no files selected for viewing
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
23 changes: 23 additions & 0 deletions
23
.../src/main/kotlin/com/damaba/damaba/adapter/outbound/photographer/BusinessDaysConverter.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 com.damaba.damaba.adapter.outbound.photographer | ||
|
||
import jakarta.persistence.AttributeConverter | ||
import jakarta.persistence.Converter | ||
import java.time.DayOfWeek | ||
|
||
@Converter | ||
class BusinessDaysConverter : AttributeConverter<Set<DayOfWeek>, String> { | ||
override fun convertToDatabaseColumn(attributes: Set<DayOfWeek>?): String? = | ||
attributes | ||
?.sortedBy { it.value } | ||
?.joinToString(DELIMITER) { it.name } | ||
|
||
override fun convertToEntityAttribute(dbData: String?): Set<DayOfWeek>? = | ||
dbData?.split(DELIMITER) | ||
?.map { DayOfWeek.valueOf(it) } | ||
?.sortedBy { it.value } | ||
?.toSet() | ||
|
||
companion object { | ||
private const val DELIMITER = "," | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...main/kotlin/com/damaba/damaba/adapter/outbound/photographer/BusinessScheduleEmbeddable.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,20 @@ | ||
package com.damaba.damaba.adapter.outbound.photographer | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Convert | ||
import jakarta.persistence.Embeddable | ||
import java.time.DayOfWeek | ||
import java.time.LocalTime | ||
|
||
@Embeddable | ||
data class BusinessScheduleEmbeddable( | ||
@Convert(converter = BusinessDaysConverter::class) | ||
@Column(name = "business_days", nullable = true) | ||
val days: Set<DayOfWeek>, | ||
|
||
@Column(name = "business_start_time", nullable = true) | ||
val startTime: LocalTime, | ||
|
||
@Column(name = "business_end_time", nullable = true) | ||
val endTime: LocalTime, | ||
) |
24 changes: 24 additions & 0 deletions
24
...n/kotlin/com/damaba/damaba/adapter/outbound/photographer/MainPhotohraphyTypesConverter.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,24 @@ | ||
package com.damaba.damaba.adapter.outbound.photographer | ||
|
||
import com.damaba.damaba.domain.common.PhotographyType | ||
import jakarta.persistence.AttributeConverter | ||
import jakarta.persistence.Converter | ||
import java.util.stream.Collectors | ||
|
||
@Converter | ||
class MainPhotohraphyTypesConverter : AttributeConverter<Set<PhotographyType>, String> { | ||
override fun convertToDatabaseColumn(attribute: Set<PhotographyType>): String = | ||
attribute.stream() | ||
.map { roleType -> roleType.name } | ||
.sorted() | ||
.collect(Collectors.joining(DELIMITER)) | ||
|
||
override fun convertToEntityAttribute(dbData: String): Set<PhotographyType> = | ||
dbData.split(DELIMITER) | ||
.map { roleType -> PhotographyType.valueOf(roleType) } | ||
.toSet() | ||
|
||
companion object { | ||
private const val DELIMITER = "," | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...tlin/com/damaba/damaba/adapter/outbound/photographer/PhotographerActiveRegionJpaEntity.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,38 @@ | ||
package com.damaba.damaba.adapter.outbound.photographer | ||
|
||
import com.damaba.damaba.adapter.outbound.common.BaseJpaTimeEntity | ||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.FetchType | ||
import jakarta.persistence.GeneratedValue | ||
import jakarta.persistence.GenerationType | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.JoinColumn | ||
import jakarta.persistence.ManyToOne | ||
import jakarta.persistence.Table | ||
|
||
@Table(name = "photographer_active_region") | ||
@Entity | ||
class PhotographerActiveRegionJpaEntity( | ||
photographer: PhotographerJpaEntity, | ||
category: String, | ||
name: String, | ||
) : BaseJpaTimeEntity() { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", nullable = false) | ||
val id: Long = 0 | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "photographer_id", nullable = false) | ||
var photographer: PhotographerJpaEntity = photographer | ||
private set | ||
|
||
@Column(name = "category", nullable = false) | ||
var category: String = category | ||
private set | ||
|
||
@Column(name = "name", nullable = false) | ||
var name: String = name | ||
private set | ||
} |
54 changes: 54 additions & 0 deletions
54
.../src/main/kotlin/com/damaba/damaba/adapter/outbound/photographer/PhotographerJpaEntity.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,54 @@ | ||
package com.damaba.damaba.adapter.outbound.photographer | ||
|
||
import com.damaba.damaba.adapter.outbound.common.AddressJpaEmbeddable | ||
import com.damaba.damaba.adapter.outbound.common.BaseJpaTimeEntity | ||
import com.damaba.damaba.domain.common.PhotographyType | ||
import jakarta.persistence.CascadeType | ||
import jakarta.persistence.Column | ||
import jakarta.persistence.Convert | ||
import jakarta.persistence.Embedded | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.OneToMany | ||
import jakarta.persistence.Table | ||
|
||
@Table(name = "photographer") | ||
@Entity | ||
class PhotographerJpaEntity( | ||
@Id @Column(name = "user_id", nullable = false) | ||
val userId: Long, | ||
mainPhotographyTypes: Set<PhotographyType>, | ||
contactLink: String?, | ||
description: String?, | ||
address: AddressJpaEmbeddable?, | ||
businessSchedule: BusinessScheduleEmbeddable?, | ||
) : BaseJpaTimeEntity() { | ||
@Convert(converter = MainPhotohraphyTypesConverter::class) | ||
@Column(name = "main_photography_type", nullable = false) | ||
var mainPhotographyTypes: Set<PhotographyType> = mainPhotographyTypes | ||
private set | ||
|
||
@Column(name = "contact_link", nullable = false) | ||
var contactLink: String? = contactLink | ||
private set | ||
|
||
@Column(name = "description", length = 500, nullable = true) | ||
var description: String? = description | ||
private set | ||
|
||
@Embedded | ||
var address: AddressJpaEmbeddable? = address | ||
private set | ||
|
||
@Embedded | ||
var businessSchedule: BusinessScheduleEmbeddable? = businessSchedule | ||
private set | ||
|
||
@OneToMany(mappedBy = "photographer", cascade = [CascadeType.PERSIST]) | ||
var portfolio: MutableList<PhotographerPortfolioImageJpaEntity> = mutableListOf() | ||
private set | ||
|
||
@OneToMany(mappedBy = "photographer", cascade = [CascadeType.ALL], orphanRemoval = true) | ||
var activeRegions: MutableSet<PhotographerActiveRegionJpaEntity> = mutableSetOf() | ||
private set | ||
} |
43 changes: 43 additions & 0 deletions
43
...in/com/damaba/damaba/adapter/outbound/photographer/PhotographerPortfolioImageJpaEntity.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 com.damaba.damaba.adapter.outbound.photographer | ||
|
||
import com.damaba.damaba.adapter.outbound.common.BaseJpaEntity | ||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.FetchType | ||
import jakarta.persistence.GeneratedValue | ||
import jakarta.persistence.GenerationType | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.JoinColumn | ||
import jakarta.persistence.ManyToOne | ||
import jakarta.persistence.Table | ||
import java.time.LocalDateTime | ||
|
||
@Table(name = "photographer_portfolio_image") | ||
@Entity | ||
class PhotographerPortfolioImageJpaEntity( | ||
photographer: PhotographerJpaEntity, | ||
name: String, | ||
url: String, | ||
) : BaseJpaEntity() { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", nullable = false) | ||
val id: Long = 0 | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "photographer_id", nullable = false) | ||
var photographer: PhotographerJpaEntity = photographer | ||
private set | ||
|
||
@Column(name = "name", unique = true, nullable = false) | ||
var name: String = name | ||
private set | ||
|
||
@Column(name = "url", unique = true, nullable = false) | ||
var url: String = url | ||
private set | ||
|
||
@Column(name = "deleted_at", nullable = true) | ||
var deletedAt: LocalDateTime? = null | ||
private set | ||
} |
9 changes: 9 additions & 0 deletions
9
damaba/src/main/kotlin/com/damaba/damaba/domain/common/PhotographyType.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,9 @@ | ||
package com.damaba.damaba.domain.common | ||
|
||
enum class PhotographyType { | ||
SNAP, | ||
PROFILE, | ||
CONCEPT, | ||
ID_PHOTO, | ||
SELF, | ||
} |
10 changes: 10 additions & 0 deletions
10
damaba/src/main/kotlin/com/damaba/damaba/domain/photographer/BusinessSchedule.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,10 @@ | ||
package com.damaba.damaba.domain.photographer | ||
|
||
import java.time.DayOfWeek | ||
import java.time.LocalTime | ||
|
||
data class BusinessSchedule( | ||
val days: Set<DayOfWeek>, | ||
val startTime: LocalTime, | ||
val endTime: LocalTime, | ||
) |
15 changes: 15 additions & 0 deletions
15
damaba/src/main/kotlin/com/damaba/damaba/domain/photographer/Photographer.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,15 @@ | ||
package com.damaba.damaba.domain.photographer | ||
|
||
import com.damaba.damaba.domain.common.Address | ||
import com.damaba.damaba.domain.common.PhotographyType | ||
|
||
data class Photographer( | ||
val userId: Long, | ||
val mainPhotographyTypes: Set<PhotographyType>, | ||
val contactLink: String?, | ||
val description: String?, | ||
val address: Address?, | ||
val businessSchedule: BusinessSchedule?, | ||
val portfolio: List<PhotographerPortfolioImage>, | ||
val activeRegions: List<PhotographerActiveRegion>, | ||
) |
6 changes: 6 additions & 0 deletions
6
damaba/src/main/kotlin/com/damaba/damaba/domain/photographer/PhotographerActiveRegion.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,6 @@ | ||
package com.damaba.damaba.domain.photographer | ||
|
||
data class PhotographerActiveRegion( | ||
val category: String, | ||
val name: String, | ||
) |
6 changes: 6 additions & 0 deletions
6
damaba/src/main/kotlin/com/damaba/damaba/domain/photographer/PhotographerPortfolioImage.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,6 @@ | ||
package com.damaba.damaba.domain.photographer | ||
|
||
data class PhotographerPortfolioImage( | ||
val name: String, | ||
val url: String, | ||
) |
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
Oops, something went wrong.