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

import jnpf.base.ActionResult;
import jnpf.cultivate.v2.service.FtbCultivateCourseSettingGlobalService;
import jnpf.model.cultivate.dto.FtbCultivateCourseSettingGlobalDTO;
import jnpf.model.cultivate.po.FtbCultivateCourseSettingGlobal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * web课程全局配置模块
 *
 * @author xgl
 */
@RestController
@RequestMapping("/v2/web/course/setting")
public class FtbCultivateCourseSettingGlobalController {

    @Autowired
    private FtbCultivateCourseSettingGlobalService ftbCultivateCourseSettingGlobalService;

    /**
     * 获取课程配置信息
     *
     * @return {@link ActionResult}<{@link FtbCultivateCourseSettingGlobal}>
     */
    @GetMapping("/info")
    public ActionResult<FtbCultivateCourseSettingGlobal> getInfo() {
        return ActionResult.success(ftbCultivateCourseSettingGlobalService.getInfo());
    }

    /**
     * 提交课程配置
     *
     * @param req 课程配置信息
     * @return {@link ActionResult}
     */
    @PostMapping("/update")
    public ActionResult<Void> update(@RequestBody @Valid FtbCultivateCourseSettingGlobalDTO req) {
        ftbCultivateCourseSettingGlobalService.update(req);
        return ActionResult.success("提交成功");
    }
}