TASK:code-create 注册用户添加为AiDA的游客

BUGFIX:0关注状态下获取动态
This commit is contained in:
2024-08-27 11:27:05 +08:00
parent e86b576050
commit d23ac82b1b
8 changed files with 160 additions and 2 deletions

View File

@@ -61,4 +61,8 @@ public class CommonConstant {
public static final String DEFAULT_AVATAR = "aida-users/87/avatar/default.jpg";
/* 截止至2024/08/26在Code-Create DB中pmr_users表中最大的用户id */
public static final Long MAXIMUM_USER_ID = 704L;
// public static final Long MAXIMUM_USER_ID = 225L;
}

View File

@@ -57,4 +57,12 @@ public class AccountTask {
accountService.toVisitor(account);
}
}
/**
* 将Code-Create上注册的用户添加为AiDA的游客
*/
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
public void registerUserToVisitor(){
accountService.registerUserToVisitor();
}
}

View File

@@ -590,4 +590,40 @@ public class SendEmailUtil {
throw new BusinessException("failed.to.send.mail");
}
}
private final static Long NEW_USER_REGISTER_NOTIFICATION_EN = 126919L;
public static void notificationForRegisterUser(String receiverAddress){
try{
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露并威胁账号下所有资源的安全性。以下代码示例仅供参考建议采用更安全的方式来使用密钥请参见https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
// 实例化一个http选项可选的没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("ses.tencentcloudapi.com");
// 实例化一个client选项可选的没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象
SendEmailRequest req = new SendEmailRequest();
req.setFromEmailAddress(SEND_ADDRESS);
req.setDestination(new String[]{receiverAddress});
req.setSubject("Welcome to AiDa");
Template template = new Template();
template.setTemplateID(NEW_USER_REGISTER_NOTIFICATION_EN);
template.setTemplateData("{\"email\":\" " + receiverAddress + "\"}");
req.setTemplate(template);
// 返回的resp是一个SendEmailResponse的实例与请求对象对应
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");
}
}
}