Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 마이페이지 알림 수신 여부 API #165

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ class UserController(
fun findPWSearch(@RequestBody @Validated findIdPwReq: FindIdPwReq): BaseResponse<Any>{
if(!StringUtils.hasText(findIdPwReq.email)) throw BaseException(BaseResponseCode.NOT_EMPTY_EMAIL)
userService.findPWSearch(findIdPwReq)
return BaseResponse(BaseResponseCode.SUCCESS);
return BaseResponse(BaseResponseCode.SUCCESS)
}

/**
* 마이페이지 알림 수신 여부
*/
@PostMapping("/notification")
fun postNotiStatus(@AuthenticationPrincipal userAccount: UserAccount): BaseResponse<Any>{
return BaseResponse(userService.postNotiStatus(userAccount.getUser()))
}
}
11 changes: 11 additions & 0 deletions src/main/kotlin/com/psr/psr/user/dto/response/PostNotiRes.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.psr.psr.user.dto.response

data class PostNotiRes(
val notification: Boolean
){
companion object {
fun toDto(notification: Boolean) : PostNotiRes{
return PostNotiRes(notification)
}
}
}
9 changes: 9 additions & 0 deletions src/main/kotlin/com/psr/psr/user/service/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.psr.psr.user.dto.eidReq.BusinessListRes
import com.psr.psr.user.dto.request.*
import com.psr.psr.user.dto.response.EmailRes
import com.psr.psr.user.dto.response.MyPageInfoRes
import com.psr.psr.user.dto.response.PostNotiRes
import com.psr.psr.user.dto.response.ProfileRes
import com.psr.psr.user.entity.Category
import com.psr.psr.user.entity.Type
Expand Down Expand Up @@ -318,6 +319,14 @@ class UserService(
userRepository.findByEmailAndPhoneAndStatus(findIdPwReq.email!!, findIdPwReq.phone, ACTIVE_STATUS) ?: throw BaseException(NOT_FOUND_USER)
}

// 마이페이지 알림 수신 여부
@Transactional
fun postNotiStatus(user: User) : PostNotiRes{
user.notification = !user.notification
userRepository.save(user)
return PostNotiRes.toDto(user.notification)
}

// signature
private fun makeSignature(time: Long): String {
val message = StringBuilder()
Expand Down
Loading