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.entity.dto.CostbgWaterDto;
import com.tofly.xrtygis.custom.service.CustomWaterPlanService;
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-17
 */
@RestController
@Api(tags = "计划管理-水量计划")
@AllArgsConstructor
@RequestMapping("/waterPlan")
public class CustomWaterPlanController {

    private final CustomWaterPlanService customWaterPlanService;

    /**
     * 新增计划
     *
     * @param year 年份
     * @return true
     */
    @PostMapping("/insertPlan")
    @ApiOperation("新增年份计划")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "string")
    )
    public ResultRespone insertPlan(String year) {
        return ResultRespone.success(customWaterPlanService.insertPlan(year));
    }

    /**
     * 预算水量填报
     *
     * @param costbgwaters list
     * @return true
     */
    @ApiOperation("预算水量填报")
    @PostMapping("/fillInTheBudget")
    public ResultRespone fillInTheBudget(@RequestBody CostbgWaterDto costbgwaters) {
        return ResultRespone.success(customWaterPlanService.fillInTheBudget(costbgwaters));
    }

    /**
     * 当前用户查看自己所创建计划
     *
     * @param page  page
     * @param year  年份
     * @param state 状态
     * @return page
     */
    @GetMapping("/pagePlan")
    @ApiOperation("查看创建计划")
    public ResultRespone pagePlan(Page page, String year, String state) {
        return ResultRespone.success(customWaterPlanService.pagePlan(page, year, state));
    }

    /**
     * 查看预算计划详情
     *
     * @param id 年份id
     * @return list
     */
    @GetMapping("/selectPlanInfo")
    @ApiOperation("查看预算计划详情")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "id", value = "年份id", required = true, dataType = "long")
    )
    public ResultRespone selectPlanInfo(Long id) {
        return ResultRespone.success(customWaterPlanService.selectPlanInfo( id));
    }

    /**
     * 删除预算计划
     *
     * @param id 计划id
     * @return true
     */
    @DeleteMapping("/deletePlan")
    @ApiOperation("删除预算计划")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "id",value = "计划id 多个，分隔",required = true,dataType = "string")
    )
    public ResultRespone deletePlan(String id) {
        return ResultRespone.success(customWaterPlanService.deletePlan(id));
    }

    /**
     * 修改计划详情
     *
     * @param costbgWaterDto vo
     * @return true
     */
    @PutMapping("/updatePlanInfo")
    @ApiOperation("修改计划详情")
    public ResultRespone updatePlanInfo(@RequestBody CostbgWaterDto costbgWaterDto) {
        return ResultRespone.success(customWaterPlanService.updatePlanInfo(costbgWaterDto));
    }

}
