Browse Source

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

xuyiping 1 năm trước cách đây
mục cha
commit
ce4ba80436

+ 16 - 5
http/handler/feed/feed_formula.go

@@ -2,11 +2,6 @@ package feed
 
 import (
 	"fmt"
-	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
-	"gitee.com/xuyiping_admin/pkg/apierr"
-	"gitee.com/xuyiping_admin/pkg/ginutil"
-	"gitee.com/xuyiping_admin/pkg/valid"
-	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/http/middleware"
 	"mime/multipart"
 	"net/http"
@@ -14,6 +9,12 @@ import (
 	"strconv"
 	"time"
 
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
+	"gitee.com/xuyiping_admin/pkg/xerr"
+
 	"github.com/gin-gonic/gin"
 )
 
@@ -559,3 +560,13 @@ func Usage(c *gin.Context) {
 		ginutil.JSONResp(c, res)
 	}
 }
+
+// ForageByGroup 集团端可用的饲料列表
+func ForageByGroup(c *gin.Context) {
+	if res, err := middleware.BackendOperation(c).OpsService.ForageListByGroup(c); err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	} else {
+		ginutil.JSONResp(c, res)
+	}
+}

+ 1 - 0
http/route/ops_api.go

@@ -74,6 +74,7 @@ func OpsAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		opsRoute.POST("/feed_formula/feed_detail/list", feed.ForageDetailList)
 		opsRoute.POST("/feed_formula/edit_record/list", feed.EditRecordFeedFormula)
 		opsRoute.POST("/feed_formula/usage", feed.Usage)
+		opsRoute.GET("/feed_formula/forage_list", feed.ForageByGroup)
 
 		//统计分析 statistic analysis
 		opsRoute.POST("/feed_estimate/list", statistic.SearchFormulaEstimateList)

+ 21 - 0
module/backend/feed_service.go

@@ -1177,3 +1177,24 @@ func (s *StoreEntry) CheckFeedFormulaDistribute(ctx context.Context, pastureId,
 
 	return false
 }
+
+// ForageListByGroup 查询集团端饲料的列表数据
+func (s *StoreEntry) ForageListByGroup(ctx context.Context) (*operationPb.SearchForageListResponse, error) {
+	forage := make([]*model.Forage, 0)
+	var count int64 = 0
+
+	if err := s.DB.Model(new(model.Forage)).Where("is_delete = ?", operationPb.IsShow_OK).
+		Where("pasture_id = 0").Where("is_show = ?", operationPb.IsShow_OK).
+		Order("id DESC").Count(&count).Find(&forage).Error; err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
+	return &operationPb.SearchForageListResponse{
+		Code: http.StatusOK,
+		Msg:  "ok",
+		Data: &operationPb.SearchForageList{
+			Total: int32(count),
+			List:  model.ForageSlice(forage).ToPB(),
+		},
+	}, nil
+}

+ 4 - 2
module/backend/interface.go

@@ -3,14 +3,15 @@ package backend
 import (
 	"bytes"
 	"context"
-	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
-	"gitee.com/xuyiping_admin/pkg/di"
 	"io"
 	"kpt-tmr-group/config"
 	"kpt-tmr-group/model"
 	"kpt-tmr-group/service/wechat"
 	"kpt-tmr-group/store/kptstore"
 
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/di"
+
 	"go.uber.org/dig"
 )
 
@@ -109,6 +110,7 @@ type PastureService interface {
 	EditRecodeFeedFormula(ctx context.Context, req *operationPb.EditRecodeFeedFormulaRequest) (*operationPb.EditRecodeFeedFormulaResponse, error)
 	FeedFormulaDetailList(ctx context.Context, req *operationPb.FeedFormulaDetailRequest) (*operationPb.FeedFormulaDetailResponse, error)
 	FeedFormulaUsage(ctx context.Context, req *operationPb.FeedFormulaUsageRequest) (*operationPb.FeedFormulaUsageResponse, error)
+	ForageListByGroup(ctx context.Context) (*operationPb.SearchForageListResponse, error)
 }
 
 //go:generate mockgen -destination mock/SystemService.go -package kptservicemock kpt-tmr-group/module/backend SystemService

+ 2 - 3
module/backend/pasture_service.go

@@ -539,7 +539,7 @@ func (s *StoreEntry) CategoryDistribution(ctx context.Context, url string, req *
 			defer wg.Done()
 			res := &model.PastureCommonResponse{}
 			req.PastureId = int32(data.Id)
-			if err = s.PastureHttpClient(ctx, url, int64(data.Id), req, res); err != nil {
+			if err = s.PastureHttpClient(ctx, url, data.Id, req, res); err != nil {
 				zaplog.Error("CategoryDistribution",
 					zap.Any("url", url),
 					zap.Any("err", err),
@@ -555,7 +555,6 @@ func (s *StoreEntry) CategoryDistribution(ctx context.Context, url string, req *
 					zap.Any("res", res),
 				)
 			}
-
 		}(v)
 	}
 	wg.Wait()
@@ -681,7 +680,7 @@ func (s *StoreEntry) SearchForageList(ctx context.Context, req *operationPb.Sear
 		pref.Where("jump_delay = ?", req.JumpDelay)
 	}
 
-	if err := pref.Order("sort").Count(&count).Limit(int(req.Pagination.PageSize)).Offset(int(req.Pagination.PageOffset)).
+	if err := pref.Order("id DESC").Count(&count).Limit(int(req.Pagination.PageSize)).Offset(int(req.Pagination.PageOffset)).
 		Find(&forage).Error; err != nil {
 		return nil, xerr.WithStack(err)
 	}