Skip to content

Commit

Permalink
Issues boostcampwm-2022#287 feat: DB 데이터에 balance 제거, total_cash, rem…
Browse files Browse the repository at this point in the history
…ain_cash 추가
  • Loading branch information
audxo112 committed Feb 27, 2023
1 parent be61838 commit ed54480
Show file tree
Hide file tree
Showing 23 changed files with 480 additions and 441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.lighthouse.navigator
import android.content.Context
import android.content.Intent
import com.lighthouse.features.common.navigator.MainNavigator
import com.lighthouse.features.main.ui.MainActivity
import com.lighthouse.features.main.ui.MainContainerFragment
import javax.inject.Inject

internal class MainNavigatorImpl @Inject constructor() : MainNavigator {

override fun openMain(context: Context) {
val intent = Intent(context, MainActivity::class.java)
val intent = Intent(context, MainContainerFragment::class.java)
context.startActivity(intent)
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<variable
name="vm"
type="com.lighthouse.features.main.ui.MainViewModel" />
type="com.lighthouse.features.main.ui.MainContainerViewModel" />
</data>

<androidx.fragment.app.FragmentContainerView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ internal interface GifticonEditDao {
"expire_at = :expire_at, " +
"barcode = :barcode, " +
"is_cash_card = :isCashCard, " +
"balance = :balance, " +
"total_cash = :totalCash, " +
"remain_cash = :remainCash, " +
"memo = :memo " +
"WHERE user_id = :userId AND id = :gifticonId"
)
Expand All @@ -70,7 +71,8 @@ internal interface GifticonEditDao {
expire_at: Date,
barcode: String,
isCashCard: Boolean,
balance: Int,
totalCash: Int,
remainCash: Int,
memo: String
): Int

Expand Down Expand Up @@ -110,7 +112,8 @@ internal interface GifticonEditDao {
expireAt,
barcode,
isCashCard,
balance,
totalCash,
remainCash,
memo
)
if (updatedCount == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.lighthouse.data.database.dao

import androidx.room.Dao
import androidx.room.Query
import com.lighthouse.data.database.entity.DBGifticonEntity
import com.lighthouse.data.database.model.DBBrandWithGifticonCount
import com.lighthouse.data.database.model.DBGifticon
import com.lighthouse.data.database.model.DBGifticonNotification
Expand All @@ -19,7 +18,7 @@ internal interface GifticonSearchDao {
* 2. Limit
*/
@Query(
"SELECT *, " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
Expand Down Expand Up @@ -61,13 +60,18 @@ internal interface GifticonSearchDao {
* 2. 기프티콘 ID
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND id = :gifticonId"
)
fun getGifticon(
userId: String,
gifticonId: String
): Flow<DBGifticonEntity>
): Flow<DBGifticon>

/**
* 사용 가능한 기프티콘 중에서 count 만큼만 갖고 오기
Expand All @@ -76,15 +80,20 @@ internal interface GifticonSearchDao {
* 3. 가져올 개수
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND expire_at = :time AND is_used = 0 " +
"LIMIT :count"
)
fun getGifticons(
userId: String,
time: Date,
count: Int
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 기프티콘 리스트를 가져온다
Expand All @@ -93,14 +102,19 @@ internal interface GifticonSearchDao {
* 최신순으로 정렬
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND is_used = :isUsed " +
"ORDER BY created_at DESC"
)
fun getAllGifticonsSortByRecent(
userId: String,
isUsed: Boolean
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 기프티콘 리스트를 가져온다
Expand All @@ -110,15 +124,20 @@ internal interface GifticonSearchDao {
* 최신순으로 정렬
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND is_used = :isUsed AND expire_at > :expired " +
"ORDER BY created_at DESC"
)
fun getAllGifticonsSortByRecent(
userId: String,
isUsed: Boolean,
expired: Date
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 기프티콘 리스트를 가져온다
Expand All @@ -127,14 +146,19 @@ internal interface GifticonSearchDao {
* 만료일기준으로 정렬
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND is_used = :isUsed " +
"ORDER BY expire_at"
)
fun getAllGifticonsSortByDeadline(
userId: String,
isUsed: Boolean
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 기프티콘 리스트를 가져온다
Expand All @@ -144,15 +168,20 @@ internal interface GifticonSearchDao {
* 만료일기준으로 정렬
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND is_used = :isUsed AND expire_at > :expired " +
"ORDER BY expire_at"
)
fun getAllGifticonsSortByDeadline(
userId: String,
isUsed: Boolean,
expired: Date
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 브랜드 이름으로 필터된 기프티콘 리스트를 가져온다
Expand All @@ -162,15 +191,20 @@ internal interface GifticonSearchDao {
* 최신순으로 정렬
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND is_used = :isUsed AND UPPER(brand) IN(:filters) " +
"ORDER BY created_at DESC"
)
fun getFilteredGifticonsSortByRecent(
userId: String,
isUsed: Boolean,
filters: Set<String>
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 브랜드 이름으로 필터된 기프티콘 리스트를 가져온다
Expand All @@ -181,7 +215,12 @@ internal interface GifticonSearchDao {
* 최신순으로 정렬
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND " +
"is_used = :isUsed AND " +
"UPPER(brand) IN(:filters) AND " +
Expand All @@ -193,7 +232,7 @@ internal interface GifticonSearchDao {
isUsed: Boolean,
filters: Set<String>,
expired: Date
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 브랜드 이름으로 필터된 기프티콘 리스트를 가져온다
Expand All @@ -203,15 +242,20 @@ internal interface GifticonSearchDao {
* 만료일기준으로 정렬
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND is_used = :isUsed AND UPPER(brand) IN(:filters) " +
"ORDER BY expire_at"
)
fun getFilteredGifticonsSortByDeadline(
userId: String,
isUsed: Boolean,
filters: Set<String>
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 브랜드 이름으로 필터된 기프티콘 리스트를 가져온다
Expand All @@ -222,7 +266,12 @@ internal interface GifticonSearchDao {
* 만료일기준으로 정렬
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND " +
"is_used = :isUsed AND " +
"UPPER(brand) IN(:filters) AND " +
Expand All @@ -234,7 +283,7 @@ internal interface GifticonSearchDao {
isUsed: Boolean,
filters: Set<String>,
expired: Date
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 브랜드 이름과 해당 브랜드의 기프티콘 개수를 가져오기
Expand Down Expand Up @@ -292,14 +341,19 @@ internal interface GifticonSearchDao {
* 3. 브랜드 이름
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND is_used = :isUsed AND brand =:brand"
)
fun getGifticonByBrand(
userId: String,
isUsed: Boolean,
brand: String
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 기프티콘 리스트 가져오기
Expand All @@ -309,7 +363,12 @@ internal interface GifticonSearchDao {
* 4. 만료일
* */
@Query(
"SELECT * FROM gifticon_table " +
"SELECT id, cropped_uri, name, brand, expire_at, is_cash_card, total_cash, remain_cash, " +
"Cast(" +
"JulianDay(date(expire_at / 1000), 'unixepoch') - " +
"JulianDay(date('now')) as Integer" +
") as d_day " +
"FROM gifticon_table " +
"WHERE user_id = :userId AND " +
"is_used = :isUsed AND " +
"brand =:brand AND " +
Expand All @@ -320,7 +379,7 @@ internal interface GifticonSearchDao {
isUsed: Boolean,
brand: String,
expired: Date
): Flow<List<DBGifticonEntity>>
): Flow<List<DBGifticon>>

/**
* 기프티콘 존재여부 확인
Expand Down
Loading

0 comments on commit ed54480

Please sign in to comment.