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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.miniapp.bean.material.parts.PartsChangeSalesBean;
import com.gree.mall.miniapp.exception.RemoteServiceException;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.material.parts.WebsitPartsChangeSalesLogic;
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;

@Slf4j
@RestController
@Api(value = "新件转销售", tags ={"新件转销售"} )
@RequestMapping(value = "/app/worker/change-sales", produces = "application/json; charset=utf-8")
public class ChangeSalesController {

    @Resource
    WebsitPartsChangeSalesLogic websitPartsChangeSalesLogic;

    @ApiOperation(value = "新件转销售列表")
    @PostMapping("/list")
    public ResponseHelper<IPage<PartsChangeSalesBean>> appList(
            @ApiParam(value = "转销单号") @RequestParam(required = false) String changeSalesNo,
            @ApiParam(value = "单据状态 SUBMIT=提交 AGREE=通过 REJECT=驳回") @RequestParam(required = false) String flag,
            @ApiParam(value = "师傅身份证", required = true) @RequestParam String identity,
            @ApiParam(value = "配件编码") @RequestParam(required = false) String partsNumber,
            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNo,
            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize
    ) throws RemoteServiceException {
        return ResponseHelper.success(websitPartsChangeSalesLogic.appList(changeSalesNo, flag, identity, pageNo, pageSize));
    }

    @ApiOperation(value = "新件转销售详情")
    @PostMapping("/detail")
    public ResponseHelper<PartsChangeSalesBean> detail(
            @ApiParam(value = "转销单号",required = true) @RequestParam String changeSalesNo
    ) throws RemoteServiceException {
        return ResponseHelper.success(websitPartsChangeSalesLogic.detail(changeSalesNo));
    }
}
