Skip to content

Commit

Permalink
Merge pull request #231 from twenty-three-23/feature/TT-286-modify-sc…
Browse files Browse the repository at this point in the history
…ript-id

TT-286 대본 수정 응답 구성 변경
  • Loading branch information
snacktime81 authored Jul 19, 2024
2 parents b78d61e + 680a28d commit 89148de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public static LocalTime transferSeoondToLocalTime(float time) {
int hour = second / 3600;
int minute = (second % 3600) / 60;
int secondSet = (second % 3600) % 60;

return LocalTime.of(hour, minute, secondSet);
int milliSecond = (int) ((time - second) * 1_000_000_000);
return LocalTime.of(hour, minute, secondSet, milliSecond);
}

public static LocalTime sumLocalTime(LocalTime time1, LocalTime time2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import com.twentythree.peech.script.dto.ModifiedParagraphDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.cglib.core.Local;

import java.time.LocalTime;
import java.util.List;

@Data
@AllArgsConstructor
public class ModifyScriptResponseDTO {
List<ModifiedParagraphDTO> script;
private Long scriptId;
private LocalTime totalTime;
private List<ModifiedParagraphDTO> script;
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public MinorScriptsResponseDTO getMinorScripts(Long themeId, Long majorVersion)
return new MinorScriptsResponseDTO(minorScripts);
}

@Transactional // Redis는 분산 락을 걸어야 하나?
@Transactional
public ModifyScriptResponseDTO modifyScriptService(List<ParagraphDTO> modifiedParagraphs, Long scriptId, Long userId) {

Map<ParagraphId, Map<SentenceId, RedisSentenceDTO>> redisSentences = new HashMap<>(); // Redis에서 문단 id별로 문장들을 저장하기 위한 map
Expand All @@ -166,7 +166,7 @@ public ModifyScriptResponseDTO modifyScriptService(List<ParagraphDTO> modifiedPa
log.info("redisSentences: {}", redisSentences);
List<ModifiedParagraphDTO> modifiedParagraphList = new ArrayList<>(); // ResponseDTO를 만들기 위함

// 이러면 paragraph domain을 만드는게 맞지 않을까요..
// TODO 이러면 paragraph domain을 만드는게 맞지 않을까요..
for (ParagraphDTO modifiedParagraph : modifiedParagraphs) {

List<SentenceDTO> modifiedSentenceList = new ArrayList<>(); // ResponseDTO를 만들기 위함
Expand Down Expand Up @@ -282,7 +282,14 @@ public ModifyScriptResponseDTO modifyScriptService(List<ParagraphDTO> modifiedPa
scriptRedisRepository.saveSentencesIdList("user"+userId, newSentenceIds);

}
return new ModifyScriptResponseDTO(modifiedParagraphList);

LocalTime totalTime = LocalTime.of(0, 0, 0, 0);

for (ModifiedParagraphDTO modifiedParagraph : modifiedParagraphList) {
totalTime = ScriptUtils.sumLocalTime(totalTime, modifiedParagraph.getTime());
}

return new ModifyScriptResponseDTO(scriptId, totalTime, modifiedParagraphList);
}

public ParagraphsResponseDTO getParagraphsByScriptId(Long scriptId) {
Expand Down

0 comments on commit 89148de

Please sign in to comment.