package vip.xiaonuo.production.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.entity.ProductionTarget;
import vip.xiaonuo.production.entity.ProductionWritePlan;
import vip.xiaonuo.production.param.ProductionPageParam;
import vip.xiaonuo.production.param.ProductionParam;
import vip.xiaonuo.production.param.ProductionWritePlanAddParam;
import vip.xiaonuo.production.service.IProductionWritePlanService;

import java.text.ParseException;
import java.util.Map;

/**
 * <p>
 * 计划生产量填报 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-02-25
 */
@RestController
@Api(tags = "计划生产量填报")
@ApiSupport(author = "wang", order = 1)
@Validated
public class ProductionWritePlanController {

    @Autowired
    private IProductionWritePlanService planService;

    @PostMapping("/production-write-plan/add")
    @ApiOperationSupport(order = 1)
    @ApiOperation("计划生产量填报添加")
    public CommonResult add(@RequestBody ProductionWritePlanAddParam param) throws ParseException {
        return planService.add(param);
    }

    @PostMapping("/production-write-plan/edit")
    @ApiOperationSupport(order = 2)
    @ApiOperation("计划生产量填报修改")
    public CommonResult edit(@RequestBody ProductionWritePlan writePlan) {
        return planService.edit(writePlan);
    }

    @PostMapping("/production-write-plan/delete")
    @ApiOperationSupport(order = 3)
    @ApiOperation("计划生产量填报删除")
    public CommonResult delete(@RequestBody Map<String, String> paramsMap) {
        return planService.delete(paramsMap);
    }

    @PostMapping("/production-write-plan/page")
    @ApiOperationSupport(order = 4)
    @ApiOperation("计划生产量填报分页")
    public CommonResult<Page<ProductionWritePlan>> page(@RequestBody ProductionPageParam pageParam) {
        return CommonResult.data(planService.page(pageParam));
    }
}
