Merge remote-tracking branch 'origin/dev/dev' into dev/dev_shb

This commit is contained in:
shahaibo
2024-03-27 13:31:08 +08:00
71 changed files with 2960 additions and 232 deletions

View File

@@ -14,6 +14,7 @@ import java.util.concurrent.*;
@Component
public class AsyncCallerUtil {
// 存放状态 表示当前任务是否需要继续等待,默认持续等待
public static Map<String, Boolean> waitingStatus = new HashMap<>();
private static PythonService pythonService;
@@ -58,7 +59,7 @@ public class AsyncCallerUtil {
return null;
} catch (InterruptedException | ExecutionException | BusinessException e) {
// 处理异常
log.error("发生错误 " + e);
log.error("发生错误 " + e, e);
// 取消定时任务
assert timeoutTask != null;
timeoutTask.cancel(true);

View File

@@ -7,8 +7,10 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@@ -17,6 +19,10 @@ public class RedisUtil {
@Resource
private RedisTemplate<String, String> redisTemplate;
public Boolean hasKey(String key){
return redisTemplate.hasKey(key);
}
//- - - - - - - - - - - - - - - - - - - - - ZSet类型 - - - - - - - - - - - - - - - - - - - -
/**
@@ -64,10 +70,15 @@ public class RedisUtil {
/**
* 获取当前ZSet中数据量的总和
*/
public Long getZSetTotal(String key) {
public Long getZSetTotalCount(String key) {
return redisTemplate.opsForZSet().zCard(key);
}
public Set<String> getZSetTotalData(String key){
return redisTemplate.opsForZSet().range(key, 0, -1);
}
//- - - - - - - - - - - - - - - - - - - - - set类型 - - - - - - - - - - - - - - - - - - - -
/**
@@ -123,4 +134,26 @@ public class RedisUtil {
public Long removeFromMap(String key, String hashKeys) {
return redisTemplate.opsForHash().delete(key, hashKeys);
}
//- - - - - - - - - - - - - - - - - - - - - String类型 - - - - - - - - - - - - - - - - - - - -
public void addToString(String key, String value, Long expiresIn){
redisTemplate.opsForValue().set(key,value,expiresIn, TimeUnit.SECONDS);
}
public String getFromString(String key){
return redisTemplate.opsForValue().get(key);
}
public Set<String> getKeysFromString(String key){
return redisTemplate.keys(key);
}
public List<String> getMultiValue(Set<String> keys){
return redisTemplate.opsForValue().multiGet(keys);
}
public Long getExpire(String key){
return redisTemplate.getExpire(key);
}
}

View File

@@ -0,0 +1,30 @@
package com.ai.da.common.utils.paypalRequest;
import com.alibaba.fastjson.JSONObject;
import com.paypal.http.HttpRequest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@Component
public class AuthenticationRequest extends HttpRequest<HashMap> {
public AuthenticationRequest() {
super("/v1/oauth2/token", "POST", HashMap.class);
this.header("Content-Type", "application/x-www-form-urlencoded");
body();
}
public AuthenticationRequest authorization(String clientId, String clientSecret) {
this.header(clientId, clientSecret);
return this;
}
public AuthenticationRequest body() {
HashMap<String, String> body = new HashMap<>();
body.put("grant_type", "client_credentials");
this.requestBody(body);
return this;
}
}

View File

@@ -0,0 +1,26 @@
package com.ai.da.common.utils.paypalRequest;
import com.ai.da.model.dto.WebhookVerifyDTO;
import com.alibaba.fastjson.JSONObject;
import com.paypal.http.HttpRequest;
import com.paypal.orders.OrdersCreateRequest;
import java.io.Serializable;
import java.util.HashMap;
public class WebhookVerifyRequest extends HttpRequest<HashMap> {
public WebhookVerifyRequest() {
super("/v1/notifications/verify-webhook-signature", "POST", HashMap.class);
this.header("Content-Type", "application/json");
}
public WebhookVerifyRequest authorization(String authorization) {
this.header("Authorization", "Bearer " + String.valueOf(authorization));
return this;
}
public WebhookVerifyRequest requestBody(HashMap<String,String> webhookVerify) {
super.requestBody(webhookVerify);
return this;
}
}