Skip to content

Commit

Permalink
imp: resource에 return type 명시
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Sep 16, 2024
1 parent 544c9ef commit 2bcf859
Show file tree
Hide file tree
Showing 19 changed files with 231 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ package com.hero.alignlab.domain.auth.resource

import com.hero.alignlab.common.extension.wrapCreated
import com.hero.alignlab.common.extension.wrapOk
import com.hero.alignlab.common.model.Response
import com.hero.alignlab.domain.auth.application.AuthFacade
import com.hero.alignlab.domain.auth.model.AuthUser
import com.hero.alignlab.domain.auth.model.DevAuthUser
import com.hero.alignlab.domain.auth.model.request.SignInRequest
import com.hero.alignlab.domain.auth.model.request.SignUpRequest
import com.hero.alignlab.domain.auth.model.response.SignInResponse
import com.hero.alignlab.domain.auth.model.response.SignUpResponse
import com.hero.alignlab.domain.user.model.response.UserInfoResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*

@Tag(name = "Auth 인증 및 인가 관리")
Expand All @@ -24,19 +29,25 @@ class AuthResource(
suspend fun signUp(
dev: DevAuthUser,
@RequestBody request: SignUpRequest,
) = authFacade.signUp(request).wrapCreated()
): ResponseEntity<Response<SignUpResponse>> {
return authFacade.signUp(request).wrapCreated()
}

/** 일반 로그인 */
@Operation(summary = "로그인")
@PostMapping("/api/v1/auth/sign-in")
suspend fun signUp(
dev: DevAuthUser,
@RequestBody request: SignInRequest,
) = authFacade.signIn(request).wrapOk()
): ResponseEntity<Response<SignInResponse>> {
return authFacade.signIn(request).wrapOk()
}

