Skip to content

Commit

Permalink
Merge pull request #85 from MacroSoft-Team/feat/#83/allTimeFormat
Browse files Browse the repository at this point in the history
[FEAT] 모든 반환값에 시간 형식 UTC로 Z 붙힘
  • Loading branch information
dgh06175 authored Nov 26, 2024
2 parents d545eed + a59181a commit c01ad63
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.macrosoft.modakserver.domain.log.dto.LogResponse.ImageDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Set;

Expand All @@ -16,8 +18,11 @@ public record CampfireJoinInfo(
@Schema(description = "모닥불 이름", example = "매크로")
String campfireName,
@Schema(description = "모닥불 개설시간", example = "2024-11-06T02:21:05.43212")
LocalDateTime createdAt,
OffsetDateTime createdAt,
Set<String> membersNames) {
public static CampfireJoinInfo of(String campfireName, LocalDateTime createdAt, Set<String> membersNames) {
return new CampfireJoinInfo(campfireName, createdAt.atOffset(ZoneOffset.UTC), membersNames);
}
}

public record CampfireInfos(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class CampfireServiceImpl implements CampfireService {
private final LogRepository logRepository;
private final EmotionRepository emotionRepository;

private static boolean isLastMember(Campfire campfire) {
return campfire.getMemberCampfires().size() == 1;
}

@Override
@Transactional
public CampfirePin createCampfire(Member member, String campfireName) {
Expand Down Expand Up @@ -126,7 +130,7 @@ public ImageDTO getTodayImageDTO(Campfire campfire) {
@Override
public CampfireJoinInfo getCampfireJoin(int campfirePin) {
Campfire campfire = findCampfireByPin(campfirePin);
return new CampfireJoinInfo(
return CampfireJoinInfo.of(
campfire.getName(),
campfire.getCreatedAt(),
campfire.getMemberCampfires().stream()
Expand Down Expand Up @@ -184,7 +188,6 @@ private void validateMemberCampfireJoin(String campfireName, Campfire campfire,
}
}


private boolean isCampfireMemberFull(Campfire campfire) {
return campfire.getMemberCampfires().size() >= 6;
}
Expand Down Expand Up @@ -228,10 +231,6 @@ public CampfireResponse.CampfirePin leaveCampfire(Member member, int campfirePin
return new CampfirePin(campfirePin);
}

private static boolean isLastMember(Campfire campfire) {
return campfire.getMemberCampfires().size() == 1;
}

private CampfireResponse.CampfirePin deleteCampfire(Member member, int campfirePin) {
Member memberInDB = memberService.getMemberInDB(member);
Campfire campfire = findCampfireByPin(campfirePin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ public record LogOverview(
@Schema(description = "장작 아이디", example = "1")
Long logId,
@Schema(description = "장작 사건 시작 시간", example = "2024-11-06T01:41:01.83819")
LocalDateTime startAt,
OffsetDateTime startAt,
@Schema(description = "장작 주소", example = "포항시 남구")
String address,
@Schema(description = "장작 미리보기 사진들, 최대 8장")
List<String> imageNames
) {
public static LogOverview of(Long logId, LocalDateTime startAt, String address, List<String> imageNames) {
return new LogOverview(
logId,
startAt.atOffset(ZoneOffset.UTC),
address,
imageNames
);
}
}

public record LogDetails(
Expand Down Expand Up @@ -99,7 +107,7 @@ public record ImageDetail(
String imageName,
double latitude,
double longitude,
LocalDateTime takenAt,
OffsetDateTime takenAt,
String memberNickname,
Long logId,
List<ImageEmotionDTO> emotions) {
Expand All @@ -109,7 +117,7 @@ public static ImageDetail of(LogImage logImage) {
logImage.getName(),
logImage.getLatitude(),
logImage.getLongitude(),
logImage.getTakenAt(),
logImage.getTakenAt().atOffset(ZoneOffset.UTC),
logImage.getMember().getNickname(),
logImage.getLog().getId(),
logImage.getEmotions().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public LogResponse.LogOverviews getLogOverviews(Member member, int campfirePin,
.map(LogImage::getName)
.toList();

LogOverview overview = new LogOverview(
LogOverview overview = LogOverview.of(
log.getId(),
log.getStartAt(),
log.getLocation().getAddress(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
@JsonPropertyOrder({"timeStamp", "code", "message", "result"})
public class BaseResponse<T> {
private final LocalDateTime timeStamp = LocalDateTime.now();
private final OffsetDateTime timeStamp = LocalDateTime.now().atOffset(ZoneOffset.UTC);
private final String code;
private final String message;
private T result;
Expand Down

0 comments on commit c01ad63

Please sign in to comment.