package com.dsk.cscec.controller;


import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.R;
import com.dsk.cscec.domain.bo.CbSummaryActualBo;
import com.dsk.cscec.domain.bo.CbSummaryActualListBo;
import com.dsk.cscec.domain.bo.CbSummaryBo;
import com.dsk.cscec.service.CbSummaryService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 成本汇总(CbSummary)表控制层
 *
 * @author cyf
 * @since 2024-02-06
 */
@RestController
@RequestMapping("/cbSummary")
public class CbSummaryController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private CbSummaryService cbSummaryService;


    /**
     * 成本汇总左侧列表
     *
     * @param bo
     * @return
     */
    @GetMapping("/cbNameList")
    public R<List<Map<String, Object>>> getCbNameList(CbSummaryBo bo) {
        return R.ok(cbSummaryService.getCbNameList(bo));
    }

    //成本汇总数据列表
    @GetMapping("/list")
    public R getList(CbSummaryActualListBo bo) {
        return R.ok(cbSummaryService.getActualList(bo));
    }

    /**
     * 已添加成本月份
     *
     * @param bo
     * @return
     */
    @GetMapping("/expenseDateList")
    public R<List<String>> getExpenseDateList(@Validated CbSummaryBo bo) {
        return R.ok(cbSummaryService.getExpenseDateList(bo));
    }

    /**
     * 编辑成本
     *
     * @param boList
     * @return
     */
    @PutMapping("/editActual")
    public R editActual(@RequestBody List<CbSummaryActualBo> boList) {
        return cbSummaryService.insertOrUpdateActual(boList) == true ? R.ok() : R.fail();
    }

    //锁定成本-至少有一条实际数据？

    //导出excel-缺模板
}
