package cn.stylefeng.team.portal.modular.front.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
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 jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "轮播图组件")
public class ComponentSlideshowController {

    @Resource
    private ComponentSlideshowService componentSlideshowService;

    @GetResource(name = "获取门户下的所有轮播图", path = "/component/slideshow/getSelectList")
    public ResponseData<List<PortalSlideshow>> getSelectList(@Validated(CommonComponentRequest.list.class) CommonComponentRequest slideshowSelectListRequest) {
        List<PortalSlideshow> list = componentSlideshowService.getSelectList(slideshowSelectListRequest);
        return new SuccessResponseData<>(list);
    }

    @PostResource(name = "获取前台轮播图列表", path = "/component/slideshow/summary")
    public ResponseData<List<PortalSlideshow>> summary(@RequestBody @Validated FrontSlideshowRequest frontSlideshowRequest) {
        List<PortalSlideshow> list = componentSlideshowService.summary(frontSlideshowRequest);
        return new SuccessResponseData<>(list);
    }

}
