package cn.newfeifan.mall.module.distri.controller.admin.consumptionerroruser;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
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.admin.consumptionerroruser.vo.*;
import cn.newfeifan.mall.module.distri.dal.dataobject.consumptionerroruser.ConsumptionErrorUserDO;
import cn.newfeifan.mall.module.distri.service.consumptionerroruser.ConsumptionErrorUserService;

@Tag(name = "管理后台 - 消费分异动用户")
@RestController
@RequestMapping("/distri/consumption-error-user")
@Validated
public class ConsumptionErrorUserController {

    @Resource
    private ConsumptionErrorUserService consumptionErrorUserService;
    @GetMapping("/get")
    @Operation(summary = "获得消费分异动用户")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('distri:consumption-error-user:query')")
    public CommonResult<ConsumptionErrorUserRespVO> getConsumptionErrorUser(@RequestParam("id") Long id) {
        ConsumptionErrorUserDO consumptionErrorUser = consumptionErrorUserService.getConsumptionErrorUser(id);
        return success(BeanUtils.toBean(consumptionErrorUser, ConsumptionErrorUserRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得消费分异动用户分页")
    @PreAuthorize("@ss.hasPermission('distri:consumption-error-user:query')")
    public CommonResult<PageResult<ConsumptionErrorUserRespVO>> getConsumptionErrorUserPage(@Valid ConsumptionErrorUserPageReqVO pageReqVO) {
        PageResult<ConsumptionErrorUserDO> pageResult = consumptionErrorUserService.getConsumptionErrorUserPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, ConsumptionErrorUserRespVO.class));
    }

}