package com.miaxis.system.controller.gzpt;


import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.core.domain.Response;
import com.miaxis.common.core.domain.entity.UserInfo;
import com.miaxis.common.core.page.ResponsePageInfo;
import com.miaxis.newgzpt.domain.GzptUserInfo;
import com.miaxis.newgzpt.dto.GzptUserInfoDTO;
import com.miaxis.newgzpt.service.IGzptUserInfoService;
import com.miaxis.system.dto.system.UserInfoDTO;
import com.miaxis.user.service.IUserInfoService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 学员基本信息表 前端控制器
 * </p>
 *
 * @since 2021-03-09
 */
@RestController
@Api(tags = "【小程序-学员基本信息】")
@RequestMapping("/gzpt-user-info")
public class GzptUserInfoController extends BaseController {

    @Autowired
    private IGzptUserInfoService gzptUserInfoService;

    /**
     * 查询用户信息列表
     */
    @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<GzptUserInfo> list(@ModelAttribute GzptUserInfo gzptUserInfo){
        startPage();
        List<GzptUserInfo> list = gzptUserInfoService.getList();
        return toResponsePageInfo(list);
    }


    /**
     * 获取用户id获取详细信息
     */
    @GetMapping(value = "/ids/{id}")
    @ApiOperation("获取学员详细信息")
    public Response<GzptUserInfo> getInfo(
            @ApiParam(name = "id", value = "用户信息参数", required = true)
            @PathVariable("id") Long id
    ){
        return Response.success(gzptUserInfoService.getById(id));
    }


    /**
     * 获取用户id获取详细信息
     */
    @GetMapping(value = "/getUserWxlogin")
    @ApiOperation("根据密码获取学员")
    public Response<GzptUserInfo> getUserWxlogin(@ModelAttribute GzptUserInfoDTO gzptUserInfoDTO){
        return Response.success(gzptUserInfoService.getUserWxlogin(gzptUserInfoDTO));
    }
}

