Skip to content

Commit 1d695a5

Browse files
authored
merge: v3.0.3
2 parents a7092b5 + e531f27 commit 1d695a5

File tree

108 files changed

+4616
-1394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+4616
-1394
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ JWT_REFRESH_TOKEN_SECRET=string
3030
JWT_REFRESH_TOKEN_EXPIRATION=number
3131
SPRINGDOC_ENABLED=boolean
3232
SWAGGER_ENABLED=boolean
33+
SERVER_COOKIE_DOMAIN=string

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ kotlin {
118118
}
119119

120120
jacoco {
121-
toolVersion = "0.8.10"
121+
toolVersion = "0.8.14"
122122
reportsDirectory.set(file("$rootDir/.qodana/code-coverage"))
123123
}
124124

src/main/kotlin/com/team/incube/gsmc/v3/domain/alert/dto/Alert.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ data class Alert(
99
val id: Long,
1010
val sender: Member,
1111
val receiver: Member,
12-
val score: Score,
12+
val score: Score?,
1313
val alertType: AlertType,
1414
val isRead: Boolean,
1515
val content: String,

src/main/kotlin/com/team/incube/gsmc/v3/domain/alert/dto/constant/AlertType.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ enum class AlertType(
1212
APPROVED(
1313
title = "합격 알림",
1414
),
15+
TEACHER_SIGNUP_REQUEST(
16+
title = "선생님 회원가입 요청",
17+
),
1518
}

src/main/kotlin/com/team/incube/gsmc/v3/domain/alert/entity/AlertExposedEntity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object AlertExposedEntity : Table(name = "tb_alert") {
1111
val id = long(name = "alert_id").autoIncrement()
1212
val senderId = long(name = "alert_sender_id").references(MemberExposedEntity.id)
1313
val receiverId = long(name = "alert_receiver_id").references(MemberExposedEntity.id)
14-
val scoreId = long(name = "score_id").references(ScoreExposedEntity.id)
14+
val scoreId = long(name = "score_id").references(ScoreExposedEntity.id).nullable()
1515
val alertType = enumeration<AlertType>(name = "alert_type")
1616
val isRead = bool(name = "alert_is_read").default(false)
1717
val content = varchar(name = "alert_content", length = 255).default("")

src/main/kotlin/com/team/incube/gsmc/v3/domain/alert/presentation/data/response/GetAlertResponse.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ data class GetAlertResponse(
1515
val createdAt: LocalDateTime,
1616
@field:Schema(description = "알림 타입", example = "APPROVED")
1717
val alertType: AlertType,
18-
@field:Schema(description = "점수 ID", example = "1")
19-
val scoreId: Long,
18+
@field:Schema(description = "점수 ID(Nullable)", example = "1")
19+
val scoreId: Long?,
2020
)

src/main/kotlin/com/team/incube/gsmc/v3/domain/alert/repository/AlertExposedRepository.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ interface AlertExposedRepository {
2020
content: String,
2121
): Alert
2222

23+
fun saveWithoutScore(
24+
sender: Member,
25+
receiver: Member,
26+
alertType: AlertType,
27+
content: String,
28+
): Alert
29+
2330
fun updateIsReadTrueByReceiverIdAndLastAlertId(
2431
receiverId: Long,
2532
lastAlertId: Long,
@@ -28,4 +35,6 @@ interface AlertExposedRepository {
2835
fun deleteByScoreId(scoreId: Long): Int
2936

3037
fun deleteAllByScoreIdIn(scoreIds: List<Long>): Int
38+
39+
fun deleteAllByMemberId(memberId: Long): Int
3140
}

src/main/kotlin/com/team/incube/gsmc/v3/domain/alert/repository/impl/AlertExposedRepositoryImpl.kt

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import org.jetbrains.exposed.v1.core.and
1616
import org.jetbrains.exposed.v1.core.eq
1717
import org.jetbrains.exposed.v1.core.inList
1818
import org.jetbrains.exposed.v1.core.lessEq
19+
import org.jetbrains.exposed.v1.core.or
1920
import org.jetbrains.exposed.v1.jdbc.deleteWhere
2021
import org.jetbrains.exposed.v1.jdbc.insert
2122
import org.jetbrains.exposed.v1.jdbc.selectAll
@@ -31,7 +32,7 @@ class AlertExposedRepositoryImpl : AlertExposedRepository {
3132
val receiverAlias = MemberExposedEntity.alias("receiver")
3233

3334
return AlertExposedEntity
34-
.join(ScoreExposedEntity, JoinType.INNER) {
35+
.join(ScoreExposedEntity, JoinType.LEFT) {
3536
AlertExposedEntity.scoreId eq ScoreExposedEntity.id
3637
}.join(senderAlias, JoinType.INNER) {
3738
AlertExposedEntity.senderId eq senderAlias[MemberExposedEntity.id]
@@ -64,19 +65,25 @@ class AlertExposedRepositoryImpl : AlertExposedRepository {
6465
)
6566

6667
val score =
67-
Score(
68-
id = row[ScoreExposedEntity.id],
69-
member = receiver,
70-
categoryType = CategoryType.fromEnglishName(row[ScoreExposedEntity.categoryEnglishName]),
71-
status = row[ScoreExposedEntity.status],
72-
sourceId = row[ScoreExposedEntity.sourceId],
73-
activityName = row[ScoreExposedEntity.activityName],
74-
scoreValue = row[ScoreExposedEntity.scoreValue],
75-
rejectionReason = row[ScoreExposedEntity.rejectionReason],
76-
)
68+
row[AlertExposedEntity.scoreId]?.let {
69+
Score(
70+
id = row[ScoreExposedEntity.id],
71+
member = receiver,
72+
categoryType = CategoryType.fromEnglishName(row[ScoreExposedEntity.categoryEnglishName]),
73+
status = row[ScoreExposedEntity.status],
74+
sourceId = row[ScoreExposedEntity.sourceId],
75+
activityName = row[ScoreExposedEntity.activityName],
76+
scoreValue = row[ScoreExposedEntity.scoreValue],
77+
rejectionReason = row[ScoreExposedEntity.rejectionReason],
78+
updatedAt = row[ScoreExposedEntity.updatedAt],
79+
)
80+
}
7781

78-
val createdAtInstant = row[AlertExposedEntity.createdAt]
79-
val createdAt = LocalDateTime.ofInstant(createdAtInstant, ZoneId.systemDefault())
82+
val createdAt =
83+
LocalDateTime.ofInstant(
84+
row[AlertExposedEntity.createdAt],
85+
ZoneId.systemDefault(),
86+
)
8087

8188
Alert(
8289
id = row[AlertExposedEntity.id],
@@ -101,7 +108,7 @@ class AlertExposedRepositoryImpl : AlertExposedRepository {
101108
val receiverAlias = MemberExposedEntity.alias("receiver")
102109

103110
return AlertExposedEntity
104-
.join(ScoreExposedEntity, JoinType.INNER) {
111+
.join(ScoreExposedEntity, JoinType.LEFT) {
105112
AlertExposedEntity.scoreId eq ScoreExposedEntity.id
106113
}.join(senderAlias, JoinType.INNER) {
107114
AlertExposedEntity.senderId eq senderAlias[MemberExposedEntity.id]
@@ -136,19 +143,25 @@ class AlertExposedRepositoryImpl : AlertExposedRepository {
136143
)
137144

138145
val score =
139-
Score(
140-
id = row[ScoreExposedEntity.id],
141-
member = receiver,
142-
categoryType = CategoryType.fromEnglishName(row[ScoreExposedEntity.categoryEnglishName]),
143-
status = row[ScoreExposedEntity.status],
144-
sourceId = row[ScoreExposedEntity.sourceId],
145-
activityName = row[ScoreExposedEntity.activityName],
146-
scoreValue = row[ScoreExposedEntity.scoreValue],
147-
rejectionReason = row[ScoreExposedEntity.rejectionReason],
148-
)
146+
row[AlertExposedEntity.scoreId]?.let {
147+
Score(
148+
id = row[ScoreExposedEntity.id],
149+
member = receiver,
150+
categoryType = CategoryType.fromEnglishName(row[ScoreExposedEntity.categoryEnglishName]),
151+
status = row[ScoreExposedEntity.status],
152+
sourceId = row[ScoreExposedEntity.sourceId],
153+
activityName = row[ScoreExposedEntity.activityName],
154+
scoreValue = row[ScoreExposedEntity.scoreValue],
155+
rejectionReason = row[ScoreExposedEntity.rejectionReason],
156+
updatedAt = row[ScoreExposedEntity.updatedAt],
157+
)
158+
}
149159

150-
val createdAtInstant = row[AlertExposedEntity.createdAt]
151-
val createdAt = LocalDateTime.ofInstant(createdAtInstant, ZoneId.systemDefault())
160+
val createdAt =
161+
LocalDateTime.ofInstant(
162+
row[AlertExposedEntity.createdAt],
163+
ZoneId.systemDefault(),
164+
)
152165

153166
Alert(
154167
id = row[AlertExposedEntity.id],
@@ -195,6 +208,37 @@ class AlertExposedRepositoryImpl : AlertExposedRepository {
195208
)
196209
}
197210

211+
override fun saveWithoutScore(
212+
sender: Member,
213+
receiver: Member,
214+
alertType: AlertType,
215+
content: String,
216+
): Alert {
217+
val now = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()
218+
219+
val insertedId =
220+
AlertExposedEntity.insert {
221+
it[this.senderId] = sender.id
222+
it[this.receiverId] = receiver.id
223+
it[this.scoreId] = null
224+
it[this.alertType] = alertType
225+
it[this.isRead] = false
226+
it[this.content] = content
227+
it[this.createdAt] = now
228+
} get AlertExposedEntity.id
229+
230+
return Alert(
231+
id = insertedId,
232+
sender = sender,
233+
receiver = receiver,
234+
score = null,
235+
alertType = alertType,
236+
isRead = false,
237+
content = content,
238+
createdAt = LocalDateTime.ofInstant(now, ZoneId.systemDefault()),
239+
)
240+
}
241+
198242
override fun updateIsReadTrueByReceiverIdAndLastAlertId(
199243
receiverId: Long,
200244
lastAlertId: Long,
@@ -217,4 +261,10 @@ class AlertExposedRepositoryImpl : AlertExposedRepository {
217261
AlertExposedEntity.scoreId inList scoreIds
218262
}
219263
}
264+
265+
override fun deleteAllByMemberId(memberId: Long): Int =
266+
AlertExposedEntity.deleteWhere {
267+
(AlertExposedEntity.senderId eq memberId) or
268+
(AlertExposedEntity.receiverId eq memberId)
269+
}
220270
}

src/main/kotlin/com/team/incube/gsmc/v3/domain/alert/service/impl/CreateAlertServiceImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class CreateAlertServiceImpl(
4242
AlertType.APPROVED -> {
4343
"${score.categoryType.koreanName} 점수를 ${sender.name} 선생님께서 통과시키셨습니다."
4444
}
45+
46+
AlertType.TEACHER_SIGNUP_REQUEST -> {
47+
throw GsmcException(ErrorCode.INVALID_ALERT_TYPE)
48+
}
4549
}
4650

4751
alertExposedRepository.save(sender, receiver, score, alertType, content)

src/main/kotlin/com/team/incube/gsmc/v3/domain/alert/service/impl/FindMyAlertsServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FindMyAlertsServiceImpl(
2828
content = alert.content,
2929
createdAt = alert.createdAt,
3030
alertType = alert.alertType,
31-
scoreId = alert.score.id!!,
31+
scoreId = alert.score?.id,
3232
)
3333
},
3434
)

0 commit comments

Comments
 (0)