Skip to content

Commit

Permalink
Merge pull request #28 from depromeet/fix/LS-18
Browse files Browse the repository at this point in the history
fix/LS-18: 빌드 실패 해결
  • Loading branch information
raymondanythings authored Jul 13, 2024
2 parents 50dbae3 + 45324a5 commit 736e0f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.layer.domain.space.service;

import jakarta.transaction.Transactional;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.layer.common.dto.Meta;
import org.layer.common.exception.BaseCustomException;
import org.layer.domain.space.dto.SpaceRequest;
import org.layer.domain.space.dto.SpaceResponse;
import org.layer.domain.space.dto.SpaceWithMemberCount;
import org.layer.domain.space.entity.MemberSpaceRelation;
import org.layer.domain.space.entity.Space;
import org.layer.domain.space.repository.MemberSpaceRelationRepository;
import org.layer.domain.space.repository.SpaceRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.stream.Collectors;

Expand Down Expand Up @@ -46,7 +46,7 @@ public SpaceResponse.SpacePage getSpaceListFromMemberId(Long memberId, SpaceRequ
@Transactional
public void createSpace(Long memberId, SpaceRequest.CreateSpaceRequest mutateSpaceRequest) {
var newSpace = spaceRepository.save(mutateSpaceRequest.toEntity(memberId));
var memberSpaceRelation = MemberSpaceRelation.builder().memberId(memberId).spaceId(newSpace.getId()).build();
var memberSpaceRelation = MemberSpaceRelation.builder().memberId(memberId).space(newSpace).build();

memberSpaceRelationRepository.save(memberSpaceRelation);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.layer.domain.space.repository;

import org.layer.domain.space.dto.SpaceWithMemberCount;
import static org.layer.common.exception.SpaceExceptionType.*;

import org.layer.domain.space.entity.Space;
import org.layer.domain.space.entity.SpaceCategory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.layer.domain.space.exception.SpaceException;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;


public interface SpaceRepository extends JpaRepository<Space, Long> {

public interface SpaceRepository extends JpaRepository<Space, Long>, SpaceCustomRepository {
default Space findByIdOrThrow(Long spaceId){
return findById(spaceId)
.orElseThrow(() -> new SpaceException(NOT_FOUND_SPACE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public List<SpaceWithMemberCount> findAllSpacesByMemberIdAndCategoryAndCursor(Lo
memberSpaceRelation.id.count()
)
.from(memberSpaceRelation)
.where(memberSpaceRelation.spaceId.eq(space.id))
.where(memberSpaceRelation.space.id.eq(space.id))
, "userCount")
))
.from(space)
.join(memberSpaceRelation).on(space.id.eq(memberSpaceRelation.spaceId))
.join(memberSpaceRelation).on(space.id.eq(memberSpaceRelation.space.id))
.where(predicate)
.groupBy(space.id)
.orderBy(space.id.asc())
Expand All @@ -77,13 +77,13 @@ public Optional<SpaceWithMemberCount> findByIdAndJoinedMemberId(Long spaceId, Lo
memberSpaceRelation.id.count()
)
.from(memberSpaceRelation)
.where(memberSpaceRelation.spaceId.eq(space.id))
.where(memberSpaceRelation.space.id.eq(space.id))
, "userCount")
)
)
.from(memberSpaceRelation)
.join(space)
.on(space.id.eq(memberSpaceRelation.spaceId))
.on(space.id.eq(memberSpaceRelation.space.id))
.where(space.id.eq(spaceId)
.and(memberSpaceRelation.memberId.eq(memberId)))
.limit(1)
Expand Down

0 comments on commit 736e0f8

Please sign in to comment.