Skip to content

Commit 08a11a9

Browse files
authored
Merge: LocalDateTime으로 변환 (#165)
Refactor: LocalDateTime으로 변환
2 parents 2eb50c6 + e2d1849 commit 08a11a9

File tree

11 files changed

+55
-52
lines changed

11 files changed

+55
-52
lines changed
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
package io.ejangs.docsa.domain.doc.dto.graph;
22

33
import java.time.LocalDateTime;
4-
import java.time.OffsetDateTime;
5-
import java.time.ZoneOffset;
64

7-
public record GraphBranchDto(Long id, String name, OffsetDateTime createdAt, Long fromCommitId,
5+
public record GraphBranchDto(Long id, String name, LocalDateTime createdAt, Long fromCommitId,
86
Long rootCommitId, Long leafCommitId, Long saveId
97

108
) {
9+
1110
public GraphBranchDto(Long id, String name, LocalDateTime createdAt, Long fromCommitId,
1211
Long rootCommitId, Long leafCommitId, Long saveId) {
13-
this(id, name, createdAt.atOffset(ZoneOffset.ofHours(9)), fromCommitId, rootCommitId,
14-
leafCommitId, saveId);
15-
12+
this.id = id;
13+
this.name = name;
14+
this.createdAt = createdAt.plusHours(9L);
15+
this.fromCommitId = fromCommitId;
16+
this.rootCommitId = rootCommitId;
17+
this.leafCommitId = leafCommitId;
18+
this.saveId = saveId;
1619
}
1720

1821
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package io.ejangs.docsa.domain.doc.dto.graph;
22

33
import java.time.LocalDateTime;
4-
import java.time.OffsetDateTime;
5-
import java.time.ZoneOffset;
64

75
public record GraphCommitDto(Long id, Long branchId, String title, String description,
8-
OffsetDateTime createdAt) {
9-
public GraphCommitDto(Long id, Long branchId, String title, String description,
10-
LocalDateTime createdAt
6+
LocalDateTime createdAt) {
117

12-
) {
13-
this(id, branchId, title, description, createdAt.atOffset(ZoneOffset.ofHours(9)));
8+
public GraphCommitDto(Long id, Long branchId, String title, String description,
9+
LocalDateTime createdAt) {
10+
this.id = id;
11+
this.branchId = branchId;
12+
this.title = title;
13+
this.description = description;
14+
this.createdAt = createdAt.plusHours(9L);
1415
}
15-
1616
}

src/main/java/io/ejangs/docsa/domain/doc/dto/response/DocListResponse.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33
import io.ejangs.docsa.domain.doc.dto.RecentActivityDto;
44
import java.time.LocalDateTime;
5-
import java.time.OffsetDateTime;
6-
import java.time.ZoneOffset;
75

86
public record DocListResponse(
97
Long id,
108
String title,
11-
OffsetDateTime createdAt,
12-
OffsetDateTime updatedAt,
9+
LocalDateTime createdAt,
10+
LocalDateTime updatedAt,
1311
String preview,
1412
RecentActivityDto recent
1513
) {
1614

1715
public DocListResponse(Long id, String title, LocalDateTime createdAt,
1816
LocalDateTime updatedAt, String preview, RecentActivityDto recent) {
19-
this(id, title, createdAt.atOffset(ZoneOffset.ofHours(9)),
20-
updatedAt.atOffset(ZoneOffset.ofHours(9)), preview, recent);
17+
this.id = id;
18+
this.title = title;
19+
this.createdAt = createdAt.plusHours(9L);
20+
this.updatedAt = updatedAt.plusHours(9L);
21+
this.preview = preview;
22+
this.recent = recent;
2123
}
2224
}

src/main/java/io/ejangs/docsa/domain/doc/dto/response/DocListSimpleResponse.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
import io.ejangs.docsa.domain.doc.dto.RecentActivityDto;
44
import java.time.LocalDateTime;
5-
import java.time.OffsetDateTime;
6-
import java.time.ZoneOffset;
75

86
public record DocListSimpleResponse(
97
Long id,
108
String title,
11-
OffsetDateTime createdAt,
12-
OffsetDateTime updatedAt,
9+
LocalDateTime createdAt,
10+
LocalDateTime updatedAt,
1311
RecentActivityDto recent
1412
) {
1513

1614
public DocListSimpleResponse(Long id, String title, LocalDateTime createdAt,
1715
LocalDateTime updatedAt, RecentActivityDto recent) {
18-
this(id, title, createdAt.atOffset(ZoneOffset.ofHours(9)),
19-
updatedAt.atOffset(ZoneOffset.ofHours(9)), recent);
16+
this.id = id;
17+
this.title = title;
18+
this.createdAt = createdAt.plusHours(9L);
19+
this.updatedAt = updatedAt.plusHours(9L);
20+
this.recent = recent;
2021
}
2122
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package io.ejangs.docsa.domain.doc.dto.response;
22

33
import java.time.LocalDateTime;
4-
import java.time.OffsetDateTime;
5-
import java.time.ZoneOffset;
64

75
public record DocTitleUpdateResponse(
86
Long id,
97
String title,
10-
OffsetDateTime updatedAt
8+
LocalDateTime updatedAt
119
) {
1210

1311
public DocTitleUpdateResponse(
1412
Long id,
1513
String title,
1614
LocalDateTime updatedAt
1715
) {
18-
this(id, title, updatedAt.atOffset(ZoneOffset.ofHours(9)));
16+
this.id = id;
17+
this.title = title;
18+
this.updatedAt = updatedAt.plusHours(9L);
1919
}
2020
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package io.ejangs.docsa.domain.save.dto.response;
22

3-
import java.time.OffsetDateTime;
3+
import java.time.LocalDateTime;
44
import java.util.List;
55
import java.util.Map;
66

7-
public record SaveGetResponse(OffsetDateTime updatedAt, List<Map<String, Object>> content) {
7+
public record SaveGetResponse(LocalDateTime updatedAt, List<Map<String, Object>> content) {
88

9+
public SaveGetResponse(LocalDateTime updatedAt, List<Map<String, Object>> content) {
10+
this.updatedAt = updatedAt.plusHours(9L);
11+
this.content = content;
12+
}
913
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.ejangs.docsa.domain.save.dto.response;
22

3-
import java.time.OffsetDateTime;
3+
import java.time.LocalDateTime;
44

5-
public record SaveUpdateResponse(OffsetDateTime updatedAt) {
5+
public record SaveUpdateResponse(LocalDateTime updatedAt) {
66

7+
public SaveUpdateResponse(LocalDateTime updatedAt) {
8+
this.updatedAt = updatedAt.plusHours(9L);
9+
}
710
}

src/main/java/io/ejangs/docsa/domain/save/util/SaveMapper.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@
33
import io.ejangs.docsa.domain.save.dto.response.SaveGetResponse;
44
import io.ejangs.docsa.domain.save.dto.response.SaveUpdateResponse;
55
import java.time.LocalDateTime;
6-
import java.time.OffsetDateTime;
7-
import java.time.ZoneOffset;
86
import java.util.List;
97
import java.util.Map;
108

119
public class SaveMapper {
1210

1311
public static SaveUpdateResponse toSaveUpdateResponse(LocalDateTime localDateTime) {
14-
return new SaveUpdateResponse(toOffsetDateTime(localDateTime));
12+
return new SaveUpdateResponse(localDateTime);
1513
}
1614

1715
public static SaveGetResponse toSaveGetResponse(LocalDateTime localDateTime,
1816
List<Map<String, Object>> content) {
19-
return new SaveGetResponse(toOffsetDateTime(localDateTime), content);
20-
}
21-
22-
private static OffsetDateTime toOffsetDateTime(LocalDateTime localDateTime) {
23-
return localDateTime.atOffset(ZoneOffset.ofHours(9));
17+
return new SaveGetResponse(localDateTime, content);
2418
}
2519
}

src/test/java/io/ejangs/docsa/domain/doc/unit/DocServiceUnitTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import io.ejangs.docsa.global.exception.CustomException;
3030
import java.time.LocalDateTime;
3131
import java.util.Comparator;
32-
import java.time.OffsetDateTime;
3332
import java.util.List;
3433
import java.util.Optional;
3534
import org.junit.jupiter.api.DisplayName;
@@ -231,7 +230,7 @@ void getGraph_shouldReturnGraphResponse_whenDocExists() {
231230
.thenReturn(Optional.of(new DocTitleOnlyResponse("Test Document")));
232231

233232
// Mock Branch, Commit, Edge 리스트
234-
OffsetDateTime now = OffsetDateTime.now();
233+
LocalDateTime now = LocalDateTime.now();
235234
List<GraphBranchDto> branches = List.of(
236235
new GraphBranchDto(1L, "main", now, null, null, null, null)
237236
);

src/test/java/io/ejangs/docsa/domain/save/api/SaveControllerTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package io.ejangs.docsa.domain.save.api;
22

33
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
4-
import static org.mockito.Mockito.mock;
54
import static org.mockito.Mockito.when;
65
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
76
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
87
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
9-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
108
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
119
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
1210

@@ -17,7 +15,7 @@
1715
import io.ejangs.docsa.domain.save.dto.response.SaveGetResponse;
1816
import io.ejangs.docsa.domain.save.dto.response.SaveUpdateResponse;
1917
import io.ejangs.docsa.global.security.WithCustomMockUser;
20-
import java.time.OffsetDateTime;
18+
import java.time.LocalDateTime;
2119
import java.util.List;
2220
import java.util.Map;
2321
import org.junit.jupiter.api.BeforeEach;
@@ -68,7 +66,7 @@ void updateSave_success() throws Exception {
6866
Long saveId = 1L;
6967

7068
when(saveService.updateSave(dto, request)).thenReturn(new SaveUpdateResponse(
71-
OffsetDateTime.now()));
69+
LocalDateTime.now()));
7270

7371
mockMvc.perform(
7472
put("/api/document/{documentId}/save/{saveId}", documentId, saveId)
@@ -104,7 +102,7 @@ void getSave_success() throws Exception {
104102
Long saveId = 1L;
105103

106104
when(saveService.getSave(dto)).thenReturn(new SaveGetResponse(
107-
OffsetDateTime.now(), data));
105+
LocalDateTime.now(), data));
108106

109107
mockMvc.perform(
110108
get("/api/document/{documentId}/save/{saveId}", documentId, saveId))

0 commit comments

Comments
 (0)