mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-04 22:35:48 +08:00
初步完成新版IP库
This commit is contained in:
@@ -72,8 +72,9 @@ func (this *IPLibraryFileDAO) FindEnabledIPLibraryFile(tx *dbs.Tx, id int64) (*I
|
||||
}
|
||||
|
||||
// CreateLibraryFile 创建文件
|
||||
func (this *IPLibraryFileDAO) CreateLibraryFile(tx *dbs.Tx, template string, emptyValues []string, fileId int64, countries []string, provinces [][2]string, cities [][3]string, towns [][4]string, providers []string) (int64, error) {
|
||||
func (this *IPLibraryFileDAO) CreateLibraryFile(tx *dbs.Tx, name string, template string, emptyValues []string, fileId int64, countries []string, provinces [][2]string, cities [][3]string, towns [][4]string, providers []string) (int64, error) {
|
||||
var op = NewIPLibraryFileOperator()
|
||||
op.Name = name
|
||||
op.Template = template
|
||||
|
||||
if emptyValues == nil {
|
||||
@@ -137,6 +138,18 @@ func (this *IPLibraryFileDAO) CreateLibraryFile(tx *dbs.Tx, template string, emp
|
||||
return this.SaveInt64(tx, op)
|
||||
}
|
||||
|
||||
// FindAllFinishedLibraryFiles 查找所有已完成的文件
|
||||
func (this *IPLibraryFileDAO) FindAllFinishedLibraryFiles(tx *dbs.Tx) (result []*IPLibraryFile, err error) {
|
||||
_, err = this.Query(tx).
|
||||
State(IPLibraryFileStateEnabled).
|
||||
Result("id", "fileId", "createdAt", "generatedFileId", "generatedAt", "name"). // 这里不需要其他信息
|
||||
Attr("isFinished", true).
|
||||
DescPk().
|
||||
Slice(&result).
|
||||
FindAll()
|
||||
return
|
||||
}
|
||||
|
||||
// FindAllUnfinishedLibraryFiles 查找所有未完成的文件
|
||||
func (this *IPLibraryFileDAO) FindAllUnfinishedLibraryFiles(tx *dbs.Tx) (result []*IPLibraryFile, err error) {
|
||||
_, err = this.Query(tx).
|
||||
|
||||
@@ -5,6 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
||||
// IPLibraryFile IP库上传的文件
|
||||
type IPLibraryFile struct {
|
||||
Id uint64 `field:"id"` // ID
|
||||
Name string `field:"name"` // IP库名称
|
||||
FileId uint64 `field:"fileId"` // 原始文件ID
|
||||
Template string `field:"template"` // 模板
|
||||
EmptyValues dbs.JSON `field:"emptyValues"` // 空值列表
|
||||
@@ -23,6 +24,7 @@ type IPLibraryFile struct {
|
||||
|
||||
type IPLibraryFileOperator struct {
|
||||
Id any // ID
|
||||
Name any // IP库名称
|
||||
FileId any // 原始文件ID
|
||||
Template any // 模板
|
||||
EmptyValues any // 空值列表
|
||||
|
||||
@@ -162,3 +162,19 @@ func (this *RegionTownDAO) FindSimilarTowns(towns []*RegionTown, townName string
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateTown 创建区县
|
||||
func (this *RegionTownDAO) CreateTown(tx *dbs.Tx, cityId int64, townName string) (int64, error) {
|
||||
var op = NewRegionTownOperator()
|
||||
op.CityId = cityId
|
||||
op.Name = townName
|
||||
|
||||
codes, err := json.Marshal([]string{townName})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
op.Codes = codes
|
||||
|
||||
op.State = RegionTownStateEnabled
|
||||
return this.SaveInt64(tx, op)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user