Skip to content

Commit

Permalink
Merge pull request #382 from daedongbread/feature/carousel
Browse files Browse the repository at this point in the history
feat : 케러셀 큐레이션 & 이벤트 통합 출력 수정
  • Loading branch information
JayPark7821 authored Dec 15, 2023
2 parents c99e0b5 + 29fa0e7 commit a0c3c4c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import com.depromeet.breadmapbackend.domain.admin.carousel.domain.CarouselManager;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.CarouselType;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.dto.command.CreateCarouselCommand;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.dto.command.UpdateCarouselOrderCommand;
import com.depromeet.breadmapbackend.domain.admin.post.domain.dto.info.CarouselInfo;
Expand All @@ -22,4 +24,6 @@ public interface CarouselManagerService {
List<CarouselInfo> getCarousels();

void toggleCarousel(final Long carouselId, final boolean isCarousel);

CarouselManager getCarouselByTargetIdAndCarouselType(final Long carouselId, final CarouselType carouselType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.transaction.annotation.Transactional;

import com.depromeet.breadmapbackend.domain.admin.carousel.domain.CarouselManager;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.CarouselType;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.dto.command.CreateCarouselCommand;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.dto.command.UpdateCarouselOrderCommand;
import com.depromeet.breadmapbackend.domain.admin.carousel.repository.CarouselRepository;
Expand Down Expand Up @@ -96,6 +97,15 @@ public void toggleCarousel(final Long carouselId, final boolean isCarousel) {
});
}

@Override
public CarouselManager getCarouselByTargetIdAndCarouselType(
final Long carouselId,
final CarouselType carouselType
) {
return carouselRepository.findByTargetIdAndCarouselType(carouselId, carouselType)
.orElseThrow(() -> new DaedongException(DaedongStatus.CAROUSEL_NOT_FOUND));
}

@Override
public List<CarouselInfo> getCarousels() {
return carouselRepository.findByCarouseledIsOrderByCarouselOrderAsc(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import com.depromeet.breadmapbackend.domain.admin.Admin;
import com.depromeet.breadmapbackend.domain.admin.AdminRepository;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.CarouselType;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.dto.command.CreateCarouselCommand;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.service.CarouselManagerService;
import com.depromeet.breadmapbackend.domain.admin.category.domain.Category;
import com.depromeet.breadmapbackend.domain.admin.category.repository.CategoryRepository;
import com.depromeet.breadmapbackend.domain.admin.feed.domain.CurationBakery;
Expand Down Expand Up @@ -42,6 +45,7 @@ public class CurationFeedService implements FeedService {
private final CategoryRepository categoryRepository;
private final ProductRepository productRepository;
private final FlagBakeryRepository flagBakeryRepository;
private final CarouselManagerService carouselManagerService;

@Transactional
@Override
Expand All @@ -58,6 +62,16 @@ public Long addFeed(Long adminId, FeedRequestDto requestDto) {
feed.addAll(bakeries, curationBakeries);

CurationFeed newFeed = repository.save(feed);

carouselManagerService.saveCarousel(
new CreateCarouselCommand(
CarouselType.CURATION,
newFeed.getId(),
requestDto.getCommon().getThumbnailUrl(),
true
)
);

return newFeed.getId();
}

Expand All @@ -74,6 +88,9 @@ public void updateFeed(Long adminId, Long feedId, FeedRequestDto updateDto) {
List<CurationBakery> curationBakeries = FeedAssembler.toCurationBakery(feed, bakeries, updateDto);

feed.update(updateFeed, bakeries, curationBakeries);

carouselManagerService.getCarouselByTargetIdAndCarouselType(feedId, CarouselType.CURATION)
.updateBannerImage(updateDto.getCommon().getThumbnailUrl());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public interface ScoredBakeryJpaRepository extends JpaRepository<ScoredBakery, L
+ "from ScoredBakery sb "
+ "join fetch sb.bakery b "
+ "where sb.calculatedDate = :calculatedDate "
+ "and b.status = 'POSTING' "
+ "order by sb.rank asc ")
List<ScoredBakery> findScoredBakeryByCalculatedDate(
@Param("calculatedDate") final LocalDate calculatedDate,
Expand All @@ -30,7 +31,8 @@ List<ScoredBakery> findScoredBakeryByCalculatedDate(
@Query("select sb "
+ "from ScoredBakery sb "
+ "join fetch sb.bakery b "
+ "where sb.calculatedDate between :startDate and :endDate")
+ "where sb.calculatedDate between :startDate and :endDate "
+ "and b.status = 'POSTING' ")
List<ScoredBakery> findScoredBakeryWithStartDate(
@Param("startDate") final LocalDate startDate,
@Param("endDate") final LocalDate endDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.springframework.test.web.servlet.ResultActions;

import com.depromeet.breadmapbackend.domain.admin.Admin;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.CarouselManager;
import com.depromeet.breadmapbackend.domain.admin.carousel.domain.CarouselType;
import com.depromeet.breadmapbackend.domain.admin.category.domain.Category;
import com.depromeet.breadmapbackend.domain.admin.feed.domain.CurationBakery;
import com.depromeet.breadmapbackend.domain.admin.feed.domain.CurationFeed;
Expand Down Expand Up @@ -209,6 +211,7 @@ public void setDown() {
categoryRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
adminRepository.deleteAllInBatch();
carouselRepository.deleteAllInBatch();
}

@Test
Expand Down Expand Up @@ -355,6 +358,15 @@ public void setDown() {
void 큐레이션피드_수정_테스트() throws Exception {

//given
final CarouselManager carouselManager = CarouselManager.builder()
.targetId(curation.getId())
.carouseled(true)
.carouselType(CarouselType.CURATION)
.bannerImage(customAWSS3Properties.getCloudFront() + "/" + "productImage.jpg")
.carouselOrder(1)
.build();

carouselRepository.save(carouselManager);

CommonFeedRequestDto updateCommon = CommonFeedRequestDto.builder()
.subTitle("업데이트된 큐레이션 테스트 피드")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.depromeet.breadmapbackend.domain.admin.AdminRepository;
import com.depromeet.breadmapbackend.domain.admin.AdminService;
import com.depromeet.breadmapbackend.domain.admin.carousel.repository.CarouselRepository;
import com.depromeet.breadmapbackend.domain.admin.category.repository.CategoryRepository;
import com.depromeet.breadmapbackend.domain.admin.category.service.CategoryService;
import com.depromeet.breadmapbackend.domain.admin.feed.repository.CurationBakeryRepository;
Expand Down Expand Up @@ -227,6 +228,9 @@ public abstract class ControllerTest {
@Autowired
DataSource dataSource;

@Autowired
protected CarouselRepository carouselRepository;

@BeforeEach
void beforeEach() throws Exception {

Expand Down

0 comments on commit a0c3c4c

Please sign in to comment.