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

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.integraltransferlog.vo.*;
import cn.newfeifan.mall.module.distri.service.integraltransferlog.IntegralTransferLogService;

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

    @Resource
    private IntegralTransferLogService consumptionTransferLogService;

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

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

}