You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
844 B
Go

package svc
import (
"context"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
)
var DistrictHelperInst = NewDistrictHelper()
type (
DistrictHelper struct {
getNameFn GetDistrictNameFunc
svcCtx *ServiceContext
}
DistrictCacheItem struct {
Code string // 区域代码
NameList []string // 区域名称列表(从根节点开始)
}
GetDistrictNameFunc func(ctx context.Context, svcCtx *ServiceContext, code, separator string) (*core.GetDistrictNameResp, error)
)
func NewDistrictHelper() *DistrictHelper {
return &DistrictHelper{}
}
func (h *DistrictHelper) SetGetDistrictNameFn(fn GetDistrictNameFunc) {
h.getNameFn = fn
}
func (h *DistrictHelper) GetDistrictName(ctx context.Context, code, separator string) (*core.GetDistrictNameResp, error) {
return h.getNameFn(ctx, h.svcCtx, code, separator)
}