-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
1,518 additions
and
500 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
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/com/wafflestudio/csereal/core/about/api/res/AboutSearchElementDto.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,37 @@ | ||
package com.wafflestudio.csereal.core.about.api.res | ||
|
||
import com.wafflestudio.csereal.common.properties.LanguageType | ||
import com.wafflestudio.csereal.common.utils.cleanTextFromHtml | ||
import com.wafflestudio.csereal.common.utils.substringAroundKeyword | ||
import com.wafflestudio.csereal.core.about.database.AboutEntity | ||
import com.wafflestudio.csereal.core.about.database.AboutPostType | ||
|
||
data class AboutSearchElementDto private constructor( | ||
val id: Long, | ||
val language: String, | ||
val aboutPostType: AboutPostType, | ||
val name: String?, | ||
val partialDescription: String, | ||
val boldStartIndex: Int, | ||
val boldEndIndex: Int | ||
) { | ||
companion object { | ||
fun of(about: AboutEntity, keyword: String, amount: Int) = about.run { | ||
val (boldStartIdx, partialDescription) = substringAroundKeyword( | ||
keyword, | ||
cleanTextFromHtml(description), | ||
amount | ||
) | ||
|
||
AboutSearchElementDto( | ||
id = id, | ||
language = LanguageType.makeLowercase(language), | ||
aboutPostType = postType, | ||
name = name, | ||
partialDescription = partialDescription.replace('\n', ' '), | ||
boldStartIndex = boldStartIdx ?: 0, | ||
boldEndIndex = boldStartIdx?.plus(keyword.length) ?: 0 | ||
) | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/com/wafflestudio/csereal/core/about/api/res/AboutSearchResBody.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.wafflestudio.csereal.core.about.api.res | ||
|
||
data class AboutSearchResBody( | ||
val total: Long, | ||
val results: List<AboutSearchElementDto> | ||
) |
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
Oops, something went wrong.