diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/memes/dto/MemesInfo.java b/backend/memetory/src/main/java/com/example/memetory/domain/memes/dto/MemesInfo.java index 512c623b..29ec755f 100644 --- a/backend/memetory/src/main/java/com/example/memetory/domain/memes/dto/MemesInfo.java +++ b/backend/memetory/src/main/java/com/example/memetory/domain/memes/dto/MemesInfo.java @@ -1,59 +1,61 @@ package com.example.memetory.domain.memes.dto; +import java.time.LocalDateTime; + import com.example.memetory.domain.memes.entity.Memes; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor @Schema(description = "밈스 정보") public class MemesInfo { - @Schema(description = "밈스 아이디") - private Long memesId; - - @Schema(description = "밈스를 생성한 멤버 아이디") - private Long memberId; - - @Schema(description = "밈스로 보여줄 밈의 S3 주소") - private String memeUrl; - - @Schema(description = "밈스 제목") - private String title; - - @Schema(description = "댓글 수") - private int commentCount; - - @Schema(description = "좋아요 수") - private int likeCount; - - @Schema(description = "밈스 생성 시각") - private LocalDateTime createdAt; - - @Builder - public MemesInfo(Long memesId, Long memberId, String memeUrl, String title, int commentCount, int likeCount, LocalDateTime createdAt) { - this.memesId = memesId; - this.memberId = memberId; - this.memeUrl = memeUrl; - this.title = title; - this.commentCount = commentCount; - this.likeCount = likeCount; - this.createdAt = createdAt; - } - - public static MemesInfo of(Memes memes) { - return MemesInfo.builder() - .memesId(memes.getId()) - .memberId(memes.getMember().getId()) - .memeUrl(memes.getMeme().getS3Url()) - .title(memes.getTitle()) - .commentCount(memes.getCommentCount()) - .likeCount(memes.getLikeCount()) - .createdAt(memes.getCreatedAt()) - .build(); - } + @Schema(description = "밈스 아이디") + private Long memesId; + + @Schema(description = "밈스를 생성한 멤버 아이디") + private Long memberId; + + @Schema(description = "밈스로 보여줄 밈의 S3 주소") + private String memeUrl; + + @Schema(description = "밈스 제목") + private String title; + + @Schema(description = "댓글 수") + private Long commentCount; + + @Schema(description = "좋아요 수") + private Long likeCount; + + @Schema(description = "밈스 생성 시각") + private LocalDateTime createdAt; + + @Builder + public MemesInfo(Long memesId, Long memberId, String memeUrl, String title, Long commentCount, Long likeCount, + LocalDateTime createdAt) { + this.memesId = memesId; + this.memberId = memberId; + this.memeUrl = memeUrl; + this.title = title; + this.commentCount = commentCount; + this.likeCount = likeCount; + this.createdAt = createdAt; + } + + public static MemesInfo of(Memes memes) { + return MemesInfo.builder() + .memesId(memes.getId()) + .memberId(memes.getMember().getId()) + .memeUrl(memes.getMeme().getS3Url()) + .title(memes.getTitle()) + .commentCount(memes.getCommentCount()) + .likeCount(memes.getLikeCount()) + .createdAt(memes.getCreatedAt()) + .build(); + } } diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/memes/dto/response/MemesResponse.java b/backend/memetory/src/main/java/com/example/memetory/domain/memes/dto/response/MemesResponse.java index c919c43a..61d60406 100644 --- a/backend/memetory/src/main/java/com/example/memetory/domain/memes/dto/response/MemesResponse.java +++ b/backend/memetory/src/main/java/com/example/memetory/domain/memes/dto/response/MemesResponse.java @@ -1,70 +1,72 @@ package com.example.memetory.domain.memes.dto.response; +import java.time.LocalDateTime; +import java.util.List; + import com.example.memetory.domain.comment.dto.CommentInfo; import com.example.memetory.domain.memes.entity.Memes; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; -import java.util.List; - @Getter @NoArgsConstructor @Schema(description = "밈스 단일 조회 반환 형식") public class MemesResponse { - @Schema(description = "밈스 아이디") - private Long memesId; + @Schema(description = "밈스 아이디") + private Long memesId; - @Schema(description = "밈스를 생성한 멤버 아이디") - private Long memberId; + @Schema(description = "밈스를 생성한 멤버 아이디") + private Long memberId; - @Schema(description = "밈스를 생성한 멤버 이름") - private String memberName; + @Schema(description = "밈스를 생성한 멤버 이름") + private String memberName; - @Schema(description = "밈스로 보여줄 밈의 S3 주소") - private String memeUrl; + @Schema(description = "밈스로 보여줄 밈의 S3 주소") + private String memeUrl; - @Schema(description = "밈스 제목") - private String title; + @Schema(description = "밈스 제목") + private String title; - @Schema(description = "댓글 수") - private int commentCount; + @Schema(description = "댓글 수") + private Long commentCount; - @Schema(description = "댓글 리스트") - private List commentInfoList; + @Schema(description = "댓글 리스트") + private List commentInfoList; - @Schema(description = "좋아요 수") - private int likeCount; + @Schema(description = "좋아요 수") + private Long likeCount; - @Schema(description = "밈스 생성 시각") - private LocalDateTime createdAt; + @Schema(description = "밈스 생성 시각") + private LocalDateTime createdAt; - @Builder - public MemesResponse(Long memesId, Long memberId, String memberName, String memeUrl, String title, int commentCount, List commentInfoList, int likeCount, LocalDateTime createdAt) { - this.memesId = memesId; - this.memberId = memberId; - this.memberName = memberName; - this.memeUrl = memeUrl; - this.title = title; - this.commentCount = commentCount; - this.commentInfoList = commentInfoList; - this.likeCount = likeCount; - this.createdAt = createdAt; - } + @Builder + public MemesResponse(Long memesId, Long memberId, String memberName, String memeUrl, String title, + Long commentCount, List commentInfoList, Long likeCount, LocalDateTime createdAt) { + this.memesId = memesId; + this.memberId = memberId; + this.memberName = memberName; + this.memeUrl = memeUrl; + this.title = title; + this.commentCount = commentCount; + this.commentInfoList = commentInfoList; + this.likeCount = likeCount; + this.createdAt = createdAt; + } - public static MemesResponse of(Memes memes) { - return MemesResponse.builder() - .memesId(memes.getId()) - .memberId(memes.getMember().getId()) - .memberName(memes.getMember().getName()) - .memeUrl(memes.getMeme().getS3Url()) - .title(memes.getTitle()) - .commentCount(memes.getCommentCount()) - .commentInfoList(memes.getComments().stream().map(CommentInfo::of).toList()) - .likeCount(memes.getLikeCount()) - .createdAt(memes.getCreatedAt()) - .build(); - } + public static MemesResponse of(Memes memes) { + return MemesResponse.builder() + .memesId(memes.getId()) + .memberId(memes.getMember().getId()) + .memberName(memes.getMember().getName()) + .memeUrl(memes.getMeme().getS3Url()) + .title(memes.getTitle()) + .commentCount(memes.getCommentCount()) + .commentInfoList(memes.getComments().stream().map(CommentInfo::of).toList()) + .likeCount(memes.getLikeCount()) + .createdAt(memes.getCreatedAt()) + .build(); + } } diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/memes/service/MemesService.java b/backend/memetory/src/main/java/com/example/memetory/domain/memes/service/MemesService.java index 2f974323..e71f4eb2 100644 --- a/backend/memetory/src/main/java/com/example/memetory/domain/memes/service/MemesService.java +++ b/backend/memetory/src/main/java/com/example/memetory/domain/memes/service/MemesService.java @@ -36,10 +36,10 @@ public class MemesService { @Transactional public void register(MemesServiceDto memesServiceDto) { - Member foundMember = memberService.findByEmail(memesServiceDto.getEmail()); - Meme foundMeme = memeService.getMemeBetweenService(memesServiceDto.getMemeId()); + Member member = memberService.findByEmail(memesServiceDto.getEmail()); + Meme meme = memeService.getMemeBetweenService(memesServiceDto.getMemeId()); - Memes newMemes = memesServiceDto.toEntity(findMember, findMeme); + Memes newMemes = memesServiceDto.toEntity(member, meme); memesRepository.save(newMemes); }