tgyuuAn / BaekyoungE

์ž์—ฐ์–ด ์ฒ˜๋ฆฌ ๊ธฐ๋ฐ˜ ์ง„๋กœ ์ƒ๋‹ด chat bot ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜
7 stars 0 forks source link

Feature/#41 #42

Closed tgyuuAn closed 7 months ago

tgyuuAn commented 7 months ago

1. ๐Ÿ“„ ๊ด€๋ จ๋œ ์ด์Šˆ ๋ฐ ์†Œ๊ฐœ

2. ๐Ÿ”ฅ๋ณ€๊ฒฝ๋œ ์ 

- ์ฑ„ํŒ… ๋กœ์ปฌ ์ž๋™ ์บ์‹ฑ - ์บ์‹ฑ๋œ ์ฑ„ํŒ… ๋‚ด์—ญ ์‚ญ์ œ ๊ธฐ๋Šฅ - ์ฑ„ํŒ… ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

3. ๐Ÿ“ธ ์Šคํฌ๋ฆฐ์ƒท(์„ ํƒ)

4. ๐Ÿ’ก์•Œ๊ฒŒ๋œ ํ˜น์€ ๊ถ๊ธˆํ•œ ์‚ฌํ•ญ๋“ค

Horizontal Divider์˜ default Modifier๊ฐ€ fillMaxWidth() ์ธ๋ฐ์š”?

๋ชฉํ‘œ -

image




๋ฌธ์ œ 1 -

                    itemsIndexed(yearList) { index, year ->
                        Column(
                            modifier = Modifier.clickable { showSpinner = false },
                        ) {
                            Text(
                                text = year,
                                style = BaekyoungTheme.typography.labelRegular.copy(fontSize = 13.sp),
                                color = BaekyoungTheme.colors.gray95,
                                textAlign = TextAlign.Center,
                                modifier = Modifier.padding(horizontal = 20.dp, vertical = 6.dp)
                            )

                            if (index < yearList.size - 1) {
                                HorizontalDivider(color = BaekyoungTheme.colors.grayAC)
                            }
                        }
                    }
                }

image




๋ฌธ์ œ 1์˜ ์›์ธ -

Horizontal Divider์˜ ๊ธฐ๋ณธ Default Modifier๊ฐ€ fillMaxWidth() ์˜€์Œ.




๋ฌธ์ œ 2 -

                    itemsIndexed(yearList) { index, year ->
                        Column(
                            modifier = Modifier
                                .width(IntrinsicSize.Min) // <-- ์š” ๋…€์„ ์ถ”๊ฐ€ํ•ด์„œ Column ๋‚ด๋ถ€์˜ ์ตœ์†Œ width๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๊ทธ๋ฆฌ๋„๋ก ๋ณ€๊ฒฝ
                                .clickable { showSpinner = false },
                        ) {
                            Text(
                                text = year,
                                style = BaekyoungTheme.typography.labelRegular.copy(fontSize = 13.sp),
                                color = BaekyoungTheme.colors.gray95,
                                textAlign = TextAlign.Center,
                                modifier = Modifier.padding(horizontal = 20.dp, vertical = 6.dp)
                            )

                            if (index < yearList.size - 1) {
                                HorizontalDivider(color = BaekyoungTheme.colors.grayAC)
                            }
                        }
                    }

image

๊ทผ๋ฐ ์™œ Text์— ๊ฐœํ–‰์ด ๋ ๊นŒ์š”?

์ด๊ฑด ์•„์ง๋„ ์ž˜ ๋ชจ๋ฅด๊ฒ ๋”ฐ.




์—ฌํ•˜ํŠผ ์ตœ์ข… -

๋ ˆํผ๋Ÿฐ์Šค

                    itemsIndexed(yearList) { index, year ->
                        Column(
                            modifier = Modifier
                                .width(IntrinsicSize.Min)
                                .clickable { showSpinner = false },
                        ) {
                            Text(
                                text = year,
                                style = BaekyoungTheme.typography.labelRegular.copy(fontSize = 13.sp),
                                color = BaekyoungTheme.colors.gray95,
                                textAlign = TextAlign.Center,
                                modifier = Modifier
                                    .padding(horizontal = 20.dp, vertical = 6.dp)
                                    .requiredWidth(IntrinsicSize.Max),    // <-- ์ด ๋…€์„์„ ์ถ”๊ฐ€ํ•ด์„œ ๊ฐ€๋Šฅํ•œ ํ•œ ๋งŽ์ด ์ฐจ์ง€ํ•˜๋„๋ก ๋ณ€๊ฒฝ
                            )

                            if (index < yearList.size - 1) {
                                HorizontalDivider(color = BaekyoungTheme.colors.grayAC)
                            }
                        }
                    }

