feat(server): 添加服务器地理位置信息字段
Build docker and publish / build (20.15.1) (push) Successful in 7m3s

为服务器模型添加经度、纬度及中心点坐标字段,并在相关逻辑中处理这些字段
同时修复服务器用户列表缓存功能
This commit is contained in:
2025-11-03 23:50:23 -08:00
parent 071bb1940d
commit 15f4e69dc3
12 changed files with 2689 additions and 58 deletions
+2524
View File
File diff suppressed because it is too large Load Diff
+15 -7
View File
@@ -74,6 +74,12 @@ func GetRegionByIp(ip string) (*GeoLocationResponse, error) {
if response.Country == "" {
continue
}
response.LatitudeCenter, response.LongitudeCenter, _ = GetCapitalCoordinates(fmt.Sprintf("%s,%s", response.Country, response.City))
if response.LatitudeCenter == "" || response.LongitudeCenter == "" {
response.LatitudeCenter = response.Latitude
response.LongitudeCenter = response.Longitude
}
return response, nil
}
}
@@ -181,11 +187,13 @@ func decompressResponse(resp *http.Response) ([]byte, error) {
// GeoLocationResponse represents the geolocation data returned by the API.
type GeoLocationResponse struct {
Country string `json:"country"`
CountryName string `json:"country_name"`
Region string `json:"region"`
City string `json:"city"`
Latitude string `json:"latitude"`
Longitude string `json:"longitude"`
Loc string `json:"loc"`
Country string `json:"country"`
CountryName string `json:"country_name"`
Region string `json:"region"`
City string `json:"city"`
Latitude string `json:"latitude"`
Longitude string `json:"longitude"`
LatitudeCenter string `json:"latitude_center"`
LongitudeCenter string `json:"longitude_center"`
Loc string `json:"loc"`
}