package com.tofly.xrtygis.custom.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.xrtygis.custom.service.CustomPriceService;
import com.tofly.xrtygis.entity.Costrlprice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**制水成本
 * @author 陈浩
 * @date 2021-3-24
 */
@RestController
@RequestMapping("/customPrice")
@Api(tags = "实际管理-指标单价")
@AllArgsConstructor
public class CustomPriceController {

    private final CustomPriceService customPriceService;

    @PostMapping("/insertPrice")
    @ApiOperation("添加指标单价")
    public ResultRespone insertPrice(@RequestBody Costrlprice costrlprice) {
        return ResultRespone.success(customPriceService.insertPrice(costrlprice));
    }

    @DeleteMapping("/deletePrice")
    @ApiOperation("删除指标单价")
    public ResultRespone deletePrice(String id) {
        return ResultRespone.success(customPriceService.deletePrice(id));
    }

    @PutMapping("/updatePrice")
    @ApiOperation("修改指标单价")
    public ResultRespone updatePrice(Costrlprice costrlprice) {
        return ResultRespone.success(customPriceService.updatePrice(costrlprice));
    }

    @GetMapping("/viewPrice")
    @ApiOperation("查询某年指标单价历史记录")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "year",value = "年份",required = true,dataType = "string")
    )
    public ResultRespone viewPrice(Page page, String year, String start, String end) {
        return ResultRespone.success(customPriceService.viewPrice(page, year,start,end));
    }
    @GetMapping("/viewNewPrice")
    @ApiOperation("查询某年最新指标单价")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "year",value = "年份",dataType = "string")
    )
    public ResultRespone viewNewPrice(Page page,String year){
        return ResultRespone.success(customPriceService.viewNewPrice(page,year));
    }

}
