package com.sqx.modules.wxMsg.controller;

import com.jfinal.weixin.sdk.api.ApiResult;
import com.jfinal.weixin.sdk.api.CustomServiceApi;
import com.jfinal.weixin.sdk.api.MenuApi;
import com.jfinal.weixin.sdk.api.QrcodeApi;
import com.sqx.common.utils.Result;
import net.dreamlu.weixin.annotation.WxApi;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *小程序
 */
@WxApi("/weixin/api")
public class WeixinApiController {
    /**
     * 获取临时二维码
     * @param tempId
     * @return Result
     */
    @GetMapping("loginQr")
    @ResponseBody
    public Result loginQr(String tempId) {
        //创建二维码
        ApiResult result = QrcodeApi.createTemporary(300, tempId);
        String ticket = (String) result.getAttrs().get("ticket");
        return Result.success().put("data", QrcodeApi.getShowQrcodeUrl(ticket));
    }


}