-
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.
[Feature/400] 알림 설정 및 조회 API 구현 (#405)
* feat: 알림 설정 및 조회 API 구현 * feat: 주석 추가 * feat: 응답 형태 변경 * feat: 웹훅 수정
- Loading branch information
1 parent
a731b51
commit f759bf3
Showing
10 changed files
with
168 additions
and
12 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
9 changes: 9 additions & 0 deletions
9
api/src/main/kotlin/com/nexters/bottles/api/user/facade/dto/AlimyOnOffRequest.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 com.nexters.bottles.api.user.facade.dto | ||
|
||
import com.nexters.bottles.app.user.domain.enum.AlimyType | ||
|
||
data class AlimyOnOffRequest( | ||
val alimyType: AlimyType, | ||
val enabled: Boolean, | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
api/src/main/kotlin/com/nexters/bottles/api/user/facade/dto/AlimyResponse.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 com.nexters.bottles.api.user.facade.dto | ||
|
||
import com.nexters.bottles.app.user.domain.enum.AlimyType | ||
|
||
data class AlimyResponse( | ||
val alimyType: AlimyType, | ||
val enabled: Boolean, | ||
) { | ||
} |
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
app/src/main/kotlin/com/nexters/bottles/app/user/domain/UserAlimy.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.nexters.bottles.app.user.domain | ||
|
||
import com.nexters.bottles.app.common.BaseEntity | ||
import com.nexters.bottles.app.user.domain.enum.AlimyType | ||
import org.springframework.data.relational.core.mapping.Table | ||
import javax.persistence.* | ||
|
||
@Entity | ||
data class UserAlimy( | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long = 0L, | ||
|
||
val userId: Long, | ||
|
||
@Enumerated(EnumType.STRING) | ||
val alimyType: AlimyType, | ||
|
||
val enabled: Boolean = true, | ||
): BaseEntity() { | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/kotlin/com/nexters/bottles/app/user/domain/enum/AlimyType.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 com.nexters.bottles.app.user.domain.enum | ||
|
||
enum class AlimyType { | ||
DAILY_RANDOM, // 떠다니는 보틀 알림 | ||
RECEIVE_LIKE, // 호감 도착 알림 | ||
PINGPONG, // 대화 알림 | ||
MARKETING, // 마케팅 수신 동의 | ||
; | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/kotlin/com/nexters/bottles/app/user/repository/UserAlimyRepository.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,12 @@ | ||
package com.nexters.bottles.app.user.repository | ||
|
||
import com.nexters.bottles.app.user.domain.UserAlimy | ||
import com.nexters.bottles.app.user.domain.enum.AlimyType | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface UserAlimyRepository: JpaRepository<UserAlimy, Long> { | ||
|
||
fun findByUserIdAndAlimyType(userId: Long, alimyType: AlimyType): UserAlimy? | ||
|
||
fun findAllByUserId(userId: Long): List<UserAlimy> | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/kotlin/com/nexters/bottles/app/user/service/UserAlimyService.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,30 @@ | ||
package com.nexters.bottles.app.user.service | ||
|
||
import com.nexters.bottles.app.user.domain.UserAlimy | ||
import com.nexters.bottles.app.user.domain.enum.AlimyType | ||
import com.nexters.bottles.app.user.repository.UserAlimyRepository | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
class UserAlimyService( | ||
private val userAlimyRepository: UserAlimyRepository, | ||
) { | ||
@Transactional | ||
fun turnOnOffAlimy(userId: Long, alimyType: AlimyType, enabled: Boolean) { | ||
userAlimyRepository.findByUserIdAndAlimyType(userId, alimyType)?.let { | ||
userAlimyRepository.save( | ||
UserAlimy(userId = userId, alimyType = alimyType, enabled = enabled) | ||
) | ||
} ?: run { | ||
userAlimyRepository.save( | ||
UserAlimy(userId = userId, alimyType = alimyType, enabled = enabled) | ||
) | ||
} | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
fun findAlimies(userId: Long): List<UserAlimy> { | ||
return userAlimyRepository.findAllByUserId(userId) | ||
} | ||
} |