Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TouchpointDto fromMemberId -> fromMemberNickname 변경 #51

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
// }
}
Loading