Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Me1tingPot/BE into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JangYouJung committed May 27, 2024
2 parents 29cfc0a + 9abb021 commit cf317a2
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/meltingpot/server/domain/entity/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class Account extends BaseEntity {

private LocalDateTime deletedAt;

@OneToMany(mappedBy = "account", cascade = CascadeType.ALL )
@OneToMany(mappedBy = "account", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<AccountProfileImage> profileImages = new ArrayList<>();

@Builder.Default
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package meltingpot.server.domain.repository.party;

import meltingpot.server.domain.entity.Account;
import meltingpot.server.domain.entity.party.PartyParticipant;
import meltingpot.server.domain.entity.party.enums.ParticipantStatus;
import meltingpot.server.domain.entity.party.enums.PartyStatus;
import org.springframework.data.jpa.repository.JpaRepository;

public interface PartyParticipantRepository extends JpaRepository<PartyParticipant, Long> {
int countByParty_PartyStatusAndParticipantStatusAndAccount(PartyStatus partyStatus, ParticipantStatus participantStatus, Account account);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public interface PartyRepository extends JpaRepository<Party, Integer>, JpaSpeci
Party findByChatRoomId(Long chatRoomId);

Party findByAccountAndPartyStatus(Account account, PartyStatus status);

int countByAccountAndPartyStatus(Account account, PartyStatus status);
}
32 changes: 32 additions & 0 deletions src/main/java/meltingpot/server/party/dto/PartyOwnerResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package meltingpot.server.party.dto;

import lombok.Builder;
import lombok.Setter;
import meltingpot.server.domain.entity.Account;
import meltingpot.server.domain.entity.AccountProfileImage;

import java.util.List;

@Builder
public record PartyOwnerResponse(
String name,
String introduction,
String nationality,
String country,
String language,
String city,
List<String> profileImages,
int partyParticipantCount,
int partyCreationCount
) {
public static PartyOwnerResponse of(Account account) {
return PartyOwnerResponse.builder()
.name(account.getName())
.nationality(account.getNationality())
.country(account.getCountry())
.language(account.getLanguage())
.city(account.getCity())
.profileImages(account.getProfileImages().stream().map(AccountProfileImage::getImageKey).toList())
.build();
}
}
4 changes: 2 additions & 2 deletions src/main/java/meltingpot/server/party/dto/PartyResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Builder
public record PartyResponse(
int id,
String ownerName,
PartyOwnerResponse owner,
String subject,
PartyStatus partyStatus,
String startTime,
Expand All @@ -24,7 +24,7 @@ public record PartyResponse(
) {
public static PartyResponse of(Party party) {
return PartyResponse.builder().id(party.getId())
.ownerName(party.getAccount().getName())
.owner(PartyOwnerResponse.of(party.getAccount()))
.subject(party.getPartySubject())
.partyStatus(party.getPartyStatus())
.startTime(party.getPartyStartTime().toString())
Expand Down

0 comments on commit cf317a2

Please sign in to comment.