Skip to content

Commit

Permalink
Merge pull request #217 from twenty-three-23/feature/TT-271
Browse files Browse the repository at this point in the history
TT-271
  • Loading branch information
snacktime81 authored Jul 17, 2024
2 parents da6e160 + 3faf5ba commit 08b7329
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.twentythree.peech.auth.dto.LoginUserId;
import com.twentythree.peech.auth.dto.UserIdDTO;
import com.twentythree.peech.usagetime.dto.response.CheckRemainingTimeResponseDTO;
import com.twentythree.peech.usagetime.dto.response.MaxAudioTimeResponseDTO;
import com.twentythree.peech.usagetime.dto.response.TextAndSecondTimeResponseDTO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -15,6 +16,7 @@ public interface SwaggerUsageTimeController {
@GetMapping("api/v1/usage-time")
TextAndSecondTimeResponseDTO getUsageTime(@LoginUserId UserIdDTO userId);

TextAndSecondTimeResponseDTO getMaxAudioTime();
@GetMapping("api/v1/max-audio-time")
MaxAudioTimeResponseDTO getMaxAudioTime();

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.twentythree.peech.auth.dto.UserIdDTO;
import com.twentythree.peech.usagetime.dto.response.CheckRemainingTimeResponseDTO;
import com.twentythree.peech.usagetime.dto.response.MaxAudioTimeResponseDTO;
import com.twentythree.peech.usagetime.dto.response.TextAndSecondTimeResponseDTO;
import com.twentythree.peech.usagetime.service.UsageTimeService;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -29,7 +30,7 @@ public TextAndSecondTimeResponseDTO getUsageTime(UserIdDTO userId) {

@Override
@GetMapping("api/v1/max-audio-time")
public TextAndSecondTimeResponseDTO getMaxAudioTime() {
public MaxAudioTimeResponseDTO getMaxAudioTime() {
return usageTimeService.getMaxAudioTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.Setter;

@Getter @Setter @AllArgsConstructor
public class RemainingTimeDTO {
public class TextAndSecondDTO {

private String text;
private Long second;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.twentythree.peech.usagetime.dto.response;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.twentythree.peech.usagetime.dto.TextAndSecondDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

@Getter @Setter @AllArgsConstructor
public class MaxAudioTimeResponseDTO {

private TextAndSecondDTO maxAudioTime;
}

Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.twentythree.peech.usagetime.dto.response;

import com.twentythree.peech.usagetime.dto.RemainingTimeDTO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.twentythree.peech.usagetime.dto.TextAndSecondDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

@Getter @Setter @AllArgsConstructor
public class TextAndSecondTimeResponseDTO {
private RemainingTimeDTO remainingTime;

private TextAndSecondDTO remainingTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import com.twentythree.peech.common.utils.ScriptUtils;
import com.twentythree.peech.usagetime.constant.ConstantValue;
import com.twentythree.peech.usagetime.domain.UsageTimeEntity;
import com.twentythree.peech.usagetime.dto.RemainingTimeDTO;
import com.twentythree.peech.usagetime.dto.TextAndSecondDTO;
import com.twentythree.peech.usagetime.dto.response.CheckRemainingTimeResponseDTO;
import com.twentythree.peech.usagetime.dto.response.MaxAudioTimeResponseDTO;
import com.twentythree.peech.usagetime.dto.response.TextAndSecondTimeResponseDTO;
import com.twentythree.peech.usagetime.repository.UsageTimeRepository;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -92,7 +93,7 @@ public TextAndSecondTimeResponseDTO getUsageTime(Long userId) {

remainingTimeToText = remainingTimeToText.trim();

return new TextAndSecondTimeResponseDTO(new RemainingTimeDTO(remainingTimeToText, remainingTimeToSecond));
return new TextAndSecondTimeResponseDTO(new TextAndSecondDTO(remainingTimeToText, remainingTimeToSecond));
}

public CheckRemainingTimeResponseDTO checkRemainingTime(Long userId, Long audioTime) {
Expand All @@ -102,7 +103,7 @@ public CheckRemainingTimeResponseDTO checkRemainingTime(Long userId, Long audioT
return (remainingTime >= audioTime) ? new CheckRemainingTimeResponseDTO("성공") : new CheckRemainingTimeResponseDTO("사용 시간이 부족합니다.");
}

public TextAndSecondTimeResponseDTO getMaxAudioTime() {
public MaxAudioTimeResponseDTO getMaxAudioTime() {
Long maxAudioTimeToSecond = ConstantValue.MAX_AUDIO_TIME;
LocalTime maxAudioTimeToLocalTime = ScriptUtils.transferSeoondToLocalTime(maxAudioTimeToSecond);

Expand All @@ -124,6 +125,6 @@ public TextAndSecondTimeResponseDTO getMaxAudioTime() {

maxAudioTimeToText = maxAudioTimeToText.trim();

return new TextAndSecondTimeResponseDTO(new RemainingTimeDTO(maxAudioTimeToText, maxAudioTimeToSecond));
return new MaxAudioTimeResponseDTO(new TextAndSecondDTO(maxAudioTimeToText, maxAudioTimeToSecond));
}
}

0 comments on commit 08b7329

Please sign in to comment.