diff --git a/src/main/java/vom/spring/domain/touchpoint/TouchpointDto.java b/src/main/java/vom/spring/domain/touchpoint/TouchpointDto.java index 46dfe7e..1701da7 100644 --- a/src/main/java/vom/spring/domain/touchpoint/TouchpointDto.java +++ b/src/main/java/vom/spring/domain/touchpoint/TouchpointDto.java @@ -1,46 +1,19 @@ package vom.spring.domain.touchpoint; -import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Getter; -import vom.spring.domain.album.Album; -import vom.spring.domain.album.AlbumDto; -import vom.spring.domain.member.domain.Member; +import lombok.Setter; import java.time.LocalDateTime; +@Getter @Setter public class TouchpointDto { - private Long fromMemberId; + private String fromMemberNickname; private LocalDateTime createdAt; private String fromMemberProfileImgUrl; - public TouchpointDto(Long fromMemberId, LocalDateTime createdAt, String fromMemberProfileImgUrl) { - this.fromMemberId = fromMemberId; + public TouchpointDto(String fromMemberNickname, LocalDateTime createdAt, String fromMemberProfileImgUrl) { + this.fromMemberNickname = fromMemberNickname; this.createdAt = createdAt; this.fromMemberProfileImgUrl = fromMemberProfileImgUrl; } - - public Long getFromMemberId() { - return fromMemberId; - } - - public void setFromMemberId(Long fromMemberId) { - this.fromMemberId = fromMemberId; - } - - public LocalDateTime getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(LocalDateTime createdAt) { - this.createdAt = createdAt; - } - - public String getFromMemberProfileImgUrl() { - return fromMemberProfileImgUrl; - } - - public void setFromMemberProfileImgUrl(String fromMemberProfileUrl) { - this.fromMemberProfileImgUrl = fromMemberProfileUrl; - } } diff --git a/src/main/java/vom/spring/domain/touchpoint/TouchpointRepository.java b/src/main/java/vom/spring/domain/touchpoint/TouchpointRepository.java index 6faca30..6bd0a1f 100644 --- a/src/main/java/vom/spring/domain/touchpoint/TouchpointRepository.java +++ b/src/main/java/vom/spring/domain/touchpoint/TouchpointRepository.java @@ -3,6 +3,7 @@ import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; import jakarta.persistence.TypedQuery; +import java.time.LocalDate; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -22,12 +23,15 @@ public void save(Touchpoint touchpoint) { em.persist(touchpoint); } - public List findFromMemberIdsByToMemberId(Long toMemberId) { + public List findByToMemberId(Long toMemberId, LocalDate today) { return em.createQuery( - "select new TouchpointDto(t.fromMember.id, t.createdAt, t.fromMember.profileImgUrl) " + - "from Touchpoint t where t.toMember.id = :toMemberId", + "select new TouchpointDto(t.fromMember.nickname, t.createdAt, t.fromMember.profileImgUrl) " + + "from Touchpoint t " + + "where t.toMember.id = :toMemberId " + + "and t.createdAt < :today", TouchpointDto.class) .setParameter("toMemberId", toMemberId) + .setParameter("today", today.atStartOfDay()) .getResultList(); } diff --git a/src/main/java/vom/spring/domain/touchpoint/TouchpointService.java b/src/main/java/vom/spring/domain/touchpoint/TouchpointService.java index dd84e85..15e8ac0 100644 --- a/src/main/java/vom/spring/domain/touchpoint/TouchpointService.java +++ b/src/main/java/vom/spring/domain/touchpoint/TouchpointService.java @@ -1,5 +1,6 @@ package vom.spring.domain.touchpoint; +import java.time.LocalDate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,8 +27,8 @@ public TouchpointService(TouchpointRepository touchpointRepository, MemberReposi */ @Transactional public List getTouchpoints(Long member_id) { -// Member member = memberRepository.findById(member_id).get(); - return touchpointRepository.findFromMemberIdsByToMemberId(member_id); + LocalDate today = LocalDate.now(); + return touchpointRepository.findByToMemberId(member_id, today); } /** diff --git a/src/main/java/vom/spring/global/config/S3Config.java b/src/main/java/vom/spring/global/config/S3Config.java index 6457e1b..74d2507 100644 --- a/src/main/java/vom/spring/global/config/S3Config.java +++ b/src/main/java/vom/spring/global/config/S3Config.java @@ -11,34 +11,34 @@ @Configuration public class S3Config { -// @Value("${cloud.aws.credentials.access-key}") -// private String accessKey; -// -// @Value("${cloud.aws.credentials.secret-key}") -// private String secretKey; -// -// @Value("${cloud.aws.region.static}") -// private String region; -// -// @Bean -// public AmazonS3Client amazonS3Client() { -// BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); -// -// return (AmazonS3Client) AmazonS3ClientBuilder -// .standard() -// .withRegion(region) -// .withCredentials(new AWSStaticCredentialsProvider(credentials)) -// .build(); -// } + @Value("${cloud.aws.credentials.access-key}") + private String accessKey; + + @Value("${cloud.aws.credentials.secret-key}") + private String secretKey; + @Value("${cloud.aws.region.static}") private String region; @Bean public AmazonS3Client amazonS3Client() { + BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); return (AmazonS3Client) AmazonS3ClientBuilder .standard() .withRegion(region) + .withCredentials(new AWSStaticCredentialsProvider(credentials)) .build(); } +// @Value("${cloud.aws.region.static}") +// private String region; +// +// @Bean +// public AmazonS3Client amazonS3Client() { +// +// return (AmazonS3Client) AmazonS3ClientBuilder +// .standard() +// .withRegion(region) +// .build(); +// } }