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.CustomPricePlanService;
import com.tofly.xrtygis.entity.Costbgprice;
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/22
 */
@RestController
@RequestMapping("/pricePlan")
@Api(tags = "计划管理-指标单价")
@AllArgsConstructor
public class CustomPricePlanController {

    private CustomPricePlanService customPricePlanService;

    /**
     * 添加预算单价计划
     *
     * @param costbgprice 预算指标单价信息
     * @return true
     */
    @PostMapping("/insetPlan")
    @ApiOperation("添加预算单价")
    public ResultRespone insetPricePlan(@RequestBody Costbgprice costbgprice) {
        return ResultRespone.success(customPricePlanService.insetPricePlan(costbgprice));
    }

    @GetMapping("/viewNewPlan")
    @ApiOperation("查询最新单价信息")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "year",value = "年份xxxx",dataType = "string")
    )
    public ResultRespone viewNewPlan(Page page,String year){
        return ResultRespone.success(customPricePlanService.viewNewPlan(page,year));
    }

    @GetMapping("/viewHistoryPlan")
    @ApiOperation("查询历史单价信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "year",value = "年份xxxx",required = true,dataType = "string"),
            @ApiImplicitParam(name = "start",value = "开始时间（精确到秒）",dataType = "string"),
            @ApiImplicitParam(name = "end",value = "结束时间（精确到秒）",dataType = "string")
    })
    public ResultRespone viewHistoryPlan(Page page,String year,String start,String end){
        return ResultRespone.success(customPricePlanService.viewHistoryPlan(page,year,start,end));
    }



    @DeleteMapping("/deletePlan")
    @ApiOperation("删除计划")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "id", value = "计划id", required = true, dataType = "long")
    )
    public ResultRespone deletePlan(String id) {
        return ResultRespone.success(customPricePlanService.deletePlan(id));
    }

    @PutMapping("/updatePlanInfo")
    @ApiOperation("修改计划详情")
    public ResultRespone updatePlanInfo(@RequestBody Costbgprice costbgprice){
        return ResultRespone.success(customPricePlanService.updatePlan(costbgprice));
    }


}
