package com.dsk.cscec.controller;

import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.R;
import com.dsk.common.helper.LoginHelper;
import com.dsk.cscec.domain.CbSceneExpenseChildren;
import com.dsk.cscec.domain.bo.CbSceneExpenseChildrenDataBo;
import com.dsk.cscec.domain.bo.CbSceneExpenseMonthBo;
import com.dsk.cscec.domain.vo.CbSceneExpenseMenuVo;
import com.dsk.cscec.service.CbSceneExpenseChildrenService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 现场经费-工资统筹、其他费用、现场管理费表(CbSceneExpenseChildren)表控制层
 *
 * @author sxk
 * @since 2024-02-22 09:58:57
 */
@RestController
@RequestMapping("cbSceneExpenseChildren")
public class CbSceneExpenseChildrenController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private CbSceneExpenseChildrenService baseService;

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

    /**
     * 现场经费二级分类数据解析
     */
    @GetMapping("/parseChildrenData/{projectId}")
    public R<Void> parseSceneExpenseChildrenData(@PathVariable Long projectId) throws Exception {
        String username = Objects.requireNonNull(LoginHelper.getLoginUser()).getUsername();
        baseService.parseSceneExpenseChildrenData(projectId, 1, username);
        return R.ok();
    }

    /**
     * 获取现场经费二级分类数据
     */
    @GetMapping("/getChildrenData")
    public R<List<CbSceneExpenseChildren>> getChildrenData(@Validated CbSceneExpenseChildrenDataBo childrenDataBo) {
        return R.ok(baseService.getChildrenData(childrenDataBo));
    }

    /**
     * 获取现场经费已添加成本数据月份
     */
    @GetMapping("/getMonthList/")
    public R<List<String>> getMonthList(@Validated CbSceneExpenseMonthBo monthBo) {
        return baseService.getMonthList(monthBo);
    }
}