-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from apeun-gidaechi/feature/340-apply-ai-mapping
Feature/Apply Ai Mapping
- Loading branch information
Showing
10 changed files
with
242 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
data/message/src/main/java/com/seugi/data/message/mapper/CatSeugiMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.seugi.data.message.mapper | ||
|
||
import com.seugi.data.core.model.MealType | ||
import com.seugi.data.message.model.CatSeugiResponse | ||
|
||
fun CatSeugiResponse.toModel(): String { | ||
return when (this) { | ||
is CatSeugiResponse.ETC -> { | ||
this.data | ||
} | ||
is CatSeugiResponse.Meal -> { | ||
val breakfast = this.data.firstOrNull { it.mealType == MealType.BREAKFAST } | ||
val lunch = this.data.firstOrNull { it.mealType == MealType.LUNCH } | ||
val dinner = this.data.firstOrNull { it.mealType == MealType.DINNER } | ||
|
||
val visibleMessage = buildString { | ||
breakfast?.let { | ||
append("- 오늘의 조식\n") | ||
append(it.menu.joinToString(separator = "\n")) | ||
if (lunch != null || dinner != null) { | ||
append("\n\n") | ||
} | ||
} | ||
|
||
lunch?.let { | ||
append("- 오늘의 중식\n") | ||
append(it.menu.joinToString(separator = "\n")) | ||
if (dinner != null) { | ||
append("\n\n") | ||
} | ||
} | ||
|
||
dinner?.let { | ||
append("- 오늘의 석식\n") | ||
append(it.menu.joinToString(separator = "\n")) | ||
} | ||
|
||
if (isEmpty()) { | ||
append("오늘의 급식 없습니다.") | ||
} | ||
} | ||
|
||
visibleMessage | ||
} | ||
is CatSeugiResponse.NotSupport -> { | ||
this.data | ||
} | ||
is CatSeugiResponse.Timetable -> { | ||
val result = this.data.map { | ||
"${it.time}교시 ${it.subject}" | ||
}.joinToString(separator = "\n") | ||
result | ||
} | ||
is CatSeugiResponse.Picking -> { | ||
val cleanedData = this.data.replace("::", "") | ||
cleanedData | ||
} | ||
|
||
is CatSeugiResponse.Team -> { | ||
val result = this.data.replace("::", "") | ||
result | ||
} | ||
is CatSeugiResponse.Notification -> { | ||
var visibleMessage = "" | ||
this.data.forEach { | ||
visibleMessage += "${it.userName} 선생님이 공지를 작성하셨어요\n" + | ||
"제목: ${it.title}" + | ||
it.content | ||
} | ||
|
||
visibleMessage | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
data/message/src/main/java/com/seugi/data/message/model/CatSeugiResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.seugi.data.message.model | ||
|
||
import com.seugi.data.core.model.MealModel | ||
import com.seugi.data.core.model.NotificationModel | ||
import com.seugi.data.core.model.TimetableModel | ||
import kotlinx.collections.immutable.ImmutableList | ||
|
||
sealed interface CatSeugiResponse { | ||
data class Meal( | ||
val data: ImmutableList<MealModel>, | ||
) : CatSeugiResponse | ||
|
||
data class Timetable( | ||
val data: ImmutableList<TimetableModel>, | ||
) : CatSeugiResponse | ||
|
||
data class ETC( | ||
val data: String, | ||
) : CatSeugiResponse | ||
|
||
data class NotSupport( | ||
val data: String, | ||
) : CatSeugiResponse | ||
|
||
data class Picking( | ||
val data: String, | ||
) : CatSeugiResponse | ||
|
||
data class Team( | ||
val data: String, | ||
) : CatSeugiResponse | ||
|
||
data class Notification( | ||
val data: ImmutableList<NotificationModel>, | ||
) : CatSeugiResponse | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
network/message/src/main/java/com/seugi/network/message/request/CatSeugiRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.seugi.network.message.request | ||
|
||
data class CatSeugiRequest( | ||
val message: String, | ||
val roomId: String, | ||
) |
32 changes: 32 additions & 0 deletions
32
network/message/src/main/java/com/seugi/network/message/response/CatSeugiResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.seugi.network.message.response | ||
|
||
sealed class CatSeugiResponse( | ||
@Transient open val type: String, | ||
) { | ||
data class Meal( | ||
override val type: String, | ||
val id: Long, | ||
val workspaceId: String, | ||
val mealType: String, | ||
val menu: List<String>, | ||
val calorie: String, | ||
val mealInfo: List<String>, | ||
val mealDate: List<String>, | ||
) : CatSeugiResponse(type) | ||
|
||
data class Timetable( | ||
override val type: String, | ||
val id: Long, | ||
val workspaceId: String, | ||
val grade: String, | ||
val className: String, | ||
val time: String, | ||
val subject: String, | ||
val date: String, | ||
) : CatSeugiResponse(type) | ||
|
||
data class ETC( | ||
override val type: String, | ||
val data: String, | ||
) : CatSeugiResponse(type) | ||
} |