Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Daybreak312 committed Jun 17, 2024
2 parents 8b7eb22 + 210077f commit 1b6f9c8
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import javax.persistence.Entity
@Entity(name = TableNames.POSE_TABLE)
class PoseJpaEntity(
needMachine: Boolean,
category: MutableSet<String>,
simpleName: String,
exactName: String,
thumbnail: String,
Expand All @@ -27,6 +28,11 @@ class PoseJpaEntity(
var needMachine: Boolean = needMachine // 기ꡬ μš΄λ™μΈμ§€ μ—¬λΆ€
protected set

@Convert(converter = StringAttributeConverter::class)
@Column(name = "category", updatable = true, nullable = false)
var category: MutableSet<String> = category
protected set

@Column(name = "simple_name", length = 30, updatable = true, nullable = false)
var simpleName: String = simpleName // κ°„λ‹¨ν•œ 이름
protected set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class PoseMapper {
fun toEntity(pose: Pose): PoseJpaEntity = pose.run {
PoseJpaEntity(
needMachine,
category,
simpleName,
exactName,
thumbnail,
Expand All @@ -26,6 +27,7 @@ class PoseMapper {
fun toDomain(poseJpaEntity: PoseJpaEntity): Pose = poseJpaEntity.run {
Pose(
needMachine,
category,
simpleName,
exactName,
thumbnail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ data class CreatePoseRequest(

val needMachine: Boolean,

val category: List<String>,

val simpleName: String,

val exactName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ data class PoseDetailResponse(

val needMachine: Boolean,

val category: MutableSet<String>,

val simpleName: String,

val exactName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.info.maeumgagym.core.pose.dto.response

data class PoseInfoResponse(
val id: Long,
val category: MutableSet<String>,
val needMachine: Boolean,
val name: String,
val simplePart: List<String>,
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/com/info/maeumgagym/core/pose/model/Pose.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ data class Pose(

val needMachine: Boolean,

val category: MutableSet<String>,

val simpleName: String,

val exactName: String,
Expand All @@ -31,6 +33,7 @@ data class Pose(
) {
fun toDetailResponse() = PoseDetailResponse(
needMachine = needMachine,
category = category,
simpleName = simpleName,
exactName = exactName,
thumbnail = thumbnail,
Expand All @@ -45,6 +48,7 @@ data class Pose(

fun toInfoResponse() = PoseInfoResponse(
id = id!!,
category = category,
needMachine = needMachine,
name = exactName,
simplePart = simplePart.toList(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.info.maeumgagym.core.pose.port.`in`

import com.info.maeumgagym.core.pose.dto.request.ReadAllPoseRequest
import com.info.maeumgagym.core.pose.dto.response.PoseListResponse
import java.time.LocalDateTime

interface ReadAllPoseUseCase {

fun readAll(req: ReadAllPoseRequest): PoseListResponse
fun readAll(lastUpdated: LocalDateTime?): PoseListResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal class CreatePoseService(
savePosePort.save(
Pose(
needMachine = needMachine,
category = category.toMutableSet(),
simpleName = simpleName,
exactName = exactName,
thumbnail = thumbnail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ package com.info.maeumgagym.core.pose.service

import com.info.maeumgagym.common.annotation.responsibility.ReadOnlyUseCase
import com.info.maeumgagym.common.exception.MaeumGaGymException
import com.info.maeumgagym.core.pose.dto.request.ReadAllPoseRequest
import com.info.maeumgagym.core.pose.dto.response.PoseListResponse
import com.info.maeumgagym.core.pose.port.`in`.ReadAllPoseUseCase
import com.info.maeumgagym.core.pose.port.out.ReadPosePort
import java.time.LocalDateTime

@ReadOnlyUseCase
internal class ReadAllPoseService(
private val readPosePort: ReadPosePort
) : ReadAllPoseUseCase {

override fun readAll(req: ReadAllPoseRequest): PoseListResponse {
if (!req.lastUpdated.isBefore(readPosePort.getLastModifiedAt())) {
override fun readAll(lastUpdated: LocalDateTime?): PoseListResponse {
// ν΄λΌμ΄μ–ΈνŠΈμ˜ μžμ„Έ 정보가 μ΅œμ‹ μΈμ§€λ₯Ό νŒλ‹¨ν•˜λŠ” 둜직
// ν΄λΌμ΄μ–ΈνŠΈμ˜ λ§ˆμ§€λ§‰ 쑰회 μ‹œμ μ΄ μ„œλ²„μ˜ λ§ˆμ§€λ§‰ λ³€κ²½ μ‹œμ λ³΄λ‹€ 이후인 경우 No Content λ°˜ν™˜
// => ν΄λΌμ΄μ–ΈνŠΈμ˜ 정보가 κ°€μž₯ μ΅œμ‹ μΈ 경우
// ν΄λΌμ΄μ–ΈνŠΈκ°€ ν•œ λ²ˆλ„ μ‘°νšŒν•œ 적 μ—†λŠ” 경우 정보 λ°˜ν™˜ (lastUpdated == null)
if (lastUpdated?.isAfter(readPosePort.getLastModifiedAt()) ?: false) {
throw MaeumGaGymException.NO_CONTENT
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ class ReadPosesRecommendationService(
// μ‚¬μš©μžμ—κ²Œ μΆ”μ²œν•  μžμ„Έ μΆ”μΆœ
readPosePort.readAllRandomLimit30().forEach {
// μžμ„Έμ˜ μ’…λ₯˜
val partName = it.simplePart.first()
// μžμ„Έμ˜ μ’…λ₯˜μ— ν•΄λ‹Ήν•˜λŠ” μžμ„Έλ“€μ˜ 리슀트
var poses = recommendationPoses[partName]
// λ§Œμ•½ μ΄λ²ˆμ— 처음으둜 μžμ„Έλ“€μ„ 담은 λ¦¬μŠ€νŠΈμ— μ ‘κ·Όν•œλ‹€λ©΄
if (poses == null) {
// μœ„ μ£Όμ„μ—μ„œ μ–ΈκΈ‰ν–ˆλ“―, μƒˆλ‘œμš΄ μžμ„Έ μ’…λ₯˜μ΄λ―€λ‘œ μ΄ˆκΈ°ν™” 진행
recommendationPoses[partName] = mutableListOf()
poses = recommendationPoses[partName]
it.category.forEach { partName ->
// μžμ„Έμ˜ μ’…λ₯˜μ— ν•΄λ‹Ήν•˜λŠ” μžμ„Έλ“€μ˜ 리슀트
var poses = recommendationPoses[partName]
// λ§Œμ•½ μ΄λ²ˆμ— 처음으둜 μžμ„Έλ“€μ„ 담은 λ¦¬μŠ€νŠΈμ— μ ‘κ·Όν•œλ‹€λ©΄
if (poses == null) {
// μœ„ μ£Όμ„μ—μ„œ μ–ΈκΈ‰ν–ˆλ“―, μƒˆλ‘œμš΄ μžμ„Έ μ’…λ₯˜μ΄λ―€λ‘œ μ΄ˆκΈ°ν™” 진행
recommendationPoses[partName] = mutableListOf()
poses = recommendationPoses[partName]
}
// μžμ„Έ λ¦¬μŠ€νŠΈμ— μΆ”κ°€
poses!!.add(it)
}
// μžμ„Έ λ¦¬μŠ€νŠΈμ— μΆ”κ°€
poses!!.add(it)
}

return PoseRecommendationListResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ data class UpdateUserInfoRequest(
val nickname: String,
val weight: Double,
val height: Double,
val genderModel: GenderModel
val gender: GenderModel
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class UpdateUserInfoService(
physicalInfoModel = PhysicalInfoModel(
weight = weight,
height = height,
genderModel = genderModel
genderModel = gender
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import com.info.maeumgagym.core.pose.port.`in`.*
import com.info.maeumgagym.core.user.model.Role
import com.info.maeumgagym.presentation.common.locationheader.LocationHeaderManager
import com.info.maeumgagym.presentation.controller.pose.dto.request.CreatePoseWebRequest
import com.info.maeumgagym.presentation.controller.pose.dto.request.ReadAllPoseWebRequest
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.format.annotation.DateTimeFormat
import org.springframework.http.HttpStatus
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*
import java.time.LocalDateTime
import javax.validation.Valid
import javax.validation.constraints.NotBlank
import javax.validation.constraints.Positive
Expand Down Expand Up @@ -52,10 +53,11 @@ private class PoseController(
@RequireAuthentication
@GetMapping("/all")
fun readAll(
@RequestBody
@Valid
readAllPoseWebRequest: ReadAllPoseWebRequest
): PoseListResponse = readAllPoseUseCase.readAll(readAllPoseWebRequest.toRequest())
@RequestParam(value = "last_updated")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
lastUpdated: LocalDateTime?
): PoseListResponse = readAllPoseUseCase.readAll(lastUpdated)

@Operation(summary = "μžμ„Έ id 쑰회 API")
@RequireAuthentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ data class CreatePoseWebRequest(
@field:NotNull(message = "null일 수 μ—†μŠ΅λ‹ˆλ‹€")
val needMachine: Boolean?,

@field:NotNull(message = "null일 수 μ—†μŠ΅λ‹ˆλ‹€")
val category: List<String>?,

@field:NotBlank(message = "null일 수 μ—†μŠ΅λ‹ˆλ‹€")
val simpleName: String?,

Expand Down Expand Up @@ -41,6 +44,7 @@ data class CreatePoseWebRequest(
) {
fun toRequest(): CreatePoseRequest = CreatePoseRequest(
needMachine = needMachine!!,
category = category!!,
simpleName = simpleName!!,
exactName = exactName!!,
thumbnail = thumbnail!!,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ data class UpdateUserInfoWebRequest(
@field:DecimalMax(value = "300.0", message = "μ‹ μž₯은 300.0 μ΄ν•˜μ—¬μ•Ό ν•©λ‹ˆλ‹€.")
val height: Double,

val genderModel: GenderModel
val gender: GenderModel
) {
fun toRequest(): UpdateUserInfoRequest =
UpdateUserInfoRequest(
nickname = nickname,
height = height,
weight = weight,
genderModel = genderModel
gender = gender
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ internal class MaeumgagymTokenValidatorImpl(
throw AuthenticationException.EXPIRED_TOKEN
}

if (currentRequestContext.getCurrentRequest().remoteAddr != maeumgagymToken.ip) {
throw AuthenticationException.WRONG_USER_TOKEN
}
// λ°œκΈ‰ λŒ€μƒκ³Ό μ‚¬μš©μžμ˜ IP μ£Όμ†Œλ₯Ό ν™•μΈν•˜λŠ” 둜직
// μ‚¬μš©μžμ˜ λ„€νŠΈμ›Œν¬ ν™˜κ²½μ— 따라 변동될 수 μžˆμœΌλ―€λ‘œ, ν•΄λ‹Ή 인증은 제거됨
// if (currentRequestContext.getCurrentRequest().remoteAddr != maeumgagymToken.ip) {
// throw AuthenticationException.WRONG_USER_TOKEN
// }
}

private fun getAccessTokenExpireAt(baseTime: LocalDateTime): LocalDateTime =
Expand Down

0 comments on commit 1b6f9c8

Please sign in to comment.