package com.yida.data.school.secondClass.controller;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.school.dto.secondClass.SaveHomeInfoDTO;
import com.yida.data.school.secondClass.service.EduSecondClassContentService;
import com.yida.data.school.vo.secondClass.HomeInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "第二课堂")
@Slf4j
@RestController
@RequestMapping("/secondClass/content")
@RequiredArgsConstructor
public class EduSecondClassContentController {

    private final EduSecondClassContentService eduSecondClassContentService;

    @ApiOperation("查询主页信息")
    @GetMapping("/getHomeInfo")
    public ResultBean<HomeInfoVO> getHomeInfo(@ApiParam("0-主页，1-场馆，2-平台，3-课程") Integer type) {
        Long deptId = FebsUtil.getTopDeptId();
        return ResultBean.buildSuccess(eduSecondClassContentService.getHomeInfo(deptId, type));
    }

    @ApiOperation("保存主页信息")
    @PostMapping("/saveHomeInfo")
    public ResultBean saveHomeInfo(@RequestBody SaveHomeInfoDTO dto) {
        eduSecondClassContentService.saveHomeInfo(dto, FebsUtil.getTopDeptId());
        return ResultBean.buildSuccess();
    }

}
