package com.yonge.cooleshow.tenant.controller;

import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
import com.yonge.cooleshow.auth.api.entity.SysUser;
import com.yonge.cooleshow.biz.dal.queryInfo.SysMusicCompareRecordQueryInfo;
import com.yonge.cooleshow.biz.dal.service.SysMusicCompareRecordService;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.yonge.toolset.base.page.PageInfo;
import io.swagger.annotations.Api;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "机构端训练记录")
@RequestMapping("${app-config.url.tenant:}/wechatMusicCompareRecord")
@RestController
public class WechatMusicCompareRecordController extends BaseController {

    @Autowired
    private SysUserFeignService sysUserFeignService;
    @Autowired
    private SysMusicCompareRecordService sysMusicCompareRecordService;


    @ApiOperation("学员评测记录")
    @PostMapping("queryStudentTrain")
    public HttpResponseResult<PageInfo<SysMusicCompareRecordQueryInfo.StudentMusicCompareRecord>>
    queryStudentTrain(SysMusicCompareRecordQueryInfo.StudentMusicCompareRecordQuery query){
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            return failed("获取用户信息失败");
        }
        query.setTenantId(sysUser.getTenantId());
        return succeed(sysMusicCompareRecordService.queryStudentTrain(query));
    }


    @ApiOperation("学员训练统计以及基本信息查询")
    @PostMapping("studentTrainStat")
    public HttpResponseResult<SysMusicCompareRecordQueryInfo.StudentMusicCompareRecordStat>
    studentMusicCompareRecordStat(SysMusicCompareRecordQueryInfo.StudentMusicCompareRecordQuery query){
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            return failed("获取用户信息失败");
        }
        query.setTenantId(sysUser.getTenantId());
        return succeed(sysMusicCompareRecordService.studentMusicCompareRecordStat(query));
    }

}
