package com.ruoyi.wx.web.controller;


import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.service.WxLoginService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
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;

/**
 * 登录服务
 */
@Tag(name = "登录服务")
@RestController
@RequestMapping("/wx")
@Slf4j
public class WxLoginController {
    @Autowired
    private WxLoginService wxLoginService;

    @ApiOperation("微信小程序登录")
    @GetMapping("/login")
    public AjaxResult minLogin(String code){
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = wxLoginService.minLogin(code);
        ajax.put(Constants.TOKEN, token);
        return ajax;
    }

}
