Skip to content

Commit

Permalink
๐Ÿ”€ :: ma-445 -> develop
Browse files Browse the repository at this point in the history
โ™ป๏ธ :: step ๋กœ์ง ์ˆ˜์ •
  • Loading branch information
HyunSu1768 authored Mar 8, 2024
2 parents 3ab62a8 + decab67 commit 9b8881a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class BusinessLogicException(
BusinessLogicException(ErrorCodePrefixSuffix.XXX_NOT_FOUND, DomainNames.PICKLE_COMMENT)
val PICKLE_REPLY_NOT_FOUND =
BusinessLogicException(ErrorCodePrefixSuffix.XXX_NOT_FOUND, DomainNames.PICKLE_REPLY)
val STEP_NOT_FOUND = BusinessLogicException(ErrorCodePrefixSuffix.XXX_NOT_FOUND, DomainNames.STEP)
val PURPOSE_NOT_FOUND = BusinessLogicException(ErrorCodePrefixSuffix.XXX_NOT_FOUND, DomainNames.PURPOSE)
val DAILY_NOT_FOUND = BusinessLogicException(ErrorCodePrefixSuffix.XXX_NOT_FOUND, DomainNames.PURPOSE)

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package com.info.maeumgagym.step.service

import com.info.common.UseCase
import com.info.maeumgagym.auth.port.out.ReadCurrentUserPort
import com.info.maeumgagym.common.exception.BusinessLogicException
import com.info.maeumgagym.step.model.Step
import com.info.maeumgagym.step.port.`in`.UpdateStepUseCase
import com.info.maeumgagym.step.port.out.ReadStepPort
import com.info.maeumgagym.step.port.out.SaveStepPort
import java.time.Duration
import java.time.LocalDateTime

@UseCase
internal class UpdateStepService(
Expand All @@ -15,8 +17,12 @@ internal class UpdateStepService(
) : UpdateStepUseCase {
override fun updateStep(numberOfSteps: Int) {
val user = readCurrentUserPort.readCurrentUser()
val step = readStepPort.readByUserOauthId(user.oauthId) ?: throw BusinessLogicException.STEP_NOT_FOUND
saveStepPort.save(Step(id = user.oauthId, numberOfSteps = numberOfSteps, ttl = secondsUntilTomorrow()))
}

saveStepPort.save(step.copy(numberOfSteps = numberOfSteps))
private fun secondsUntilTomorrow(): Long {
val now = LocalDateTime.now()
val tomorrowStart = now.toLocalDate().plusDays(1).atStartOfDay()
return Duration.between(now, tomorrowStart).toSeconds()
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.info.maeumgagym.controller.step

import com.info.common.WebAdapter
import com.info.maeumgagym.step.port.`in`.CreateStepUseCase
import com.info.maeumgagym.step.port.`in`.ReadTodayStepCountUseCase
import com.info.maeumgagym.step.port.`in`.UpdateStepUseCase
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
Expand All @@ -18,16 +16,10 @@ import org.springframework.web.bind.annotation.RequestParam
@WebAdapter
@RequestMapping("/step")
class StepController(
private val createStepUseCase: CreateStepUseCase,
private val updateStepUseCase: UpdateStepUseCase,
private val readTodayStepCountUseCase: ReadTodayStepCountUseCase
) {

@Operation(summary = "๊ฑธ์Œ ์ˆ˜ ์นด์šดํŠธ ์‹œ์ž‘ API")
@PostMapping
fun createStep() = createStepUseCase.createStep()

@Operation(summary = "๊ฑธ์Œ ์ˆ˜ ์นด์šดํŠธ ์ถ”๊ฐ€ API")
@Operation(summary = "๊ฑธ์Œ ์ˆ˜ ์นด์šดํŠธ ์—…๋ฐ์ดํŠธ API")
@PutMapping
fun updateStep(
@RequestParam(name = "number_of_steps")
Expand Down

0 comments on commit 9b8881a

Please sign in to comment.