8 | * 解析记录表 Mapper 接口 9 | *
10 | * 11 | * @author sssd 12 | * @since 2023-03-19 13 | */ 14 | public interface ParsingRecordMapper extends BaseMapper13 | * 解析记录表 服务类 14 | *
15 | * 16 | * @author sssd 17 | * @since 2023-03-19 18 | */ 19 | public interface IParsingRecordService extends IService17 | * 解析记录表 18 | *
19 | * 20 | * @author sssd 21 | * @since 2023-03-19 22 | */ 23 | @TableName("parsing_record") 24 | @Data 25 | public class ParsingRecord extends AmisPageEntity implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @NotNull(groups = {ValidGroup.UpdateGroup.class,ValidGroup.CopyGroup.class}, message = "id不能为空") 30 | @TableId(type = IdType.ASSIGN_ID) 31 | @JsonSerialize(using = ToStringSerializer.class) 32 | private Long id; 33 | 34 | @NotNull(groups = {ValidGroup.SaveGroup.class, ValidGroup.UpdateGroup.class,ValidGroup.CopyGroup.class}, message = "服务提供商不能为空,1 阿里云 2 腾讯云 3 cloudflare") 35 | private Integer serviceProvider; 36 | 37 | @TableField(exist = false) 38 | private String serviceProviderName; 39 | 40 | @NotBlank(groups = {ValidGroup.SaveGroup.class, ValidGroup.UpdateGroup.class,ValidGroup.CopyGroup.class}, message = "服务提供商密钥key不能为空,1 阿里云 2 腾讯云 ") 41 | private String serviceProviderId; 42 | 43 | @NotBlank(groups = {ValidGroup.SaveGroup.class, ValidGroup.UpdateGroup.class,ValidGroup.CopyGroup.class}, message = "服务提供商密钥value不能为空,1 阿里云 2 腾讯云,1 阿里云 2 腾讯云 3 cloudflare") 44 | private String serviceProviderSecret; 45 | 46 | @NotNull(groups = {ValidGroup.SaveGroup.class, ValidGroup.UpdateGroup.class,ValidGroup.CopyGroup.class}, message = "解析类型不能为空,解析类型:1 AAAA 2 A") 47 | private Integer recordType; 48 | 49 | @TableField(exist = false) 50 | private String recordTypeName; 51 | 52 | private String ip; 53 | 54 | @NotNull(groups = {ValidGroup.SaveGroup.class, ValidGroup.UpdateGroup.class,ValidGroup.CopyGroup.class}, message = "获取ip方式不能为空,获取ip方式: 1 interface 2 network 3 cmd") 55 | private Integer getIpMode; 56 | 57 | private String getIpModeValue; 58 | 59 | @NotBlank(groups = {ValidGroup.SaveGroup.class, ValidGroup.UpdateGroup.class,ValidGroup.CopyGroup.class}, message = "域名不能为空") 60 | private String domain; 61 | 62 | @NotNull(groups = {ValidGroup.SaveGroup.class, ValidGroup.UpdateGroup.class,ValidGroup.CopyGroup.class}, message = "更新频率不能为空") 63 | private Integer updateFrequency; 64 | 65 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 66 | @TableField(fill = FieldFill.INSERT) 67 | private LocalDateTime createDate; 68 | 69 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 70 | @TableField(fill = FieldFill.INSERT_UPDATE) 71 | private LocalDateTime updateDate; 72 | 73 | @TableField(fill = FieldFill.INSERT) 74 | private Long creator; 75 | 76 | @TableField(fill = FieldFill.INSERT_UPDATE) 77 | private Long updater; 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/top/sssd/ddns/strategy/HuaweiDynamicDnsStrategyImpl.java: -------------------------------------------------------------------------------- 1 | package top.sssd.ddns.strategy; 2 | 3 | import com.huaweicloud.sdk.dns.v2.DnsClient; 4 | import com.huaweicloud.sdk.dns.v2.model.ListRecordSetsResponse; 5 | import com.huaweicloud.sdk.dns.v2.model.ListRecordSetsWithTags; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.util.CollectionUtils; 9 | import top.sssd.ddns.common.enums.RecordTypeEnum; 10 | import top.sssd.ddns.model.entity.ParsingRecord; 11 | import top.sssd.ddns.utils.HuaweiDnsUtils; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author sssd 17 | * @careate 2023-11-13-21:56 18 | */ 19 | @Service 20 | @Slf4j 21 | public class HuaweiDynamicDnsStrategyImpl implements DynamicDnsStrategy { 22 | @Override 23 | public boolean exist(String serviceProviderId, String serviceProviderSecret, String subDomain, String recordType) throws Exception { 24 | DnsClient client = HuaweiDnsUtils.createClient(serviceProviderId, serviceProviderSecret); 25 | ListRecordSetsResponse listRecordSetsResponse = HuaweiDnsUtils.listRecordSetsByDomainWithType(client, subDomain, recordType); 26 | List