Merge branch 'refs/heads/dev/dev' into dev/dev_xp

# Conflicts:
#	src/main/java/com/ai/da/common/utils/SendEmailUtil.java
#	src/main/java/com/ai/da/mapper/primary/entity/Account.java
This commit is contained in:
2024-12-11 16:52:16 +08:00
38 changed files with 1613 additions and 123 deletions

View File

@@ -51,7 +51,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
"/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease",
"/api/account/designWorksRegister","/api/account/questionnaire","/api/stripe/trade/notify",
"/notification","/api/account/activateNewEmail","/api/third/party/auth/google_callback"
"/notification","/api/account/activateNewEmail","/api/third/party/auth/google_callback","/api/third/party/parseGoogleCredential","/api/third/party/receiveDesignResults","/api/third/party/parseWeChatCode"
);
@Override

View File

@@ -484,6 +484,57 @@ public class MinioUtil {
return null; // or throw an exception
}
}
/**
* 从 MinIO 下载对象到本地路径
*
* @param bucketName 存储桶名称
* @param objectName MinIO 上对象的名称
* @param localFilePath 本地文件路径
*/
public void downloadMinioObjectToLocal(String bucketName, String objectName, String localFilePath) {
File localFile = new File(localFilePath);
File parentDir = localFile.getParentFile();
if (parentDir != null) {
parentDir.mkdirs(); // 创建文件夹,确保路径结构与 MinIO 一致
}
try (InputStream stream = minioClient.getObject(
GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
FileOutputStream out = new FileOutputStream(localFile)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = stream.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
log.info("Downloaded object {} to {}", objectName, localFilePath);
} catch (Exception e) {
log.error("Error while downloading object {}: {}", objectName, e.getMessage());
}
}
/**
* 从路径中提取存储桶名称
*
* @param path MinIO 路径
* @return 存储桶名称
*/
public String getBucketNameFromPath(String path) {
int index = path.indexOf("/");
return path.substring(0, index); // 获取第一级路径作为 bucket 名称
}
/**
* 从路径中提取对象名称
*
* @param path MinIO 路径
* @return 对象名称
*/
public String getObjectNameFromPath(String path) {
int index = path.indexOf("/");
return path.substring(index + 1); // 获取路径的其余部分作为对象名称
}
}

View File

@@ -395,20 +395,20 @@ public class SendEmailUtil {
// 根据邮件类型设置不同的主题和模板
String subject = "";
Template template = new Template();
if (type == 1) {
subject = "Upcoming System Upgrade for AiDA 3.0";
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
} else {
subject = "即将到来的AiDA 3.0系统升级";
template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
}
// if (type == 1) {
// subject = "Successful System Upgrade and New Features in AiDA 3.1";
// template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID);
// subject = "Upcoming System Upgrade for AiDA 3.0";
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
// }else {
// subject = "系统升级成功和AiDA 3.1新功能";
// template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE);
// subject = "即将到来的AiDA 3.0系统升级";
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
// }
if (type == 1) {
subject = "Successful System Upgrade and New Features in AiDA 3.1";
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID);
}else {
subject = "系统升级成功和AiDA 3.1新功能";
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE);
}
template.setTemplateData(buildAccountData(account));
req.setSubject(subject);
@@ -776,6 +776,47 @@ public class SendEmailUtil {
throw new BusinessException("failed.to.send.mail");
}
}
private final static Long SYSTEM_UPGRADE_CN_ID = 131743L;
private final static Long SYSTEM_UPGRADE_EN_ID = 131744L;
public static void temporaryUpgrade(Account account, String senderAddress, int type) {
try {
// 实例化一个认证对象
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("ses.tencentcloudapi.com");
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
SendEmailRequest req = new SendEmailRequest();
if (StringUtils.isEmpty(senderAddress)) {
senderAddress = CODE_CREATE_SEND_ADDRESS;
}
req.setFromEmailAddress(senderAddress);
req.setDestination(new String[]{account.getUserEmail()});
// 根据邮件类型设置不同的主题和模板
String subject = "";
Template template = new Template();
if (type == 1) {
subject = "AiDA system upgrade completed";
template.setTemplateID(SYSTEM_UPGRADE_EN_ID);
}else {
subject = "AiDA系统升级完成";
template.setTemplateID(SYSTEM_UPGRADE_CN_ID);
}
template.setTemplateData(buildAccountData(account));
req.setSubject(subject);
req.setTemplate(template);
// 发送邮件
SendEmailResponse resp = client.SendEmail(req);
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
} catch (TencentCloudSDKException e) {
log.info("邮件发送失败###{}", e.toString());
throw new BusinessException("failed.to.send.mail");
}
}
private final static Long CANCEL_MERCHANT_EN = 130720L;
private final static Long NEW_MERCHANT_EN = 130721L;