package com.ruoyi.cai.controller.admin;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.cai.domain.PayTotal;
import com.ruoyi.cai.dto.admin.vo.PayTotalAdminVo;
import com.ruoyi.cai.service.PayTotalService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * 支付统计
 *
 * @author 77
 * @date 2024-01-21
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/cai/payTotal")
public class PayTotalController extends BaseController {

    private final PayTotalService payTotalService;

    /**
     * 查询支付统计列表
     */
    @SaCheckPermission("cai:payTotal:list")
    @GetMapping("/list")
    public TableDataInfo<PayTotalAdminVo> list(PayTotal bo, PageQuery pageQuery) {
        Page<PayTotalAdminVo> page = payTotalService.pageAdmin(pageQuery, bo);
        return TableDataInfo.build(page);
    }

    /**
     * 获取支付统计详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("cai:payTotal:query")
    @GetMapping("/{id}")
    public R<PayTotal> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(payTotalService.getById(id));
    }

}
