Skip to content

Commit

Permalink
[#42] 전체 밈 조회 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
JunRain2 committed Mar 21, 2024
1 parent 938e007 commit 15806c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public static MemeServiceDto create(String email, Long memeId) {
.build();
}

public static MemeServiceDto create(String email) {
return MemeServiceDto.builder()
.email(email)
.build();
}

public Meme toEntity(Member member) {
return Meme.builder()
.member(member)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.example.memetory.domain.meme.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.memetory.domain.member.entity.Member;
import com.example.memetory.domain.member.service.MemberService;
import com.example.memetory.domain.meme.dto.AIServerSendDto;
import com.example.memetory.domain.meme.dto.MemeListResponse;
import com.example.memetory.domain.meme.dto.MemeResponse;
import com.example.memetory.domain.meme.dto.MemeServiceDto;
import com.example.memetory.domain.meme.entity.Meme;
Expand Down Expand Up @@ -57,4 +60,18 @@ public boolean checkMember(MemeServiceDto memeServiceDto) {

return meme.getMember() != member;
}

@Transactional
public MemeListResponse getAllMeme(MemeServiceDto memeServiceDto) {
Member member = memberService.findByEmail(memeServiceDto.getEmail());

List<MemeResponse> memeList = memeRepository.findAllByMember(member)
.stream()
.map(MemeResponse::of)
.toList();

return MemeListResponse.builder()
.memeList(memeList)
.build();
}
}

0 comments on commit 15806c6

Please sign in to comment.