This commit is contained in:
unknown
2026-02-04 20:27:13 +08:00
commit 3b042d1dad
9410 changed files with 1488147 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package countries
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("", "", "country")
}
func (this *IndexAction) RunGet(params struct{}) {
// 检查权限
if !iplibraryutils.CanAccess() {
return
}
this.Data["canAccess"] = true
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 {
if country.Codes == nil {
country.Codes = []string{}
}
if country.CustomCodes == nil {
country.CustomCodes = []string{}
}
countryMaps = append(countryMaps, maps.Map{
"id": country.Id,
"name": country.Name,
"codes": country.Codes,
"customName": country.CustomName,
"customCodes": country.CustomCodes,
})
}
this.Data["countries"] = countryMaps
this.Show()
}

View File

@@ -0,0 +1,74 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package countries
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 {
CountryId int64
}) {
countryResp, err := this.RPC().RegionCountryRPC().FindRegionCountry(this.AdminContext(), &pb.FindRegionCountryRequest{
RegionCountryId: params.CountryId,
})
if err != nil {
this.ErrorPage(err)
return
}
var country = countryResp.RegionCountry
if country == nil {
this.NotFound("regionCountry", params.CountryId)
return
}
if country.Codes == nil {
country.Codes = []string{}
}
if country.CustomCodes == nil {
country.CustomCodes = []string{}
}
this.Data["country"] = maps.Map{
"id": country.Id,
"name": country.Name,
"codes": country.Codes,
"customName": country.CustomName,
"customCodes": country.CustomCodes,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
CountryId int64
CustomName string
CustomCodes []string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo(codes.RegionCountry_LogUpdateRegionCountryCustom, params.CountryId)
_, err := this.RPC().RegionCountryRPC().UpdateRegionCountryCustom(this.AdminContext(), &pb.UpdateRegionCountryCustomRequest{
RegionCountryId: params.CountryId,
CustomName: params.CustomName,
CustomCodes: params.CustomCodes,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}