package vip.xiaonuo.write.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.production.param.ProductionPageParam;
import vip.xiaonuo.quality.entity.QualityWrite;
import vip.xiaonuo.quality.param.QualityWriteAddParam;
import vip.xiaonuo.write.entity.WriteProduct;
import vip.xiaonuo.write.param.WriteProductAddParam;
import vip.xiaonuo.write.service.IWriteProductService;

import java.util.Map;

/**
 * <p>
 * 成品检验台账填报 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-02
 */
@RestController
@RequestMapping("/write-product")
@Api(tags = "成品检验台账填报")
@ApiSupport(author = "wang", order = 1)
@Validated
public class WriteProductController {

    @Autowired
    private IWriteProductService writeProductService;

    @PostMapping("/quality-write/add")
    @ApiOperationSupport(order = 1)
    @ApiOperation("成品检验台账填报添加")
    public CommonResult add(@RequestBody WriteProductAddParam addParam){
        return writeProductService.add(addParam);
    }

    @PostMapping("/quality-write/edit")
    @ApiOperationSupport(order = 2)
    @ApiOperation("成品检验台账填报修改")
    public CommonResult edit(@RequestBody WriteProduct writeProduct) {
        return writeProductService.edit(writeProduct);
    }

    @PostMapping("/quality-write/delete")
    @ApiOperationSupport(order = 3)
    @ApiOperation("成品检验台账填报删除")
    public CommonResult delete(@RequestBody Map<String, String> paramsMap) {
        return writeProductService.delete(paramsMap);
    }

    @PostMapping("/quality-write/page")
    @ApiOperationSupport(order = 4)
    @ApiOperation("成品检验台账填报分页")
    public CommonResult<Page<WriteProduct>> page(@RequestBody ProductionPageParam pageParam) {
        return CommonResult.data(writeProductService.page(pageParam));
    }
}
