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,81 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package cities
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("", "", "city")
}
func (this *IndexAction) RunGet(params struct {
CountryId int64
ProvinceId int64
}) {
// 检查权限
if !iplibraryutils.CanAccess() {
return
}
this.Data["canAccess"] = true
if params.CountryId <= 0 || params.ProvinceId <= 0 {
params.CountryId = 1 // china
params.ProvinceId = 1 // beijing
}
this.Data["countryId"] = params.CountryId
this.Data["provinceId"] = params.ProvinceId
// 所有国家/地区
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
// 城市列表
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 {
if city.Codes == nil {
city.Codes = []string{}
}
if city.CustomCodes == nil {
city.CustomCodes = []string{}
}
cityMaps = append(cityMaps, maps.Map{
"id": city.Id,
"name": city.Name,
"codes": city.Codes,
"customName": city.CustomName,
"customCodes": city.CustomCodes,
})
}
this.Data["cities"] = cityMaps
this.Show()
}

View File

@@ -0,0 +1,36 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package cities
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 cities
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 {
CityId int64
}) {
cityResp, err := this.RPC().RegionCityRPC().FindRegionCity(this.AdminContext(), &pb.FindRegionCityRequest{RegionCityId: params.CityId})
if err != nil {
this.ErrorPage(err)
return
}
var city = cityResp.RegionCity
if city == nil {
this.NotFound("regionCity", params.CityId)
return
}
if city.Codes == nil {
city.Codes = []string{}
}
if city.CustomCodes == nil {
city.CustomCodes = []string{}
}
this.Data["city"] = maps.Map{
"id": city.Id,
"name": city.Name,
"codes": city.Codes,
"customName": city.CustomName,
"customCodes": city.CustomCodes,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
CityId int64
CustomName string
CustomCodes []string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo(codes.RegionCity_LogUpdateRegionCityCustom, params.CityId)
_, err := this.RPC().RegionCityRPC().UpdateRegionCityCustom(this.AdminContext(), &pb.UpdateRegionCityCustomRequest{
RegionCityId: params.CityId,
CustomName: params.CustomName,
CustomCodes: params.CustomCodes,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}