|
|
@@ -29,9 +29,9 @@ func NewDistrictService(ctx context.Context) (svc *districtService, err error) {
|
|
|
return svc, nil
|
|
|
}
|
|
|
|
|
|
-//ListToTree 所属区域列表
|
|
|
-func (s *districtService) ListToTree(Id int64) (treeList []*model.T, err error) {
|
|
|
- ms := make(map[int]*model.T)
|
|
|
+//GetProvincesList 所属区域列表
|
|
|
+func (s *districtService) GetProvincesList(Id int64) (treeList []*model.ProvincesTree, err error) {
|
|
|
+ ms := make(map[int]*model.ProvincesTree)
|
|
|
var distributorList []model.BaseDistrict
|
|
|
err = s.Dao.Order("id asc").Scan(&distributorList)
|
|
|
if err != nil {
|
|
|
@@ -40,7 +40,7 @@ func (s *districtService) ListToTree(Id int64) (treeList []*model.T, err error)
|
|
|
}
|
|
|
|
|
|
for _, v := range distributorList {
|
|
|
- ms[v.Id] = &model.T{
|
|
|
+ ms[v.Id] = &model.ProvincesTree{
|
|
|
Id: v.Id,
|
|
|
ParentId: v.ParentId,
|
|
|
DistName: v.DistName,
|
|
|
@@ -58,7 +58,7 @@ func (s *districtService) ListToTree(Id int64) (treeList []*model.T, err error)
|
|
|
}
|
|
|
|
|
|
// SortToProvince 省市区排序
|
|
|
-func (s *districtService) SortToProvince(treeList []*model.T) []*model.T {
|
|
|
+func (s *districtService) SortToProvince(treeList []*model.ProvincesTree) []*model.ProvincesTree {
|
|
|
length := len(treeList)
|
|
|
for i := 0; i < length-1; i++ {
|
|
|
for j := i + 1; j < length; j++ {
|
|
|
@@ -85,8 +85,8 @@ func (s *districtService) GetProvinceList() (list []*model.Province, err error)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//ListToRegions 区域下所有的省份
|
|
|
-func (s *districtService) ListToRegions() (region []*model.Region, err error) {
|
|
|
+//GetRegionsProvinceList 区域下所有的省份
|
|
|
+func (s *districtService) GetRegionsProvinceList() (region []*model.Region, err error) {
|
|
|
|
|
|
err = s.RegionDao.Fields(s.RegionDao.Columns.RegionDesc, s.RegionDao.Columns.Id).Scan(®ion)
|
|
|
if err != nil {
|
|
|
@@ -114,6 +114,5 @@ func (s *districtService) ListToRegions() (region []*model.Region, err error) {
|
|
|
for _, v := range region {
|
|
|
v.Children = ms[v.Id]
|
|
|
}
|
|
|
- g.Log().Info("return", region)
|
|
|
return
|
|
|
}
|