mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-08 05:29:51 +00:00
refactor: clean code
This commit is contained in:
parent
ad0125fe0d
commit
0545945697
@ -122,8 +122,8 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||
}
|
||||
|
||||
func (d *DNSProvider) getDNSRecord(zoneName, subDomain string) (*gnamesdk.ResolutionRecord, error) {
|
||||
page := 1
|
||||
pageSize := 20
|
||||
page := int32(1)
|
||||
pageSize := int32(20)
|
||||
for {
|
||||
request := &gnamesdk.ListDomainResolutionRequest{}
|
||||
request.ZoneName = zoneName
|
||||
@ -166,18 +166,19 @@ func (d *DNSProvider) addOrUpdateDNSRecord(zoneName, subDomain, value string) er
|
||||
RecordType: "TXT",
|
||||
RecordName: subDomain,
|
||||
RecordValue: value,
|
||||
TTL: d.config.TTL,
|
||||
TTL: int32(d.config.TTL),
|
||||
}
|
||||
_, err := d.client.AddDomainResolution(request)
|
||||
return err
|
||||
} else {
|
||||
recordId, _ := record.ID.Int64()
|
||||
request := &gnamesdk.ModifyDomainResolutionRequest{
|
||||
ID: record.ID,
|
||||
ID: recordId,
|
||||
ZoneName: zoneName,
|
||||
RecordType: "TXT",
|
||||
RecordName: subDomain,
|
||||
RecordValue: value,
|
||||
TTL: d.config.TTL,
|
||||
TTL: int32(d.config.TTL),
|
||||
}
|
||||
_, err := d.client.ModifyDomainResolution(request)
|
||||
return err
|
||||
@ -194,9 +195,10 @@ func (d *DNSProvider) removeDNSRecord(zoneName, subDomain string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
recordId, _ := record.ID.Int64()
|
||||
request := &gnamesdk.DeleteDomainResolutionRequest{
|
||||
ZoneName: zoneName,
|
||||
RecordID: record.ID,
|
||||
RecordID: recordId,
|
||||
}
|
||||
_, err = d.client.DeleteDomainResolution(request)
|
||||
return err
|
||||
|
6
internal/pkg/vendors/baishan-sdk/models.go
vendored
6
internal/pkg/vendors/baishan-sdk/models.go
vendored
@ -1,16 +1,16 @@
|
||||
package baishansdk
|
||||
|
||||
type BaseResponse interface {
|
||||
GetCode() int
|
||||
GetCode() int32
|
||||
GetMessage() string
|
||||
}
|
||||
|
||||
type baseResponse struct {
|
||||
Code *int `json:"code,omitempty"`
|
||||
Code *int32 `json:"code,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (r *baseResponse) GetCode() int {
|
||||
func (r *baseResponse) GetCode() int32 {
|
||||
if r.Code != nil {
|
||||
return *r.Code
|
||||
}
|
||||
|
6
internal/pkg/vendors/dnsla-sdk/models.go
vendored
6
internal/pkg/vendors/dnsla-sdk/models.go
vendored
@ -1,16 +1,16 @@
|
||||
package dnslasdk
|
||||
|
||||
type BaseResponse interface {
|
||||
GetCode() int
|
||||
GetCode() int32
|
||||
GetMessage() string
|
||||
}
|
||||
|
||||
type baseResponse struct {
|
||||
Code *int `json:"code,omitempty"`
|
||||
Code *int32 `json:"code,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (r *baseResponse) GetCode() int {
|
||||
func (r *baseResponse) GetCode() int32 {
|
||||
if r.Code != nil {
|
||||
return *r.Code
|
||||
}
|
||||
|
44
internal/pkg/vendors/gname-sdk/models.go
vendored
44
internal/pkg/vendors/gname-sdk/models.go
vendored
@ -1,16 +1,18 @@
|
||||
package gnamesdk
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type BaseResponse interface {
|
||||
GetCode() int
|
||||
GetCode() int32
|
||||
GetMessage() string
|
||||
}
|
||||
|
||||
type baseResponse struct {
|
||||
Code int `json:"code"`
|
||||
Code int32 `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
}
|
||||
|
||||
func (r *baseResponse) GetCode() int {
|
||||
func (r *baseResponse) GetCode() int32 {
|
||||
return r.Code
|
||||
}
|
||||
|
||||
@ -23,23 +25,23 @@ type AddDomainResolutionRequest struct {
|
||||
RecordType string `json:"lx"`
|
||||
RecordName string `json:"zj"`
|
||||
RecordValue string `json:"jlz"`
|
||||
MX int `json:"mx"`
|
||||
TTL int `json:"ttl"`
|
||||
MX int32 `json:"mx"`
|
||||
TTL int32 `json:"ttl"`
|
||||
}
|
||||
|
||||
type AddDomainResolutionResponse struct {
|
||||
baseResponse
|
||||
Data string `json:"data"`
|
||||
Data json.Number `json:"data"`
|
||||
}
|
||||
|
||||
type ModifyDomainResolutionRequest struct {
|
||||
ID string `json:"jxid"`
|
||||
ID int64 `json:"jxid"`
|
||||
ZoneName string `json:"ym"`
|
||||
RecordType string `json:"lx"`
|
||||
RecordName string `json:"zj"`
|
||||
RecordValue string `json:"jlz"`
|
||||
MX int `json:"mx"`
|
||||
TTL int `json:"ttl"`
|
||||
MX int32 `json:"mx"`
|
||||
TTL int32 `json:"ttl"`
|
||||
}
|
||||
|
||||
type ModifyDomainResolutionResponse struct {
|
||||
@ -48,7 +50,7 @@ type ModifyDomainResolutionResponse struct {
|
||||
|
||||
type DeleteDomainResolutionRequest struct {
|
||||
ZoneName string `json:"ym"`
|
||||
RecordID string `json:"jxid"`
|
||||
RecordID int64 `json:"jxid"`
|
||||
}
|
||||
|
||||
type DeleteDomainResolutionResponse struct {
|
||||
@ -57,23 +59,23 @@ type DeleteDomainResolutionResponse struct {
|
||||
|
||||
type ListDomainResolutionRequest struct {
|
||||
ZoneName string `json:"ym"`
|
||||
Page *int `json:"page,omitempty"`
|
||||
PageSize *int `json:"limit,omitempty"`
|
||||
Page *int32 `json:"page,omitempty"`
|
||||
PageSize *int32 `json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
type ListDomainResolutionResponse struct {
|
||||
baseResponse
|
||||
Count int `json:"count"`
|
||||
Count int32 `json:"count"`
|
||||
Data []*ResolutionRecord `json:"data"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"pagesize"`
|
||||
Page int32 `json:"page"`
|
||||
PageSize int32 `json:"pagesize"`
|
||||
}
|
||||
|
||||
type ResolutionRecord struct {
|
||||
ID string `json:"id"`
|
||||
ZoneName string `json:"ym"`
|
||||
RecordType string `json:"lx"`
|
||||
RecordName string `json:"zjt"`
|
||||
RecordValue string `json:"jxz"`
|
||||
MX int `json:"mx"`
|
||||
ID json.Number `json:"id"`
|
||||
ZoneName string `json:"ym"`
|
||||
RecordType string `json:"lx"`
|
||||
RecordName string `json:"zjt"`
|
||||
RecordValue string `json:"jxz"`
|
||||
MX int32 `json:"mx"`
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ type baseResponseData struct {
|
||||
ErrorMessage string `json:"message"`
|
||||
}
|
||||
|
||||
func (r *baseResponseData) GetErrorCode() int {
|
||||
func (r *baseResponseData) GetErrorCode() int32 {
|
||||
if r.ErrorCode.String() == "" {
|
||||
return 0
|
||||
}
|
||||
@ -27,7 +27,7 @@ func (r *baseResponseData) GetErrorCode() int {
|
||||
return -1
|
||||
}
|
||||
|
||||
return int(errcode)
|
||||
return int32(errcode)
|
||||
}
|
||||
|
||||
func (r *baseResponseData) GetErrorMessage() string {
|
||||
@ -56,7 +56,7 @@ type UploadHttpsCertificateResponse struct {
|
||||
baseResponse
|
||||
Data *struct {
|
||||
baseResponseData
|
||||
Status int `json:"status"`
|
||||
Status int32 `json:"status"`
|
||||
Result struct {
|
||||
CertificateId string `json:"certificate_id"`
|
||||
CommonName string `json:"commonName"`
|
||||
@ -109,7 +109,7 @@ type GetHttpsServiceManagerResponse struct {
|
||||
baseResponse
|
||||
Data *struct {
|
||||
baseResponseData
|
||||
Status int `json:"status"`
|
||||
Status int32 `json:"status"`
|
||||
Domains []HttpsServiceManagerDomain `json:"result"`
|
||||
} `json:"data,omitempty"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user