mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 03:00:26 +08:00
新版IP库管理阶段性提交(未完成)
This commit is contained in:
69
internal/db/models/ip_library_file_model_ext.go
Normal file
69
internal/db/models/ip_library_file_model_ext.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package models
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func (this *IPLibraryFile) DecodeCountries() []string {
|
||||
var countries = []string{}
|
||||
if IsNotNull(this.Countries) {
|
||||
err := json.Unmarshal(this.Countries, &countries)
|
||||
if err != nil {
|
||||
// ignore error
|
||||
}
|
||||
}
|
||||
return countries
|
||||
}
|
||||
|
||||
func (this *IPLibraryFile) DecodeProvinces() [][2]string {
|
||||
var provinces = [][2]string{}
|
||||
if IsNotNull(this.Provinces) {
|
||||
err := json.Unmarshal(this.Provinces, &provinces)
|
||||
if err != nil {
|
||||
// ignore error
|
||||
}
|
||||
}
|
||||
return provinces
|
||||
}
|
||||
|
||||
func (this *IPLibraryFile) DecodeCities() [][3]string {
|
||||
var cities = [][3]string{}
|
||||
if IsNotNull(this.Cities) {
|
||||
err := json.Unmarshal(this.Cities, &cities)
|
||||
if err != nil {
|
||||
// ignore error
|
||||
}
|
||||
}
|
||||
return cities
|
||||
}
|
||||
|
||||
func (this *IPLibraryFile) DecodeTowns() [][4]string {
|
||||
var towns = [][4]string{}
|
||||
if IsNotNull(this.Towns) {
|
||||
err := json.Unmarshal(this.Towns, &towns)
|
||||
if err != nil {
|
||||
// ignore error
|
||||
}
|
||||
}
|
||||
return towns
|
||||
}
|
||||
|
||||
func (this *IPLibraryFile) DecodeProviders() []string {
|
||||
var providers = []string{}
|
||||
if IsNotNull(this.Providers) {
|
||||
err := json.Unmarshal(this.Providers, &providers)
|
||||
if err != nil {
|
||||
// ignore error
|
||||
}
|
||||
}
|
||||
return providers
|
||||
}
|
||||
|
||||
func (this *IPLibraryFile) DecodeEmptyValues() []string {
|
||||
var result = []string{}
|
||||
if IsNotNull(this.EmptyValues) {
|
||||
err := json.Unmarshal(this.EmptyValues, &result)
|
||||
if err != nil {
|
||||
// ignore error
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user