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.AddCbDirectExpenseBo;
import com.dsk.cscec.domain.vo.CbDirectExpenseDataDetailVo;
import com.dsk.cscec.domain.vo.CbDirectExpenseMenuVo;
import com.dsk.cscec.service.CbDirectExpenseService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 直接费成本表(CbDirectExpense)表控制层
 *
 * @author sxk
 * @since 2024-02-05 14:43:31
 */
@RestController
@RequestMapping("cbDirectExpense")
public class CbDirectExpenseController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private CbDirectExpenseService baseService;

    /**
     * 获取直接费菜单
     */
    @GetMapping("/getMenuList/{projectId}")
    public R<CbDirectExpenseMenuVo> getMenuList(@NotNull(message = "项目ID不能为空") @PathVariable Long projectId) {
        return R.ok(baseService.getMenuList(projectId));
    }

    /**
     * 直接费数据解析
     */
    @GetMapping("/parseDirectExpenseData/{projectId}")
    public R<Void> parseDirectExpenseData(@PathVariable Long projectId) throws Exception {
        baseService.parseDirectExpenseData(projectId, 1);
        return R.ok();
    }

    /**
     * 获取直接费数据详情
     */
    @GetMapping("/getDataDetail/{menuId}")
    public R<List<CbDirectExpenseDataDetailVo>> getDataDetail(@NotNull(message = "菜单ID不能为空") @PathVariable Long menuId) {
        return R.ok(baseService.getDataDetail(menuId));
    }

    /**
     * 新增直接费费用项
     */
    @PostMapping("/addExpense")
    public R<Void> addExpense(@Validated @RequestBody AddCbDirectExpenseBo addBo) {
        return toAjax(baseService.addExpense(addBo));
    }

    /***
     * 删除直接费费用项
     */
    @GetMapping("/deleteExpense/{id}")
    public R<Void> deleteExpense(@NotNull(message = "ID不能为空") @PathVariable Long id) {
        return toAjax(baseService.deleteExpense(id));
    }

}

