회원가입 후 초기 알림설정 기능 추가
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package kr.co.vividnext.sodalive.member.notification
|
||||
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.member.notification.QMemberNotification.memberNotification
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface MemberNotificationRepository : JpaRepository<MemberNotification, Long>, MemberNotificationQueryRepository
|
||||
|
||||
interface MemberNotificationQueryRepository {
|
||||
fun getMemberNotification(memberId: Long): MemberNotification?
|
||||
}
|
||||
|
||||
@Repository
|
||||
class MemberNotificationQueryRepositoryImpl(
|
||||
private val queryFactory: JPAQueryFactory
|
||||
) : MemberNotificationQueryRepository {
|
||||
override fun getMemberNotification(memberId: Long): MemberNotification? {
|
||||
return queryFactory
|
||||
.selectFrom(memberNotification)
|
||||
.where(memberNotification.member.id.eq(memberId))
|
||||
.fetchFirst()
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package kr.co.vividnext.sodalive.member.notification
|
||||
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
class MemberNotificationService(private val repository: MemberNotificationRepository) {
|
||||
fun updateNotification(
|
||||
live: Boolean? = null,
|
||||
uploadContent: Boolean? = null,
|
||||
message: Boolean? = null,
|
||||
member: Member
|
||||
) {
|
||||
var notification = repository.getMemberNotification(memberId = member.id!!)
|
||||
if (notification == null) {
|
||||
notification = MemberNotification(uploadContent, live, message)
|
||||
notification.member = member
|
||||
repository.save(notification)
|
||||
} else {
|
||||
if (live != null) notification.live = live
|
||||
if (message != null) notification.message = message
|
||||
if (uploadContent != null) notification.uploadContent = uploadContent
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package kr.co.vividnext.sodalive.member.notification
|
||||
|
||||
data class UpdateNotificationSettingRequest(
|
||||
val live: Boolean?,
|
||||
val message: Boolean?,
|
||||
val uploadContent: Boolean?
|
||||
)
|
Reference in New Issue
Block a user