Sfoglia il codice sorgente

refactor(aodun): 重构域盾相关结构体和错误处理

- 修改 DomainResponse 结构体,将 code、msg 和 info 字段重命名并调整类型
- 更新错误处理逻辑,使用新的 Info 字段代替原有的 Data 字段- 优化 API 错误消息格式,使其更具可读性
fusu 1 mese fa
parent
commit
eecc8b4a1e
2 ha cambiato i file con 5 aggiunte e 5 eliminazioni
  1. 3 3
      api/v1/aodun.go
  2. 2 2
      internal/service/aodun.go

+ 3 - 3
api/v1/aodun.go

@@ -27,9 +27,9 @@ type IpResponse struct {
 	Data        []interface{} `json:"data,omitempty"`
 }
 type DomainResponse struct {
-	Code        int    `json:"err"`
-	Msg         string `json:"msg,omitempty"`
-	Data        string `json:"data,omitempty"`
+	Code int    `json:"code"`
+	Msg  string `json:"msg"`
+	Info []map[string]string `json:"info"`
 }
 
 type IpGetResponse struct {

+ 2 - 2
internal/service/aodun.go

@@ -281,10 +281,10 @@ func (s *aoDunService) DomainWhiteList(ctx context.Context, domain string, ip st
 	}
 
 	if res.Code != 200 && apiType == "add" {
-		return fmt.Errorf("API 错误: code %d, msg '%s', data '%s", res.Code, res.Msg, res.Data)
+		return fmt.Errorf("API 错误: code %d, msg '%s', data '%s", res.Code, res.Msg, res.Info)
 	}
 	if res.Code != 600 && apiType == "del" {
-		return fmt.Errorf("API 错误: code %d, msg '%s', data '%s", res.Code, res.Msg, res.Data)
+		return fmt.Errorf("API 错误: code %d, msg '%s', data '%s", res.Code, res.Msg, res.Info)
 	}
 	return nil
 }