mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-13 11:53:48 +00:00
feat(更新日志):
更新日志 1. 移除个人微信模块 2. 移除直播模块 3. 移除gpts模块 4. 移除应用商店模块 5. 移除套餐管理模块 6. 移除兑换管理模块 ## 微信相关 小程序相关功能迁移至企业版 微信公众号/微信机器人迁移至企业版 微信支付迁移至企业版 ## 功能模块 智能体模块迁移至企业版 插件管理改为MCP应用并迁移至企业版 知识库: excel解析迁移至企业版 pdf图片解析迁移至企业版 milvus qdrant扩展 迁移至企业版
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
package org.ruoyi.util;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author https://www.wdbyte.com
|
||||
*/
|
||||
public class KeyUtils {
|
||||
|
||||
public synchronized static String key6() {
|
||||
return RandomStringUtils.randomAlphanumeric(6);
|
||||
}
|
||||
|
||||
public synchronized static String key16() {
|
||||
return RandomStringUtils.randomAlphanumeric(16);
|
||||
}
|
||||
|
||||
public static String uuid32() {
|
||||
return UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package org.ruoyi.util;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.ruoyi.common.core.service.ConfigService;
|
||||
import org.ruoyi.domin.WeixinQrCode;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author https://www.wdbyte.com
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class WeixinApiUtil {
|
||||
|
||||
private final ConfigService configService;
|
||||
|
||||
private static String QR_CODE_URL_PREFIX = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=";
|
||||
|
||||
private static String ACCESS_TOKEN = null;
|
||||
private static LocalDateTime ACCESS_TOKEN_EXPIRE_TIME = null;
|
||||
/**
|
||||
* 二维码 Ticket 过期时间
|
||||
*/
|
||||
private static int QR_CODE_TICKET_TIMEOUT = 10 * 60;
|
||||
|
||||
/**
|
||||
* 获取 access token
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized String getAccessToken() {
|
||||
if (ACCESS_TOKEN != null && ACCESS_TOKEN_EXPIRE_TIME.isAfter(LocalDateTime.now())) {
|
||||
return ACCESS_TOKEN;
|
||||
}
|
||||
String api = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + getKey("appid") + "&secret="
|
||||
+ getKey("secret");
|
||||
String result = HttpUtil.get(api);
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
ACCESS_TOKEN = jsonObject.getString("access_token");
|
||||
ACCESS_TOKEN_EXPIRE_TIME = LocalDateTime.now().plusSeconds(jsonObject.getLong("expires_in") - 10);
|
||||
return ACCESS_TOKEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二维码 Ticket
|
||||
*
|
||||
* https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric_QR_Code.html
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WeixinQrCode getQrCode() {
|
||||
String api = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + getAccessToken();
|
||||
String jsonBody = String.format("{\n"
|
||||
+ " \"expire_seconds\": %d,\n"
|
||||
+ " \"action_name\": \"QR_STR_SCENE\",\n"
|
||||
+ " \"action_info\": {\n"
|
||||
+ " \"scene\": {\n"
|
||||
+ " \"scene_str\": \"%s\"\n"
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ "}", QR_CODE_TICKET_TIMEOUT, KeyUtils.uuid32());
|
||||
String result = HttpUtil.post(api, jsonBody);
|
||||
log.info("get qr code params:{}", jsonBody);
|
||||
log.info("get qr code result:{}", result);
|
||||
WeixinQrCode weixinQrCode = JSON.parseObject(result, WeixinQrCode.class);
|
||||
weixinQrCode.setQrCodeUrl(QR_CODE_URL_PREFIX + URI.create(weixinQrCode.getTicket()).toASCIIString());
|
||||
return weixinQrCode;
|
||||
}
|
||||
|
||||
public String getKey(String key) {
|
||||
return configService.getConfigValue("weixin", key);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package org.ruoyi.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.ruoyi.domin.ReceiveMessage;
|
||||
|
||||
/**
|
||||
* @author https://www.wdbyte.com
|
||||
*/
|
||||
public class WeixinMsgUtil {
|
||||
|
||||
// 事件-关注
|
||||
private static String EVENT_SUBSCRIBE = "subscribe";
|
||||
|
||||
/**
|
||||
* 微信消息转对象
|
||||
*
|
||||
* @param xml
|
||||
* @return
|
||||
*/
|
||||
public static ReceiveMessage msgToReceiveMessage(String xml) {
|
||||
JSONObject jsonObject = JSON.parseObject(XmlUtil.xml2json(xml));
|
||||
ReceiveMessage receiveMessage = new ReceiveMessage();
|
||||
receiveMessage.setToUserName(jsonObject.getString("ToUserName"));
|
||||
receiveMessage.setFromUserName(jsonObject.getString("FromUserName"));
|
||||
receiveMessage.setCreateTime(jsonObject.getString("CreateTime"));
|
||||
receiveMessage.setMsgType(jsonObject.getString("MsgType"));
|
||||
receiveMessage.setContent(jsonObject.getString("Content"));
|
||||
receiveMessage.setMsgId(jsonObject.getString("MsgId"));
|
||||
receiveMessage.setEvent(jsonObject.getString("Event"));
|
||||
receiveMessage.setTicket(jsonObject.getString("Ticket"));
|
||||
return receiveMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是订阅事件
|
||||
*
|
||||
* @param receiveMessage
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEventAndSubscribe(ReceiveMessage receiveMessage) {
|
||||
return StringUtils.equals(receiveMessage.getEvent(), EVENT_SUBSCRIBE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是二维码扫描事件
|
||||
*
|
||||
* @param receiveMessage
|
||||
* @return
|
||||
*/
|
||||
public static boolean isScanQrCode(ReceiveMessage receiveMessage) {
|
||||
return StringUtils.isNotEmpty(receiveMessage.getTicket());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扫描的二维码 Ticket
|
||||
*
|
||||
* @param receiveMessage
|
||||
* @return
|
||||
*/
|
||||
public static String getQrCodeTicket(ReceiveMessage receiveMessage) {
|
||||
return receiveMessage.getTicket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package org.ruoyi.util;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* 微信二维码缓存工具类
|
||||
*
|
||||
* @author https://www.wdbyte.com
|
||||
*/
|
||||
public class WeixinQrCodeCacheUtil {
|
||||
private static long MAX_CACHE_SIZE = 10000;
|
||||
private static LinkedHashMap<String, String> QR_CODE_TICKET_MAP = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* 增加一个 Ticket
|
||||
* 首次 put:value 为 ""
|
||||
* 再次 put: value 有 openId,若openId已经存在,则已被扫码
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public synchronized static void put(String key, String value) {
|
||||
QR_CODE_TICKET_MAP.put(key, value);
|
||||
if (QR_CODE_TICKET_MAP.size() > MAX_CACHE_SIZE) {
|
||||
String first = QR_CODE_TICKET_MAP.keySet().stream().findFirst().get();
|
||||
QR_CODE_TICKET_MAP.remove(first);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static String get(String key) {
|
||||
return QR_CODE_TICKET_MAP.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package org.ruoyi.util;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @author https://www.wdbyte.com
|
||||
*/
|
||||
@Slf4j
|
||||
public class XmlUtil {
|
||||
|
||||
public static String xml2json(String requestBody) {
|
||||
requestBody = StringUtils.trim(requestBody);
|
||||
XmlMapper xmlMapper = new XmlMapper();
|
||||
JsonNode node = null;
|
||||
try {
|
||||
node = xmlMapper.readTree(requestBody.getBytes());
|
||||
ObjectMapper jsonMapper = new ObjectMapper();
|
||||
return jsonMapper.writeValueAsString(node);
|
||||
} catch (Exception e) {
|
||||
log.error("xml 2 json error,msg:" + e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user