mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-11 10:37:20 +00:00
feat(知识库): 增加知识库模块
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
package com.xmzs.common.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 支付配置信息
|
||||
*
|
||||
* @author Admin
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "pay")
|
||||
public class PayConfig {
|
||||
|
||||
/**
|
||||
* 商户ID
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 接口地址
|
||||
*/
|
||||
private String payUrl;
|
||||
|
||||
/**
|
||||
* 私钥
|
||||
*/
|
||||
private String key ;
|
||||
|
||||
/**
|
||||
* 服务器异步通知地址
|
||||
*/
|
||||
private String notify_url;
|
||||
|
||||
/**
|
||||
* 页面跳转通知地址
|
||||
*/
|
||||
private String return_url;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String device;
|
||||
|
||||
/**
|
||||
* 加密方式默认MD5
|
||||
*/
|
||||
private String sign_type;
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.xmzs.common.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 支付结果响应
|
||||
*
|
||||
* @author: wangle
|
||||
* @date: 2023/7/3
|
||||
*/
|
||||
@Data
|
||||
public class PayResponse {
|
||||
|
||||
/**
|
||||
* 商户ID
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 易支付订单号
|
||||
*/
|
||||
|
||||
@JsonProperty("trade_no")
|
||||
private String trade_no;
|
||||
|
||||
/**
|
||||
* 商户订单号
|
||||
*/
|
||||
@JsonProperty("out_trade_no")
|
||||
private String out_trade_no;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品金额
|
||||
*/
|
||||
private String money;
|
||||
|
||||
/**
|
||||
* 支付状态
|
||||
*/
|
||||
@JsonProperty("trade_status")
|
||||
private String trade_status;
|
||||
|
||||
/**
|
||||
* 业务扩展参数
|
||||
*/
|
||||
private String param;
|
||||
|
||||
/**
|
||||
* 签名字符串
|
||||
*/
|
||||
private String sign;
|
||||
|
||||
/**
|
||||
* 签名类型
|
||||
*/
|
||||
@JsonProperty("sign_type")
|
||||
private String signType;
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.xmzs.common.service;
|
||||
|
||||
/**
|
||||
* 支付服务
|
||||
*
|
||||
* @author: wangle
|
||||
* @date: 2023/7/3
|
||||
*/
|
||||
public interface PayService {
|
||||
|
||||
/**
|
||||
* 获取支付地址
|
||||
*
|
||||
* @Date 2023/7/3
|
||||
* @param orderNo
|
||||
* @param name
|
||||
* @param money
|
||||
* @param clientIp
|
||||
* @return String
|
||||
**/
|
||||
String getPayUrl(String orderNo, String name, double money, String clientIp);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.xmzs.common.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
|
||||
import com.xmzs.common.config.PayConfig;
|
||||
import com.xmzs.common.service.PayService;
|
||||
import com.xmzs.common.utils.MD5Util;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付服务
|
||||
* @author Admin
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class PayServiceImpl implements PayService {
|
||||
|
||||
private final PayConfig payConfig;
|
||||
@Override
|
||||
public String getPayUrl(String orderNo, String name, double money, String clientIp) {
|
||||
String out_trade_no = orderNo, sign = "";
|
||||
//封装请求参数
|
||||
String mdString = "clientip=" + clientIp + "&device=" + payConfig.getDevice() + "&money=" + money + "&name=" + name + "&" +
|
||||
"notify_url=" + payConfig.getNotify_url() + "&out_trade_no=" + out_trade_no + "&pid=" + payConfig.getPid() + "&return_url=" + payConfig.getReturn_url() +
|
||||
"&type=" + payConfig.getType() + payConfig.getKey();
|
||||
sign = MD5Util.GetMD5Code(mdString);
|
||||
Map<String, Object> map = new HashMap<>(10);
|
||||
map.put("clientip", clientIp);
|
||||
map.put("device", payConfig.getDevice());
|
||||
map.put("money", money);
|
||||
map.put("name", name);
|
||||
map.put("notify_url", payConfig.getNotify_url());
|
||||
map.put("out_trade_no", out_trade_no);
|
||||
map.put("pid", payConfig.getPid());
|
||||
map.put("return_url", payConfig.getReturn_url());
|
||||
map.put("sign_type", payConfig.getSign_type());
|
||||
map.put("type", payConfig.getType());
|
||||
map.put("sign", sign);
|
||||
String body = HttpUtil.post(payConfig.getPayUrl(), map);
|
||||
log.info("支付返回信息:{},配置信息: {}",body,payConfig);
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
return (String) jsonObject.get("qrcode");
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package com.xmzs.common.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* MD5 算法
|
||||
*
|
||||
* @author Admin
|
||||
*/
|
||||
public class MD5Util {
|
||||
|
||||
/**
|
||||
* 全局数组
|
||||
*/
|
||||
public final static String[] strDigits = { "0", "1", "2", "3", "4", "5",
|
||||
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
|
||||
|
||||
public MD5Util() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回形式为数字跟字符串
|
||||
*
|
||||
* @Date 2023/7/3
|
||||
* @param bByte
|
||||
* @return String
|
||||
**/
|
||||
public static String byteToArrayString(byte bByte) {
|
||||
int iRet = bByte;
|
||||
if (iRet < 0) {
|
||||
iRet += 256;
|
||||
}
|
||||
int iD1 = iRet / 16;
|
||||
int iD2 = iRet % 16;
|
||||
return strDigits[iD1] + strDigits[iD2];
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换字节数组为16进制字串
|
||||
*
|
||||
* @Date 2023/7/3
|
||||
* @param bByte
|
||||
* @return String
|
||||
**/
|
||||
public static String byteToString(byte[] bByte) {
|
||||
StringBuffer sBuffer = new StringBuffer();
|
||||
for (int i = 0; i < bByte.length; i++) {
|
||||
sBuffer.append(byteToArrayString(bByte[i]));
|
||||
}
|
||||
return sBuffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成md5代码
|
||||
*
|
||||
* @Date 2023/7/3
|
||||
* @param strObj
|
||||
* @return String
|
||||
**/
|
||||
public static String GetMD5Code(String strObj) {
|
||||
String resultString = null;
|
||||
try {
|
||||
resultString = new String(strObj);
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
resultString = byteToString(md.digest(strObj.getBytes()));
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return resultString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装签名的字段
|
||||
*
|
||||
* @param params 参数
|
||||
* @param urlEncoder 是否urlEncoder
|
||||
* @return {String}
|
||||
*/
|
||||
public static String packageSign(Map<String, Object> params, boolean urlEncoder) {
|
||||
// 先将参数以其参数名的字典序升序进行排序
|
||||
TreeMap<String, Object> sortedParams = new TreeMap<String, Object>(params);
|
||||
// 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (Map.Entry<String, Object> param : sortedParams.entrySet()) {
|
||||
String value = String.valueOf(param.getValue());
|
||||
if (StrUtil.isBlank(value)) {
|
||||
continue;
|
||||
}
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
sb.append("&");
|
||||
}
|
||||
sb.append(param.getKey()).append("=");
|
||||
sb.append(value);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user