package com.ym.mec.student.controller;

import com.ym.mec.biz.dal.entity.TempLittleArtistTrainingCamp;
import com.ym.mec.biz.dal.vo.*;
import com.ym.mec.biz.service.TempLittleArtistTrainingCampService;
import com.ym.mec.biz.service.TempLittleArtistTrainingCampUserRelationService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.page.PageInfo;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 小小艺术家训练营活动(TempLittleArtistTrainingCamp)表控制层
 *
 * @author hgw
 * @since 2022-05-17 20:56:22
 */
@Api(tags = "小小艺术家训练营活动")
@RestController
@RequestMapping("/tempLittleArtistTrainingCamp")
public class TempLittleArtistTrainingCampController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private TempLittleArtistTrainingCampService tempLittleArtistTrainingCampService;
    @Resource
    private TempLittleArtistTrainingCampUserRelationService tempLittleArtistTrainingCampUserRelationService;

    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", dataType = "String", value = "训练营标题-模糊搜索"),
            @ApiImplicitParam(name = "state", dataType = "String", value = "筹备中 READY,报名中 APPLY,未开始 NOT_START,进行中 ING,已结束 END"),
            @ApiImplicitParam(name = "applyStartDate", dataType = "String", value = "申请报名登记开始日期-年月日"),
            @ApiImplicitParam(name = "applyEndDate", dataType = "String", value = "申请报名登记结束日期-年月日"),
            @ApiImplicitParam(name = "trainStartDate", dataType = "String", value = "训练开始日期-年月日"),
            @ApiImplicitParam(name = "trainEndDate", dataType = "String", value = "训练结束日期-年月日"),
            @ApiImplicitParam(name = "page", dataType = "Integer", required = true, value = "页数"),
            @ApiImplicitParam(name = "rows", dataType = "Integer", required = true, value = "每页数量"),
    })
    @ApiOperation("分页查询-训练营列表")
    @PostMapping(value = "/queryPageTrainingCamp")
    public HttpResponseResult<PageInfo<TempLittleArtistTrainingCamp>> queryPageTrainingCamp(@RequestBody Map<String, Object> param) {
        return succeed(tempLittleArtistTrainingCampService.queryPageTrainingCamp(param));
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", dataType = "Integer", required = true, value = "用户id"),
    })
    @ApiOperation("查询指定学生-训练营每日训练时长")
    @PostMapping(value = "/queryUserTrainingTime")
    public HttpResponseResult<List<TempUserTrainingTimeDetailVo>> queryUserTrainingTime(@RequestBody Map<String, Object> param) {
        return succeed(tempLittleArtistTrainingCampService.queryUserTrainingTime(param));
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "search", dataType = "String", value = "学员姓名/手机号/编号-模糊搜索"),
            @ApiImplicitParam(name = "imGroupId", dataType = "Integer", value = "所在群组Id"),
            @ApiImplicitParam(name = "campId", dataType = "Integer", value = "训练营id"),
            @ApiImplicitParam(name = "page", dataType = "Integer", required = true, value = "页数"),
            @ApiImplicitParam(name = "rows", dataType = "Integer", required = true, value = "每页数量"),
    })
    @ApiOperation("分页查询-训练营详情")
    @PostMapping(value = "/queryUserTrainingDetail")
    public HttpResponseResult<PageInfo<TempCampUserTrainingDetailVo>> queryUserTrainingDetail(@RequestBody Map<String, Object> param){
        return succeed(tempLittleArtistTrainingCampService.queryUserTrainingDetail(param));
    }

    /**
     * 查询训练营周期表
     *
     * @return result：
     * <p>user 学员信息
     * <p>campList 训练营信息
     */
    @ApiOperation(value="查询训练营周期表", notes="user 学员信息，campList 训练营信息")
    @GetMapping(value = "/queryCampCycle")
    public HttpResponseResult<Map<String, Object>> queryCampCycle(){
        return succeed(tempLittleArtistTrainingCampService.queryCampCycle());
    }

    @ApiOperation(value="云教练训练是否达标数据查询")
    @GetMapping(value = "/queryUserTrainingPlayTime")
    public HttpResponseResult<TempCampUserTrainingPlayTimeVo> queryUserTrainingPlayTime(){
        return succeed(tempLittleArtistTrainingCampService.queryUserTrainingPlayTime());
    }

    @ApiOperation(value="查询当前登录学生有没有资格参加训练营")
    @GetMapping(value = "/checkCampQualifications")
    public HttpResponseResult<TempCampUserQualificationsVo> checkCampQualifications(){
        return succeed(tempLittleArtistTrainingCampUserRelationService.checkCampQualifications());
    }

    @ApiOperation(value="参与训练营")
    @GetMapping(value = "/addCamp")
    public HttpResponseResult<Object> addCamp(Integer campId){
        tempLittleArtistTrainingCampUserRelationService.add(campId);
        return succeed();
    }

}

