浏览代码

mod: node

Ben 1 年之前
父节点
当前提交
1ddaa6db68
共有 5 个文件被更改,包括 6 次插入1 次删除
  1. 1 1
      cmd/slave.go
  2. 1 0
      internal/dto/request.go
  3. 1 0
      internal/dto/response.go
  4. 1 0
      internal/model/node.go
  5. 2 0
      internal/server/server.go

+ 1 - 1
cmd/slave.go

@@ -35,7 +35,7 @@ func main() {
 	city := gjson.Get(string(bs), "city").String()
 	log.Printf("ipinfo: %s", string(bs))
 
-	request := dto.RegisterRequest{Ip: ip, CountryCode: countryCode, CountryName: city, Secret: buf.String()}
+	request := dto.RegisterRequest{Ip: ip, CountryCode: countryCode, CountryName: city, Secret: buf.String(), City: city}
 	body, err := json.Marshal(request)
 	if err != nil {
 		log.Printf("err: %+v", err)

+ 1 - 0
internal/dto/request.go

@@ -4,6 +4,7 @@ type RegisterRequest struct {
 	Ip          string `json:"ip"`
 	CountryCode string `json:"countryCode"`
 	CountryName string `json:"countryName"`
+	City        string `json:"city"`
 	Secret      string `json:"secret"`
 }
 

+ 1 - 0
internal/dto/response.go

@@ -56,6 +56,7 @@ type DetailResponse struct {
 type Node struct {
 	CountryCode  string `json:"countryCode"`
 	CountryName  string `json:"countryName"`
+	City         string `json:"city"`
 	CountryLabel string `json:"countryLabel"`
 	Ip           string `json:"ip"`
 	Icon         string `json:"icon"`

+ 1 - 0
internal/model/node.go

@@ -6,6 +6,7 @@ type Node struct {
 	Ip          string
 	CountryCode string
 	CountryName string
+	City        string
 	Secret      string
 
 	LastUpdateTime time.Time

+ 2 - 0
internal/server/server.go

@@ -90,6 +90,7 @@ func Register(c *gin.Context) {
 			node.Secret = request.Secret
 			node.CountryCode = request.CountryCode
 			node.CountryName = request.CountryName
+			node.City = request.City
 			node.LastUpdateTime = time.Now()
 			c.JSON(http.StatusOK, dto.RegisterResponse{
 				Response: dto.NewOkResponse(),
@@ -218,6 +219,7 @@ func convert2DtoNode(node *model.Node, seq int) *dto.Node {
 		Ip:           node.Ip,
 		CountryCode:  node.CountryCode,
 		CountryName:  node.CountryName,
+		City:         node.City,
 		CountryLabel: fmt.Sprintf("%s - %d", countryLabels[node.CountryCode], seq+1),
 		Icon:         icons[node.CountryCode],
 	}