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

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.controller.app.consumptiontransferlog.vo.*;
import cn.newfeifan.mall.module.distri.dal.dataobject.consumptiontransferlog.ConsumptionTransferLogDO;
import cn.newfeifan.mall.module.distri.service.consumptiontransferlog.ConsumptionTransferLogService;

@Tag(name = "管理后台 - 消费分转让记录")
@RestController
@RequestMapping("/distri/consumption-transfer-log")
@Validated
public class ConsumptionTransferLogController {

    @Resource
    private ConsumptionTransferLogService consumptionTransferLogService;

    @PostMapping("/create")
    @Operation(summary = "创建消费分转让记录")
    public CommonResult<Long> createConsumptionTransferLog(@Valid @RequestBody ConsumptionTransferLogSaveReqVO createReqVO) {
        return success(consumptionTransferLogService.createConsumptionTransferLog(createReqVO));
    }

    @GetMapping("/page")
    @Operation(summary = "获得消费分转让记录分页")
    public CommonResult<PageResult<ConsumptionTransferLogRespVO>> getConsumptionTransferLogPage(@Valid ConsumptionTransferLogPageReqVO pageReqVO) {
        PageResult<ConsumptionTransferLogDO> pageResult = consumptionTransferLogService.getConsumptionTransferLogPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, ConsumptionTransferLogRespVO.class));
    }

}