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