package cn.newfeifan.mall.module.product.controller.admin.spuapplylog;

import cn.newfeifan.mall.framework.common.pojo.CommonResult;
import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
import cn.newfeifan.mall.module.product.controller.admin.spuapplylog.vo.SpuApplyLogPageReqVO;
import cn.newfeifan.mall.module.product.controller.admin.spuapplylog.vo.SpuApplyLogRespVO;
import cn.newfeifan.mall.module.product.dal.dataobject.spuapplylog.SpuApplyLogDO;
import cn.newfeifan.mall.module.product.service.spuapplylog.SpuApplyLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 商品审核记录")
@RestController
@RequestMapping("/product/spu-apply-log")
@Validated
public class SpuApplyLogController {

    @Resource
    private SpuApplyLogService spuApplyLogService;

    @GetMapping("/page")
    @Operation(summary = "获得商品审核记录分页")
    @PreAuthorize("@ss.hasPermission('product:spu:query')")
    public CommonResult<PageResult<SpuApplyLogRespVO>> getSpuApplyLogPage(@Valid SpuApplyLogPageReqVO pageReqVO) {
        PageResult<SpuApplyLogDO> pageResult = spuApplyLogService.getSpuApplyLogPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, SpuApplyLogRespVO.class));
    }

}