package com.miaxis.app.controller.tms;


import com.miaxis.common.constant.Constants;
import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.core.domain.Response;
import com.miaxis.common.core.page.ResponsePageInfo;
import com.miaxis.tms.dto.TmsStudentInfoDTO;
import com.miaxis.tms.dto.TmsStudentInfoIdDTO;
import com.miaxis.tms.dto.TmsStudentInfoQrDTO;
import com.miaxis.tms.service.ITmsStudentInfoService;
import com.miaxis.tms.vo.TmsStudentInfoIdVo;
import com.miaxis.tms.vo.TmsStudentInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 学员基本信息表 前端控制器
 * </p>
 *
 * @since 2021-03-09
 */
@RestController
@Api(tags = "【app-教练端-学员接口】")
@RequestMapping(Constants.OPEN_PREFIX + "/tms/coachInfo")
public class TmsStudentInfoController extends BaseController {

    @Autowired
    private ITmsStudentInfoService studentInfoService;

    /**
     * 查询学员信息列表
     */
    @GetMapping("/list")
    @ApiOperation("查询学员信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<TmsStudentInfoVo> list(@ModelAttribute TmsStudentInfoDTO studentInfoDTO) throws Exception {
        startPage();
        List<TmsStudentInfoVo> stuInfoList = studentInfoService.getTmsStudentInfoList(studentInfoDTO);
        return toResponsePageInfo(stuInfoList);
    }


    /**
     * 获取用户id获取详细信息
     */
    @GetMapping("/getTmsStudentInfoById")
    @ApiOperation("根据ID获取学员员详细信息")
    public Response<TmsStudentInfoIdVo> getTmsStudentInfoById(TmsStudentInfoIdDTO studentInfoIdDTO) {
        return Response.success(studentInfoService.getTmsStudentInfoById(studentInfoIdDTO));
    }



    /**
     * 绑定IP
     */
    @GetMapping("/updateStudentAppCoachIdById")
    @ApiOperation("根据ID获取学员员详细信息")
    public Response updateStuAppCoachIdById(TmsStudentInfoQrDTO studentInfoQrDTO) {
        studentInfoService.upStuAppCoachIdById(studentInfoQrDTO);
        return Response.success();
    }

}














