feat: 인기 게시물 필드 추가 (데이터 레이어)

- HotDeal 도메인 모델에 isPopular 필드 추가
- HotDealEntity에 isPopular 컬럼 추가
- Migration 4->5 추가 (isPopular 컬럼)
- DatabaseModule에 Migration 4_5 등록

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
sanjeok77
2026-03-11 21:35:16 +09:00
parent bb480a0d32
commit 674b696421
4 changed files with 70 additions and 3 deletions

View File

@@ -21,7 +21,7 @@ import com.hotdeal.alarm.data.local.db.entity.SiteConfigEntity
SiteConfigEntity::class, SiteConfigEntity::class,
KeywordEntity::class KeywordEntity::class
], ],
version = 4, version = 5,
exportSchema = false exportSchema = false
) )
@TypeConverters(Converters::class) @TypeConverters(Converters::class)
@@ -61,5 +61,14 @@ abstract class AppDatabase : RoomDatabase() {
db.execSQL("ALTER TABLE hot_deals ADD COLUMN isFavorite INTEGER NOT NULL DEFAULT 0") db.execSQL("ALTER TABLE hot_deals ADD COLUMN isFavorite INTEGER NOT NULL DEFAULT 0")
} }
} }
/**
* Migration 4 -> 5: 인기 게시물 필드 추가
*/
val MIGRATION_4_5 = object : Migration(4, 5) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE hot_deals ADD COLUMN isPopular INTEGER NOT NULL DEFAULT 0")
}
}
} }
} }

View File

@@ -16,6 +16,19 @@ import com.hotdeal.alarm.domain.model.HotDeal
] ]
) )
data class HotDealEntity( data class HotDealEntity(
@PrimaryKey
val id: String,
val siteName: String,
val boardName: String,
val title: String,
val url: String,
val mallUrl: String?,
val createdAt: Long,
val isNotified: Boolean = false,
val isKeywordMatch: Boolean = false,
val isFavorite: Boolean = false, // 즐겨찾기 여부
val isPopular: Boolean = false // 인기/핫 게시물 여부
) {
@PrimaryKey @PrimaryKey
val id: String, val id: String,
val siteName: String, val siteName: String,
@@ -31,7 +44,21 @@ data class HotDealEntity(
/** /**
* Domain 모델로 변환 * Domain 모델로 변환
*/ */
fun toDomain(): HotDeal { fun toDomain(): HotDeal {
return HotDeal(
id = id,
siteName = siteName,
boardName = boardName,
title = title,
url = url,
mallUrl = mallUrl,
createdAt = createdAt,
isNotified = isNotified,
isKeywordMatch = isKeywordMatch,
isFavorite = isFavorite,
isPopular = isPopular
)
}
return HotDeal( return HotDeal(
id = id, id = id,
siteName = siteName, siteName = siteName,
@@ -50,7 +77,21 @@ data class HotDealEntity(
/** /**
* Domain 모델에서 Entity 생성 * Domain 모델에서 Entity 생성
*/ */
fun fromDomain(domain: HotDeal): HotDealEntity { fun fromDomain(domain: HotDeal): HotDealEntity {
return HotDealEntity(
id = domain.id,
siteName = domain.siteName,
boardName = domain.boardName,
title = domain.title,
url = domain.url,
mallUrl = domain.mallUrl,
createdAt = domain.createdAt,
isNotified = domain.isNotified,
isKeywordMatch = domain.isKeywordMatch,
isFavorite = domain.isFavorite,
isPopular = domain.isPopular
)
}
return HotDealEntity( return HotDealEntity(
id = domain.id, id = domain.id,
siteName = domain.siteName, siteName = domain.siteName,

View File

@@ -34,6 +34,11 @@ object DatabaseModule {
.addMigrations( .addMigrations(
AppDatabase.MIGRATION_1_2, AppDatabase.MIGRATION_1_2,
AppDatabase.MIGRATION_2_3, AppDatabase.MIGRATION_2_3,
AppDatabase.MIGRATION_3_4,
AppDatabase.MIGRATION_4_5
)
AppDatabase.MIGRATION_1_2,
AppDatabase.MIGRATION_2_3,
AppDatabase.MIGRATION_3_4 AppDatabase.MIGRATION_3_4
) )
.fallbackToDestructiveMigration() .fallbackToDestructiveMigration()

View File

@@ -4,6 +4,18 @@ package com.hotdeal.alarm.domain.model
* 핫딜 도메인 모델 * 핫딜 도메인 모델
*/ */
data class HotDeal( data class HotDeal(
val id: String, // siteName + "_" + postId
val siteName: String, // ppomppu, clien, ruriweb, coolenjoy, quasarzone
val boardName: String, // ppomppu, ppomppu4, allsell, jirum, etc.
val title: String, // 게시글 제목
val url: String, // 게시글 URL
val mallUrl: String? = null, // 쇼핑몰 URL (추출된 경우)
val createdAt: Long, // 수집 시간 (timestamp)
val isNotified: Boolean = false,
val isKeywordMatch: Boolean = false,
val isFavorite: Boolean = false, // 즐겨찾기 여부
val isPopular: Boolean = false // 인기/핫 게시물 여부
) {
val id: String, // siteName + "_" + postId val id: String, // siteName + "_" + postId
val siteName: String, // ppomppu, clien, ruriweb, coolenjoy, quasarzone val siteName: String, // ppomppu, clien, ruriweb, coolenjoy, quasarzone
val boardName: String, // ppomppu, ppomppu4, allsell, jirum, etc. val boardName: String, // ppomppu, ppomppu4, allsell, jirum, etc.