-
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.
* Refactor | CAKK-41 | Param에 Builder 추 * Refactor | CAKK-41 | api 설계 수정 * Refactor | CAKK-41 | 케이크 샵 관련 기능 이관 * Refactor | CAKK-41 | kotlin 관련 설정 * Refactor | CAKK-41 | kotlin 관련 설정
- Loading branch information
Showing
16 changed files
with
272 additions
and
44 deletions.
There are no files selected for viewing
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
64 changes: 64 additions & 0 deletions
64
cakk-admin/src/main/kotlin/com/cakk/admin/controller/ShopController.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,64 @@ | ||
package com.cakk.admin.controller | ||
|
||
import com.cakk.admin.dto.request.* | ||
import com.cakk.admin.dto.response.CakeShopCreateResponse | ||
import com.cakk.admin.service.ShopService | ||
import com.cakk.common.response.ApiResponse | ||
import jakarta.validation.Valid | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
@RequestMapping("/shops") | ||
class ShopController( | ||
private val shopService: ShopService | ||
) { | ||
|
||
@PostMapping | ||
fun createByAdmin( | ||
@RequestBody @Valid request: CakeShopCreateByAdminRequest | ||
): ApiResponse<CakeShopCreateResponse> { | ||
val response = shopService.createCakeShopByCertification(request.toParam()) | ||
|
||
return ApiResponse.success(response) | ||
} | ||
|
||
@PutMapping("/{cakeShopId}") | ||
fun updateBasicInformation( | ||
@PathVariable cakeShopId: Long, | ||
@RequestBody @Valid request: CakeShopUpdateByAdminRequest | ||
): ApiResponse<Unit> { | ||
shopService.updateBasicInformation(request.toParam(cakeShopId)) | ||
|
||
return ApiResponse.success() | ||
} | ||
|
||
@PutMapping("/{cakeShopId}/links") | ||
fun updateLinks( | ||
@PathVariable cakeShopId: Long, | ||
@RequestBody request: @Valid LinkUpdateByAdminRequest | ||
): ApiResponse<Unit> { | ||
shopService.updateShopLinks(request.toParam(cakeShopId)) | ||
|
||
return ApiResponse.success() | ||
} | ||
|
||
@PutMapping("/{cakeShopId}/operation-days") | ||
fun updateOperationDays( | ||
@PathVariable cakeShopId: Long, | ||
@RequestBody @Valid request: ShopOperationUpdateByAdminRequest | ||
): ApiResponse<Unit> { | ||
shopService.updateShopOperationDays(request.toParam(cakeShopId)) | ||
|
||
return ApiResponse.success() | ||
} | ||
|
||
@PutMapping("/{cakeShopId}/address") | ||
fun updateAddress( | ||
@PathVariable cakeShopId: Long, | ||
@RequestBody @Valid request: AddressUpdateByAdminRequest | ||
): ApiResponse<Unit> { | ||
shopService.updateShopAddress(request.toParam(cakeShopId)) | ||
|
||
return ApiResponse.success() | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
cakk-admin/src/main/kotlin/com/cakk/admin/dto/request/AddressUpdateByAdminRequest.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,27 @@ | ||
package com.cakk.admin.dto.request | ||
|
||
import com.cakk.admin.mapper.supplyPointBy | ||
import com.cakk.domain.mysql.dto.param.shop.UpdateShopAddressParam | ||
import jakarta.validation.constraints.Max | ||
import jakarta.validation.constraints.Min | ||
import jakarta.validation.constraints.NotBlank | ||
import jakarta.validation.constraints.NotNull | ||
import jakarta.validation.constraints.Size | ||
|
||
data class AddressUpdateByAdminRequest( | ||
@field:NotBlank @field:Size(max = 50) | ||
val shopAddress: String?, | ||
@field:NotNull @field:Min(-90) @field:Max(90) | ||
val latitude: Double?, | ||
@field:NotNull @field:Min(-180) @field:Max(180) | ||
val longitude: Double? | ||
) { | ||
|
||
fun toParam(cakeShopId: Long): UpdateShopAddressParam { | ||
return UpdateShopAddressParam.builder() | ||
.cakeShopId(cakeShopId) | ||
.shopAddress(shopAddress) | ||
.location(supplyPointBy(latitude, longitude)) | ||
.build() | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
cakk-admin/src/main/kotlin/com/cakk/admin/dto/request/CakeShopUpdateByAdminRequest.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,27 @@ | ||
package com.cakk.admin.dto.request | ||
|
||
import com.cakk.domain.mysql.dto.param.shop.CakeShopUpdateParam | ||
import jakarta.validation.constraints.NotBlank | ||
import jakarta.validation.constraints.Size | ||
|
||
data class CakeShopUpdateByAdminRequest( | ||
@field:Size(max = 200) | ||
val thumbnailUrl: String?, | ||
@field:NotBlank @Size(max = 30) | ||
val shopName: String, | ||
@field:Size(max = 40) | ||
val shopBio: String?, | ||
@field:Size(max = 500) | ||
val shopDescription: String? | ||
) { | ||
|
||
fun toParam(cakeShopId: Long): CakeShopUpdateParam { | ||
return CakeShopUpdateParam.builder() | ||
.cakeShopId(cakeShopId) | ||
.thumbnailUrl(thumbnailUrl) | ||
.shopName(shopName) | ||
.shopBio(shopBio) | ||
.shopDescription(shopDescription) | ||
.build() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
cakk-admin/src/main/kotlin/com/cakk/admin/dto/request/LinkUpdateByAdminRequest.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,31 @@ | ||
package com.cakk.admin.dto.request | ||
|
||
import com.cakk.admin.mapper.supplyCakeShopLinkByInstagram | ||
import com.cakk.admin.mapper.supplyCakeShopLinkByKakao | ||
import com.cakk.admin.mapper.supplyCakeShopLinkByWeb | ||
import com.cakk.domain.mysql.dto.param.link.UpdateLinkParam | ||
import com.cakk.domain.mysql.entity.shop.CakeShopLink | ||
import jakarta.validation.constraints.Size | ||
|
||
data class LinkUpdateByAdminRequest( | ||
@field:Size(min = 1, max = 200) | ||
val instagram: String?, | ||
@field:Size(min = 1, max = 200) | ||
val kakao: String?, | ||
@field:Size(min = 1, max = 200) | ||
val web: String? | ||
) { | ||
|
||
fun toParam(cakeShopId: Long): UpdateLinkParam { | ||
val cakeShopLinks = mutableListOf<CakeShopLink>() | ||
|
||
instagram?.let { cakeShopLinks.add(supplyCakeShopLinkByInstagram(it)) } | ||
kakao?.let { cakeShopLinks.add(supplyCakeShopLinkByKakao(it)) } | ||
web?.let { cakeShopLinks.add(supplyCakeShopLinkByWeb(it)) } | ||
|
||
return UpdateLinkParam.builder() | ||
.cakeShopId(cakeShopId) | ||
.cakeShopLinks(cakeShopLinks) | ||
.build() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
cakk-admin/src/main/kotlin/com/cakk/admin/dto/request/ShopOperationUpdateByAdminRequest.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,19 @@ | ||
package com.cakk.admin.dto.request | ||
|
||
import com.cakk.admin.mapper.supplyCakeShopOperationListBy | ||
import com.cakk.domain.mysql.dto.param.operation.UpdateShopOperationParam | ||
import com.cakk.domain.mysql.dto.param.shop.ShopOperationParam | ||
import jakarta.validation.constraints.NotNull | ||
|
||
data class ShopOperationUpdateByAdminRequest( | ||
@field:NotNull | ||
val operationDays: List<ShopOperationParam> | ||
) { | ||
|
||
fun toParam(cakeShopId: Long): UpdateShopOperationParam { | ||
return UpdateShopOperationParam.builder() | ||
.cakeShopId(cakeShopId) | ||
.cakeShopOperations(supplyCakeShopOperationListBy(operationDays)) | ||
.build() | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
cakk-admin/src/main/kotlin/com/cakk/admin/mapper/ShopOperationMapper.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,18 @@ | ||
package com.cakk.admin.mapper | ||
|
||
import com.cakk.domain.mysql.dto.param.shop.ShopOperationParam | ||
import com.cakk.domain.mysql.entity.shop.CakeShopOperation | ||
|
||
fun supplyCakeShopOperationListBy(operationDays: List<ShopOperationParam>): List<CakeShopOperation> { | ||
return operationDays | ||
.map { supplyCakeShopOperationBy(it) } | ||
.toList() | ||
} | ||
|
||
fun supplyCakeShopOperationBy(param: ShopOperationParam): CakeShopOperation { | ||
return CakeShopOperation.builder() | ||
.operationDay(param.operationDay) | ||
.operationStartTime(param.operationStartTime) | ||
.operationEndTime(param.operationEndTime) | ||
.build() | ||
} |
17 changes: 0 additions & 17 deletions
17
cakk-admin/src/main/kotlin/com/cakk/admin/service/BusinessInformationService.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
57 changes: 57 additions & 0 deletions
57
cakk-admin/src/main/kotlin/com/cakk/admin/service/ShopService.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,57 @@ | ||
package com.cakk.admin.service | ||
|
||
import com.cakk.admin.dto.param.CakeShopCreateByAdminParam | ||
import com.cakk.admin.dto.response.CakeShopCreateResponse | ||
import com.cakk.admin.mapper.supplyCakeShopCreateResponseBy | ||
import com.cakk.domain.mysql.dto.param.link.UpdateLinkParam | ||
import com.cakk.domain.mysql.dto.param.operation.UpdateShopOperationParam | ||
import com.cakk.domain.mysql.dto.param.shop.CakeShopUpdateParam | ||
import com.cakk.domain.mysql.dto.param.shop.UpdateShopAddressParam | ||
import com.cakk.domain.mysql.entity.shop.CakeShop | ||
import com.cakk.domain.mysql.repository.reader.CakeShopReader | ||
import com.cakk.domain.mysql.repository.writer.CakeShopWriter | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
class ShopService( | ||
private val cakeShopReader: CakeShopReader, | ||
private val cakeShopWriter: CakeShopWriter | ||
) { | ||
|
||
@Transactional | ||
fun createCakeShopByCertification(dto: CakeShopCreateByAdminParam): CakeShopCreateResponse { | ||
val result: CakeShop = cakeShopWriter.createCakeShop( | ||
dto.cakeShop, | ||
dto.cakeShopOperations, | ||
dto.businessInformation, | ||
dto.cakeShopLinks | ||
) | ||
|
||
return supplyCakeShopCreateResponseBy(result) | ||
} | ||
|
||
@Transactional | ||
fun updateBasicInformation(dto: CakeShopUpdateParam) { | ||
val cakeShop = cakeShopReader.findById(dto.cakeShopId) | ||
cakeShop.updateBasicInformation(dto) | ||
} | ||
|
||
@Transactional | ||
fun updateShopLinks(param: UpdateLinkParam) { | ||
val cakeShop = cakeShopReader.findById(param.cakeShopId) | ||
cakeShop.updateShopLinks(param.cakeShopLinks) | ||
} | ||
|
||
@Transactional | ||
fun updateShopOperationDays(param: UpdateShopOperationParam) { | ||
val cakeShop = cakeShopReader.findById(param.cakeShopId) | ||
cakeShop.updateShopOperationDays(param.cakeShopOperations) | ||
} | ||
|
||
@Transactional | ||
fun updateShopAddress(param: UpdateShopAddressParam) { | ||
val cakeShop = cakeShopReader.findById(param.cakeShopId) | ||
cakeShop.updateShopAddress(param) | ||
} | ||
} |
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
Oops, something went wrong.