Skip to content

Commit

Permalink
Merge pull request #51 from VOM-Project/feature/touchpoint
Browse files Browse the repository at this point in the history
fix: TouchpointDto fromMemberId -> fromMemberNickname 변경
  • Loading branch information
okodeee authored Nov 21, 2024
2 parents 6ca1f6b + 2454999 commit 2d85ccf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 56 deletions.
37 changes: 5 additions & 32 deletions src/main/java/vom/spring/domain/touchpoint/TouchpointDto.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,12 +23,15 @@ public void save(Touchpoint touchpoint) {
em.persist(touchpoint);
}

public List<TouchpointDto> findFromMemberIdsByToMemberId(Long toMemberId) {
public List<TouchpointDto> 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();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -26,8 +27,8 @@ public TouchpointService(TouchpointRepository touchpointRepository, MemberReposi
*/
@Transactional
public List<TouchpointDto> 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);
}

/**
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/vom/spring/global/config/S3Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
// }
}

0 comments on commit 2d85ccf

Please sign in to comment.