package com.miaxis.app.controller.wx;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.domain.entity.UserInfo;
import com.miaxis.common.utils.SecurityUtils;
import com.miaxis.user.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequiredArgsConstructor
@RequestMapping(Constants.STUDENT_PREFIX+"/user")
@Api(tags = {"【H5-用户信息】"})
@Slf4j
public class UserInfoController extends BaseController {

    @Autowired
    private IUserInfoService userInfoService;



    @GetMapping(value = "/info")
    @ApiOperation("获取用户信息")
    public Response<UserInfo> getInfo(){
        String openid = SecurityUtils.getLoginUser().getStudent().getOpenid();
        return Response.success(userInfoService.getOne(new QueryWrapper<UserInfo>().eq("openid",openid)));
    }











}
