| | |
| | | import com.rongyichuang.common.dto.PageResponse; |
| | | import com.rongyichuang.common.entity.Media; |
| | | import com.rongyichuang.common.exception.BusinessException; |
| | | import com.rongyichuang.common.enums.MediaTargetType; |
| | | import com.rongyichuang.common.repository.MediaRepository; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | |
| | | .map(CarouselResponse::getId) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 查询媒体数量(targetType=4表示轮播图) |
| | | List<Object[]> mediaCountResults = mediaRepository.countByTargetTypeAndTargetIdInAndState(4, carouselIds, 1); |
| | | // 查询媒体数量(使用枚举常量表示轮播图类型) |
| | | List<Object[]> mediaCountResults = mediaRepository.countByTargetTypeAndTargetIdInAndState( |
| | | MediaTargetType.CAROUSEL.getValue(), carouselIds, 1); |
| | | Map<Long, Integer> mediaCountMap = mediaCountResults.stream() |
| | | .collect(Collectors.toMap( |
| | | result -> (Long) result[0], |
| | |
| | | CarouselResponse response = convertToResponse(carousel); |
| | | |
| | | // 查询媒体数量 |
| | | List<Media> mediaList = mediaRepository.findByTargetTypeAndTargetIdAndState(4, id, 1); |
| | | List<Media> mediaList = mediaRepository.findByTargetTypeAndTargetIdAndState( |
| | | MediaTargetType.CAROUSEL.getValue(), id, 1); |
| | | response.setMediaCount(mediaList.size()); |
| | | |
| | | return response; |