Skip to content

Commit

Permalink
Merge pull request #165 from PSR-Co/feat/#160-postNotiStatus
Browse files Browse the repository at this point in the history
[feat] 마이페이지 알림 수신 여부 API
  • Loading branch information
chaerlo127 authored Sep 6, 2023
2 parents eeff879 + ce9f017 commit e0e42f1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/kotlin/com/psr/psr/user/controller/UserController.kt
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

0 comments on commit e0e42f1

Please sign in to comment.