基础结构修改,以及基础接口添加完善逻辑
This commit is contained in:
@@ -143,18 +143,22 @@
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sendgrid</groupId>
|
||||
<artifactId>sendgrid-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
@@ -175,6 +179,11 @@
|
||||
<artifactId>tomcat-embed-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.twilio.sdk</groupId>
|
||||
<artifactId>twilio</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ public class TwilioConfig {
|
||||
private String apiKey;
|
||||
private String fromEmail;
|
||||
private String fromName;
|
||||
private String fromEmailEm7941;
|
||||
private String fromNameEm7941;
|
||||
private String replyToEm7941;
|
||||
private TemplateIds templateIds;
|
||||
|
||||
|
||||
|
||||
@@ -83,8 +83,9 @@ public class BaseController
|
||||
{
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setSuccess(true);
|
||||
rspData.setMessage("查询成功");
|
||||
rspData.setDatas(list);
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.vetti.common.core.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.vetti.common.constant.HttpStatus;
|
||||
import com.vetti.common.utils.StringUtils;
|
||||
|
||||
@@ -18,11 +20,23 @@ public class AjaxResult<T> extends HashMap<String, Object>
|
||||
public static final String CODE_TAG = "code";
|
||||
|
||||
/** 返回内容 */
|
||||
public static final String MSG_TAG = "msg";
|
||||
public static final String MSG_TAG = "message";
|
||||
|
||||
/** 数据对象 */
|
||||
public static final String DATA_TAG = "data";
|
||||
|
||||
/**
|
||||
* 请求返回时间
|
||||
*/
|
||||
public static final String DATE_TIME = "timestamp";
|
||||
|
||||
/**
|
||||
* 成功状态标识
|
||||
*/
|
||||
public static final String SUCCESS = "success";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||
*/
|
||||
@@ -40,6 +54,12 @@ public class AjaxResult<T> extends HashMap<String, Object>
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
super.put(DATE_TIME, DateUtil.now());
|
||||
if(HttpStatus.SUCCESS == code){
|
||||
super.put(SUCCESS, true);
|
||||
}else {
|
||||
super.put(SUCCESS, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,10 +73,17 @@ public class AjaxResult<T> extends HashMap<String, Object>
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
super.put(DATE_TIME, DateUtil.now());
|
||||
if(HttpStatus.SUCCESS == code){
|
||||
super.put(SUCCESS, true);
|
||||
}else {
|
||||
super.put(SUCCESS, false);
|
||||
}
|
||||
if (StringUtils.isNotNull(data))
|
||||
{
|
||||
super.put(DATA_TAG, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,25 +1,38 @@
|
||||
package com.vetti.common.core.domain.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户登录对象
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
public class LoginBody
|
||||
{
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ApiModelProperty("用户名")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
@ApiModelProperty("用户密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 确认密码
|
||||
*/
|
||||
@ApiModelProperty("确认密码")
|
||||
private String repeatPassword;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@ApiModelProperty("验证码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
@@ -27,43 +40,4 @@ public class LoginBody
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code)
|
||||
{
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getUuid()
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,18 @@ public class TableDataInfo implements Serializable
|
||||
private long total;
|
||||
|
||||
/** 列表数据 */
|
||||
private List<?> rows;
|
||||
private List<?> datas;
|
||||
|
||||
/** 消息状态码 */
|
||||
private int code;
|
||||
|
||||
/** 消息内容 */
|
||||
private String msg;
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 成功标识
|
||||
*/
|
||||
private Boolean success;
|
||||
|
||||
/**
|
||||
* 表格数据对象
|
||||
@@ -39,7 +44,7 @@ public class TableDataInfo implements Serializable
|
||||
*/
|
||||
public TableDataInfo(List<?> list, long total)
|
||||
{
|
||||
this.rows = list;
|
||||
this.datas = list;
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
@@ -53,14 +58,14 @@ public class TableDataInfo implements Serializable
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public List<?> getRows()
|
||||
public List<?> getDatas()
|
||||
{
|
||||
return rows;
|
||||
return datas;
|
||||
}
|
||||
|
||||
public void setRows(List<?> rows)
|
||||
public void setDatas(List<?> rows)
|
||||
{
|
||||
this.rows = rows;
|
||||
this.datas = rows;
|
||||
}
|
||||
|
||||
public int getCode()
|
||||
@@ -73,13 +78,21 @@ public class TableDataInfo implements Serializable
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg()
|
||||
public String getMessage()
|
||||
{
|
||||
return msg;
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMsg(String msg)
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.msg = msg;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(Boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,14 @@ public interface VerificationEmailService {
|
||||
*/
|
||||
boolean sendVerificationRoutezVerificationCode(String email);
|
||||
|
||||
/**
|
||||
* 使用 em7941.routez.app 域名发送验证码(官网模板)
|
||||
*
|
||||
* @param email 收件人邮箱
|
||||
* @return
|
||||
*/
|
||||
boolean sendVerificationEm7941VerificationCode(String email);
|
||||
|
||||
/**
|
||||
* 发动邮箱验证码 (内容走的官网配置模板)
|
||||
*
|
||||
|
||||
@@ -66,6 +66,27 @@ public class VerificationEmailServiceImpl implements VerificationEmailService {
|
||||
twilioConfig.getTemplateIds().getRoutezVerificationCode(), template);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 em7941.routez.app 域名发送验证码(官网模板)
|
||||
*/
|
||||
@Override
|
||||
public boolean sendVerificationEm7941VerificationCode(String email) {
|
||||
String code = generateVerificationCode();
|
||||
RoutezVerificationCodeTemplate template = new RoutezVerificationCodeTemplate();
|
||||
template.setVerification_code(code);
|
||||
template.setVerification_expiration(verificationConfig.getExpirationMinutes());
|
||||
try {
|
||||
redisCache.setCacheObject(CacheConstants.VERIFICATION_EMAIL_CODE_KEY + email, code,
|
||||
verificationConfig.getExpirationMinutes(), TimeUnit.MINUTES);
|
||||
emailUtil.sendEmailByEm7941(email, twilioConfig.getTemplateIds().getRoutezVerificationCode(), template);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
// 记录日志
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发动邮箱验证码 (内容走的官网配置模板)
|
||||
*
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.sendgrid.helpers.mail.Mail;
|
||||
import com.sendgrid.helpers.mail.objects.Content;
|
||||
import com.sendgrid.helpers.mail.objects.Email;
|
||||
import com.sendgrid.helpers.mail.objects.Personalization;
|
||||
import com.vetti.common.utils.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -111,4 +112,34 @@ public class EmailUtil {
|
||||
mail.addPersonalization(personalization);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 em7941.routez.app 域名发送模板邮件
|
||||
*/
|
||||
public void sendEmailByEm7941(String toEmail, String templateId, BaseTemplateEmail templateEmail) throws IOException {
|
||||
|
||||
Email from = new Email(twilioConfig.getFromEmailEm7941(), twilioConfig.getFromNameEm7941());
|
||||
Email to = new Email(toEmail);
|
||||
Content emailContent = new Content("text/html", " ");
|
||||
|
||||
Mail mail = new Mail();
|
||||
mail.setFrom(from);
|
||||
mail.addContent(emailContent);
|
||||
if (StringUtils.isNotEmpty(twilioConfig.getReplyToEm7941())) {
|
||||
mail.setReplyTo(new Email(twilioConfig.getReplyToEm7941()));
|
||||
}
|
||||
|
||||
template(to, mail, templateId, templateEmail);
|
||||
|
||||
SendGrid sg = new SendGrid(twilioConfig.getApiKey());
|
||||
Request request = new Request();
|
||||
request.setMethod(Method.POST);
|
||||
request.setEndpoint("mail/send");
|
||||
request.setBody(mail.build());
|
||||
Response response = sg.api(request);
|
||||
|
||||
if (response.getStatusCode() >= 400) {
|
||||
throw new RuntimeException(MessageUtils.messageCustomize("systemEmailUtil10001")+": " + response.getBody());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.vetti.common.utils.sms;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.twilio.Twilio;
|
||||
import com.twilio.rest.api.v2010.account.Message;
|
||||
import com.twilio.type.PhoneNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 短信发送工具类
|
||||
* @author wangxiangshun
|
||||
* @date 2025/10/22 22:36
|
||||
*/
|
||||
@Component
|
||||
public class TwilioSmsUtil {
|
||||
|
||||
/**
|
||||
* 你的AccountSID
|
||||
*/
|
||||
@Value("${twilio.accountSID}")
|
||||
public String ACCOUNT_SID;
|
||||
|
||||
/**
|
||||
* 你的AuthToken
|
||||
*/
|
||||
@Value("${twilio.authToken}")
|
||||
public String AUTH_TOKEN;
|
||||
|
||||
|
||||
/**
|
||||
* 发送手机号号码
|
||||
*/
|
||||
@Value("${twilio.sendPhoneNumber}")
|
||||
private String sendPhoneNumber;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param phoneNumber 接收手机号
|
||||
* @param msg 短信内容
|
||||
*/
|
||||
public void send(String phoneNumber, String msg) {
|
||||
|
||||
// 初始化
|
||||
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
|
||||
|
||||
// 发送短信
|
||||
Message message = Message.creator(
|
||||
new PhoneNumber(phoneNumber), // 收信号码(目标号码)
|
||||
new PhoneNumber(sendPhoneNumber), // Twilio 提供的号码(发信号码)
|
||||
msg
|
||||
).create();
|
||||
// 打印发送结果
|
||||
System.out.println("短信已发送,SID:" + message.getSid());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user