package com.kcim.web;

import com.kcim.common.util.Result;
import com.kcim.dao.model.FreeCostMap;
import com.kcim.service.FreeCostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-04-03 14:17
 **/
@Api(tags = "闲置成本功能")
@AllArgsConstructor
@RequestMapping("freeCost")
@RestController
public class FreeCostController {

    FreeCostService freeCostService;

    @ApiOperation("闲置成本设置-获取列表")
    @GetMapping("getList")
    public Result getList(@RequestParam(required = false) String filter){
        return Result.ok(freeCostService.getList(filter));
    }

    @ApiOperation("闲置成本设置-新增")
    @PostMapping("addFreeCost")
    public Result addFreeCost(@RequestBody FreeCostMap freeCostMap){
        freeCostService.addFreeCost(freeCostMap);
        return Result.ok();
    }

    @ApiOperation("闲置成本设置-编辑")
    @PostMapping("editFreeCost")
    public Result editFreeCost(@RequestBody FreeCostMap freeCostMap){
        freeCostService.editFreeCost(freeCostMap);
        return Result.ok();
    }

    @ApiOperation("闲置成本设置-删除")
    @PostMapping("deleteFreeCost")
    public Result deleteFreeCost(@RequestParam Integer id){
        freeCostService.deleteFreeCost(id);
        return Result.ok();
    }

    @ApiOperation("闲置成本设置-获取成本项目")
    @GetMapping("getAccountList")
    public Result getAccountList(@RequestParam(required = false)String filter ){
        return Result.ok(freeCostService.getAccountList(filter));
    }

    @ApiOperation("闲置成本设置-获取分摊参数")
    @GetMapping("getShareParamList")
    public Result getShareParamList(@RequestParam(required = false)String filter ){
        return Result.ok(freeCostService.getShareParamList(filter));
    }

    @ApiOperation("闲置成本设置-获取责任中心")
    @GetMapping("getResponsibilityList")
    public Result getResponsibilityList(@RequestParam(required = false)String filter ){
        return Result.ok(freeCostService.getResponsibilityList(filter));
    }

    @ApiOperation("闲置成本-计算闲置成本")
    @PostMapping("computeFreeCost")
    public Result computeFreeCost(@RequestParam String computeDate ){
        freeCostService.computeFreeCost(computeDate);
        return Result.ok();
    }
}
