package cn.stylefeng.team.portal.modular.front.service.impl;

import cn.stylefeng.team.portal.modular.front.pojo.request.CommonComponentRequest;
import cn.stylefeng.team.portal.modular.front.pojo.request.FrontSlideshowRequest;
import cn.stylefeng.team.portal.modular.front.service.ComponentSlideshowService;
import cn.stylefeng.team.portal.modular.management.entity.PortalSlideshow;
import cn.stylefeng.team.portal.modular.management.service.PortalNewsService;
import cn.stylefeng.team.portal.modular.management.service.PortalSlideshowService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComponentSlideshowServiceImpl implements ComponentSlideshowService {

    @Resource
    private PortalSlideshowService portalSlideshowService;

    @Resource
    private PortalNewsService portalNewsService;

    @Override
    public List<PortalSlideshow> getSelectList(CommonComponentRequest slideshowSelectListRequest) {
        LambdaQueryWrapper<PortalSlideshow> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PortalSlideshow::getDesignId, slideshowSelectListRequest.getDesignId());
        wrapper.select(PortalSlideshow::getSlideshowId, PortalSlideshow::getSlideshowTitle);
        return portalSlideshowService.list(wrapper);
    }

    @Override
    public List<PortalSlideshow> summary(FrontSlideshowRequest frontSlideshowRequest) {
        LambdaQueryWrapper<PortalSlideshow> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PortalSlideshow::getDesignId, frontSlideshowRequest.getDesignId());
        wrapper.in(PortalSlideshow::getSlideshowId, frontSlideshowRequest.getSlideshowIdList());
        wrapper.select(PortalSlideshow::getSlideshowId, PortalSlideshow::getSlideshowTitle,
                PortalSlideshow::getSlideshowCoverFileId, PortalSlideshow::getSlideshowRedirectType,
                PortalSlideshow::getSlideshowNewsId, PortalSlideshow::getSlideshowRedirectUrl);
        wrapper.orderByAsc(PortalSlideshow::getFldSort);
        return portalSlideshowService.list(wrapper);
    }

}
