package com.ruoyi.web.controller.business.api.open;

import com.ruoyi.business.service.IAiUserinfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@Api(tags = "用户开放接口", value = "用户开放接口")
@RequestMapping("/open/wx")
@RestController
@Validated
public class AiUserinfoApi extends BaseController {

    private final IAiUserinfoService aiUserinfoService;

    public AiUserinfoApi(IAiUserinfoService aiUserinfoService) {
        this.aiUserinfoService = aiUserinfoService;
    }

    @ApiOperation("获取临时会话凭证")
    @PostMapping("/login")
    public AjaxResult login(String appid, String code) {
        String loginState = aiUserinfoService.handleCode(appid, code);
        return AjaxResult.success("获取临时会话凭证成功", loginState);
    }


}
