Ben 1 year ago
parent
commit
13ba5f64c0
2 changed files with 14 additions and 8 deletions
  1. 8 4
      internal/dto/response.go
  2. 6 4
      internal/server/server.go

+ 8 - 4
internal/dto/response.go

@@ -45,7 +45,12 @@ type RegisterResult struct {
 
 type ListResponse struct {
 	Response
-	Data []Node `json:"data"`
+	Data ListResult `json:"data"`
+}
+
+type ListResult struct {
+	FreeTrialDuration int64  `json:"freeTrialDuration"`
+	Nodes             []Node `json:"nodes"`
 }
 
 type DetailResponse struct {
@@ -54,7 +59,6 @@ type DetailResponse struct {
 }
 
 type Node struct {
-	CountryCode       string `json:"countryCode"`
-	Ip                string `json:"ip"`
-	FreeTrialDuration int64  `json:"freeTrialDuration"`
+	CountryCode string `json:"countryCode"`
+	Ip          string `json:"ip"`
 }

+ 6 - 4
internal/server/server.go

@@ -55,16 +55,18 @@ func List(c *gin.Context) {
 	for _, node := range nodes {
 		if node.LastUpdateTime.Add(10 * time.Second).After(time.Now()) {
 			dtoNodes = append(dtoNodes, dto.Node{
-				Ip:                node.Ip,
-				CountryCode:       node.CountryCode,
-				FreeTrialDuration: (time.Hour * 1).Milliseconds() / 1000,
+				Ip:          node.Ip,
+				CountryCode: node.CountryCode,
 			})
 		}
 	}
 
 	c.JSON(http.StatusOK, dto.ListResponse{
 		Response: dto.NewOkResponse(),
-		Data:     dtoNodes,
+		Data: dto.ListResult{
+			Nodes:             dtoNodes,
+			FreeTrialDuration: (time.Hour * 1).Milliseconds() / 1000,
+		},
 	})
 }