package com.gree.mall.miniapp.controller.material;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.miniapp.bean.material.NormRecordVO;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.material.NormRecordLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@Api(value = "使用记录API", tags ={"使用记录API"} )
@RequestMapping(value = "/material/norm/record", produces = "application/json; charset=utf-8")
public class NormRecordController {

    @Resource
    NormRecordLogic normRecordLogic;

    @PostMapping("list")
    @ApiOperation(value = "使用记录")
    public ResponseHelper<IPage<NormRecordVO>> list(
            @ApiParam(value = "单号") @RequestParam(required = false) String orderId,
            @ApiParam(value = "类型 M=辅材 P=配件") @RequestParam(required = false) String goodsType,
            @ApiParam(value = "月份 YYYY-mm") @RequestParam(required = false) String yearMonth,
            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize,
            HttpServletRequest request
    ) {
        IPage<NormRecordVO> page = normRecordLogic.list(orderId, goodsType, yearMonth, pageNum, pageSize, request);
        return ResponseHelper.success(page);
    }
}
