-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from f-lab-edu/feature/3
코드정리
- Loading branch information
Showing
12 changed files
with
81 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/study/bookcafe/common/LocalDateTimeAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.study.bookcafe.common; | ||
|
||
import com.google.gson.*; | ||
|
||
import java.lang.reflect.Type; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class LocalDateTimeAdapter implements JsonDeserializer<LocalDateTime>, JsonSerializer<LocalDateTime> { | ||
private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE; | ||
|
||
@Override | ||
public JsonElement serialize(LocalDateTime date, Type typeOfSrc, JsonSerializationContext context) { | ||
return new JsonPrimitive(date.format(formatter)); // "yyyy-MM-dd" 형식으로 직렬화 | ||
} | ||
|
||
@Override | ||
public LocalDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||
return LocalDateTime.parse(json.getAsString(), formatter); // JSON 문자열을 LocalDate로 역직렬화 | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
src/main/java/com/study/bookcafe/dao/GeneralMemberRepository.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../study/bookcafe/dao/BorrowRepository.java → ...bookcafe/repository/BorrowRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.study.bookcafe.dao; | ||
package com.study.bookcafe.repository; | ||
|
||
import com.study.bookcafe.domain.Borrow; | ||
|
||
|
32 changes: 32 additions & 0 deletions
32
src/main/java/com/study/bookcafe/repository/GeneralMemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.study.bookcafe.repository; | ||
|
||
import com.study.bookcafe.domain.Level; | ||
import com.study.bookcafe.domain.Member; | ||
import com.study.bookcafe.entity.MemberEntity; | ||
import com.study.bookcafe.mapper.MemberMapper; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Repository | ||
public class GeneralMemberRepository implements MemberRepository { | ||
|
||
private final MemberMapper memberMapper; | ||
|
||
public GeneralMemberRepository(MemberMapper memberMapper) { | ||
this.memberMapper = memberMapper; | ||
} | ||
|
||
Map<Long, MemberEntity> members = new HashMap<>(){{ | ||
put(1L, MemberEntity.builder().id(1L).name("슈카").level(Level.BASIC).borrowCount(0).build()); | ||
put(2L, MemberEntity.builder().id(2L).name("머스크").level(Level.WORM).borrowCount(3).build()); | ||
put(3L, MemberEntity.builder().id(3L).name("트럼프").level(Level.LIBRARIAN).borrowCount(5).build()); | ||
}}; | ||
|
||
@Override | ||
public Member findById(long memberId) { | ||
MemberEntity memberEntity = members.get(memberId); | ||
return memberMapper.toMember(memberEntity); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../study/bookcafe/dao/MemberRepository.java → ...bookcafe/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.study.bookcafe.dao; | ||
package com.study.bookcafe.repository; | ||
|
||
import com.study.bookcafe.domain.Member; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...dy/bookcafe/dao/TestBorrowRepository.java → ...cafe/repository/TestBorrowRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/study/bookcafe/service/BorrowServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters