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

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
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.management.entity.PortalSlideshow;
import cn.stylefeng.team.portal.modular.management.pojo.request.PortalSlideshowRequest;
import cn.stylefeng.team.portal.modular.management.service.PortalSlideshowService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ApiResource(name = "轮播图")
public class PortalSlideshowController {

    @Resource
    private PortalSlideshowService portalSlideshowService;

    @PostResource(name = "添加轮播图", path = "/portalSlideshow/add")
    public ResponseData<PortalSlideshow> add(@RequestBody @Validated(PortalSlideshowRequest.add.class) PortalSlideshowRequest portalSlideshowRequest) {
        portalSlideshowService.add(portalSlideshowRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "删除轮播图", path = "/portalSlideshow/delete")
    public ResponseData<?> delete(@RequestBody @Validated(PortalSlideshowRequest.delete.class) PortalSlideshowRequest portalSlideshowRequest) {
        portalSlideshowService.del(portalSlideshowRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "批量删除轮播图", path = "/portalSlideshow/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) PortalSlideshowRequest portalSlideshowRequest) {
        portalSlideshowService.batchDelete(portalSlideshowRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "编辑轮播图", path = "/portalSlideshow/edit")
    public ResponseData<?> edit(@RequestBody @Validated(PortalSlideshowRequest.edit.class) PortalSlideshowRequest portalSlideshowRequest) {
        portalSlideshowService.edit(portalSlideshowRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "查看轮播图详情", path = "/portalSlideshow/detail")
    public ResponseData<PortalSlideshow> detail(@Validated(PortalSlideshowRequest.detail.class) PortalSlideshowRequest portalSlideshowRequest) {
        return new SuccessResponseData<>(portalSlideshowService.detail(portalSlideshowRequest));
    }

    @GetResource(name = "获取轮播图列表（带分页）", path = "/portalSlideshow/page")
    public ResponseData<PageResult<PortalSlideshow>> page(@Validated(BaseRequest.page.class) PortalSlideshowRequest portalSlideshowRequest) {
        return new SuccessResponseData<>(portalSlideshowService.findPage(portalSlideshowRequest));
    }

}
