package com.srs.web.controller.common;

import com.alibaba.fastjson2.JSONObject;
import com.srs.common.utils.WeChatUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/wechat")
public class WeChatController {

    @Autowired
    private WeChatUtil weChatUtil;

    /**
     * 获取微信 JS-SDK 配置
     */
    @GetMapping("/getWxConfig/{type}")
    public JSONObject getWxConfig(@PathVariable String type, @RequestParam String url) {
        return weChatUtil.generateSignature(type, url);
    }

    // 获取扣子的access_token，返给前端
    @GetMapping("/getAccessToken")
    public String getAccessToken() {
        return weChatUtil.getAccessToken();
    }

}

