From 298ec9703de9b104fa41cd0137dd083a390fd42d Mon Sep 17 00:00:00 2001 From: xiaoxiamo <82970607@qq.com> Date: Wed, 10 Jul 2024 14:31:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SpotBugs=E6=89=AB=E6=8F=8F=E5=88=86?= =?UTF-8?q?=E6=9E=90=EF=BC=88=E4=BA=8C=EF=BC=89=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AD=90=E7=88=B6=E7=B1=BBequals()=E6=96=B9=E6=B3=95=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9=E7=A7=B0=E9=97=AE=E9=A2=98=EF=BC=88=E9=9C=80=E7=94=A8?= =?UTF-8?q?getClass=E8=80=8C=E4=B8=8D=E6=98=AFinstanceof=E5=81=9A=E5=88=A4?= =?UTF-8?q?=E6=96=AD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/account/sms/LinTongSmsAccount.java | 35 ++++++++++++++++- .../common/dto/account/sms/SmsAccount.java | 30 ++++++++++++++ .../dto/account/sms/TencentSmsAccount.java | 39 +++++++++++++++++++ .../dto/account/sms/YunPianSmsAccount.java | 34 ++++++++++++++++ 4 files changed, 137 insertions(+), 1 deletion(-) diff --git a/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/LinTongSmsAccount.java b/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/LinTongSmsAccount.java index 542288f..35f7483 100644 --- a/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/LinTongSmsAccount.java +++ b/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/LinTongSmsAccount.java @@ -2,6 +2,8 @@ package com.java3y.austin.common.dto.account.sms; import lombok.*; +import java.util.Objects; + /** * Form File *
Description
@@ -13,7 +15,6 @@ import lombok.*; * @Description * @see com.java3y.austin.common.dto.account austin */ -@EqualsAndHashCode(callSuper = true) @Data @Builder @AllArgsConstructor @@ -30,4 +31,36 @@ public class LinTongSmsAccount extends SmsAccount { private String userName; private String password; + /** + * 重写equals方法 + * + * @param o + * @return + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + LinTongSmsAccount that = (LinTongSmsAccount) o; + return url.equals(that.url) && + userName.equals(that.userName) && + password.equals(that.password); + } + + /** + * 重写hashCode方法 + * + * @return + */ + @Override + public int hashCode() { + return Objects.hash(url, userName, password); + } } diff --git a/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/SmsAccount.java b/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/SmsAccount.java index d4a9410..c34b4c0 100644 --- a/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/SmsAccount.java +++ b/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/SmsAccount.java @@ -4,6 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Objects; + /** * @author 3y */ @@ -27,5 +29,33 @@ public class SmsAccount { */ protected String scriptName; + /** + * 重写equals方法 + * + * @param o + * @return + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SmsAccount that = (SmsAccount) o; + return supplierId.equals(that.supplierId) && + supplierName.equals(that.supplierName) && + scriptName.equals(that.scriptName); + } + /** + * 重写hashCode方法 + * + * @return + */ + @Override + public int hashCode() { + return Objects.hash(supplierId, supplierName, scriptName); + } } diff --git a/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/TencentSmsAccount.java b/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/TencentSmsAccount.java index bd62d54..bb0717b 100644 --- a/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/TencentSmsAccount.java +++ b/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/TencentSmsAccount.java @@ -4,6 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Objects; + /** * 腾讯短信参数 *@@ -42,4 +44,41 @@ public class TencentSmsAccount extends SmsAccount { private String smsSdkAppId; private String templateId; private String signName; + + /** + * 重写equals方法 + * + * @param o + * @return + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + TencentSmsAccount that = (TencentSmsAccount) o; + return url.equals(that.url) && + region.equals(that.region) && + secretId.equals(that.secretId) && + secretKey.equals(that.secretKey) && + smsSdkAppId.equals(that.smsSdkAppId) && + templateId.equals(that.templateId) && + signName.equals(that.signName); + } + + /** + * 重写hashCode方法 + * + * @return + */ + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), url, region, secretId, secretKey, smsSdkAppId, templateId, signName); + } } diff --git a/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/YunPianSmsAccount.java b/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/YunPianSmsAccount.java index f33e369..9e1e28a 100644 --- a/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/YunPianSmsAccount.java +++ b/austin-common/src/main/java/com/java3y/austin/common/dto/account/sms/YunPianSmsAccount.java @@ -4,6 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Objects; + /** * 云片账号信息 *
@@ -31,4 +33,36 @@ public class YunPianSmsAccount extends SmsAccount { */ private String url; + /** + * 重写equals方法 + * + * @param o + * @return + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + YunPianSmsAccount that = (YunPianSmsAccount) o; + return apikey.equals(that.apikey) && + tplId.equals(that.tplId) && + url.equals(that.url); + } + + /** + * 重写hashCode方法 + * + * @return + */ + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), apikey, tplId, url); + } }