Merge remote-tracking branch 'origin/release/3.0' into release/3.0

This commit is contained in:
shahaibo
2024-07-11 15:54:49 +08:00
12 changed files with 96 additions and 27 deletions

View File

@@ -12,16 +12,16 @@ public class MQConfig {
// public static final String GENERATE_QUEUE = "generate-queue-test";
// ==================================================================
// public static final String GENERATE_QUEUE = "generate-queue-local";
// public static final String GENERATE_QUEUE = "generate-queue-dev";
public static final String GENERATE_QUEUE = "generate-queue-prod";
// public static final String GENERATE_QUEUE = "generate-queue-prod";
//
// public static final String SR_QUEUE = "SR-queue-local";
public static final String SR_QUEUE = "SR-queue-prod";
// public static final String SR_QUEUE = "SR-queue-prod";
// public static final String SR_QUEUE = "SR-queue-dev";
public static final String SR_QUEUE = "SR-queue-prod";
//
// public static final String SR_RESULT_QUEUE = "SuperResolution-local";
public static final String SR_RESULT_QUEUE = "SuperResolution-prod";
// public static final String SR_RESULT_QUEUE = "SuperResolution-prod";
// public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
public static final String SR_RESULT_QUEUE = "SuperResolution-prod";
//
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod";

View File

@@ -27,7 +27,7 @@ public class AliPayTask {
// @Scheduled(cron = "0/30 * * * * ?")
public void orderConfirm(){
log.info("Alipay orderConfirm 被执行......");
// log.info("Alipay orderConfirm 被执行......");
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(5, PayTypeEnum.ALIPAY.getType());

View File

@@ -26,7 +26,7 @@ public class PaypalTask {
@Scheduled(cron = "0/30 * * * * ?")
public void orderConfirm() throws SerializeException {
log.info("PayPal orderConfirm 被执行......");
// log.info("PayPal orderConfirm 被执行......");
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(5, PayTypeEnum.PAYPAL.getType());

View File

@@ -1,5 +1,6 @@
package com.ai.da.common.utils;
import cn.hutool.core.io.resource.ClassPathResource;
import com.ai.da.model.dto.AlipayHKParametersDTO;
import com.ai.da.model.dto.AlipayHKRequestDTO;
import com.alibaba.fastjson.JSONObject;
@@ -14,6 +15,7 @@ import org.bouncycastle.crypto.util.PublicKeyFactory;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemReader;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@@ -165,7 +167,23 @@ public class AlipayHKEncryptionUtil {
* @throws Exception
*/
private static PrivateKey readPrivateKeyFromFile(String filePath) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(filePath));
ClassPathResource classPathResource = new ClassPathResource(filePath);
InputStream inputstream = classPathResource.getStream();
String privateKeyContent = getString(inputstream);
// 进行 Base64 解码
byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyContent);
// 根据 PKCS8 格式的私钥字节数组构造私钥对象
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
return keyFactory.generatePrivate(keySpec);
}
@NotNull
private static String getString(InputStream inputstream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream));
// BufferedReader reader = new BufferedReader(new FileReader(filePath));
StringBuilder keyBuffer = new StringBuilder();
String line;
@@ -180,14 +198,7 @@ public class AlipayHKEncryptionUtil {
.replace("-----BEGIN PRIVATE KEY-----", "")
.replace("-----END PRIVATE KEY-----", "")
.replaceAll("\\s+", ""); // 去除空格、换行等字符
// 进行 Base64 解码
byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyContent);
// 根据 PKCS8 格式的私钥字节数组构造私钥对象
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
return keyFactory.generatePrivate(keySpec);
return privateKeyContent;
}
/**
@@ -233,7 +244,7 @@ public class AlipayHKEncryptionUtil {
// 使用 RSA 公钥加密 AES 密钥
String rsaPublicKeyPath = publicKeyPath;
PublicKey publicKey = readPublicKey(new File(rsaPublicKeyPath));
PublicKey publicKey = readPublicKey(rsaPublicKeyPath);
Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
// Cipher rsaCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
@@ -313,11 +324,14 @@ public class AlipayHKEncryptionUtil {
System.out.println("数字签名验证结果:" + signatureValid);
}
public static PublicKey readPublicKey(File file) throws Exception {
// public static PublicKey readPublicKey(File file) throws Exception {
public static PublicKey readPublicKey(String fileName) throws Exception {
KeyFactory factory = KeyFactory.getInstance("RSA");
try (FileReader keyReader = new FileReader(file);
PemReader pemReader = new PemReader(keyReader)) {
ClassPathResource classPathResource = new ClassPathResource(fileName);
InputStream inputStream = classPathResource.getStream();
BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream));
try (PemReader pemReader = new PemReader(fileReader)) {
PemObject pemObject = pemReader.readPemObject();
byte[] content = pemObject.getContent();
@@ -338,8 +352,10 @@ public class AlipayHKEncryptionUtil {
Base64.Decoder decoder = Base64.getDecoder();
// Verify key
try {
ClassPathResource classPathResource = new ClassPathResource(CODPublicKeyPath);
InputStream inputstream = classPathResource.getStream();
// 从指定的路径读取公钥文件
InputStreamReader isrPub = new InputStreamReader(new FileInputStream(CODPublicKeyPath));
InputStreamReader isrPub = new InputStreamReader(inputstream);
PEMParser pemParserPub = new PEMParser(isrPub);
// 使用 PEMParser 解析公钥文件
SubjectPublicKeyInfo pubInfo = (SubjectPublicKeyInfo) pemParserPub.readObject();

View File

@@ -4,10 +4,12 @@ import com.ai.da.mapper.primary.entity.DesignItem;
import com.ai.da.model.dto.DesignSingleDTO;
import com.ai.da.model.dto.DesignSingleIncludeLayersDTO;
import com.ai.da.model.vo.*;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* 服务类
@@ -51,6 +53,8 @@ public interface DesignItemService extends IService<DesignItem> {
DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO);
Map<String, String> setTypeAndUndividedLayer(JSONArray layers);
ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException;
List<DesignItem> selectDesignIdById(List<Long> designItemIdList);

View File

@@ -568,7 +568,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
});
}
private Map<String, String> setTypeAndUndividedLayer(JSONArray layers){
@Override
public Map<String, String> setTypeAndUndividedLayer(JSONArray layers){
HashMap<String, String> categoryAndLayer = new HashMap<>();
for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i);

View File

@@ -607,6 +607,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
Map<String, Integer> typePriority = list.stream().collect(Collectors.toMap(d -> d.getImageCategory().split("_")[0],
d -> Math.abs(d.getPriority()),
(existing, replacement) -> replacement));
Map<String, String> typeAndUndividedLayer = designItemService.setTypeAndUndividedLayer(layers);
for (DesignPythonItem detail : item.getItems()) {
if (null == detail) {
continue;
@@ -617,6 +618,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType().toLowerCase()));
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
designItemDetail.setPath(detail.getBody_path());
//BODY不关联businessId