Initial commit (code only without large binaries)
This commit is contained in:
@@ -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()
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user