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

Refactor | CAKK-103 | Entity 네이밍 변경 및 애그리거트 추상 클래스 구현 #230

Merged
merged 4 commits into from
Dec 11, 2024
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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ subprojects {
if (project.name == "cakk-admin" ||
project.name == "cakk-external" ||
project.name == "cakk-core" ||
project.name == "cakk-domain" ||
project.name == "cakk-common" ||
project.name == "cakk-api"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.cakk.admin.mapper.supplyCakeCreateParamBy
import com.cakk.admin.mapper.supplyCakeUpdateParamBy
import com.cakk.common.response.ApiResponse
import com.cakk.core.service.cake.CakeService
import com.cakk.infrastructure.persistence.entity.user.User
import com.cakk.infrastructure.persistence.entity.user.UserEntity

@RestController
@RequestMapping("/shops/{cakeShopId}/cakes")
Expand All @@ -23,7 +23,7 @@ class CakeController(
fun create(
@PathVariable cakeShopId: Long,
@RequestBody @Valid dto: CakeCreateByAdminRequest,
@AdminUser admin: com.cakk.infrastructure.persistence.entity.user.User
@AdminUser admin: UserEntity
): ApiResponse<Unit> {
val param = supplyCakeCreateParamBy(dto, admin, cakeShopId)
cakeService.createCake(param)
Expand All @@ -36,7 +36,7 @@ class CakeController(
@PathVariable cakeShopId: Long,
@PathVariable cakeId: Long,
@RequestBody @Valid dto: CakeUpdateByAdminRequest,
@AdminUser admin: com.cakk.infrastructure.persistence.entity.user.User
@AdminUser admin: UserEntity
): ApiResponse<Unit> {
val param = supplyCakeUpdateParamBy(dto, admin, cakeShopId)
cakeService.updateCake(param)
Expand All @@ -48,7 +48,7 @@ class CakeController(
fun delete(
@PathVariable cakeShopId: Long,
@PathVariable cakeId: Long,
@AdminUser admin: com.cakk.infrastructure.persistence.entity.user.User
@AdminUser admin: UserEntity
): ApiResponse<Unit> {
cakeService.deleteCake(admin, cakeId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.cakk.admin.mapper.*
import com.cakk.common.response.ApiResponse
import com.cakk.core.dto.response.shop.CakeShopCreateResponse
import com.cakk.core.service.shop.ShopService
import com.cakk.infrastructure.persistence.entity.user.User
import com.cakk.infrastructure.persistence.entity.user.UserEntity

@RestController
@RequestMapping("/shops")
Expand All @@ -32,7 +32,7 @@ class ShopController(
fun updateBasicInformation(
@PathVariable cakeShopId: Long,
@RequestBody @Valid request: CakeShopUpdateByAdminRequest,
@AdminUser admin: com.cakk.infrastructure.persistence.entity.user.User
@AdminUser admin: UserEntity
): ApiResponse<Unit> {
val param = supplyCakeShopUpdateParamBy(request, admin, cakeShopId)
shopService.updateBasicInformation(param)
Expand All @@ -44,7 +44,7 @@ class ShopController(
fun updateLinks(
@PathVariable cakeShopId: Long,
@RequestBody @Valid request: LinkUpdateByAdminRequest,
@AdminUser admin: com.cakk.infrastructure.persistence.entity.user.User
@AdminUser admin: UserEntity
): ApiResponse<Unit> {
val param = supplyUpdateLinkParamBy(request, admin, cakeShopId)
shopService.updateShopLinks(param)
Expand All @@ -56,7 +56,7 @@ class ShopController(
fun updateOperationDays(
@PathVariable cakeShopId: Long,
@RequestBody @Valid request: ShopOperationUpdateByAdminRequest,
@AdminUser admin: com.cakk.infrastructure.persistence.entity.user.User
@AdminUser admin: UserEntity
): ApiResponse<Unit> {
val param = supplyUpdateShopOperationParamBy(request, admin, cakeShopId)
shopService.updateShopOperationDays(param)
Expand All @@ -68,7 +68,7 @@ class ShopController(
fun updateAddress(
@PathVariable cakeShopId: Long,
@RequestBody @Valid request: AddressUpdateByAdminRequest,
@AdminUser admin: com.cakk.infrastructure.persistence.entity.user.User
@AdminUser admin: UserEntity
): ApiResponse<Unit> {
val param = supplyUpdateShopAddressParamBy(request, admin, cakeShopId)
shopService.updateShopAddress(param)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.cakk.admin.mapper

import com.cakk.common.enums.CakeDesignCategory
import com.cakk.infrastructure.persistence.entity.cake.CakeCategory
import com.cakk.infrastructure.persistence.entity.cake.CakeCategoryEntity

fun supplyCakeCategoryListBy(cakeDesignCategories: List<CakeDesignCategory>): List<com.cakk.infrastructure.persistence.entity.cake.CakeCategory> {
fun supplyCakeCategoryListBy(cakeDesignCategories: List<CakeDesignCategory>): List<CakeCategoryEntity> {
return cakeDesignCategories.map { supplyCakeCategoryBy(it) }.toList()
}

private fun supplyCakeCategoryBy(cakeDesignCategory: CakeDesignCategory?): com.cakk.infrastructure.persistence.entity.cake.CakeCategory {
return com.cakk.infrastructure.persistence.entity.cake.CakeCategory.builder()
private fun supplyCakeCategoryBy(cakeDesignCategory: CakeDesignCategory?): CakeCategoryEntity {
return CakeCategoryEntity.builder()
.cakeDesignCategory(cakeDesignCategory)
.build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import com.cakk.admin.dto.request.CakeUpdateByAdminRequest
import com.cakk.core.dto.param.cake.CakeCreateParam
import com.cakk.core.dto.param.cake.CakeUpdateParam
import com.cakk.core.mapper.supplyCakeBy
import com.cakk.infrastructure.persistence.entity.user.User
import com.cakk.infrastructure.persistence.entity.user.UserEntity

fun supplyCakeCreateParamBy(dto: CakeCreateByAdminRequest, user: com.cakk.infrastructure.persistence.entity.user.User, cakeShopId: Long): CakeCreateParam {
fun supplyCakeCreateParamBy(dto: CakeCreateByAdminRequest, userEntity: UserEntity, cakeShopId: Long): CakeCreateParam {
return CakeCreateParam(
cake = supplyCakeBy(dto.cakeImageUrl!!),
cakeCategories = supplyCakeCategoryListBy(dto.cakeDesignCategories!!),
tagNames = dto.tagNames!!,
owner = user,
owner = userEntity,
cakeShopId = cakeShopId
)
}

fun supplyCakeUpdateParamBy(dto: CakeUpdateByAdminRequest, owner: com.cakk.infrastructure.persistence.entity.user.User, cakeId: Long): CakeUpdateParam {
fun supplyCakeUpdateParamBy(dto: CakeUpdateByAdminRequest, owner: UserEntity, cakeId: Long): CakeUpdateParam {
return CakeUpdateParam(
owner = owner,
cakeId = cakeId,
Expand Down
16 changes: 8 additions & 8 deletions cakk-admin/src/main/kotlin/com/cakk/admin/mapper/LinkMapper.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
package com.cakk.admin.mapper

import com.cakk.common.enums.LinkKind
import com.cakk.infrastructure.persistence.entity.shop.CakeShop
import com.cakk.infrastructure.persistence.entity.shop.CakeShopLink
import com.cakk.infrastructure.persistence.entity.shop.CakeShopEntity
import com.cakk.infrastructure.persistence.entity.shop.CakeShopLinkEntity

fun supplyCakeShopLinkByWeb(web: String, cakeShop: com.cakk.infrastructure.persistence.entity.shop.CakeShop? = null): com.cakk.infrastructure.persistence.entity.shop.CakeShopLink {
return com.cakk.infrastructure.persistence.entity.shop.CakeShopLink.builder()
fun supplyCakeShopLinkByWeb(web: String, cakeShop: CakeShopEntity? = null): CakeShopLinkEntity {
return CakeShopLinkEntity.builder()
.linkKind(LinkKind.WEB)
.linkPath(web)
.cakeShop(cakeShop)
.build()
}

fun supplyCakeShopLinkByInstagram(instagram: String, cakeShop: com.cakk.infrastructure.persistence.entity.shop.CakeShop? = null): com.cakk.infrastructure.persistence.entity.shop.CakeShopLink {
return com.cakk.infrastructure.persistence.entity.shop.CakeShopLink.builder()
fun supplyCakeShopLinkByInstagram(instagram: String, cakeShop: CakeShopEntity? = null): CakeShopLinkEntity {
return CakeShopLinkEntity.builder()
.linkKind(LinkKind.INSTAGRAM)
.linkPath(instagram)
.cakeShop(cakeShop)
.build()
}

fun supplyCakeShopLinkByKakao(kakao: String, cakeShop: com.cakk.infrastructure.persistence.entity.shop.CakeShop? = null): com.cakk.infrastructure.persistence.entity.shop.CakeShopLink {
return com.cakk.infrastructure.persistence.entity.shop.CakeShopLink.builder()
fun supplyCakeShopLinkByKakao(kakao: String, cakeShop: CakeShopEntity? = null): CakeShopLinkEntity {
return CakeShopLinkEntity.builder()
.linkKind(LinkKind.KAKAOTALK)
.linkPath(kakao)
.cakeShop(cakeShop)
Expand Down
26 changes: 11 additions & 15 deletions cakk-admin/src/main/kotlin/com/cakk/admin/mapper/ShopMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ import com.cakk.admin.dto.request.*
import com.cakk.core.dto.param.shop.CreateShopParam
import com.cakk.core.dto.param.shop.PromotionParam
import com.cakk.core.mapper.supplyPointBy
import com.cakk.infrastructure.persistence.param.link.UpdateLinkParam
import com.cakk.infrastructure.persistence.param.operation.UpdateShopOperationParam
import com.cakk.infrastructure.persistence.param.shop.CakeShopUpdateParam
import com.cakk.infrastructure.persistence.param.shop.UpdateShopAddressParam
import com.cakk.infrastructure.persistence.entity.shop.CakeShopLink
import com.cakk.infrastructure.persistence.entity.user.User
import com.cakk.infrastructure.persistence.entity.shop.CakeShopLinkEntity
import com.cakk.infrastructure.persistence.entity.user.UserEntity

fun supplyCreateShopParamBy(request: CakeShopCreateByAdminRequest): CreateShopParam {
return CreateShopParam(
Expand All @@ -29,11 +25,11 @@ fun supplyCreateShopParamBy(request: CakeShopCreateByAdminRequest): CreateShopPa

fun supplyCakeShopUpdateParamBy(
request: CakeShopUpdateByAdminRequest,
user: com.cakk.infrastructure.persistence.entity.user.User,
userEntity: UserEntity,
cakeShopId: Long
): com.cakk.infrastructure.persistence.param.shop.CakeShopUpdateParam {
return com.cakk.infrastructure.persistence.param.shop.CakeShopUpdateParam.builder()
.user(user)
.user(userEntity)
.cakeShopId(cakeShopId)
.thumbnailUrl(request.thumbnailUrl)
.shopName(request.shopName)
Expand All @@ -44,37 +40,37 @@ fun supplyCakeShopUpdateParamBy(

fun supplyUpdateLinkParamBy(
dto: LinkUpdateByAdminRequest,
user: com.cakk.infrastructure.persistence.entity.user.User,
userEntity: UserEntity,
cakeShopId: Long
): com.cakk.infrastructure.persistence.param.link.UpdateLinkParam {
val cakeShopLinks: MutableList<com.cakk.infrastructure.persistence.entity.shop.CakeShopLink> = ArrayList()
val cakeShopLinks: MutableList<CakeShopLinkEntity> = ArrayList()

dto.instagram?.let { cakeShopLinks.add(supplyCakeShopLinkByInstagram(dto.instagram)) }
dto.kakao?.let { cakeShopLinks.add(supplyCakeShopLinkByKakao(dto.kakao)) }
dto.web?.let { cakeShopLinks.add(supplyCakeShopLinkByWeb(dto.web)) }

return com.cakk.infrastructure.persistence.param.link.UpdateLinkParam(user, cakeShopId, cakeShopLinks)
return com.cakk.infrastructure.persistence.param.link.UpdateLinkParam(userEntity, cakeShopId, cakeShopLinks)
}

fun supplyUpdateShopOperationParamBy(
request: ShopOperationUpdateByAdminRequest,
user: com.cakk.infrastructure.persistence.entity.user.User,
userEntity: UserEntity,
cakeShopId: Long
): com.cakk.infrastructure.persistence.param.operation.UpdateShopOperationParam {
val cakeShopOperations = supplyCakeShopOperationListBy(request.operationDays!!)

return com.cakk.infrastructure.persistence.param.operation.UpdateShopOperationParam(cakeShopOperations, user, cakeShopId)
return com.cakk.infrastructure.persistence.param.operation.UpdateShopOperationParam(cakeShopOperations, userEntity, cakeShopId)
}

fun supplyUpdateShopAddressParamBy(
dto: AddressUpdateByAdminRequest,
user: com.cakk.infrastructure.persistence.entity.user.User,
userEntity: UserEntity,
cakeShopId: Long
): com.cakk.infrastructure.persistence.param.shop.UpdateShopAddressParam {
return com.cakk.infrastructure.persistence.param.shop.UpdateShopAddressParam(
dto.shopAddress!!,
supplyPointBy(dto.latitude!!, dto.longitude!!),
user,
userEntity,
cakeShopId
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.cakk.admin.mapper

import com.cakk.infrastructure.persistence.param.shop.ShopOperationParam
import com.cakk.infrastructure.persistence.entity.shop.CakeShopOperation
import com.cakk.infrastructure.persistence.entity.shop.CakeShopOperationEntity

fun supplyCakeShopOperationListBy(operationDays: List<com.cakk.infrastructure.persistence.param.shop.ShopOperationParam>): List<com.cakk.infrastructure.persistence.entity.shop.CakeShopOperation> {
fun supplyCakeShopOperationListBy(operationDays: List<com.cakk.infrastructure.persistence.param.shop.ShopOperationParam>): List<CakeShopOperationEntity> {
return operationDays
.map { supplyCakeShopOperationBy(it) }
.toList()
}

fun supplyCakeShopOperationBy(param: com.cakk.infrastructure.persistence.param.shop.ShopOperationParam): com.cakk.infrastructure.persistence.entity.shop.CakeShopOperation {
return com.cakk.infrastructure.persistence.entity.shop.CakeShopOperation.builder()
fun supplyCakeShopOperationBy(param: com.cakk.infrastructure.persistence.param.shop.ShopOperationParam): CakeShopOperationEntity {
return CakeShopOperationEntity.builder()
.operationDay(param.operationDay)
.operationStartTime(param.operationStartTime)
.operationEndTime(param.operationEndTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import org.springframework.web.method.support.ModelAndViewContainer
import com.cakk.admin.annotation.AdminUser
import com.cakk.admin.vo.OAuthUserDetails

import com.cakk.infrastructure.persistence.entity.user.User
import com.cakk.infrastructure.persistence.entity.user.UserEntity

class AdminUserResolver : HandlerMethodArgumentResolver {
override fun supportsParameter(parameter: MethodParameter): Boolean {
return parameter.hasParameterAnnotation(AdminUser::class.java)
&& com.cakk.infrastructure.persistence.entity.user.User::class.java.isAssignableFrom(parameter.parameterType)
&& UserEntity::class.java.isAssignableFrom(parameter.parameterType)
}

override fun resolveArgument(
Expand Down
16 changes: 8 additions & 8 deletions cakk-admin/src/main/kotlin/com/cakk/admin/vo/OAuthUserDetails.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ import org.springframework.security.oauth2.core.oidc.OidcUserInfo
import org.springframework.security.oauth2.core.oidc.user.OidcUser
import org.springframework.security.oauth2.core.user.OAuth2User

import com.cakk.infrastructure.persistence.entity.user.User
import com.cakk.infrastructure.persistence.entity.user.UserEntity

class OAuthUserDetails(
private val user: com.cakk.infrastructure.persistence.entity.user.User,
private val attribute: Map<String, Any>
private val userEntity: UserEntity,
private val attribute: Map<String, Any>
) : UserDetails, OidcUser, OAuth2User {

constructor(user: com.cakk.infrastructure.persistence.entity.user.User) : this(user, mapOf<String, Any>("id" to user.id))
constructor(userEntity: UserEntity) : this(userEntity, mapOf<String, Any>("id" to userEntity.id))

fun getUser(): com.cakk.infrastructure.persistence.entity.user.User = user
fun getUser(): UserEntity = userEntity

override fun getName(): String {
return user.id.toString()
return userEntity.id.toString()
}

override fun getAttributes(): Map<String, Any> {
return attribute
}

override fun getAuthorities(): Collection<GrantedAuthority> {
return listOf(SimpleGrantedAuthority(user.role.securityRole))
return listOf(SimpleGrantedAuthority(userEntity.role.securityRole))
}

override fun getPassword(): String {
return "password"
}

override fun getUsername(): String {
return user.id.toString()
return userEntity.id.toString()
}

override fun isAccountNonExpired(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.cakk.core.service.cake.CakeService
import com.cakk.core.service.like.HeartService
import com.cakk.common.response.ApiResponse
import com.cakk.core.dto.response.cake.CakeImageWithShopInfoListResponse
import com.cakk.infrastructure.persistence.entity.user.User
import com.cakk.infrastructure.persistence.entity.user.UserEntity

@RestController
@RequestMapping("/cakes")
Expand Down Expand Up @@ -71,54 +71,54 @@ class CakeController(

@PostMapping("/{cakeShopId}")
fun create(
@SignInUser user: com.cakk.infrastructure.persistence.entity.user.User,
@SignInUser userEntity: UserEntity,
@PathVariable cakeShopId: Long,
@RequestBody @Valid request: CakeCreateRequest
): ApiResponse<Unit> {
val param = supplyCakeCreateParamBy(request, user, cakeShopId)
val param = supplyCakeCreateParamBy(request, userEntity, cakeShopId)
cakeService.createCake(param)

return ApiResponse.success()
}

@GetMapping("/{cakeId}/heart")
fun isHeart(
@SignInUser user: com.cakk.infrastructure.persistence.entity.user.User,
@SignInUser userEntity: UserEntity,
@PathVariable cakeId: Long
): ApiResponse<HeartResponse> {
val response = heartService.isHeartCake(user, cakeId)
val response = heartService.isHeartCake(userEntity, cakeId)

return ApiResponse.success(response)
}

@PutMapping("/{cakeId}/heart")
fun heart(
@SignInUser user: com.cakk.infrastructure.persistence.entity.user.User,
@SignInUser userEntity: UserEntity,
@PathVariable cakeId: Long
): ApiResponse<Unit> {
heartService.heartCake(user, cakeId)
heartService.heartCake(userEntity, cakeId)

return ApiResponse.success()
}

@PutMapping("/{cakeId}")
fun update(
@SignInUser user: com.cakk.infrastructure.persistence.entity.user.User,
@SignInUser userEntity: UserEntity,
@PathVariable cakeId: Long,
@RequestBody request: @Valid CakeUpdateRequest
): ApiResponse<Unit> {
val param = supplyCakeUpdateParamBy(request, user, cakeId)
val param = supplyCakeUpdateParamBy(request, userEntity, cakeId)
cakeService.updateCake(param)

return ApiResponse.success()
}

@DeleteMapping("/{cakeId}")
fun delete(
@SignInUser user: com.cakk.infrastructure.persistence.entity.user.User,
@SignInUser userEntity: UserEntity,
@PathVariable cakeId: Long
): ApiResponse<Unit> {
cakeService.deleteCake(user, cakeId)
cakeService.deleteCake(userEntity, cakeId)

return ApiResponse.success()
}
Expand Down
Loading
Loading