package com.ruoyi.web.controller.weChat;

import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.weChat.service.WeChatService;
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
@RequestMapping("/system/weChat")
public class WeChatController {

    @Autowired
    private WeChatService weChatService;
    @Autowired
    private ISysUserService userService;


    /**
     * 获取accessToken
     * @return
     */
    @GetMapping("/getAccessToken")
    public AjaxResult getAccessToken() {
        return AjaxResult.success("200",weChatService.getAccessToken());
    }

    /**
     * 获取openId
     * @return
     */
    @GetMapping("/getOpenId")
    public AjaxResult getOpenId(String code) {
        String openId=userService.setOpenId(code);
        return AjaxResult.success("200",openId);
    }




}
