Kaynağa Gözat

Merge branch 'feature/customer_1.0' into develop

wangxingcheng 3 yıl önce
ebeveyn
işleme
6f68758e8b

+ 13 - 15
opms_parent/app/handler/base/distributor.go

@@ -18,7 +18,7 @@ type DistributorHandler struct{}
 func (p *DistributorHandler) GetList(ctx context.Context, req *model.BaseDistributorSearchReq, rsp *comm_def.CommonMsg) error {
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	total, list, err := distributorServer.GetList(req)
@@ -31,7 +31,7 @@ func (p *DistributorHandler) GetList(ctx context.Context, req *model.BaseDistrib
 	return nil
 }
 
-// 创建
+//Create 创建
 func (p *DistributorHandler) Create(ctx context.Context, req *model.AddDistributor, rsp *comm_def.CommonMsg) error {
 
 	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
@@ -39,19 +39,19 @@ func (p *DistributorHandler) Create(ctx context.Context, req *model.AddDistribut
 	}
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	distributorServer.Create(req)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	return nil
 }
 
-//详情
+//GetEntityById 详情
 func (p *DistributorHandler) GetEntityById(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
 
 	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
@@ -59,22 +59,20 @@ func (p *DistributorHandler) GetEntityById(ctx context.Context, req *comm_def.Id
 	}
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	list, err := distributorServer.GetEntityById(req.Id)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	rsp.Data = g.Map{"list": list}
 	return nil
 }
 
-//删掉
-
-// 编辑
+//UpdateById 编辑
 func (p *DistributorHandler) UpdateById(ctx context.Context, req *model.UpdateDistributorReq, rsp *comm_def.CommonMsg) error {
 
 	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
@@ -82,27 +80,27 @@ func (p *DistributorHandler) UpdateById(ctx context.Context, req *model.UpdateDi
 	}
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	distributorServer.UpdateById(req)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	return nil
 }
 
-//删掉
+//DeleteByIds 删掉
 func (p *DistributorHandler) DeleteByIds(ctx context.Context, req *model.DeleteDistributorReq, rsp *comm_def.CommonMsg) error {
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	err = distributorServer.DeleteByIds(req.Ids)
-	g.Log().Info("req", req)
+
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)

+ 2 - 2
opms_parent/app/handler/base/district.go

@@ -18,7 +18,7 @@ func (d *DistrictHandler) GetList(ctx context.Context, req *comm_def.IdReq, rsp
 	if err != nil {
 		return err
 	}
-	list, err := districtServer.ListToTree(req.Id)
+	list, err := districtServer.GetProvincesList(req.Id)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		return err
@@ -33,7 +33,7 @@ func (s *DistrictHandler) GetRegionList(ctx context.Context, req *comm_def.IdReq
 	if err != nil {
 		return err
 	}
-	list, err := districtServer.ListToRegions()
+	list, err := districtServer.GetRegionsProvinceList()
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		return err

+ 7 - 5
opms_parent/app/model/base/base_district.go

@@ -14,16 +14,18 @@ import (
 type BaseDistrict internal.BaseDistrict
 
 // Fill with you ideas below.
+
 type BaseDistrictSearchReq struct {
 	Id int `json:"id"` //  省份ID
 	request.PageReq
 }
 
-type T struct {
-	Id       int    `json:"id"`
-	ParentId int    `json:"parentId"`
-	DistName string `json:"distName" `
-	Children []*T   `json:"children"`
+//Provinces  省市区三级结构
+type ProvincesTree struct {
+	Id       int              `json:"id"`
+	ParentId int              `json:"parentId"`
+	DistName string           `json:"distName" `
+	Children []*ProvincesTree `json:"children"`
 }
 type Province struct {
 	Id       int    `json:"id"`

+ 0 - 3
opms_parent/app/service/base/base_distributor.go

@@ -6,7 +6,6 @@ import (
 	"strconv"
 
 	"dashoo.cn/opms_libary/myerrors"
-	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/text/gstr"
@@ -52,11 +51,9 @@ func (s *distributorService) GetList(req *model.BaseDistributorSearchReq) (total
 	total, err = distributorModel.Count()
 	if err != nil {
 		g.Log().Error(err)
-		err = gerror.New("获取总行数失败")
 		return
 	}
 	err = distributorModel.Page(req.GetPage()).Order("id desc").Scan(&distributorList)
-	g.Log().Info("返回列表", distributorList)
 	return
 }
 

+ 7 - 8
opms_parent/app/service/base/base_district.go

@@ -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(&region)
 	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
 }