Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package towns
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type CityOptionsAction struct {
actionutils.ParentAction
}
func (this *CityOptionsAction) RunPost(params struct {
ProvinceId int64
}) {
citiesResp, err := this.RPC().RegionCityRPC().FindAllRegionCitiesWithRegionProvinceId(this.AdminContext(), &pb.FindAllRegionCitiesWithRegionProvinceIdRequest{
RegionProvinceId: params.ProvinceId,
})
if err != nil {
this.ErrorPage(err)
return
}
var cityMaps = []maps.Map{}
for _, city := range citiesResp.RegionCities {
cityMaps = append(cityMaps, maps.Map{
"id": city.Id,
"name": city.DisplayName,
})
}
this.Data["cities"] = cityMaps
this.Success()
}

View File

@@ -0,0 +1,84 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package towns
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/ip-library/iplibraryutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "", "town")
}
func (this *IndexAction) RunGet(params struct {
CountryId int64
ProvinceId int64
CityId int64
}) {
// 检查权限
if !iplibraryutils.CanAccess() {
return
}
this.Data["canAccess"] = true
if params.CountryId <= 0 || params.ProvinceId <= 0 || params.CityId <= 0 {
params.CountryId = 1 // china
params.ProvinceId = 1 // beijing
params.CityId = 1 // beijing
}
this.Data["countryId"] = params.CountryId
this.Data["provinceId"] = params.ProvinceId
this.Data["cityId"] = params.CityId
// 所有国家/地区
countriesResp, err := this.RPC().RegionCountryRPC().FindAllRegionCountries(this.AdminContext(), &pb.FindAllRegionCountriesRequest{})
if err != nil {
this.ErrorPage(err)
return
}
var countryMaps = []maps.Map{}
for _, country := range countriesResp.RegionCountries {
countryMaps = append(countryMaps, maps.Map{
"id": country.Id,
"name": country.DisplayName,
})
}
this.Data["countries"] = countryMaps
// 区县列表
townsResp, err := this.RPC().RegionTownRPC().FindAllRegionTownsWithRegionCityId(this.AdminContext(), &pb.FindAllRegionTownsWithRegionCityIdRequest{
RegionCityId: params.CityId,
})
if err != nil {
this.ErrorPage(err)
return
}
var townMaps = []maps.Map{}
for _, town := range townsResp.RegionTowns {
if town.Codes == nil {
town.Codes = []string{}
}
if town.CustomCodes == nil {
town.CustomCodes = []string{}
}
townMaps = append(townMaps, maps.Map{
"id": town.Id,
"name": town.Name,
"codes": town.Codes,
"customName": town.CustomName,
"customCodes": town.CustomCodes,
})
}
this.Data["towns"] = townMaps
this.Show()
}

View File

@@ -0,0 +1,36 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package towns
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type ProvinceOptionsAction struct {
actionutils.ParentAction
}
func (this *ProvinceOptionsAction) RunPost(params struct {
CountryId int64
}) {
provincesResp, err := this.RPC().RegionProvinceRPC().FindAllRegionProvincesWithRegionCountryId(this.AdminContext(), &pb.FindAllRegionProvincesWithRegionCountryIdRequest{
RegionCountryId: params.CountryId,
})
if err != nil {
this.ErrorPage(err)
return
}
var provinceMaps = []maps.Map{}
for _, province := range provincesResp.RegionProvinces {
provinceMaps = append(provinceMaps, maps.Map{
"id": province.Id,
"name": province.DisplayName,
})
}
this.Data["provinces"] = provinceMaps
this.Success()
}

View File

@@ -0,0 +1,72 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package towns
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type UpdatePopupAction struct {
actionutils.ParentAction
}
func (this *UpdatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *UpdatePopupAction) RunGet(params struct {
TownId int64
}) {
townResp, err := this.RPC().RegionTownRPC().FindRegionTown(this.AdminContext(), &pb.FindRegionTownRequest{RegionTownId: params.TownId})
if err != nil {
this.ErrorPage(err)
return
}
var town = townResp.RegionTown
if town == nil {
this.NotFound("regionTown", params.TownId)
return
}
if town.Codes == nil {
town.Codes = []string{}
}
if town.CustomCodes == nil {
town.CustomCodes = []string{}
}
this.Data["town"] = maps.Map{
"id": town.Id,
"name": town.Name,
"codes": town.Codes,
"customName": town.CustomName,
"customCodes": town.CustomCodes,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
TownId int64
CustomName string
CustomCodes []string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo(codes.RegionTown_LogUpdateRegionTownCustom, params.TownId)
_, err := this.RPC().RegionTownRPC().UpdateRegionTownCustom(this.AdminContext(), &pb.UpdateRegionTownCustomRequest{
RegionTownId: params.TownId,
CustomName: params.CustomName,
CustomCodes: params.CustomCodes,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}