-
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.
- Loading branch information
Showing
23 changed files
with
400 additions
and
116 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
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
28 changes: 28 additions & 0 deletions
28
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/bo/DiaryTagSearchBo.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,28 @@ | ||
package kim.hyunsub.diary.bo | ||
|
||
import kim.hyunsub.common.model.ApiPageResult | ||
import kim.hyunsub.diary.model.api.ApiDiaryTag | ||
import kim.hyunsub.diary.model.api.toApi | ||
import kim.hyunsub.diary.model.dto.DiaryTagSearchParams | ||
import kim.hyunsub.diary.repository.condition.DiaryTagCondition | ||
import kim.hyunsub.diary.repository.mapper.DiaryTagMapper | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class DiaryTagSearchBo( | ||
private val diaryTagMapper: DiaryTagMapper, | ||
) { | ||
fun search(userId: String, params: DiaryTagSearchParams): ApiPageResult<ApiDiaryTag> { | ||
val condition = DiaryTagCondition(userId = userId, query = params.query) | ||
|
||
val total = diaryTagMapper.count(condition) | ||
val data = diaryTagMapper.select(condition) | ||
|
||
return ApiPageResult( | ||
total = total, | ||
page = 0, | ||
pageSize = total, | ||
data = data.map { it.toApi() }, | ||
) | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/controller/DiaryTagSearchController.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,25 @@ | ||
package kim.hyunsub.diary.controller | ||
|
||
import kim.hyunsub.common.model.ApiPageResult | ||
import kim.hyunsub.common.web.model.UserAuth | ||
import kim.hyunsub.diary.bo.DiaryTagSearchBo | ||
import kim.hyunsub.diary.model.api.ApiDiaryTag | ||
import kim.hyunsub.diary.model.dto.DiaryTagSearchParams | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/search/tags") | ||
class DiaryTagSearchController( | ||
private val diaryTagSearchBo: DiaryTagSearchBo, | ||
) { | ||
@PostMapping("") | ||
fun search( | ||
user: UserAuth, | ||
@RequestBody params: DiaryTagSearchParams, | ||
): ApiPageResult<ApiDiaryTag> { | ||
return diaryTagSearchBo.search(user.idNo, params) | ||
} | ||
} |
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
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/model/api/ApiDiaryTag.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 kim.hyunsub.diary.model.api | ||
|
||
data class ApiDiaryTag( | ||
val id: String, | ||
val name: String, | ||
) |
5 changes: 5 additions & 0 deletions
5
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/model/dto/DiaryTagSearchParams.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,5 @@ | ||
package kim.hyunsub.diary.model.dto | ||
|
||
data class DiaryTagSearchParams( | ||
val query: String? = null, | ||
) |
3 changes: 2 additions & 1 deletion
3
...nsub/diary/model/dto/DiaryUpdateParams.kt → ...nsub/diary/model/dto/DiaryUpsertParams.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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package kim.hyunsub.diary.model.dto | ||
|
||
data class DiaryUpdateParams( | ||
data class DiaryUpsertParams( | ||
val content: String, | ||
val summary: String, | ||
val friendIds: List<String>, | ||
val tags: List<String>, | ||
) |
10 changes: 10 additions & 0 deletions
10
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/repository/condition/DiaryTagCondition.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,10 @@ | ||
package kim.hyunsub.diary.repository.condition | ||
|
||
import java.time.LocalDate | ||
|
||
data class DiaryTagCondition( | ||
val userId: String, | ||
val names: List<String>? = null, | ||
val query: String? = null, | ||
val date: LocalDate? = null, | ||
) |
9 changes: 9 additions & 0 deletions
9
...-diary/src/main/kotlin/kim/hyunsub/diary/repository/condition/DiaryTagMappingCondition.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,9 @@ | ||
package kim.hyunsub.diary.repository.condition | ||
|
||
import java.time.LocalDate | ||
|
||
data class DiaryTagMappingCondition( | ||
val userId: String, | ||
val date: LocalDate? = null, | ||
val tagId: String? = null, | ||
) |
7 changes: 7 additions & 0 deletions
7
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/repository/entity/DiaryTag.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,7 @@ | ||
package kim.hyunsub.diary.repository.entity | ||
|
||
data class DiaryTag( | ||
val id: String, | ||
val userId: String, | ||
val name: String, | ||
) |
9 changes: 9 additions & 0 deletions
9
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/repository/entity/DiaryTagMapping.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,9 @@ | ||
package kim.hyunsub.diary.repository.entity | ||
|
||
import java.time.LocalDate | ||
|
||
data class DiaryTagMapping( | ||
val userId: String, | ||
val date: LocalDate, | ||
val tagId: String, | ||
) |
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
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/repository/mapper/DiaryTagMapper.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 kim.hyunsub.diary.repository.mapper | ||
|
||
import kim.hyunsub.common.database.MapperBase | ||
import kim.hyunsub.common.database.generateId | ||
import kim.hyunsub.diary.repository.condition.DiaryTagCondition | ||
import kim.hyunsub.diary.repository.entity.DiaryTag | ||
import org.apache.ibatis.annotations.Mapper | ||
|
||
@Mapper | ||
interface DiaryTagMapper : MapperBase { | ||
override fun countById(id: String): Int | ||
|
||
fun select(condition: DiaryTagCondition): List<DiaryTag> | ||
fun count(condition: DiaryTagCondition): Int | ||
fun selectOne(id: String): List<DiaryTag> | ||
|
||
fun insertBulk(entities: List<DiaryTag>): Int | ||
fun update(entity: DiaryTag): Int | ||
fun deleteOne(id: String): Int | ||
} | ||
|
||
fun DiaryTagMapper.generateId() = generateId(10) |
15 changes: 15 additions & 0 deletions
15
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/repository/mapper/DiaryTagMappingMapper.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,15 @@ | ||
package kim.hyunsub.diary.repository.mapper | ||
|
||
import kim.hyunsub.diary.repository.condition.DiaryTagMappingCondition | ||
import kim.hyunsub.diary.repository.entity.DiaryTagMapping | ||
import org.apache.ibatis.annotations.Mapper | ||
import java.time.LocalDate | ||
|
||
@Mapper | ||
interface DiaryTagMappingMapper { | ||
fun select(condition: DiaryTagMappingCondition): List<DiaryTagMapping> | ||
fun count(condition: DiaryTagMappingCondition): List<DiaryTagMapping> | ||
|
||
fun insertBulk(entities: List<DiaryTagMapping>): Int | ||
fun deleteWithTagIds(userId: String, date: LocalDate, tagIds: List<String>): Int | ||
} |
Oops, something went wrong.