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.ProductionEnergy;
import vip.xiaonuo.production.entity.ProductionEnergyPrice;
import vip.xiaonuo.production.param.ProductionEnergyParam;
import vip.xiaonuo.production.param.ProductionPageParam;
import vip.xiaonuo.production.service.IProductionEnergyPriceService;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 能耗单价表填报 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-01
 */
@RestController
@Api(tags = "能耗单价表填报")
@ApiSupport(author = "wang", order = 1)
@Validated
public class ProductionEnergyPriceController {

    @Autowired
    private IProductionEnergyPriceService priceService;

    @PostMapping("/production-energy-price/getList")
    @ApiOperationSupport(order = 1)
    @ApiOperation("能耗单价表填报添加或修改")
    public CommonResult<CommonResult> addAndEdit(@RequestBody ProductionEnergyPrice energyPrice) {
        return CommonResult.data(priceService.addAndEdit(energyPrice));
    }


    @PostMapping("/production-energy-price/page")
    @ApiOperationSupport(order = 2)
    @ApiOperation("能耗单价表填报分页")
    public CommonResult<Page<ProductionEnergyPrice>> page(@RequestBody ProductionPageParam pageParam) {
        return CommonResult.data(priceService.page(pageParam));
    }

    @PostMapping("/production-energy-price/update")
    @ApiOperationSupport(order = 3)
    @ApiOperation("能耗单价表填报修改")
    public CommonResult<CommonResult> update(@RequestBody ProductionEnergyPrice energyPrice) {
        return CommonResult.data(priceService.update(energyPrice));
    }

    @PostMapping("/production-energy-price/delete")
    @ApiOperationSupport(order = 4)
    @ApiOperation("能耗单价表填报删除")
    public CommonResult<CommonResult> delete(@RequestBody Map<String,String> paramsMap) {
        return CommonResult.data(priceService.delete(paramsMap));
    }
}
