Skip to content

Commit 824e3f3

Browse files
authored
Refactor: MainImage, Attachments interface 간결화, 패키지 이동 (#373)
* refactor: make MainImage, Attachments interface more kotlin-friendly * refactor: move two interface back to entity package
1 parent 1c20dc2 commit 824e3f3

File tree

17 files changed

+61
-77
lines changed

17 files changed

+61
-77
lines changed

src/main/kotlin/com/wafflestudio/csereal/common/controller/AttachmentContentEntityType.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/kotlin/com/wafflestudio/csereal/common/controller/MainImageContentEntityType.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.wafflestudio.csereal.common.entity
2+
3+
import com.wafflestudio.csereal.core.resource.attachment.database.AttachmentEntity
4+
5+
interface AttachmentAttachable {
6+
val attachments: List<AttachmentEntity>
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.wafflestudio.csereal.common.entity
2+
3+
import com.wafflestudio.csereal.core.resource.mainImage.database.MainImageEntity
4+
5+
interface MainImageAttachable {
6+
val mainImage: MainImageEntity?
7+
}

src/main/kotlin/com/wafflestudio/csereal/core/about/database/AboutEntity.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.wafflestudio.csereal.core.about.database
22

33
import com.wafflestudio.csereal.common.entity.BaseTimeEntity
4-
import com.wafflestudio.csereal.common.controller.AttachmentContentEntityType
5-
import com.wafflestudio.csereal.common.controller.MainImageContentEntityType
4+
import com.wafflestudio.csereal.common.entity.AttachmentAttachable
5+
import com.wafflestudio.csereal.common.entity.MainImageAttachable
66
import com.wafflestudio.csereal.common.enums.LanguageType
77
import com.wafflestudio.csereal.common.utils.StringListConverter
88
import com.wafflestudio.csereal.common.utils.cleanTextFromHtml
@@ -27,17 +27,15 @@ class AboutEntity(
2727
var locations: MutableList<String> = mutableListOf(),
2828

2929
@OneToMany(mappedBy = "about", cascade = [CascadeType.ALL], orphanRemoval = true)
30-
var attachments: MutableList<AttachmentEntity> = mutableListOf(),
30+
override var attachments: MutableList<AttachmentEntity> = mutableListOf(),
3131

3232
@OneToOne(fetch = FetchType.LAZY, cascade = [CascadeType.ALL], orphanRemoval = true)
33-
var mainImage: MainImageEntity? = null,
33+
override var mainImage: MainImageEntity? = null,
3434

3535
@Column(columnDefinition = "TEXT")
3636
var searchContent: String
3737

38-
) : BaseTimeEntity(), MainImageContentEntityType, AttachmentContentEntityType {
39-
override fun bringMainImage(): MainImageEntity? = mainImage
40-
override fun bringAttachments(): List<AttachmentEntity> = attachments
38+
) : BaseTimeEntity(), MainImageAttachable, AttachmentAttachable {
4139

4240
companion object {
4341
fun of(

src/main/kotlin/com/wafflestudio/csereal/core/academics/database/AcademicsEntity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.wafflestudio.csereal.core.academics.database
22

33
import com.wafflestudio.csereal.common.entity.BaseTimeEntity
4-
import com.wafflestudio.csereal.common.controller.AttachmentContentEntityType
4+
import com.wafflestudio.csereal.common.entity.AttachmentAttachable
55
import com.wafflestudio.csereal.common.enums.LanguageType
66
import com.wafflestudio.csereal.core.academics.api.req.CreateYearReq
77
import com.wafflestudio.csereal.core.resource.attachment.database.AttachmentEntity
@@ -24,13 +24,12 @@ class AcademicsEntity(
2424
var year: Int?,
2525

2626
@OneToMany(mappedBy = "academics", cascade = [CascadeType.ALL], orphanRemoval = true)
27-
var attachments: MutableList<AttachmentEntity> = mutableListOf(),
27+
override var attachments: MutableList<AttachmentEntity> = mutableListOf(),
2828

2929
@OneToOne(mappedBy = "academics", cascade = [CascadeType.ALL], orphanRemoval = true)
3030
var academicsSearch: AcademicsSearchEntity? = null
3131

32-
) : BaseTimeEntity(), AttachmentContentEntityType {
33-
override fun bringAttachments() = attachments
32+
) : BaseTimeEntity(), AttachmentAttachable {
3433

3534
companion object {
3635
fun createYearResponse(

src/main/kotlin/com/wafflestudio/csereal/core/council/database/CouncilEntity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.wafflestudio.csereal.core.council.database
22

33
import com.wafflestudio.csereal.common.entity.BaseTimeEntity
4-
import com.wafflestudio.csereal.common.controller.MainImageContentEntityType
4+
import com.wafflestudio.csereal.common.entity.MainImageAttachable
55
import com.wafflestudio.csereal.core.council.dto.ReportCreateRequest
66
import com.wafflestudio.csereal.core.resource.mainImage.database.MainImageEntity
77
import jakarta.persistence.*
@@ -17,12 +17,11 @@ class CouncilEntity(
1717
var description: String,
1818

1919
@OneToOne
20-
var mainImage: MainImageEntity? = null,
20+
override var mainImage: MainImageEntity? = null,
2121

2222
var sequence: Int,
2323
var name: String
24-
) : BaseTimeEntity(), MainImageContentEntityType {
25-
override fun bringMainImage() = mainImage
24+
) : BaseTimeEntity(), MainImageAttachable {
2625

2726
companion object {
2827
fun createReport(req: ReportCreateRequest): CouncilEntity =

src/main/kotlin/com/wafflestudio/csereal/core/council/database/CouncilFileEntity.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.wafflestudio.csereal.core.council.database
22

33
import com.wafflestudio.csereal.common.entity.BaseTimeEntity
4-
import com.wafflestudio.csereal.common.controller.AttachmentContentEntityType
4+
import com.wafflestudio.csereal.common.entity.AttachmentAttachable
55
import com.wafflestudio.csereal.core.council.type.CouncilFileType
66
import com.wafflestudio.csereal.core.resource.attachment.database.AttachmentEntity
77
import jakarta.persistence.*
@@ -20,7 +20,5 @@ class CouncilFileEntity(
2020
val key: String,
2121

2222
@OneToMany(mappedBy = "councilFile", cascade = [CascadeType.ALL], orphanRemoval = true)
23-
val attachments: MutableList<AttachmentEntity> = mutableListOf()
24-
) : BaseTimeEntity(), AttachmentContentEntityType {
25-
override fun bringAttachments(): List<AttachmentEntity> = attachments
26-
}
23+
override val attachments: MutableList<AttachmentEntity> = mutableListOf()
24+
) : BaseTimeEntity(), AttachmentAttachable

src/main/kotlin/com/wafflestudio/csereal/core/member/database/ProfessorEntity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.wafflestudio.csereal.core.member.database
22

33
import com.wafflestudio.csereal.common.entity.BaseTimeEntity
4-
import com.wafflestudio.csereal.common.controller.MainImageContentEntityType
4+
import com.wafflestudio.csereal.common.entity.MainImageAttachable
55
import com.wafflestudio.csereal.common.enums.LanguageType
66
import com.wafflestudio.csereal.common.utils.StringListConverter
77
import com.wafflestudio.csereal.core.member.dto.ProfessorDto
@@ -48,12 +48,11 @@ class ProfessorEntity(
4848
var careers: MutableList<String> = mutableListOf(),
4949

5050
@OneToOne
51-
var mainImage: MainImageEntity? = null,
51+
override var mainImage: MainImageEntity? = null,
5252

5353
@OneToOne(mappedBy = "professor", cascade = [CascadeType.ALL], orphanRemoval = true)
5454
var memberSearch: MemberSearchEntity? = null
55-
) : BaseTimeEntity(), MainImageContentEntityType {
56-
override fun bringMainImage(): MainImageEntity? = mainImage
55+
) : BaseTimeEntity(), MainImageAttachable {
5756

5857
companion object {
5958
fun of(languageType: LanguageType, professorDto: ProfessorDto): ProfessorEntity {

src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffEntity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.wafflestudio.csereal.core.member.database
22

33
import com.wafflestudio.csereal.common.entity.BaseTimeEntity
4-
import com.wafflestudio.csereal.common.controller.MainImageContentEntityType
4+
import com.wafflestudio.csereal.common.entity.MainImageAttachable
55
import com.wafflestudio.csereal.common.enums.LanguageType
66
import com.wafflestudio.csereal.common.utils.StringListConverter
77
import com.wafflestudio.csereal.core.member.dto.StaffDto
@@ -25,12 +25,11 @@ class StaffEntity(
2525
var tasks: MutableList<String> = mutableListOf(),
2626

2727
@OneToOne
28-
var mainImage: MainImageEntity? = null,
28+
override var mainImage: MainImageEntity? = null,
2929

3030
@OneToOne(mappedBy = "staff", cascade = [CascadeType.ALL], orphanRemoval = true)
3131
var memberSearch: MemberSearchEntity? = null
32-
) : BaseTimeEntity(), MainImageContentEntityType {
33-
override fun bringMainImage(): MainImageEntity? = mainImage
32+
) : BaseTimeEntity(), MainImageAttachable {
3433

3534
companion object {
3635
fun of(languageType: LanguageType, staffDto: StaffDto): StaffEntity {

0 commit comments

Comments
 (0)