-
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
10 changed files
with
208 additions
and
128 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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/com/wafflestudio/csereal/core/research/api/res/ResearchSearchResBody.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,22 @@ | ||
package com.wafflestudio.csereal.core.research.api.res | ||
|
||
import com.wafflestudio.csereal.core.research.database.ResearchSearchEntity | ||
|
||
data class ResearchSearchResBody( | ||
val results: List<ResearchSearchResElement>, | ||
val total: Long | ||
) { | ||
companion object { | ||
fun of( | ||
researches: List<ResearchSearchEntity>, | ||
keyword: String, | ||
amount: Int, | ||
total: Long | ||
) = ResearchSearchResBody( | ||
results = researches.map { | ||
ResearchSearchResElement.of(it, keyword, amount) | ||
}, | ||
total = total | ||
) | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/main/kotlin/com/wafflestudio/csereal/core/research/api/res/ResearchSearchResElement.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,90 @@ | ||
package com.wafflestudio.csereal.core.research.api.res | ||
|
||
import com.wafflestudio.csereal.common.CserealException | ||
import com.wafflestudio.csereal.common.properties.LanguageType | ||
import com.wafflestudio.csereal.common.utils.substringAroundKeyword | ||
import com.wafflestudio.csereal.core.research.database.ResearchSearchEntity | ||
import com.wafflestudio.csereal.core.research.database.ResearchSearchType | ||
|
||
data class ResearchSearchResElement( | ||
val id: Long, | ||
val language: String, | ||
val name: String, | ||
val researchType: ResearchSearchType, | ||
val partialDescription: String, | ||
val boldStartIdx: Int, | ||
val boldEndIdx: Int | ||
) { | ||
companion object { | ||
fun of( | ||
researchSearchEntity: ResearchSearchEntity, | ||
keyword: String, | ||
amount: Int | ||
): ResearchSearchResElement = | ||
when { | ||
researchSearchEntity.research != null && | ||
researchSearchEntity.lab == null && | ||
researchSearchEntity.conferenceElement == null | ||
-> researchSearchEntity.research!!.let { | ||
val (startIdx, partialDesc) = substringAroundKeyword( | ||
keyword, | ||
researchSearchEntity.content, | ||
amount | ||
) | ||
ResearchSearchResElement( | ||
id = it.id, | ||
name = it.name, | ||
language = it.language.let { ln -> LanguageType.makeLowercase(ln) }, | ||
researchType = ResearchSearchType.RESEARCH, | ||
partialDescription = partialDesc, | ||
boldStartIdx = startIdx ?: 0, | ||
boldEndIdx = startIdx?.plus(keyword.length) ?: 0 | ||
) | ||
} | ||
|
||
researchSearchEntity.lab != null && | ||
researchSearchEntity.research == null && | ||
researchSearchEntity.conferenceElement == null | ||
-> researchSearchEntity.lab!!.let { | ||
val (startIdx, partialDesc) = substringAroundKeyword( | ||
keyword, | ||
researchSearchEntity.content, | ||
amount | ||
) | ||
ResearchSearchResElement( | ||
id = it.id, | ||
name = it.name, | ||
language = it.language.let { ln -> LanguageType.makeLowercase(ln) }, | ||
researchType = ResearchSearchType.LAB, | ||
partialDescription = partialDesc, | ||
boldStartIdx = startIdx ?: 0, | ||
boldEndIdx = startIdx?.plus(keyword.length) ?: 0 | ||
) | ||
} | ||
|
||
researchSearchEntity.conferenceElement != null && | ||
researchSearchEntity.research == null && | ||
researchSearchEntity.lab == null | ||
-> researchSearchEntity.conferenceElement!!.let { | ||
val (startIdx, partialDesc) = substringAroundKeyword( | ||
keyword, | ||
researchSearchEntity.content, | ||
amount | ||
) | ||
ResearchSearchResElement( | ||
id = it.id, | ||
name = it.name, | ||
language = it.language.let { ln -> LanguageType.makeLowercase(ln) }, | ||
researchType = ResearchSearchType.CONFERENCE, | ||
partialDescription = partialDesc, | ||
boldStartIdx = startIdx ?: 0, | ||
boldEndIdx = startIdx?.plus(keyword.length) ?: 0 | ||
) | ||
} | ||
|
||
else -> throw CserealException.Csereal401( | ||
"ResearchSearchEntity의 연결이 올바르지 않습니다." | ||
) | ||
} | ||
} | ||
} |
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
18 changes: 0 additions & 18 deletions
18
src/main/kotlin/com/wafflestudio/csereal/core/research/dto/ResearchSearchPageResponse.kt
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
src/main/kotlin/com/wafflestudio/csereal/core/research/dto/ResearchSearchResponseElement.kt
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/main/kotlin/com/wafflestudio/csereal/core/research/dto/ResearchSearchTopResponse.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.