Procházet zdrojové kódy

Merge branch 'feature/bug-list' of xuyiping/kpt-tmr-group into develop

xuyiping před 1 rokem
rodič
revize
33b0f27026
2 změnil soubory, kde provedl 14 přidání a 6 odebrání
  1. 3 0
      http/middleware/cors.go
  2. 11 6
      module/backend/pasture_service.go

+ 3 - 0
http/middleware/cors.go

@@ -1,6 +1,7 @@
 package middleware
 
 import (
+	"io/ioutil"
 	"kpt-tmr-group/pkg/logger/zaplog"
 	"net/http"
 
@@ -41,10 +42,12 @@ func CORS(configs ...cors.Config) gin.HandlerFunc {
 
 		defer func() {
 			if err := recover(); err != nil {
+				body, _ := ioutil.ReadAll(c.Request.Body)
 				zaplog.Error("cors",
 					zap.Any("recover", err),
 					zap.Any("url", c.Request.URL),
 					zap.Any("method", method),
+					zap.Any("request", string(body)),
 				)
 			}
 		}()

+ 11 - 6
module/backend/pasture_service.go

@@ -155,11 +155,16 @@ func (s *StoreEntry) SearchGroupPastureList(ctx context.Context, req *operationP
 	}, nil
 }
 
-func (s *StoreEntry) GroupPastureList(ctx context.Context) ([]*model.GroupPasture, error) {
+// DataSyncGroupPastureList 用户数据下发的牧场
+func (s *StoreEntry) DataSyncGroupPastureList(ctx context.Context) ([]*model.GroupPasture, error) {
 	groupPastureList := make([]*model.GroupPasture, 0)
-	if err := s.DB.Model(new(model.GroupPasture)).Where("is_delete = ? ", operationPb.IsShow_OK).Find(&groupPastureList).Error; err != nil {
+	if err := s.DB.Model(new(model.GroupPasture)).Where("is_delete = ? ", operationPb.IsShow_OK).
+		Where("is_show = ?", operationPb.IsShow_OK).Where("domain != ''").
+		Where("is_distribution = ?", operationPb.IsShow_OK).
+		Find(&groupPastureList).Error; err != nil {
 		return nil, xerr.WithStack(err)
 	}
+	zaplog.Info("GroupPastureList", zap.Any("data", groupPastureList))
 	return groupPastureList, nil
 }
 
@@ -514,7 +519,7 @@ func (s *StoreEntry) SearchForageCategoryList(ctx context.Context, req *operatio
 
 // CategoryDistribution 饲料分类和畜牧分类下发
 func (s *StoreEntry) CategoryDistribution(ctx context.Context, url string, req *model.CategoryRequest) error {
-	groupList, err := s.GroupPastureList(ctx)
+	groupList, err := s.DataSyncGroupPastureList(ctx)
 	if err != nil {
 		return xerr.WithStack(err)
 	}
@@ -549,7 +554,7 @@ func (s *StoreEntry) CategoryDistribution(ctx context.Context, url string, req *
 
 // CategoryDelete 饲料分类和畜牧分类删除
 func (s *StoreEntry) CategoryDelete(ctx context.Context, url string, req *model.CategoryDeleteRequest) error {
-	groupList, err := s.GroupPastureList(ctx)
+	groupList, err := s.DataSyncGroupPastureList(ctx)
 	if err != nil {
 		return xerr.WithStack(err)
 	}
@@ -560,7 +565,7 @@ func (s *StoreEntry) CategoryDelete(ctx context.Context, url string, req *model.
 			res := &model.PastureCommonResponse{}
 			req.PastureId = int32(data.Id)
 			if err = s.PastureHttpClient(ctx, url, int64(data.Id), req, res); err != nil {
-				zaplog.Error("CategoryDistribution",
+				zaplog.Error("CategoryDelete",
 					zap.Any("url", url),
 					zap.Any("err", err),
 					zap.Any("body", req),
@@ -569,7 +574,7 @@ func (s *StoreEntry) CategoryDelete(ctx context.Context, url string, req *model.
 			}
 
 			if res.Code != http.StatusOK {
-				zaplog.Error("CategoryDistribution-http",
+				zaplog.Error("CategoryDelete-http",
 					zap.Any("url", url),
 					zap.Any("body", req),
 					zap.Any("res", res),