-
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
7 changed files
with
93 additions
and
15 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
8 changes: 8 additions & 0 deletions
8
.../src/main/kotlin/kim/hyunsub/diary/repository/condition/DiaryTagMappingDetailCondition.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,8 @@ | ||
package kim.hyunsub.diary.repository.condition | ||
|
||
import java.time.LocalDate | ||
|
||
data class DiaryTagMappingDetailCondition( | ||
val userId: String, | ||
val dates: List<LocalDate>? = null, | ||
) |
10 changes: 10 additions & 0 deletions
10
hyunsub-diary/src/main/kotlin/kim/hyunsub/diary/repository/entity/DiaryTagMappingDetail.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.entity | ||
|
||
import java.time.LocalDate | ||
|
||
data class DiaryTagMappingDetail( | ||
val id: String, | ||
val date: LocalDate, | ||
val userId: String, | ||
val name: String, | ||
) |
10 changes: 10 additions & 0 deletions
10
...-diary/src/main/kotlin/kim/hyunsub/diary/repository/mapper/DiaryTagMappingDetailMapper.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.mapper | ||
|
||
import kim.hyunsub.diary.repository.condition.DiaryTagMappingDetailCondition | ||
import kim.hyunsub.diary.repository.entity.DiaryTagMappingDetail | ||
import org.apache.ibatis.annotations.Mapper | ||
|
||
@Mapper | ||
interface DiaryTagMappingDetailMapper { | ||
fun select(condition: DiaryTagMappingDetailCondition): List<DiaryTagMappingDetail> | ||
} |
28 changes: 28 additions & 0 deletions
28
hyunsub-diary/src/main/resources/mapper/diary_tag_mapping_detail-mapper.xml
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 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
|
||
<mapper namespace="kim.hyunsub.diary.repository.mapper.DiaryTagMappingDetailMapper"> | ||
<sql id="DiaryTagMappingDetailColumns"> | ||
dtm.user_id, | ||
dtm.date, | ||
dtm.tag_id, | ||
dt.name | ||
</sql> | ||
|
||
<sql id="DiaryTagMappingDetailCondition"> | ||
<where> | ||
<if test="userId != null">AND dtm.user_id = #{userId}</if> | ||
<if test="dates != null"> | ||
<if test="!dates.isEmpty()">AND dtm.date IN (<foreach collection="dates" item="v" separator=",">#{v}</foreach>)</if> | ||
<if test="dates.isEmpty()">AND FALSE</if> | ||
</if> | ||
</where> | ||
</sql> | ||
|
||
<select id="select"> | ||
SELECT <include refid="DiaryTagMappingDetailColumns" /> | ||
FROM diary_tag_mapping dtm | ||
INNER JOIN diary_tag dt ON dtm.tag_id = dt.id | ||
<include refid="DiaryTagMappingDetailCondition" /> | ||
</select> | ||
</mapper> |