@Operation(summary = "토큰 기반으로 유저 정보를 조회")
@GetMapping("/api/v1/auth/me")
suspend fun getUserInfo(
user: AuthUser
) = authFacade.getUserInfo(user).wrapOk()
): ResponseEntity<Response<UserInfoResponse>> {
return authFacade.getUserInfo(user).wrapOk()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ package com.hero.alignlab.domain.auth.resource
import com.hero.alignlab.common.extension.wrapCreated
import com.hero.alignlab.common.extension.wrapOk
import com.hero.alignlab.common.extension.wrapVoid
import com.hero.alignlab.common.model.Response
import com.hero.alignlab.domain.auth.application.OAuthFacade
import com.hero.alignlab.domain.auth.model.OAuthProvider
import com.hero.alignlab.domain.auth.model.request.OAuthSignInRequest
import com.hero.alignlab.domain.auth.model.request.OAuthSignUpRequest
import com.hero.alignlab.domain.auth.model.response.OAuthCheckSignUpResponse
import com.hero.alignlab.domain.auth.model.response.OAuthSignInResponse
import com.hero.alignlab.domain.auth.model.response.OAuthSignUpResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*

/**
Expand All @@ -26,31 +31,39 @@ class OAuthResource(
suspend fun checkSignUp(
@PathVariable provider: OAuthProvider,
@RequestParam accessToken: String,
) = oAuthFacade.checkSignUp(provider, accessToken).wrapOk()
): ResponseEntity<Response<OAuthCheckSignUpResponse>> {
return oAuthFacade.checkSignUp(provider, accessToken).wrapOk()
}

@Operation(summary = "로그인")
@PostMapping("/api/v1/oauth/{provider}/sign-in")
suspend fun signIn(
@PathVariable provider: OAuthProvider,
@RequestBody request: OAuthSignInRequest,
) = oAuthFacade.signIn(provider, request).wrapOk()
): ResponseEntity<Response<OAuthSignInResponse?>> {
return oAuthFacade.signIn(provider, request).wrapOk()
}

@Operation(summary = "회원가입")
@PostMapping("/api/v1/oauth/{provider}/sign-up")
suspend fun signUp(
@PathVariable provider: OAuthProvider,
@RequestBody request: OAuthSignUpRequest,
) = oAuthFacade.signUp(provider, request).wrapCreated()
): ResponseEntity<Response<OAuthSignUpResponse>> {
return oAuthFacade.signUp(provider, request).wrapCreated()
}

@Operation(summary = "탈퇴하기")
@DeleteMapping("/api/v1/oauth/{provider}/withdraw")
suspend fun withdraw(
@PathVariable provider: OAuthProvider,
@RequestParam accessToken: String,
@RequestParam oauthId: String,
) = oAuthFacade.withdraw(
provider = provider,
accessToken = accessToken,
oauthId = oauthId
).wrapVoid()
): ResponseEntity<Unit> {
return oAuthFacade.withdraw(
provider = provider,
accessToken = accessToken,
oauthId = oauthId
).wrapVoid()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ class DevDiscordWebhookResource(
suspend fun sendMessage(
dev: DevAuthUser,
@RequestParam message: String,
) = discordWebhookClient.sendMessage(SendMessageRequest(message))
) {
discordWebhookClient.sendMessage(SendMessageRequest(message))
}

@Operation(summary = "discord webhook daily noti")
@PostMapping("/api/dev/v1/discord-webhooks/daily-noti")
suspend fun sendDailyNoti(
dev: DevAuthUser,
@RequestParam fromDateTime: LocalDateTime,
@RequestParam toDateTime: LocalDateTime,
) = statisticsJob.sendHeroStatistics(
title = "극락통계 테스트",
fromDate = fromDateTime,
toDate = toDateTime
)
) {
statisticsJob.sendHeroStatistics(
title = "극락통계 테스트",
fromDate = fromDateTime,
toDate = toDateTime
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.hero.alignlab.config.swagger.SwaggerTag.DEV_TAG
import com.hero.alignlab.domain.auth.model.DevAuthUser
import com.hero.alignlab.domain.dev.model.request.DevGroupJoinRequest
import com.hero.alignlab.domain.group.application.GroupFacade
import com.hero.alignlab.domain.group.model.response.JoinGroupResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
Expand All @@ -21,9 +22,11 @@ class DevGroupResource(
dev: DevAuthUser,
@PathVariable groupId: Long,
@RequestBody request: DevGroupJoinRequest,
) = groupFacade.joinGroup(
groupId = groupId,
uid = request.uid,
joinCode = request.joinCode
)
): JoinGroupResponse {
return groupFacade.joinGroup(
groupId = groupId,
uid = request.uid,
joinCode = request.joinCode
)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.hero.alignlab.domain.dev.resource

import com.hero.alignlab.client.kakao.model.response.GenerateKakaoOAuthTokenResponse
import com.hero.alignlab.client.kakao.model.response.KakaoOAuthUserInfoResponse
import com.hero.alignlab.common.extension.wrapOk
import com.hero.alignlab.common.model.Response
import com.hero.alignlab.config.swagger.SwaggerTag.DEV_TAG
import com.hero.alignlab.domain.auth.model.OAuthProvider
import com.hero.alignlab.domain.dev.application.DevOAuthService
import com.hero.alignlab.domain.dev.model.response.DevOAuthCodeResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*

@Tag(name = DEV_TAG)
Expand All @@ -19,30 +24,38 @@ class DevOAuthResource(
@GetMapping("/api/dev/v1/oauth/{provider}/authorize")
suspend fun getDevOAuthAuthorizeCode(
@PathVariable provider: OAuthProvider,
) = devOAuthService.getOAuthAuthorizeCode(provider).wrapOk()
): ResponseEntity<Response<DevOAuthCodeResponse>> {
return devOAuthService.getOAuthAuthorizeCode(provider).wrapOk()
}

@Operation(summary = "[DEV] OAuth Token Generate")
@GetMapping("/api/dev/v1/oauth/{provider}/token")
suspend fun redirectedDevOAuthAuthorizeCode(
@PathVariable provider: OAuthProvider,
@RequestParam code: String,
) = devOAuthService.resolveOAuth(provider, code).wrapOk()
): ResponseEntity<Response<GenerateKakaoOAuthTokenResponse>> {
return devOAuthService.resolveOAuth(provider, code).wrapOk()
}

@Operation(summary = "[DEV] 사용자 정보 조회")
@GetMapping("/api/dev/v1/oauth/user")
suspend fun getOAuthUserInfos(
@RequestParam accessToken: String
) = devOAuthService.getUserInfo(accessToken).wrapOk()
): ResponseEntity<Response<KakaoOAuthUserInfoResponse>> {
return devOAuthService.getUserInfo(accessToken).wrapOk()
}

@Operation(summary = "[DEV] 회원 탈퇴")
@GetMapping("/api/dev/v1/oauth/{provider}/withdraw")
suspend fun withdraw(
@PathVariable provider: OAuthProvider,
@RequestParam accessToken: String,
@RequestParam oauthId: String,
) = devOAuthService.withdraw(
provider = provider,
accessToken = accessToken,
oauthId = oauthId
).wrapOk()
): ResponseEntity<Response<Boolean>> {
return devOAuthService.withdraw(
provider = provider,
accessToken = accessToken,
oauthId = oauthId
).wrapOk()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.hero.alignlab.domain.dev.model.request.DevPoseSnapshotRequest
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import java.time.LocalDate

Expand All @@ -24,18 +25,24 @@ class DevPoseResource(
suspend fun createPoseSnapshots(
dev: DevAuthUser,
@RequestBody request: DevPoseSnapshotRequest,
) = devPoseService.create(request).wrapVoid()
): ResponseEntity<Unit> {
return devPoseService.create(request).wrapVoid()
}

@Operation(summary = "[DEV] 포즈 데이터 삭제")
@DeleteMapping("/api/dev/v1/pose-snapshots/{id}")
suspend fun deletePoseSnapshots(
dev: DevAuthUser,
) = devPoseService.deleteAllPoseData()
) {
devPoseService.deleteAllPoseData()
}

@Operation(summary = "[DEV] 포즈 데이터 통계 처리")
@PostMapping("/api/dev/v1/pose-counts")
suspend fun updatePoseCounts(
dev: DevAuthUser,
@RequestParam targetDate: LocalDate
) = poseCountUpdateJob.run(targetDate)
) {
poseCountUpdateJob.run(targetDate)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.hero.alignlab.domain.dev.resource
import com.hero.alignlab.config.swagger.SwaggerTag.DEV_TAG
import com.hero.alignlab.domain.auth.model.DevAuthUser
import com.hero.alignlab.domain.user.application.UserInfoService
import com.hero.alignlab.domain.user.model.response.UserInfoResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
Expand All @@ -22,5 +23,7 @@ class DevUserInfoResource(
suspend fun getUserInfo(
dev: DevAuthUser,
@PathVariable id: Long,
) = userInfoService.getUserInfo(id)
): UserInfoResponse {
return userInfoService.getUserInfo(id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ class DevWebsocketResource(
@PostMapping("/api/dev/v1/websocket/connection-closed")
suspend fun closedConnection(
dev: DevAuthUser,
) = devWebsocketService.forceCloseAllWebSocketSessions()
) {
devWebsocketService.forceCloseAllWebSocketSessions()
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.hero.alignlab.domain.discussion.resource

import com.hero.alignlab.common.extension.wrapCreated
import com.hero.alignlab.common.model.Response
import com.hero.alignlab.domain.auth.model.AuthUser
import com.hero.alignlab.domain.discussion.application.DiscussionService
import com.hero.alignlab.domain.discussion.model.request.DiscussionRequest
import com.hero.alignlab.domain.discussion.model.response.DiscussionResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -23,5 +26,7 @@ class DiscussionResource(
suspend fun create(
user: AuthUser,
@RequestBody request: DiscussionRequest,
) = discussionService.create(user, request).wrapCreated()
): ResponseEntity<Response<DiscussionResponse>> {
return discussionService.create(user, request).wrapCreated()
}
}
Loading

0 comments on commit 2bcf859

Please sign in to comment.