package cn.iocoder.yudao.module.member.controller.app.carousel;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.member.controller.admin.carousel.vo.CarouselPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.carousel.vo.CarouselRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.carousel.CarouselDO;
import cn.iocoder.yudao.module.member.service.carousel.CarouselService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 小程序轮播图")
@RestController
@RequestMapping("/member/carousel")
@Validated
public class AppCarouselController {

    @Resource
    private CarouselService carouselService;


    @GetMapping("/list")
    @Operation(summary = "获得小程序轮播图")
    public CommonResult<PageResult<CarouselRespVO>> getCarouselPage() {
        CarouselPageReqVO pageReqVO = new CarouselPageReqVO();
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        pageReqVO.setState(1);
        PageResult<CarouselDO> pageResult = carouselService.getCarouselPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, CarouselRespVO.class));
    }



}