package cn.iocoder.yudao.module.custom.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
import cn.iocoder.yudao.module.custom.service.BasePromotionService;
import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

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

/**
 * 推广记录表 控制层
 *
 * @author 小李
 * @date 16:42 2024/8/13
 **/
@Tag(name = "管理后台 - 推广记录")
@Validated
@RestController
@RequestMapping("/base/promotion")
public class BasePromotionController {

    @Resource
    private BasePromotionService promotionService;

    /**
     * 分页查询推广记录
     *
     * @param pageReqVO 查询条件对象
     * @param pageNo    页码
     * @param pageSize  条数
     * @author 小李
     * @date 16:50 2024/8/13
     **/
    @GetMapping("/page")
    @Operation(summary = "分页查询推广记录")
    @PreAuthorize("@ss.hasPermission('base:promotion:query')")
    public CommonResult<IPage<?>> getBasePromotionPage(BasePromotionReqVO pageReqVO,
                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<BasePromotion> page = new Page<>(pageNo, pageSize);
        return success(promotionService.queryListPage(pageReqVO, page));
    }
}
