package cn.newfeifan.mall.module.distri.controller.app.consumptiontopuplog;

import cn.newfeifan.mall.module.distri.controller.app.consumptiontopuplog.vo.ConsumptionTopUpLogPageReqVO;
import cn.newfeifan.mall.module.distri.controller.app.consumptiontopuplog.vo.ConsumptionTopUpLogRespVO;
import cn.newfeifan.mall.module.distri.controller.app.consumptiontopuplog.vo.ConsumptionTopUpLogSaveReqVO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.common.pojo.CommonResult;
import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;

import cn.newfeifan.mall.module.distri.dal.dataobject.consumptiontopuplog.ConsumptionTopUpLogDO;
import cn.newfeifan.mall.module.distri.service.consumptiontopuplog.ConsumptionTopUpLogService;

@Tag(name = "管理后台 - 平台消费分充值记录")
@RestController
@RequestMapping("/distri/consumption-top-up-log")
@Validated
public class ConsumptionTopUpLogController {

    @Resource
    private ConsumptionTopUpLogService consumptionTopUpLogService;

    @PostMapping("/create")
    @Operation(summary = "创建平台消费分充值记录")
    public CommonResult<Long> createConsumptionTopUpLog(@Valid @RequestBody ConsumptionTopUpLogSaveReqVO createReqVO) {
        return success(consumptionTopUpLogService.createConsumptionTopUpLog(createReqVO));
    }

    @GetMapping("/page")
    @Operation(summary = "获得平台消费分充值记录分页")
    public CommonResult<PageResult<ConsumptionTopUpLogRespVO>> getConsumptionTopUpLogPage(@Valid ConsumptionTopUpLogPageReqVO pageReqVO) {
        PageResult<ConsumptionTopUpLogDO> pageResult = consumptionTopUpLogService.getConsumptionTopUpLogPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, ConsumptionTopUpLogRespVO.class));
    }

}