image

๋„ค์ด์“ฐ...!




๊ทผ๋ฐ ๋ฐ”๋กœ ์œ ๊ธฐ

image




์ฑ„ํŒ…๋ฐฉ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ตฌ์กฐ ์„ค๊ณ„๋Š” ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ์ข‹์„๊นŒ์š”...?

์ผ๋‹จ ์•„๋ž˜์™€ ๊ฐ™์ด ์‚ฌ์šฉ....! ๋ ˆํผ๋Ÿฐ์Šค

image

๊ทผ๋ฐ ์ง€๊ธˆ์€ ์ด์ œ 1:1 ์ฑ„ํŒ…๋ฐฉ์ด๋ผ์„œ ํšŒ์› ์ •๋ณด๋Š” ์—†๋Š”.




@Entity(tableName = "chatting_room")
data class ChattingRoomEntity(
    @PrimaryKey
    val id: String,
    @ColumnInfo(name = "last_chatting")
    val lastChatting: String,
    @ColumnInfo(name = "created_at")
    val createdAt: String,
)
@Entity(tableName = "message")
data class MessageEntity(
    @PrimaryKey
    val id: String,
    @ColumnInfo(name = "chatting_room_id")
    val chattingRoomId: String,
    @ColumnInfo(name = "message_from")
    val messageFrom: String, 
    @ColumnInfo(name = "message_to")
    val messageTo: String,
    val content: String,
    @ColumnInfo(name = "created_at")
    val createdAt: String,
)

๋ฉ”์„ธ์ง€์— from, to๊ฐ€ ์žˆ๋Š” ์ด์œ ๋Š” AI ์ฑ„ํŒ…๊ณผ ์œ ์ € ์ฑ„ํŒ…์˜ ๊ตฌ๋ถ„ ๋ชฉ์ ์ž„.

์ถ”ํ›„์— ๋ฉ˜ํ† , ๋ฉ˜ํ‹ฐ ์ฑ„ํŒ…์„ ๊ณ ๋ คํ•˜๊ธฐ๋„ ํ–ˆ์Œ.




DAO๋Š” ๊ฐ Entity๋ณ„๋กœ ๊ตฌ๋ถ„ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„๊นŒ์š” ...?

์ง€๊ธˆ ์œ„์— Message, ChattingRoomt Entity๊ฐ€ ์ด 2๊ฐœ๊ฐ€ ์žˆ์Œ.

๊ทผ๋ฐ DAO๋ฅผ ์„ค๊ณ„ํ•  ๋•Œ ์–ด์ฐจํ”ผ ๋‘˜ ๋‹ค ์ฑ„ํŒ… ์ •๋ณด ํ•˜๋‚˜์˜ ๋ชฉ์ ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”๋ฐ ChattingDao ํ•˜๋‚˜๋กœ ํ‰์น ์ง€,

์•„๋‹ˆ๋ฉด ๊ฐ Entity ๋ณ„๋กœ DAO๋ฅผ ์„ค๊ณ„ํ•  ์ง€ ๊ณ ๋ฏผ์ด ๋˜์—ˆ์Œ.




image

๊ทผ๋ฐ ์ƒ๊ฐํ•ด๋ณด๋‹ˆ๊นŒ ๋ญ ์—„์ฒญ๋‚˜๊ฒŒ ๊ฑฐ๋Œ€ํ•œ ๊ทœ๋ชจ๋„ ์•„๋‹ˆ๊ณ  1:1 ์ฑ„ํŒ…์ธ๋ฐ ๊ทธ๋ƒฅ ํ•˜๋‚˜์˜ DAO๋กœ ํ•ด๊ฒฐํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค๊ณ  ํŒ๋‹จ.

๋ฌด์—‡๋ณด๋‹ค ๊ท€์ฐฎ์œผ๋‹ˆ๊นŒ

@Dao
interface ChattingDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertMessage(message: MessageEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertChattingRoom(chattingRoom: ChattingRoomEntity)

    @Query("SELECT * FROM message WHERE chatting_room_id MATCH :roomId ORDER BY created_at DESC")
    suspend fun getAllChattingRoomMessages(roomId: String): List<MessageEntity>

    @Query("SELECT * FROM chatting_room ORDER BY created_at DESC")
    suspend fun getAllChattingRoom(): List<ChattingRoomEntity>
}




Local DB์— ์žˆ๋Š” ๋ฐ์ดํ„ฐ Where ๋กœ ์Šฅ์Šฅ ์‚ญ์ œ ํ•ด๋ฒ„๋ฆฌ๊ธฐ

@Query("DELETE FROM yourDatabaseTable WHERE id = :id")
suspend fun deleteById(int id);

๋Š๋‚Œ ์•Œ์ž–์•„??!