package jnpf.cultivate.v2.controller.web.common;

import jnpf.base.ActionResult;
import jnpf.cultivate.v2.service.V2CultivateCommonSettingGlobalService;
import jnpf.model.cultivate.dto.FtbCultivateCommonSettingGlobalDTO;
import jnpf.model.cultivate.vo.FtbCultivateCommonSettingGlobalVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * web培训通用配置模块
 *
 * @author xgl
 * @date 2026/02/11
 */
@RestController
@RequestMapping("/v2/web/cultivate/common/setting")
public class V2CultivateCommonSettingGlobalController {

    @Autowired
    private V2CultivateCommonSettingGlobalService ftbCultivateCommonSettingGlobalService;

    /**
     * 获取培训通用配置信息
     *
     * @return {@link ActionResult}<{@link FtbCultivateCommonSettingGlobalVO}>
     */
    @GetMapping("/info")
    public ActionResult<FtbCultivateCommonSettingGlobalVO> getInfo() {
        return ActionResult.success(ftbCultivateCommonSettingGlobalService.getInfo());
    }

    /**
     * 提交培训通用配置
     *
     * @param req 配置信息
     * @return {@link ActionResult}
     */
    @PostMapping("/update")
    public ActionResult<Void> update(@RequestBody @Valid FtbCultivateCommonSettingGlobalDTO req) {
        ftbCultivateCommonSettingGlobalService.update(req);
        return ActionResult.success("提交成功");
    }
}