Skip to content

Commit

Permalink
Merge pull request #62 from Route-Box/feature/#61
Browse files Browse the repository at this point in the history
feat: #61 내루트 조회, 인사이트 조회 mock-up API
  • Loading branch information
suyeoniii authored Aug 22, 2024
2 parents a97576b + 80f2a71 commit 2925bc8
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions routebox.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="SonarLintModuleSettings">
<option name="uniqueId" value="3131378d-7bea-4eac-baef-5d9a4d371788" />
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import com.routebox.routebox.controller.route.dto.CreateRouteRequest
import com.routebox.routebox.controller.route.dto.CreateRouteResponse
import com.routebox.routebox.controller.route.dto.DeleteRouteActivityResponse
import com.routebox.routebox.controller.route.dto.DeleteRouteResponse
import com.routebox.routebox.controller.route.dto.GetMyRouteInsightResponse
import com.routebox.routebox.controller.route.dto.GetMyRouteResponse
import com.routebox.routebox.controller.route.dto.RouteSimpleResponse
import com.routebox.routebox.controller.route.dto.UpdateRouteActivityRequest
import com.routebox.routebox.controller.route.dto.UpdateRouteActivityResponse
import com.routebox.routebox.controller.route.dto.UpdateRoutePublicRequest
Expand All @@ -33,6 +36,7 @@ import org.springframework.http.MediaType
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PatchMapping
import org.springframework.web.bind.annotation.PathVariable
Expand All @@ -41,6 +45,7 @@ import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import kotlin.random.Random

@Tag(name = "내루트 관련 API")
@RestController
Expand Down Expand Up @@ -170,7 +175,83 @@ class RouteCommandController(
@PathVariable routeId: Long,
@RequestBody @Valid request: UpdateRoutePublicRequest,
): UpdateRoutePublicResponse {
val routeResponse = updateRoutePublicUseCase(request.toCommand(userId = userPrincipal.userId, routeId = routeId))
val routeResponse =
updateRoutePublicUseCase(request.toCommand(userId = userPrincipal.userId, routeId = routeId))
return UpdateRoutePublicResponse.from(routeResponse)
}

@Operation(
summary = "내루트 목록 조회 (더미데이터)",
security = [SecurityRequirement(name = "access-token")],
)
@GetMapping("/v1/routes/my")
fun getMyRouteList(
@AuthenticationPrincipal userPrincipal: UserPrincipal,
): GetMyRouteResponse {
// TODO: 구현
val routeResponses = listOf(
RouteSimpleResponse(
routeId = 1,
routeName = "루트1",
routeDescription = "루트1 설명",
routeImageUrl = "https://routebox-resources.s3.ap-northeast-2.amazonaws.com/image/1.jpg",
isPublic = true,
createdAt = "2024-08-01T00:00:00",
purchaseCount = 15,
commentCount = 30,
),
RouteSimpleResponse(
routeId = 2,
routeName = "루트2",
routeDescription = "루트2 설명",
routeImageUrl = "https://routebox-resources.s3.ap-northeast-2.amazonaws.com/image/1.jpg",
isPublic = true,
createdAt = "2024-08-02T00:00:00",
purchaseCount = 1,
commentCount = 2,
),
RouteSimpleResponse(
routeId = 3,
routeName = null,
routeDescription = null,
routeImageUrl = null,
isPublic = false,
createdAt = "2024-08-01T00:00:00",
purchaseCount = 0,
commentCount = 0,
),
)
return GetMyRouteResponse.from(routeResponses)
}

@Operation(
summary = "인사이트 조회 (더미데이터)",
security = [SecurityRequirement(name = "access-token")],
)
@GetMapping("/v1/routes/insight")
fun getMyRouteInsight(
@AuthenticationPrincipal userPrincipal: UserPrincipal,
): GetMyRouteInsightResponse {
// TODO: 구현
val routeCount = Random.nextInt(0, 21)
val purchaseCount = Random.nextInt(0, 101)
val commentCount = Random.nextInt(0, 101)

return GetMyRouteInsightResponse(routeCount, purchaseCount, commentCount)
}

/*
@Operation(
summary = "기록 진행중인 루트 존재여부 조회",
description = "기록 진행중인 루트가 존재하는 경우 routeId: Int 반환, 없는 경우 routeId : null 반환",
security = [SecurityRequirement(name = "access-token")],
)
@GetMapping("/v1/routes/progress")
fun checkProgressRoute(
@AuthenticationPrincipal userPrincipal: UserPrincipal,
): CheckProgressRouteResponse {
// TODO: 구현
val routeId = if (Random.nextBoolean()) Random.nextLong(1, 100) else null
return CheckProgressRouteResponse(routeId)
}*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.routebox.routebox.controller.route.dto

import io.swagger.v3.oas.annotations.media.Schema

data class CheckProgressRouteResponse(
@Schema(description = "루트 ID, 기록중인 루트가 있는 경우 id 반환. 없는 경우 null 반환")
val routeId: Long?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.routebox.routebox.controller.route.dto

import io.swagger.v3.oas.annotations.media.Schema

data class GetMyRouteInsightResponse(
@Schema(description = "내 루트 수")
val routeCount: Int,
@Schema(description = "내가 작성한 루트의 총 구매 수")
val purchaseCount: Int,
@Schema(description = "내가 작성한 루트의 총 댓글 수")
val commentCount: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.routebox.routebox.controller.route.dto

import io.swagger.v3.oas.annotations.media.Schema

data class GetMyRouteResponse(
@Schema(description = "내루트 목록")
val result: List<RouteSimpleResponse>,
) {
companion object {
fun from(
result: List<RouteSimpleResponse>,
): GetMyRouteResponse {
return GetMyRouteResponse(
result = result,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.routebox.routebox.controller.route.dto

import io.swagger.v3.oas.annotations.media.Schema

data class RouteSimpleResponse(
@Schema(description = "루트 ID")
val routeId: Long,
@Schema(description = "루트 이름")
val routeName: String?,
@Schema(description = "루트 설명")
val routeDescription: String?,
@Schema(description = "루트 대표 이미지")
val routeImageUrl: String?,
@Schema(description = "루트 공개 여부")
val isPublic: Boolean,
@Schema(description = "구매 수")
val purchaseCount: Int,
@Schema(description = "댓글 수")
val commentCount: Int,
@Schema(description = "루트 생성일", example = "2021-08-01T00:00:00")
val createdAt: String,
)

0 comments on commit 2925bc8

Please sign in to comment.