package com.fs.app.controller;

import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.R;
import com.fs.common.exception.CustomException;
import com.fs.statistics.dto.WatchCourseStatisticsDTO;
import com.fs.statistics.param.WatchCourseStatisticsParam;
import com.fs.statistics.service.IStatisticsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * 企微统计数据
 */
@RestController
@RequestMapping("/app/qw/statistics")
public class QwStatisticsController extends BaseController {
    @Autowired
    private IStatisticsService statisticsService;


//    @Login
    @PostMapping("/course/watch")
    @ApiOperation("会员看课详情")
    public R queryCourseWatchStatistics(@RequestBody WatchCourseStatisticsParam param) {
        if(param.getQwExternalContactId() == null) {
            throw new CustomException("外部联系人id为空！");
        }

        WatchCourseStatisticsDTO watchCourseStatisticsDTO = statisticsService.queryWatchCourse(param);

        return R.ok().put("data",watchCourseStatisticsDTO);
    }

}
