Skip to content

Commit

Permalink
[feat] : 조회 필터링의 변수들을 역정규화 한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed Feb 20, 2024
1 parent afd36bd commit 77119d2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
4 changes: 3 additions & 1 deletion api/src/main/resources/db/migration/V7__add_gallery.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
create table if not exists gallery (
gallery_id bigint primary key,
gallery_id BIGINT primary key,
target_id BIGINT unique not null,
survey_id BIGINT unique not null,
bookmarked_count INT not null,
position TEXT not null,
created_at TIMESTAMP(6) not null,
updated_at TIMESTAMP(6) not null
);
9 changes: 5 additions & 4 deletions gallery/src/main/kotlin/me/nalab/gallery/domain/Gallery.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package me.nalab.gallery.domain

import me.nalab.core.data.common.TimeBaseEntity
import javax.persistence.Column
import javax.persistence.Embedded
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table
Expand All @@ -13,9 +14,9 @@ class Gallery(
@Column(name = "gallery_id")
val id: Long,

@Column(name = "target_id", unique = true, nullable = false, updatable = false)
val targetId: Long,
@Embedded
val target: Target,

@Column(name = "survey_id", unique = true, nullable = false)
val surveyId: Long,
@Embedded
val survey: Survey,
) : TimeBaseEntity()
13 changes: 13 additions & 0 deletions gallery/src/main/kotlin/me/nalab/gallery/domain/Survey.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package me.nalab.gallery.domain

import javax.persistence.Column
import javax.persistence.Embeddable

@Embeddable
class Survey(
@Column(name = "survey_id", nullable = false, unique = true, updatable = false)
val id: Long,

@Column(name = "bookmarked_count", nullable = false)
var bookmarkedCount: Int = 0,
)
14 changes: 14 additions & 0 deletions gallery/src/main/kotlin/me/nalab/gallery/domain/Target.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package me.nalab.gallery.domain

import javax.persistence.Column
import javax.persistence.Embeddable

@Embeddable
class Target(
@Column(name = "target_id", unique = true, nullable = false, updatable = false)
val targetId: Long,

@Column(name = "position", nullable = false)
val position: String,
) {
}

0 comments on commit 77119d2

Please sign in to comment.