-
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.
- Loading branch information
Showing
7 changed files
with
81 additions
and
2 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
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
7 changes: 7 additions & 0 deletions
7
smeem-application/src/main/java/com/smeem/application/port/output/persistence/VisitPort.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,7 @@ | ||
package com.smeem.application.port.output.persistence; | ||
|
||
import java.time.LocalDate; | ||
|
||
public interface VisitPort { | ||
void update(LocalDate date, String bitmap); | ||
} |
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
22 changes: 22 additions & 0 deletions
22
...tence/postgresql/src/main/java/com/smeem/persistence/postgresql/adapter/VisitAdapter.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,22 @@ | ||
package com.smeem.persistence.postgresql.adapter; | ||
|
||
import com.smeem.application.port.output.persistence.VisitPort; | ||
import com.smeem.persistence.postgresql.persistence.entity.VisitEntity; | ||
import com.smeem.persistence.postgresql.persistence.repository.member.VisitRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class VisitAdapter implements VisitPort { | ||
private final VisitRepository visitRepository; | ||
|
||
@Override | ||
public void update(LocalDate date, String bitmap) { | ||
VisitEntity visit = visitRepository.findByDate(date) | ||
.orElseGet(() -> visitRepository.save(new VisitEntity(date, bitmap))); | ||
visit.update(bitmap); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...gresql/src/main/java/com/smeem/persistence/postgresql/persistence/entity/VisitEntity.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,30 @@ | ||
package com.smeem.persistence.postgresql.persistence.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class VisitEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false, unique = true) | ||
private LocalDate date; | ||
|
||
@Column(columnDefinition = "TEXT", nullable = false) | ||
private String log; | ||
|
||
public VisitEntity(LocalDate date, String log) { | ||
this.date = date; | ||
this.log = log; | ||
} | ||
|
||
public void update(String log) { | ||
this.log = log; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../java/com/smeem/persistence/postgresql/persistence/repository/member/VisitRepository.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,11 @@ | ||
package com.smeem.persistence.postgresql.persistence.repository.member; | ||
|
||
import com.smeem.persistence.postgresql.persistence.entity.VisitEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Optional; | ||
|
||
public interface VisitRepository extends JpaRepository<VisitEntity, Long> { | ||
Optional<VisitEntity> findByDate(LocalDate date); | ||
} |