회원가입 후 초기 알림설정 기능 추가

This commit is contained in:
2023-07-24 14:40:41 +09:00
parent 53a64d9bd7
commit ac09de9141
5 changed files with 84 additions and 0 deletions

View File

@@ -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()
}
}

View File

@@ -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
}
}
}

View File

@@ -0,0 +1,7 @@
package kr.co.vividnext.sodalive.member.notification
data class UpdateNotificationSettingRequest(
val live: Boolean?,
val message: Boolean?,
val uploadContent: Boolean?
)