-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 회원 이메일 필드 추가 * feat: 회원 프로필 조회 API 추가 * feat: 회원 프로필 수정 API 추가 * feat: 회원 프로필에 관심, 리뷰 작성 수 포함 하여 응답하도록 수정 * test: API 테스트 추가
- Loading branch information
1 parent
601a9d1
commit 46948d3
Showing
29 changed files
with
429 additions
and
13 deletions.
There are no files selected for viewing
Submodule server-profile-submodule
updated
from 3d2f82 to eb24cd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,11 @@ import com.celuveat.restaurant.adapter.out.persistence.entity.RestaurantImageJpa | |
import com.celuveat.restaurant.adapter.out.persistence.entity.RestaurantImageJpaRepository | ||
import com.celuveat.restaurant.adapter.out.persistence.entity.RestaurantJpaEntity | ||
import com.celuveat.restaurant.adapter.out.persistence.entity.RestaurantJpaRepository | ||
import java.time.LocalDate | ||
import org.springframework.boot.context.event.ApplicationReadyEvent | ||
import org.springframework.context.annotation.Profile | ||
import org.springframework.context.event.EventListener | ||
import org.springframework.stereotype.Component | ||
import java.time.LocalDate | ||
|
||
@Suppress("ktlint:standard:max-line-length") | ||
@Component | ||
|
@@ -61,6 +61,7 @@ class DummyEntityInitializer( | |
val member = MemberJpaEntity( | ||
nickname = "celuveat", | ||
profileImageUrl = "https://www.celuveat.com/images-data/jpeg/celuveat-logo.png", | ||
email = "[email protected]", | ||
socialId = "1234567890", | ||
serverType = SocialLoginType.KAKAO, | ||
) | ||
|
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/com/celuveat/member/adapter/in/rest/MemberApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.celuveat.member.adapter.`in`.rest | ||
|
||
import com.celuveat.auth.adapter.`in`.rest.Auth | ||
import com.celuveat.auth.adapter.`in`.rest.AuthContext | ||
import com.celuveat.member.adapter.`in`.rest.request.UpdateProfileRequest | ||
import com.celuveat.member.adapter.`in`.rest.response.MemberProfileResponse | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PatchMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
|
||
@Tag(name = "회원 API") | ||
interface MemberApi { | ||
|
||
@Operation(summary = "회원 정보 조회") | ||
@SecurityRequirement(name = "JWT") | ||
@GetMapping("/profile") | ||
fun readMember(@Auth auth: AuthContext): MemberProfileResponse | ||
|
||
@Operation(summary = "회원 정보 조회") | ||
@SecurityRequirement(name = "JWT") | ||
@PatchMapping("/profile") | ||
fun updateMember( | ||
@Auth auth: AuthContext, | ||
@RequestBody request: UpdateProfileRequest, | ||
) | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/com/celuveat/member/adapter/in/rest/MemberController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.celuveat.member.adapter.`in`.rest | ||
|
||
import com.celuveat.auth.adapter.`in`.rest.Auth | ||
import com.celuveat.auth.adapter.`in`.rest.AuthContext | ||
import com.celuveat.member.adapter.`in`.rest.request.UpdateProfileRequest | ||
import com.celuveat.member.adapter.`in`.rest.response.MemberProfileResponse | ||
import com.celuveat.member.application.port.`in`.ReadMemberUseCase | ||
import com.celuveat.member.application.port.`in`.UpdateProfileUseCase | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PatchMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
|
||
@RequestMapping("/members") | ||
@RestController | ||
class MemberController( | ||
private val readMemberUseCase: ReadMemberUseCase, | ||
private val updateProfileUseCase: UpdateProfileUseCase, | ||
) : MemberApi { | ||
|
||
@GetMapping("/profile") | ||
override fun readMember(@Auth auth: AuthContext): MemberProfileResponse { | ||
val memberId = auth.memberId() | ||
val result = readMemberUseCase.readMember(memberId) | ||
return MemberProfileResponse.from(result) | ||
} | ||
|
||
@PatchMapping("/profile") | ||
override fun updateMember( | ||
@Auth auth: AuthContext, | ||
@RequestBody request: UpdateProfileRequest, | ||
) { | ||
val memberId = auth.memberId() | ||
val command = request.toCommand(memberId) | ||
updateProfileUseCase.updateProfile(command) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/com/celuveat/member/adapter/in/rest/request/UpdateProfileRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.celuveat.member.adapter.`in`.rest.request | ||
|
||
import com.celuveat.member.application.port.`in`.command.UpdateProfileCommand | ||
|
||
data class UpdateProfileRequest( | ||
val nickname: String, | ||
val profileImageUrl: String, | ||
) { | ||
fun toCommand(memberId: Long): UpdateProfileCommand { | ||
return UpdateProfileCommand( | ||
memberId = memberId, | ||
nickname = nickname, | ||
profileImageUrl = profileImageUrl, | ||
) | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/com/celuveat/member/adapter/in/rest/response/MemberProfileResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.celuveat.member.adapter.`in`.rest.response | ||
|
||
import com.celuveat.member.application.port.`in`.result.MemberProfileResult | ||
import com.celuveat.member.domain.SocialLoginType | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class MemberProfileResponse( | ||
@Schema( | ||
description = "회원 ID", | ||
example = "1", | ||
) | ||
val id: Long = 0, | ||
@Schema( | ||
description = "닉네임", | ||
example = "닉네임", | ||
) | ||
val nickname: String, | ||
@Schema( | ||
description = "프로필 이미지 URL", | ||
example = "https://example.com/profile.jpg", | ||
) | ||
val profileImageUrl: String?, | ||
@Schema( | ||
description = "이메일", | ||
example = "[email protected]" | ||
) | ||
val email: String, | ||
@Schema( | ||
description = "소셜 로그인 타입", | ||
example = "KAKAO", | ||
) | ||
val serverType: SocialLoginType, | ||
@Schema( | ||
description = "소셜 ID", | ||
example = "123", | ||
) | ||
val socialId: String, | ||
@Schema( | ||
description = "관심 등록 수", | ||
example = "1", | ||
) | ||
val interestedCount: Int, | ||
@Schema( | ||
description = "리뷰 수", | ||
example = "1", | ||
) | ||
val reviewCount: Int, | ||
) { | ||
companion object { | ||
fun from(result: MemberProfileResult): MemberProfileResponse { | ||
return MemberProfileResponse( | ||
id = result.id, | ||
nickname = result.nickname, | ||
profileImageUrl = result.profileImageUrl, | ||
email = result.email, | ||
serverType = result.serverType, | ||
socialId = result.socialId, | ||
interestedCount = result.interestedCount, | ||
reviewCount = result.reviewCount, | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/com/celuveat/member/application/MemberQueryService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.celuveat.member.application | ||
|
||
import com.celuveat.celeb.application.port.out.ReadInterestedCelebritiesPort | ||
import com.celuveat.member.application.port.`in`.ReadMemberUseCase | ||
import com.celuveat.member.application.port.`in`.result.MemberProfileResult | ||
import com.celuveat.member.application.port.out.ReadMemberPort | ||
import com.celuveat.restaurant.application.port.out.ReadInterestedRestaurantPort | ||
import com.celuveat.review.application.port.out.ReadReviewPort | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class MemberQueryService( | ||
private val readMemberPort: ReadMemberPort, | ||
private val readInterestedRestaurantPort: ReadInterestedRestaurantPort, | ||
private val readInterestedCelebritiesPort: ReadInterestedCelebritiesPort, | ||
private val readReviewPort: ReadReviewPort, | ||
) : ReadMemberUseCase { | ||
override fun readMember(memberId: Long): MemberProfileResult { | ||
val member = readMemberPort.readById(memberId) | ||
val interestedRestaurantCount = readInterestedRestaurantPort.countByMemberId(memberId) | ||
val interestedCelebrityCount = readInterestedCelebritiesPort.countByMemberId(memberId) | ||
val reviewCount = readReviewPort.countByWriterId(memberId) | ||
return MemberProfileResult.of( | ||
member = member, | ||
interestedCount = interestedRestaurantCount + interestedCelebrityCount, | ||
reviewCount = reviewCount, | ||
) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/com/celuveat/member/application/MemberService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.celuveat.member.application | ||
|
||
import com.celuveat.member.application.port.`in`.UpdateProfileUseCase | ||
import com.celuveat.member.application.port.`in`.command.UpdateProfileCommand | ||
import com.celuveat.member.application.port.out.ReadMemberPort | ||
import com.celuveat.member.application.port.out.SaveMemberPort | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class MemberService( | ||
private val readMemberPort: ReadMemberPort, | ||
private val saveMemberPort: SaveMemberPort, | ||
) : UpdateProfileUseCase { | ||
override fun updateProfile(command: UpdateProfileCommand) { | ||
val member = readMemberPort.readById(command.memberId) | ||
member.updateProfile( | ||
nickname = command.nickname, | ||
profileImageUrl = command.profileImageUrl, | ||
) | ||
saveMemberPort.save(member) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/celuveat/member/application/port/in/ReadMemberUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.celuveat.member.application.port.`in` | ||
|
||
import com.celuveat.member.application.port.`in`.result.MemberProfileResult | ||
|
||
interface ReadMemberUseCase { | ||
fun readMember(memberId: Long): MemberProfileResult | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/celuveat/member/application/port/in/UpdateProfileUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.celuveat.member.application.port.`in` | ||
|
||
import com.celuveat.member.application.port.`in`.command.UpdateProfileCommand | ||
|
||
interface UpdateProfileUseCase { | ||
fun updateProfile(command: UpdateProfileCommand) | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/celuveat/member/application/port/in/command/UpdateProfileCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.celuveat.member.application.port.`in`.command | ||
|
||
data class UpdateProfileCommand( | ||
val memberId: Long, | ||
val nickname: String, | ||
val profileImageUrl: String, | ||
) |
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/com/celuveat/member/application/port/in/result/MemberProfileResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.celuveat.member.application.port.`in`.result | ||
|
||
import com.celuveat.member.domain.Member | ||
import com.celuveat.member.domain.SocialLoginType | ||
|
||
data class MemberProfileResult( | ||
val id: Long = 0, | ||
val nickname: String, | ||
val profileImageUrl: String?, | ||
val email: String, | ||
val serverType: SocialLoginType, | ||
val socialId: String, | ||
val interestedCount: Int, | ||
val reviewCount: Int, | ||
) { | ||
companion object { | ||
fun of( | ||
member: Member, | ||
interestedCount: Int, | ||
reviewCount: Int, | ||
): MemberProfileResult { | ||
return MemberProfileResult( | ||
id = member.id, | ||
nickname = member.nickname, | ||
profileImageUrl = member.profileImageUrl, | ||
email = member.email, | ||
serverType = member.socialIdentifier.serverType, | ||
socialId = member.socialIdentifier.socialId, | ||
interestedCount = interestedCount, | ||
reviewCount = reviewCount, | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.