Browse Source

project: add gomock

Yi 1 year ago
parent
commit
fedecc85ce

+ 4 - 1
README.md

@@ -35,4 +35,7 @@ TODO 列表
 - proto3 int64 jsonpb处理后自动转成string
   * 现在处理的方式是把int64类型改成int32类型
 - 用户登出没有用redis做缓存,所以后端没有提供登出接口,有以下弊端
-  * 用户的token没有过期,如被人劫持,会被使用到直到token过期
+  * 用户的token没有过期,如被人劫持,会被使用到直到token过期
+  
+- 饲料列表
+  * 小料车下拉框问题

+ 1 - 1
backend/operation/feed_formula.proto

@@ -23,7 +23,7 @@ message AddFeedFormulaRequest {
   IsShow.Kind is_modify = 14;        // 是否可修改
   int32 created_at = 15;             // 创建时间
   string created_at_format = 16;     // 创建时间格式化
-  string Pasture_name = 17;          // 牧场名称
+  string pasture_name = 17;          // 牧场名称
 }
 
 message SearchFeedFormulaRequest {

+ 32 - 22
backend/operation/pasture.proto

@@ -118,40 +118,43 @@ message SearchForageCategoryRequest {
 message SearchForageCategoryResponse {
   int32 code = 1;
   string msg = 2;
-    SearchForageCategoryData data = 3;
+  SearchForageCategoryData data = 3;
 }
 
 message SearchForageCategoryData {
   int32 page = 1;
   int32 total = 2;
-  repeated AddForageCategoryRequest list = 3;
+  int32 page_size = 3;
+  repeated AddForageCategoryRequest list = 4;
 }
 
 // 饲料列表
 message AddForageRequest {
-  uint32 id = 1;
+  int32 id = 1;
   string name = 2;                // 饲料名称
-  uint32 category_id = 3;          // 饲料分类id
+  int32 category_id = 3;          // 饲料分类id
   string category_name = 4;       // 饲料分类名称
-  uint32 material_type = 5;        // 物料类型
+  int32 material_type = 5;        // 物料类型
   string unique_encode = 7;       // 唯一编码
-  ForageSource.Kind forage_source_id = 8;       // 饲料来源
-  ForagePlanType.Kind plan_type_id = 9;       // 计划类型
-  string  small_material_scale = 10;           // 小料称
-  uint32 allow_error = 11;                     // 允许误差 (单位kg)
-  uint32 package_weight = 12;                  // 包装重量 (单位kg)
-  uint32 price = 13;                          // 单价(单位分)
-  uint32 jump_weight = 14;                    // 跳转重量域(单位kg)
-  JumpDelaType.Kind jump_delay = 15;         // 跳转延迟
-  IsShow.Kind confirm_start = 16;            // 确认开始
-  uint32  relay_locations = 17;               // 继电器位置
-  IsShow.Kind jmp = 18;                     // 无上域
-  string backup1 = 19;                      // 备用字段1
-  string backup2 = 20;                      // 备用字段2
-  string backup3 = 21;                      // 备用字段3
-  uint32 created_at = 22;                    // 创建时间
-  string created_at_format = 23;            // 创建时间格式化
-  IsShow.Kind is_show = 24;                  // 是否启用
+  ForageSource.Kind forage_source_id = 8;       // 饲料来源id
+  string forage_source_name = 9;                // 饲料来源名称
+  ForagePlanType.Kind plan_type_id = 10;       // 计划类型id
+  string plan_type_name = 11;                  // 计划类型名称
+  string  small_material_scale = 12;           // 小料称
+  int32 allow_error = 13;                     // 允许误差 (单位kg)
+  int32 package_weight = 14;                  // 包装重量 (单位kg)
+  int32 price = 15;                          // 单价(单位分)
+  int32 jump_weight = 16;                    // 跳转重量域(单位kg)
+  JumpDelaType.Kind jump_delay = 17;         // 跳转延迟
+  IsShow.Kind confirm_start = 18;            // 确认开始
+  int32  relay_locations = 19;               // 继电器位置
+  IsShow.Kind jmp = 20;                     // 无上域
+  string backup1 = 21;                      // 备用字段1
+  string backup2 = 22;                      // 备用字段2
+  string backup3 = 23;                      // 备用字段3
+  int32 created_at = 24;                    // 创建时间
+  string created_at_format = 25;            // 创建时间格式化
+  IsShow.Kind is_show = 26;                  // 是否启用
 }
 
 message SearchForageListRequest {
@@ -166,6 +169,12 @@ message SearchForageListRequest {
 }
 
 message SearchForageListResponse {
+ int32 code = 1;
+ string msg = 2;
+ SearchForageList data = 3;
+}
+
+message SearchForageList {
   int32 page = 1;
   int32 page_size = 2;
   int32 total = 3;
@@ -193,6 +202,7 @@ message ForageEnumList {
   repeated IsShowEnum is_show = 6;
   repeated FormulaTypeEnum formula_type = 7;
   repeated FormulaOptionEnum formula_list = 8;
+  repeated IsShowEnum confirm_start = 9;
 }
 
 message ForageSourceEnum {

+ 1 - 1
config/app.go

@@ -7,7 +7,7 @@ import (
 	"sync"
 )
 
-const AppName = "kptEvent"
+const AppName = "kptTmrGroup"
 
 var (
 	Module   = di.Provide(Options)

+ 1 - 0
config/load_config.go

@@ -9,6 +9,7 @@ import (
 
 func Initialize(path string, cfgStruct interface{}) error {
 	dir := fmt.Sprintf("./config/%s", path)
+	// dir = fmt.Sprintf("D:\\project\\golangNew\\kpt-tmr-group\\config\\%s", path)
 	viper.SetConfigType("yaml")
 	viper.SetConfigFile(dir)
 	if err := viper.ReadInConfig(); err != nil {

+ 1 - 0
go.mod

@@ -12,6 +12,7 @@ require (
 	github.com/gin-gonic/gin v1.9.0
 	github.com/go-redis/redis v6.15.9+incompatible
 	github.com/go-redis/redis/v7 v7.4.1
+	github.com/golang/mock v1.4.4
 	github.com/golang/protobuf v1.5.3
 	github.com/google/go-cmp v0.5.9
 	github.com/grpc-ecosystem/go-grpc-middleware v1.4.0

+ 1 - 0
go.sum

@@ -129,6 +129,7 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
 github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
 github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
 github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
 github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=

+ 2 - 0
http/debug/debug.go

@@ -7,5 +7,7 @@ import (
 )
 
 func HelloOk(c *gin.Context) {
+	// redis
+	// kafka
 	c.JSON(http.StatusOK, gin.H{"result": "ok"})
 }

+ 22 - 0
http/debug/debug_test.go

@@ -0,0 +1,22 @@
+package debug_test
+
+import (
+	"kpt-tmr-group/http/util/httptt"
+	"net/http"
+	"net/http/httptest"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestHelloOk(t *testing.T) {
+	t.Run("ok", func(t *testing.T) {
+		g, ctrl, _ := fakeServer(t)
+		defer ctrl.Finish()
+		req := httptt.NewRequest(t, http.MethodGet, "/debug/test", nil)
+		rw := httptest.NewRecorder()
+
+		g.ServeHTTP(rw, req)
+		assert.Equal(t, http.StatusOK, rw.Code)
+	})
+}

+ 46 - 0
http/debug/x_main_test.go

@@ -0,0 +1,46 @@
+package debug_test
+
+import (
+	"io/ioutil"
+	"kpt-tmr-group/dep"
+	"kpt-tmr-group/http/middleware"
+	"kpt-tmr-group/http/route"
+	"kpt-tmr-group/module/backend"
+	kptservicemock "kpt-tmr-group/module/backend/mock"
+	"kpt-tmr-group/test/mock"
+	"os"
+	"testing"
+
+	"go.uber.org/dig"
+
+	"github.com/gin-gonic/gin"
+	"github.com/golang/mock/gomock"
+)
+
+func TestMain(m *testing.M) {
+	gin.SetMode(gin.ReleaseMode)
+	gin.DefaultWriter = ioutil.Discard
+	os.Exit(m.Run())
+}
+
+type Mock struct {
+	dig.In
+
+	KptService *kptservicemock.MockKptService
+}
+
+func fakeServer(t *testing.T) (*gin.Engine, *gomock.Controller, *Mock) {
+	ctrl := gomock.NewController(t)
+	var currMock *Mock
+	mock.GetMock(ctrl, func(entry Mock) { currMock = &entry })
+
+	g := gin.New()
+	route.HTTPServerRoute(func(engine *gin.Engine) {
+		engine.Use(middleware.WithDependency(&dep.HttpDependency{
+			StoreEventHub: backend.Hub{
+				OpsService: currMock.KptService,
+			},
+		}))
+	})(g)
+	return g, ctrl, currMock
+}

+ 8 - 6
http/handler/pasture/forage_list.go

@@ -18,7 +18,7 @@ import (
 
 func AddForage(c *gin.Context) {
 	var req operationPb.AddForageRequest
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -28,8 +28,10 @@ func AddForage(c *gin.Context) {
 		valid.Field(&req.CategoryId, valid.Required),
 		valid.Field(&req.UniqueEncode, valid.Required),
 		valid.Field(&req.ForageSourceId, valid.Required),
-		valid.Field(&req.PlanTypeId, valid.Required),
-		valid.Field(&req.JumpWeight, valid.Required, valid.Min(0), valid.Max(50)),
+		valid.Field(&req.ForageSourceName, valid.Required),
+		//valid.Field(&req.PlanTypeId, valid.Required, valid.Min(0), valid.Max(2)),
+		valid.Field(&req.PlanTypeName, valid.Required),
+		//valid.Field(&req.JumpWeight, valid.Required, valid.Min(0), valid.Max(50)),
 	); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
@@ -48,7 +50,7 @@ func AddForage(c *gin.Context) {
 
 func EditForage(c *gin.Context) {
 	var req operationPb.AddForageRequest
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -129,7 +131,7 @@ func DeleteForageList(c *gin.Context) {
 
 func IsShowForage(c *gin.Context) {
 	var req operationPb.IsShowForage
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -195,7 +197,7 @@ func ExcelImportForage(c *gin.Context) {
 func ExcelExportForage(c *gin.Context) {
 
 	req := &operationPb.SearchForageListRequest{}
-	if err := c.BindJSON(req); err != nil {
+	if err := ginutil.BindProto(c, req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}

+ 1 - 0
http/route/api_debug_route.go

@@ -15,6 +15,7 @@ func DebugAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 
 		// Not Found
 		s.NoRoute(handler.Handle404)
+		s.GET("/debug/test", debug.HelloOk)
 		debugRoute := authRouteGroup(s, "/api/v1/kpt/debug/")
 		// kpt debug api
 		debugRoute.GET("hello", debug.HelloOk)

+ 70 - 0
http/util/httptt/http.go

@@ -0,0 +1,70 @@
+package httptt
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"net/http"
+	"testing"
+
+	"kpt-tmr-group/pkg/jsonpb"
+
+	"github.com/golang/protobuf/proto"
+	"github.com/stretchr/testify/require"
+)
+
+func NewRequest(t *testing.T, method, path string, body proto.Message) *http.Request {
+	var (
+		req *http.Request
+		err error
+	)
+	switch method {
+	case http.MethodGet, http.MethodDelete:
+		var url string
+		if body != nil {
+			v := MarshalQueryPB(body)
+			query := v.Encode()
+			url = fmt.Sprintf("%s?%s", path, query)
+		} else {
+			url = path
+		}
+		req, err = http.NewRequest(method, url, nil)
+		require.NoError(t, err)
+	default:
+		if body != nil {
+			bs, err := jsonpb.MarshalBytes(body)
+			require.NoError(t, err)
+			req, err = http.NewRequest(method, path, bytes.NewReader(bs))
+			require.NoError(t, err)
+		} else {
+			req, err = http.NewRequest(method, path, nil)
+			require.NoError(t, err)
+		}
+	}
+	return req
+}
+
+func NewRequest2(t *testing.T, method, path string, body interface{}) *http.Request {
+	var (
+		req *http.Request
+		err error
+	)
+	switch method {
+	case http.MethodGet:
+		var url string
+		url = path
+		req, err = http.NewRequest(http.MethodGet, url, nil)
+		require.NoError(t, err)
+	default:
+		if body != nil {
+			bs, err := json.Marshal(body)
+			require.NoError(t, err)
+			req, err = http.NewRequest(method, path, bytes.NewReader(bs))
+			require.NoError(t, err)
+		} else {
+			req, err = http.NewRequest(method, path, nil)
+			require.NoError(t, err)
+		}
+	}
+	return req
+}

+ 100 - 0
http/util/httptt/query_encoder.go

@@ -0,0 +1,100 @@
+package httptt
+
+import (
+	"encoding/json"
+	"fmt"
+	"math"
+	"net/url"
+	"reflect"
+	"strings"
+
+	"kpt-tmr-group/pkg/xerr"
+
+	"github.com/golang/protobuf/proto"
+)
+
+type wkt interface {
+	XXX_WellKnownType() string
+}
+
+var wktType = reflect.TypeOf((*wkt)(nil)).Elem()
+
+func MarshalQueryPB(pb proto.Message) *url.Values {
+	fields := make(url.Values)
+	target := reflect.ValueOf(pb).Elem()
+	props := proto.GetProperties(target.Type())
+	for i := 0; i < target.NumField(); i++ {
+		ft := target.Type().Field(i)
+
+		if strings.HasPrefix(ft.Name, "XXX_") || ft.Anonymous {
+			continue
+		}
+		// unexported field
+		if strings.ToUpper(ft.Name[:1]) != ft.Name[:1] {
+			continue
+		}
+
+		if err := setFields(&fields, target.Field(i), props.Prop[i]); err != nil {
+			panic(err)
+		}
+	}
+	return &fields
+}
+
+func setFields(fields *url.Values, target reflect.Value, prop *proto.Properties) error {
+	if target.Kind() == reflect.Slice && target.Type().Elem().Kind() != reflect.Uint8 {
+		for i := 0; i < target.Len(); i++ {
+			if err := setFields(fields, target.Index(i), prop); err != nil {
+				return xerr.WithStack(err)
+			}
+		}
+		return nil
+	}
+	// Handle well-known types.
+	// Most are handled up in marshalObject (because 99% are messages).
+	if target.Type().Implements(wktType) {
+		wkt := target.Interface().(wkt)
+		switch wkt.XXX_WellKnownType() {
+		case "NullValue":
+			appendFields(fields, prop, "null")
+			return nil
+		}
+	}
+
+	if prop.Enum != "" {
+		appendFields(fields, prop, target.Interface().(fmt.Stringer).String())
+		return nil
+	}
+
+	if target.Kind() == reflect.Float32 || target.Kind() == reflect.Float64 {
+		f := target.Float()
+		var sval string
+		switch {
+		case math.IsInf(f, 1):
+			sval = `"Infinity"`
+		case math.IsInf(f, -1):
+			sval = `"-Infinity"`
+		case math.IsNaN(f):
+			sval = `"NaN"`
+		}
+		if sval != "" {
+			appendFields(fields, prop, sval)
+			return nil
+		}
+	}
+
+	b, err := json.Marshal(target.Interface())
+	if err != nil {
+		return xerr.WithStack(err)
+	}
+	appendFields(fields, prop, string(b))
+	return nil
+}
+
+func appendFields(v *url.Values, prop *proto.Properties, value string) {
+	key := prop.JSONName
+	if key == "" {
+		key = prop.OrigName
+	}
+	v.Add(key, value)
+}

+ 13 - 9
model/forage.go

@@ -14,7 +14,9 @@ type Forage struct {
 	MaterialType       int64                           `json:"material_type"`
 	UniqueEncode       string                          `json:"unique_encode"`
 	ForageSourceId     operationPb.ForageSource_Kind   `json:"forage_source_id"`
+	ForageSourceName   string                          `json:"forage_source_name"`
 	PlanTypeId         operationPb.ForagePlanType_Kind `json:"plan_type_id"`
+	PlanTypeName       string                          `json:"plan_type_name"`
 	SmallMaterialScale string                          `json:"small_material_scale"`
 	AllowError         int64                           `json:"allow_error"`
 	PackageWeight      int64                           `json:"package_weight"`
@@ -44,7 +46,9 @@ func NewForage(req *operationPb.AddForageRequest) *Forage {
 		CategoryId:         int64(req.CategoryId),
 		UniqueEncode:       req.UniqueEncode,
 		ForageSourceId:     req.ForageSourceId,
+		ForageSourceName:   req.ForageSourceName,
 		PlanTypeId:         req.PlanTypeId,
+		PlanTypeName:       req.PlanTypeName,
 		SmallMaterialScale: req.SmallMaterialScale,
 		AllowError:         int64(req.AllowError),
 		PackageWeight:      int64(req.PackageWeight),
@@ -69,23 +73,23 @@ func (f ForageSlice) ToPB() []*operationPb.AddForageRequest {
 	res := make([]*operationPb.AddForageRequest, len(f))
 	for i, v := range f {
 		res[i] = &operationPb.AddForageRequest{
-			Id:                 uint32(v.Id),
+			Id:                 int32(v.Id),
 			Name:               v.Name,
-			CategoryId:         uint32(v.CategoryId),
-			MaterialType:       uint32(v.MaterialType),
+			CategoryId:         int32(v.CategoryId),
+			MaterialType:       int32(v.MaterialType),
 			UniqueEncode:       v.UniqueEncode,
 			ForageSourceId:     v.ForageSourceId,
 			PlanTypeId:         v.PlanTypeId,
 			SmallMaterialScale: v.SmallMaterialScale,
-			AllowError:         uint32(v.AllowError),
-			PackageWeight:      uint32(v.PackageWeight),
-			Price:              uint32(v.Price),
-			JumpWeight:         uint32(v.JumpWeight),
+			AllowError:         int32(v.AllowError),
+			PackageWeight:      int32(v.PackageWeight),
+			Price:              int32(v.Price),
+			JumpWeight:         int32(v.JumpWeight),
 			JumpDelay:          v.JumpDelay,
 			ConfirmStart:       v.ConfirmStart,
-			RelayLocations:     uint32(v.RelayLocations),
+			RelayLocations:     int32(v.RelayLocations),
 			IsShow:             v.IsShow,
-			CreatedAt:          uint32(v.CreatedAt),
+			CreatedAt:          int32(v.CreatedAt),
 			CreatedAtFormat:    time.Unix(v.CreatedAt, 0).Format(LayoutTime),
 		}
 	}

+ 12 - 3
module/backend/interface.go

@@ -25,7 +25,7 @@ type StoreEntry struct {
 
 	Cfg *config.AppConfig
 	DB  *kptstore.DB
-	//SSO *sso.Cache
+	// SSO *sso.Cache
 	// AsynqClient asynqsvc.Client
 	// Cache *redis.Client
 	WxClient *wechat.ClientService
@@ -35,9 +35,18 @@ func NewStore(store StoreEntry) KptService {
 	return &store
 }
 
+func NewStoreEntry(cfg *config.AppConfig, Db *kptstore.DB) *StoreEntry {
+	return &StoreEntry{
+		Cfg:      cfg,
+		DB:       Db,
+		WxClient: nil,
+	}
+}
+
+//go:generate mockgen -destination mock/kptservice.go -package kptservicemock kpt-tmr-group/module/backend KptService
 type KptService interface {
 	PastureService   // 牧场相关操作
-	SystemOperation  // 系统相关操作
+	SystemService    // 系统相关操作
 	WxAppletService  // 小程序相关
 	StatisticService // 统计分析
 }
@@ -89,7 +98,7 @@ type PastureService interface {
 	ExcelTemplateFeedFormula(ctx context.Context) (*bytes.Buffer, error)
 }
 
-type SystemOperation interface {
+type SystemService interface {
 	// Auth 系统用户相关
 	Auth(ctx context.Context, auth *operationPb.UserAuthData) (*operationPb.SystemToken, error)
 	GetUserInfo(ctx context.Context, token string) (*operationPb.UserAuth, error)

+ 870 - 0
module/backend/mock/kptservice.go

@@ -0,0 +1,870 @@
+// Code generated by MockGen. DO NOT EDIT.
+// Source: kpt-tmr-group/module/backend (interfaces: KptService)
+
+// Package kptservicemock is a generated GoMock package.
+package kptservicemock
+
+import (
+	bytes "bytes"
+	context "context"
+	io "io"
+	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	reflect "reflect"
+
+	gomock "github.com/golang/mock/gomock"
+)
+
+// MockKptService is a mock of KptService interface.
+type MockKptService struct {
+	ctrl     *gomock.Controller
+	recorder *MockKptServiceMockRecorder
+}
+
+// MockKptServiceMockRecorder is the mock recorder for MockKptService.
+type MockKptServiceMockRecorder struct {
+	mock *MockKptService
+}
+
+// NewMockKptService creates a new mock instance.
+func NewMockKptService(ctrl *gomock.Controller) *MockKptService {
+	mock := &MockKptService{ctrl: ctrl}
+	mock.recorder = &MockKptServiceMockRecorder{mock}
+	return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockKptService) EXPECT() *MockKptServiceMockRecorder {
+	return m.recorder
+}
+
+// AddCattleCategory mocks base method.
+func (m *MockKptService) AddCattleCategory(arg0 context.Context, arg1 *operationPb.AddCattleCategoryRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "AddCattleCategory", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// AddCattleCategory indicates an expected call of AddCattleCategory.
+func (mr *MockKptServiceMockRecorder) AddCattleCategory(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddCattleCategory", reflect.TypeOf((*MockKptService)(nil).AddCattleCategory), arg0, arg1)
+}
+
+// AddForageCategory mocks base method.
+func (m *MockKptService) AddForageCategory(arg0 context.Context, arg1 *operationPb.AddForageCategoryRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "AddForageCategory", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// AddForageCategory indicates an expected call of AddForageCategory.
+func (mr *MockKptServiceMockRecorder) AddForageCategory(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddForageCategory", reflect.TypeOf((*MockKptService)(nil).AddForageCategory), arg0, arg1)
+}
+
+// Auth mocks base method.
+func (m *MockKptService) Auth(arg0 context.Context, arg1 *operationPb.UserAuthData) (*operationPb.SystemToken, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "Auth", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SystemToken)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// Auth indicates an expected call of Auth.
+func (mr *MockKptServiceMockRecorder) Auth(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Auth", reflect.TypeOf((*MockKptService)(nil).Auth), arg0, arg1)
+}
+
+// CreateFeedFormula mocks base method.
+func (m *MockKptService) CreateFeedFormula(arg0 context.Context, arg1 *operationPb.AddFeedFormulaRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "CreateFeedFormula", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// CreateFeedFormula indicates an expected call of CreateFeedFormula.
+func (mr *MockKptServiceMockRecorder) CreateFeedFormula(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateFeedFormula", reflect.TypeOf((*MockKptService)(nil).CreateFeedFormula), arg0, arg1)
+}
+
+// CreateForage mocks base method.
+func (m *MockKptService) CreateForage(arg0 context.Context, arg1 *operationPb.AddForageRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "CreateForage", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// CreateForage indicates an expected call of CreateForage.
+func (mr *MockKptServiceMockRecorder) CreateForage(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateForage", reflect.TypeOf((*MockKptService)(nil).CreateForage), arg0, arg1)
+}
+
+// CreateGroupPasture mocks base method.
+func (m *MockKptService) CreateGroupPasture(arg0 context.Context, arg1 *operationPb.AddPastureRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "CreateGroupPasture", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// CreateGroupPasture indicates an expected call of CreateGroupPasture.
+func (mr *MockKptServiceMockRecorder) CreateGroupPasture(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGroupPasture", reflect.TypeOf((*MockKptService)(nil).CreateGroupPasture), arg0, arg1)
+}
+
+// CreateSystemMenu mocks base method.
+func (m *MockKptService) CreateSystemMenu(arg0 context.Context, arg1 *operationPb.AddMenuRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "CreateSystemMenu", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// CreateSystemMenu indicates an expected call of CreateSystemMenu.
+func (mr *MockKptServiceMockRecorder) CreateSystemMenu(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSystemMenu", reflect.TypeOf((*MockKptService)(nil).CreateSystemMenu), arg0, arg1)
+}
+
+// CreateSystemRole mocks base method.
+func (m *MockKptService) CreateSystemRole(arg0 context.Context, arg1 *operationPb.AddRoleRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "CreateSystemRole", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// CreateSystemRole indicates an expected call of CreateSystemRole.
+func (mr *MockKptServiceMockRecorder) CreateSystemRole(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSystemRole", reflect.TypeOf((*MockKptService)(nil).CreateSystemRole), arg0, arg1)
+}
+
+// CreateSystemUser mocks base method.
+func (m *MockKptService) CreateSystemUser(arg0 context.Context, arg1 *operationPb.AddSystemUser) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "CreateSystemUser", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// CreateSystemUser indicates an expected call of CreateSystemUser.
+func (mr *MockKptServiceMockRecorder) CreateSystemUser(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSystemUser", reflect.TypeOf((*MockKptService)(nil).CreateSystemUser), arg0, arg1)
+}
+
+// DeleteCattleCategory mocks base method.
+func (m *MockKptService) DeleteCattleCategory(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DeleteCattleCategory", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// DeleteCattleCategory indicates an expected call of DeleteCattleCategory.
+func (mr *MockKptServiceMockRecorder) DeleteCattleCategory(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteCattleCategory", reflect.TypeOf((*MockKptService)(nil).DeleteCattleCategory), arg0, arg1)
+}
+
+// DeleteFeedFormula mocks base method.
+func (m *MockKptService) DeleteFeedFormula(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DeleteFeedFormula", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// DeleteFeedFormula indicates an expected call of DeleteFeedFormula.
+func (mr *MockKptServiceMockRecorder) DeleteFeedFormula(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteFeedFormula", reflect.TypeOf((*MockKptService)(nil).DeleteFeedFormula), arg0, arg1)
+}
+
+// DeleteForageCategory mocks base method.
+func (m *MockKptService) DeleteForageCategory(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DeleteForageCategory", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// DeleteForageCategory indicates an expected call of DeleteForageCategory.
+func (mr *MockKptServiceMockRecorder) DeleteForageCategory(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteForageCategory", reflect.TypeOf((*MockKptService)(nil).DeleteForageCategory), arg0, arg1)
+}
+
+// DeleteForageList mocks base method.
+func (m *MockKptService) DeleteForageList(arg0 context.Context, arg1 []int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DeleteForageList", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// DeleteForageList indicates an expected call of DeleteForageList.
+func (mr *MockKptServiceMockRecorder) DeleteForageList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteForageList", reflect.TypeOf((*MockKptService)(nil).DeleteForageList), arg0, arg1)
+}
+
+// DeleteGroupPasture mocks base method.
+func (m *MockKptService) DeleteGroupPasture(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DeleteGroupPasture", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// DeleteGroupPasture indicates an expected call of DeleteGroupPasture.
+func (mr *MockKptServiceMockRecorder) DeleteGroupPasture(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteGroupPasture", reflect.TypeOf((*MockKptService)(nil).DeleteGroupPasture), arg0, arg1)
+}
+
+// DeleteSystemMenu mocks base method.
+func (m *MockKptService) DeleteSystemMenu(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DeleteSystemMenu", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// DeleteSystemMenu indicates an expected call of DeleteSystemMenu.
+func (mr *MockKptServiceMockRecorder) DeleteSystemMenu(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSystemMenu", reflect.TypeOf((*MockKptService)(nil).DeleteSystemMenu), arg0, arg1)
+}
+
+// DeleteSystemRole mocks base method.
+func (m *MockKptService) DeleteSystemRole(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DeleteSystemRole", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// DeleteSystemRole indicates an expected call of DeleteSystemRole.
+func (mr *MockKptServiceMockRecorder) DeleteSystemRole(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSystemRole", reflect.TypeOf((*MockKptService)(nil).DeleteSystemRole), arg0, arg1)
+}
+
+// DeleteSystemUser mocks base method.
+func (m *MockKptService) DeleteSystemUser(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DeleteSystemUser", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// DeleteSystemUser indicates an expected call of DeleteSystemUser.
+func (mr *MockKptServiceMockRecorder) DeleteSystemUser(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSystemUser", reflect.TypeOf((*MockKptService)(nil).DeleteSystemUser), arg0, arg1)
+}
+
+// DetailsSystemUser mocks base method.
+func (m *MockKptService) DetailsSystemUser(arg0 context.Context, arg1 int64) (*operationPb.UserDetails, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "DetailsSystemUser", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.UserDetails)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// DetailsSystemUser indicates an expected call of DetailsSystemUser.
+func (mr *MockKptServiceMockRecorder) DetailsSystemUser(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DetailsSystemUser", reflect.TypeOf((*MockKptService)(nil).DetailsSystemUser), arg0, arg1)
+}
+
+// EditCattleCategory mocks base method.
+func (m *MockKptService) EditCattleCategory(arg0 context.Context, arg1 *operationPb.AddCattleCategoryRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "EditCattleCategory", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// EditCattleCategory indicates an expected call of EditCattleCategory.
+func (mr *MockKptServiceMockRecorder) EditCattleCategory(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditCattleCategory", reflect.TypeOf((*MockKptService)(nil).EditCattleCategory), arg0, arg1)
+}
+
+// EditFeedFormula mocks base method.
+func (m *MockKptService) EditFeedFormula(arg0 context.Context, arg1 *operationPb.AddFeedFormulaRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "EditFeedFormula", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// EditFeedFormula indicates an expected call of EditFeedFormula.
+func (mr *MockKptServiceMockRecorder) EditFeedFormula(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditFeedFormula", reflect.TypeOf((*MockKptService)(nil).EditFeedFormula), arg0, arg1)
+}
+
+// EditForage mocks base method.
+func (m *MockKptService) EditForage(arg0 context.Context, arg1 *operationPb.AddForageRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "EditForage", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// EditForage indicates an expected call of EditForage.
+func (mr *MockKptServiceMockRecorder) EditForage(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditForage", reflect.TypeOf((*MockKptService)(nil).EditForage), arg0, arg1)
+}
+
+// EditForageCategory mocks base method.
+func (m *MockKptService) EditForageCategory(arg0 context.Context, arg1 *operationPb.AddForageCategoryRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "EditForageCategory", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// EditForageCategory indicates an expected call of EditForageCategory.
+func (mr *MockKptServiceMockRecorder) EditForageCategory(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditForageCategory", reflect.TypeOf((*MockKptService)(nil).EditForageCategory), arg0, arg1)
+}
+
+// EditGroupPasture mocks base method.
+func (m *MockKptService) EditGroupPasture(arg0 context.Context, arg1 *operationPb.AddPastureRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "EditGroupPasture", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// EditGroupPasture indicates an expected call of EditGroupPasture.
+func (mr *MockKptServiceMockRecorder) EditGroupPasture(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditGroupPasture", reflect.TypeOf((*MockKptService)(nil).EditGroupPasture), arg0, arg1)
+}
+
+// EditSystemMenu mocks base method.
+func (m *MockKptService) EditSystemMenu(arg0 context.Context, arg1 *operationPb.AddMenuRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "EditSystemMenu", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// EditSystemMenu indicates an expected call of EditSystemMenu.
+func (mr *MockKptServiceMockRecorder) EditSystemMenu(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditSystemMenu", reflect.TypeOf((*MockKptService)(nil).EditSystemMenu), arg0, arg1)
+}
+
+// EditSystemRole mocks base method.
+func (m *MockKptService) EditSystemRole(arg0 context.Context, arg1 *operationPb.AddRoleRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "EditSystemRole", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// EditSystemRole indicates an expected call of EditSystemRole.
+func (mr *MockKptServiceMockRecorder) EditSystemRole(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditSystemRole", reflect.TypeOf((*MockKptService)(nil).EditSystemRole), arg0, arg1)
+}
+
+// EditSystemUser mocks base method.
+func (m *MockKptService) EditSystemUser(arg0 context.Context, arg1 *operationPb.AddSystemUser) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "EditSystemUser", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// EditSystemUser indicates an expected call of EditSystemUser.
+func (mr *MockKptServiceMockRecorder) EditSystemUser(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditSystemUser", reflect.TypeOf((*MockKptService)(nil).EditSystemUser), arg0, arg1)
+}
+
+// ExcelExportFeedFormula mocks base method.
+func (m *MockKptService) ExcelExportFeedFormula(arg0 context.Context, arg1 *operationPb.SearchFeedFormulaRequest) (*bytes.Buffer, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ExcelExportFeedFormula", arg0, arg1)
+	ret0, _ := ret[0].(*bytes.Buffer)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// ExcelExportFeedFormula indicates an expected call of ExcelExportFeedFormula.
+func (mr *MockKptServiceMockRecorder) ExcelExportFeedFormula(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExcelExportFeedFormula", reflect.TypeOf((*MockKptService)(nil).ExcelExportFeedFormula), arg0, arg1)
+}
+
+// ExcelExportForage mocks base method.
+func (m *MockKptService) ExcelExportForage(arg0 context.Context, arg1 *operationPb.SearchForageListRequest) (*bytes.Buffer, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ExcelExportForage", arg0, arg1)
+	ret0, _ := ret[0].(*bytes.Buffer)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// ExcelExportForage indicates an expected call of ExcelExportForage.
+func (mr *MockKptServiceMockRecorder) ExcelExportForage(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExcelExportForage", reflect.TypeOf((*MockKptService)(nil).ExcelExportForage), arg0, arg1)
+}
+
+// ExcelImportFeedFormula mocks base method.
+func (m *MockKptService) ExcelImportFeedFormula(arg0 context.Context, arg1 io.Reader) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ExcelImportFeedFormula", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// ExcelImportFeedFormula indicates an expected call of ExcelImportFeedFormula.
+func (mr *MockKptServiceMockRecorder) ExcelImportFeedFormula(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExcelImportFeedFormula", reflect.TypeOf((*MockKptService)(nil).ExcelImportFeedFormula), arg0, arg1)
+}
+
+// ExcelImportForage mocks base method.
+func (m *MockKptService) ExcelImportForage(arg0 context.Context, arg1 io.Reader) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ExcelImportForage", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// ExcelImportForage indicates an expected call of ExcelImportForage.
+func (mr *MockKptServiceMockRecorder) ExcelImportForage(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExcelImportForage", reflect.TypeOf((*MockKptService)(nil).ExcelImportForage), arg0, arg1)
+}
+
+// ExcelTemplateFeedFormula mocks base method.
+func (m *MockKptService) ExcelTemplateFeedFormula(arg0 context.Context) (*bytes.Buffer, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ExcelTemplateFeedFormula", arg0)
+	ret0, _ := ret[0].(*bytes.Buffer)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// ExcelTemplateFeedFormula indicates an expected call of ExcelTemplateFeedFormula.
+func (mr *MockKptServiceMockRecorder) ExcelTemplateFeedFormula(arg0 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExcelTemplateFeedFormula", reflect.TypeOf((*MockKptService)(nil).ExcelTemplateFeedFormula), arg0)
+}
+
+// ExcelTemplateForage mocks base method.
+func (m *MockKptService) ExcelTemplateForage(arg0 context.Context) (*bytes.Buffer, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ExcelTemplateForage", arg0)
+	ret0, _ := ret[0].(*bytes.Buffer)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// ExcelTemplateForage indicates an expected call of ExcelTemplateForage.
+func (mr *MockKptServiceMockRecorder) ExcelTemplateForage(arg0 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExcelTemplateForage", reflect.TypeOf((*MockKptService)(nil).ExcelTemplateForage), arg0)
+}
+
+// ForageEnumList mocks base method.
+func (m *MockKptService) ForageEnumList(arg0 context.Context) *operationPb.ForageEnumListResponse {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ForageEnumList", arg0)
+	ret0, _ := ret[0].(*operationPb.ForageEnumListResponse)
+	return ret0
+}
+
+// ForageEnumList indicates an expected call of ForageEnumList.
+func (mr *MockKptServiceMockRecorder) ForageEnumList(arg0 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForageEnumList", reflect.TypeOf((*MockKptService)(nil).ForageEnumList), arg0)
+}
+
+// GetOpenId mocks base method.
+func (m *MockKptService) GetOpenId(arg0 context.Context, arg1 string) (*operationPb.WxOpenId, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "GetOpenId", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.WxOpenId)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// GetOpenId indicates an expected call of GetOpenId.
+func (mr *MockKptServiceMockRecorder) GetOpenId(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOpenId", reflect.TypeOf((*MockKptService)(nil).GetOpenId), arg0, arg1)
+}
+
+// GetRolePermissions mocks base method.
+func (m *MockKptService) GetRolePermissions(arg0 context.Context, arg1 int64) (*operationPb.RolePermissionsList, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "GetRolePermissions", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.RolePermissionsList)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// GetRolePermissions indicates an expected call of GetRolePermissions.
+func (mr *MockKptServiceMockRecorder) GetRolePermissions(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRolePermissions", reflect.TypeOf((*MockKptService)(nil).GetRolePermissions), arg0, arg1)
+}
+
+// GetSystemUserPermissions mocks base method.
+func (m *MockKptService) GetSystemUserPermissions(arg0 context.Context, arg1 string) (*operationPb.SystemUserMenuPermissions, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "GetSystemUserPermissions", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SystemUserMenuPermissions)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// GetSystemUserPermissions indicates an expected call of GetSystemUserPermissions.
+func (mr *MockKptServiceMockRecorder) GetSystemUserPermissions(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSystemUserPermissions", reflect.TypeOf((*MockKptService)(nil).GetSystemUserPermissions), arg0, arg1)
+}
+
+// GetUserInfo mocks base method.
+func (m *MockKptService) GetUserInfo(arg0 context.Context, arg1 string) (*operationPb.UserAuth, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "GetUserInfo", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.UserAuth)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// GetUserInfo indicates an expected call of GetUserInfo.
+func (mr *MockKptServiceMockRecorder) GetUserInfo(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserInfo", reflect.TypeOf((*MockKptService)(nil).GetUserInfo), arg0, arg1)
+}
+
+// IsShowCattleCategory mocks base method.
+func (m *MockKptService) IsShowCattleCategory(arg0 context.Context, arg1 *operationPb.IsShowCattleCategory) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsShowCattleCategory", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// IsShowCattleCategory indicates an expected call of IsShowCattleCategory.
+func (mr *MockKptServiceMockRecorder) IsShowCattleCategory(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsShowCattleCategory", reflect.TypeOf((*MockKptService)(nil).IsShowCattleCategory), arg0, arg1)
+}
+
+// IsShowFeedFormula mocks base method.
+func (m *MockKptService) IsShowFeedFormula(arg0 context.Context, arg1 *operationPb.IsShowModifyFeedFormula) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsShowFeedFormula", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// IsShowFeedFormula indicates an expected call of IsShowFeedFormula.
+func (mr *MockKptServiceMockRecorder) IsShowFeedFormula(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsShowFeedFormula", reflect.TypeOf((*MockKptService)(nil).IsShowFeedFormula), arg0, arg1)
+}
+
+// IsShowForage mocks base method.
+func (m *MockKptService) IsShowForage(arg0 context.Context, arg1 *operationPb.IsShowForage) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsShowForage", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// IsShowForage indicates an expected call of IsShowForage.
+func (mr *MockKptServiceMockRecorder) IsShowForage(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsShowForage", reflect.TypeOf((*MockKptService)(nil).IsShowForage), arg0, arg1)
+}
+
+// IsShowForageCategory mocks base method.
+func (m *MockKptService) IsShowForageCategory(arg0 context.Context, arg1 *operationPb.IsShowForageCategory) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsShowForageCategory", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// IsShowForageCategory indicates an expected call of IsShowForageCategory.
+func (mr *MockKptServiceMockRecorder) IsShowForageCategory(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsShowForageCategory", reflect.TypeOf((*MockKptService)(nil).IsShowForageCategory), arg0, arg1)
+}
+
+// IsShowGroupPasture mocks base method.
+func (m *MockKptService) IsShowGroupPasture(arg0 context.Context, arg1 *operationPb.IsShowGroupPasture) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsShowGroupPasture", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// IsShowGroupPasture indicates an expected call of IsShowGroupPasture.
+func (mr *MockKptServiceMockRecorder) IsShowGroupPasture(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsShowGroupPasture", reflect.TypeOf((*MockKptService)(nil).IsShowGroupPasture), arg0, arg1)
+}
+
+// IsShowSystemMenu mocks base method.
+func (m *MockKptService) IsShowSystemMenu(arg0 context.Context, arg1 *operationPb.IsShowSystemMenuRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsShowSystemMenu", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// IsShowSystemMenu indicates an expected call of IsShowSystemMenu.
+func (mr *MockKptServiceMockRecorder) IsShowSystemMenu(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsShowSystemMenu", reflect.TypeOf((*MockKptService)(nil).IsShowSystemMenu), arg0, arg1)
+}
+
+// IsShowSystemUser mocks base method.
+func (m *MockKptService) IsShowSystemUser(arg0 context.Context, arg1 *operationPb.IsShowSystemUserRequest) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsShowSystemUser", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// IsShowSystemUser indicates an expected call of IsShowSystemUser.
+func (mr *MockKptServiceMockRecorder) IsShowSystemUser(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsShowSystemUser", reflect.TypeOf((*MockKptService)(nil).IsShowSystemUser), arg0, arg1)
+}
+
+// ParentCattleCategoryList mocks base method.
+func (m *MockKptService) ParentCattleCategoryList(arg0 context.Context) map[operationPb.CattleCategoryParent_Kind]string {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ParentCattleCategoryList", arg0)
+	ret0, _ := ret[0].(map[operationPb.CattleCategoryParent_Kind]string)
+	return ret0
+}
+
+// ParentCattleCategoryList indicates an expected call of ParentCattleCategoryList.
+func (mr *MockKptServiceMockRecorder) ParentCattleCategoryList(arg0 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParentCattleCategoryList", reflect.TypeOf((*MockKptService)(nil).ParentCattleCategoryList), arg0)
+}
+
+// ParentForageCategoryList mocks base method.
+func (m *MockKptService) ParentForageCategoryList(arg0 context.Context) map[operationPb.ForageCategoryParent_Kind]string {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ParentForageCategoryList", arg0)
+	ret0, _ := ret[0].(map[operationPb.ForageCategoryParent_Kind]string)
+	return ret0
+}
+
+// ParentForageCategoryList indicates an expected call of ParentForageCategoryList.
+func (mr *MockKptServiceMockRecorder) ParentForageCategoryList(arg0 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParentForageCategoryList", reflect.TypeOf((*MockKptService)(nil).ParentForageCategoryList), arg0)
+}
+
+// ResetPasswordGroupPasture mocks base method.
+func (m *MockKptService) ResetPasswordGroupPasture(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ResetPasswordGroupPasture", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// ResetPasswordGroupPasture indicates an expected call of ResetPasswordGroupPasture.
+func (mr *MockKptServiceMockRecorder) ResetPasswordGroupPasture(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResetPasswordGroupPasture", reflect.TypeOf((*MockKptService)(nil).ResetPasswordGroupPasture), arg0, arg1)
+}
+
+// ResetPasswordSystemUser mocks base method.
+func (m *MockKptService) ResetPasswordSystemUser(arg0 context.Context, arg1 int64) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ResetPasswordSystemUser", arg0, arg1)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// ResetPasswordSystemUser indicates an expected call of ResetPasswordSystemUser.
+func (mr *MockKptServiceMockRecorder) ResetPasswordSystemUser(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResetPasswordSystemUser", reflect.TypeOf((*MockKptService)(nil).ResetPasswordSystemUser), arg0, arg1)
+}
+
+// SearchCattleCategoryList mocks base method.
+func (m *MockKptService) SearchCattleCategoryList(arg0 context.Context, arg1 *operationPb.SearchCattleCategoryRequest) (*operationPb.SearchCattleCategoryResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchCattleCategoryList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchCattleCategoryResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchCattleCategoryList indicates an expected call of SearchCattleCategoryList.
+func (mr *MockKptServiceMockRecorder) SearchCattleCategoryList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchCattleCategoryList", reflect.TypeOf((*MockKptService)(nil).SearchCattleCategoryList), arg0, arg1)
+}
+
+// SearchFeedFormulaList mocks base method.
+func (m *MockKptService) SearchFeedFormulaList(arg0 context.Context, arg1 *operationPb.SearchFeedFormulaRequest) (*operationPb.SearchFeedFormulaListResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchFeedFormulaList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchFeedFormulaListResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchFeedFormulaList indicates an expected call of SearchFeedFormulaList.
+func (mr *MockKptServiceMockRecorder) SearchFeedFormulaList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchFeedFormulaList", reflect.TypeOf((*MockKptService)(nil).SearchFeedFormulaList), arg0, arg1)
+}
+
+// SearchForageCategoryList mocks base method.
+func (m *MockKptService) SearchForageCategoryList(arg0 context.Context, arg1 *operationPb.SearchForageCategoryRequest) (*operationPb.SearchForageCategoryResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchForageCategoryList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchForageCategoryResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchForageCategoryList indicates an expected call of SearchForageCategoryList.
+func (mr *MockKptServiceMockRecorder) SearchForageCategoryList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchForageCategoryList", reflect.TypeOf((*MockKptService)(nil).SearchForageCategoryList), arg0, arg1)
+}
+
+// SearchForageList mocks base method.
+func (m *MockKptService) SearchForageList(arg0 context.Context, arg1 *operationPb.SearchForageListRequest) (*operationPb.SearchForageListResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchForageList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchForageListResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchForageList indicates an expected call of SearchForageList.
+func (mr *MockKptServiceMockRecorder) SearchForageList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchForageList", reflect.TypeOf((*MockKptService)(nil).SearchForageList), arg0, arg1)
+}
+
+// SearchFormulaEstimateList mocks base method.
+func (m *MockKptService) SearchFormulaEstimateList(arg0 context.Context, arg1 *operationPb.SearchFormulaEstimateRequest) (*operationPb.SearchFormulaEstimateResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchFormulaEstimateList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchFormulaEstimateResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchFormulaEstimateList indicates an expected call of SearchFormulaEstimateList.
+func (mr *MockKptServiceMockRecorder) SearchFormulaEstimateList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchFormulaEstimateList", reflect.TypeOf((*MockKptService)(nil).SearchFormulaEstimateList), arg0, arg1)
+}
+
+// SearchGroupPastureList mocks base method.
+func (m *MockKptService) SearchGroupPastureList(arg0 context.Context, arg1 *operationPb.SearchPastureRequest) (*operationPb.SearchPastureResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchGroupPastureList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchPastureResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchGroupPastureList indicates an expected call of SearchGroupPastureList.
+func (mr *MockKptServiceMockRecorder) SearchGroupPastureList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchGroupPastureList", reflect.TypeOf((*MockKptService)(nil).SearchGroupPastureList), arg0, arg1)
+}
+
+// SearchMobileList mocks base method.
+func (m *MockKptService) SearchMobileList(arg0 context.Context, arg1 *operationPb.SearchMobileRequest) (*operationPb.SearchMobileResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchMobileList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchMobileResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchMobileList indicates an expected call of SearchMobileList.
+func (mr *MockKptServiceMockRecorder) SearchMobileList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchMobileList", reflect.TypeOf((*MockKptService)(nil).SearchMobileList), arg0, arg1)
+}
+
+// SearchSystemMenuList mocks base method.
+func (m *MockKptService) SearchSystemMenuList(arg0 context.Context, arg1 *operationPb.SearchMenuRequest) (*operationPb.SearchMenuResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchSystemMenuList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchMenuResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchSystemMenuList indicates an expected call of SearchSystemMenuList.
+func (mr *MockKptServiceMockRecorder) SearchSystemMenuList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchSystemMenuList", reflect.TypeOf((*MockKptService)(nil).SearchSystemMenuList), arg0, arg1)
+}
+
+// SearchSystemRoleList mocks base method.
+func (m *MockKptService) SearchSystemRoleList(arg0 context.Context, arg1 *operationPb.SearchRoleRequest) (*operationPb.SearchRoleResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchSystemRoleList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchRoleResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchSystemRoleList indicates an expected call of SearchSystemRoleList.
+func (mr *MockKptServiceMockRecorder) SearchSystemRoleList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchSystemRoleList", reflect.TypeOf((*MockKptService)(nil).SearchSystemRoleList), arg0, arg1)
+}
+
+// SearchSystemUserList mocks base method.
+func (m *MockKptService) SearchSystemUserList(arg0 context.Context, arg1 *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "SearchSystemUserList", arg0, arg1)
+	ret0, _ := ret[0].(*operationPb.SearchUserResponse)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// SearchSystemUserList indicates an expected call of SearchSystemUserList.
+func (mr *MockKptServiceMockRecorder) SearchSystemUserList(arg0, arg1 interface{}) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchSystemUserList", reflect.TypeOf((*MockKptService)(nil).SearchSystemUserList), arg0, arg1)
+}

+ 35 - 20
module/backend/pasture_service.go

@@ -383,9 +383,10 @@ func (s *StoreEntry) SearchForageCategoryList(ctx context.Context, req *operatio
 		Code: http.StatusOK,
 		Msg:  "ok",
 		Data: &operationPb.SearchForageCategoryData{
-			Page:  req.Pagination.Page,
-			Total: int32(count),
-			List:  model.ForageCategorySlice(forageCategory).ToPB(),
+			Page:     req.Pagination.Page,
+			PageSize: req.Pagination.PageSize,
+			Total:    int32(count),
+			List:     model.ForageCategorySlice(forageCategory).ToPB(),
 		},
 	}, nil
 }
@@ -462,10 +463,6 @@ func (s *StoreEntry) SearchForageList(ctx context.Context, req *operationPb.Sear
 		pref.Where("allow_error = ?", req.AllowError)
 	}
 
-	if req.AllowError > 0 {
-		pref.Where("allow_error = ?", req.AllowError)
-	}
-
 	if req.JumpWeight > 0 {
 		pref.Where("jump_weight = ?", req.JumpWeight)
 	}
@@ -480,10 +477,14 @@ func (s *StoreEntry) SearchForageList(ctx context.Context, req *operationPb.Sear
 	}
 
 	return &operationPb.SearchForageListResponse{
-		Page:     req.Pagination.Page,
-		PageSize: req.Pagination.PageSize,
-		Total:    int32(count),
-		List:     model.ForageSlice(forage).ToPB(),
+		Code: http.StatusOK,
+		Msg:  "ok",
+		Data: &operationPb.SearchForageList{
+			Page:     req.Pagination.Page,
+			PageSize: req.Pagination.PageSize,
+			Total:    int32(count),
+			List:     model.ForageSlice(forage).ToPB(),
+		},
 	}, nil
 }
 
@@ -500,6 +501,7 @@ func (s *StoreEntry) ForageEnumList(ctx context.Context) *operationPb.ForageEnum
 			IsShow:               make([]*operationPb.IsShowEnum, 0),
 			FormulaType:          make([]*operationPb.FormulaTypeEnum, 0),
 			FormulaList:          make([]*operationPb.FormulaOptionEnum, 0),
+			ConfirmStart:         make([]*operationPb.IsShowEnum, 0),
 		},
 	}
 
@@ -525,13 +527,18 @@ func (s *StoreEntry) ForageEnumList(ctx context.Context) *operationPb.ForageEnum
 	})
 
 	// 计划类型
-	res.Data.ForagePlanType = append(res.Data.ForagePlanType, &operationPb.ForagePlanTypeEnum{
-		Value: operationPb.ForagePlanType_FORKLIFT,
-		Label: "铲车",
-	}, &operationPb.ForagePlanTypeEnum{
-		Value: operationPb.ForagePlanType_CONCENTRATE,
-		Label: "精料",
-	})
+	res.Data.ForagePlanType = append(res.Data.ForagePlanType,
+		&operationPb.ForagePlanTypeEnum{
+			Value: operationPb.ForagePlanType_INVALID,
+			Label: "无",
+		},
+		&operationPb.ForagePlanTypeEnum{
+			Value: operationPb.ForagePlanType_FORKLIFT,
+			Label: "铲车",
+		}, &operationPb.ForagePlanTypeEnum{
+			Value: operationPb.ForagePlanType_CONCENTRATE,
+			Label: "精料",
+		})
 
 	// 畜牧类别
 	res.Data.CattleParentCategory = append(res.Data.CattleParentCategory, &operationPb.CattleParentCategoryEnum{
@@ -588,6 +595,14 @@ func (s *StoreEntry) ForageEnumList(ctx context.Context) *operationPb.ForageEnum
 		Label: "补料配方",
 	})
 
+	res.Data.ConfirmStart = append(res.Data.ConfirmStart, &operationPb.IsShowEnum{
+		Value: operationPb.IsShow_OK,
+		Label: "启用",
+	}, &operationPb.IsShowEnum{
+		Value: operationPb.IsShow_NO,
+		Label: "禁用",
+	})
+
 	res.Data.FormulaList = append(res.Data.FormulaList, &operationPb.FormulaOptionEnum{
 		Value: 0,
 		Label: "所有",
@@ -746,7 +761,7 @@ func (s *StoreEntry) ExcelExportForage(ctx context.Context, req *operationPb.Sea
 	if err != nil {
 		return nil, xerr.WithStack(err)
 	}
-	if len(res.List) <= 0 {
+	if len(res.Data.List) <= 0 {
 		return nil, xerr.Custom("数据为空")
 	}
 
@@ -762,7 +777,7 @@ func (s *StoreEntry) ExcelExportForage(ctx context.Context, req *operationPb.Sea
 	if err = streamWriter.SetRow("A1", titles); err != nil {
 		return nil, xerr.WithStack(err)
 	}
-	for i, item := range res.List {
+	for i, item := range res.Data.List {
 		cell, err := excelize.CoordinatesToCellName(1, i+2)
 		if err != nil {
 			zaplog.Error("excelize.CoordinatesToCellName", zap.Any("Err", err))

+ 56 - 0
module/backend/x_suite_test.go

@@ -0,0 +1,56 @@
+package backend
+
+import (
+	"context"
+	"kpt-tmr-group/config"
+	"kpt-tmr-group/store/kptstore"
+	"kpt-tmr-group/test/mock"
+
+	"golang.org/x/sync/errgroup"
+
+	"github.com/golang/mock/gomock"
+	"github.com/stretchr/testify/suite"
+	"go.uber.org/dig"
+)
+
+var dbName = "kpt_tmr_group_test"
+
+type Suite struct {
+	suite.Suite
+
+	ctx  context.Context
+	cfg  *config.AppConfig
+	db   *kptstore.DB
+	ctrl *gomock.Controller
+	m    Mock
+
+	storeEntry *StoreEntry
+}
+
+type Mock struct {
+	dig.In
+}
+
+func (s *Suite) SetupSuite() {
+	s.cfg = config.Options()
+}
+
+func (s *Suite) SetupTest() {
+	s.ctx = context.Background()
+	s.ctrl = gomock.NewController(s.T())
+
+	mock.GetMock(s.ctrl, func(m Mock) { s.m = m })
+	s.storeEntry = NewStoreEntry(s.cfg, s.db)
+}
+
+func (s *Suite) prepareDB() {
+	s.cfg = config.Options()
+	g, _ := errgroup.WithContext(context.Background())
+	g.Go(func() error { // todo 连接数据库
+
+		return nil
+	})
+	if err := g.Wait(); err != nil {
+		panic(err)
+	}
+}

+ 1 - 0
pkg/xstore/database/dbtest/mysql.go

@@ -0,0 +1 @@
+package dbtest

+ 50 - 0
pkg/xstore/database/gorm.go

@@ -0,0 +1,50 @@
+package database
+
+import (
+	"kpt-tmr-group/config"
+	KptLogger "kpt-tmr-group/pkg/logger/logrus"
+	"kpt-tmr-group/pkg/xerr"
+	"time"
+
+	"gorm.io/gorm"
+
+	"gorm.io/driver/mysql"
+
+	"gorm.io/gorm/logger"
+)
+
+type goRmLog struct {
+}
+
+func (g goRmLog) Printf(s string, i ...interface{}) {
+	KptLogger.Infof(s, i...)
+
+}
+
+// NewDatabase return xorm engine
+// with some default params
+func NewDatabase(cfg *config.AppConfig, drivers ...string) (*gorm.DB, error) {
+
+	newLogger := logger.New(
+		goRmLog{},
+		logger.Config{
+			SlowThreshold: 5 * time.Second,
+			LogLevel:      logger.Info,
+		},
+	)
+
+	db, err := gorm.Open(mysql.New(mysql.Config{
+		DriverName: cfg.StoreSetting.DriverName,
+		DSN:        cfg.StoreSetting.KptEventDSNRW}),
+		&gorm.Config{Logger: newLogger},
+	)
+	if err != nil {
+		panic(xerr.WithStack(err))
+	}
+
+	if cfg.StoreSetting.ShowSQL {
+		db.Logger.LogMode(logger.Info)
+	}
+
+	return db, err
+}

+ 1 - 0
pkg/xstore/database/migrator/migrate.go

@@ -0,0 +1 @@
+package migrator

+ 3 - 3
proto/go/backend/operation/feed_formula.pb.go

@@ -41,7 +41,7 @@ type AddFeedFormulaRequest struct {
 	IsModify           IsShow_Kind               `protobuf:"varint,14,opt,name=is_modify,json=isModify,proto3,enum=backend.operation.IsShow_Kind" json:"is_modify,omitempty"`                                        // 是否可修改
 	CreatedAt          int32                     `protobuf:"varint,15,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`                                                                        // 创建时间
 	CreatedAtFormat    string                    `protobuf:"bytes,16,opt,name=created_at_format,json=createdAtFormat,proto3" json:"created_at_format,omitempty"`                                                     // 创建时间格式化
-	PastureName        string                    `protobuf:"bytes,17,opt,name=Pasture_name,json=PastureName,proto3" json:"Pasture_name,omitempty"`                                                                   // 牧场名称
+	PastureName        string                    `protobuf:"bytes,17,opt,name=pasture_name,json=pastureName,proto3" json:"pasture_name,omitempty"`                                                                   // 牧场名称
 }
 
 func (x *AddFeedFormulaRequest) Reset() {
@@ -480,8 +480,8 @@ var file_backend_operation_feed_formula_proto_rawDesc = []byte{
 	0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x2a, 0x0a, 0x11, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
 	0x5f, 0x61, 0x74, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09,
 	0x52, 0x0f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x46, 0x6f, 0x72, 0x6d, 0x61,
-	0x74, 0x12, 0x21, 0x0a, 0x0c, 0x50, 0x61, 0x73, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x6e, 0x61, 0x6d,
-	0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x50, 0x61, 0x73, 0x74, 0x75, 0x72, 0x65,
+	0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, 0x73, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x6e, 0x61, 0x6d,
+	0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x61, 0x73, 0x74, 0x75, 0x72, 0x65,
 	0x4e, 0x61, 0x6d, 0x65, 0x22, 0xbc, 0x02, 0x0a, 0x18, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x46,
 	0x65, 0x65, 0x64, 0x46, 0x6f, 0x72, 0x6d, 0x75, 0x6c, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
 	0x74, 0x12, 0x2c, 0x0a, 0x12, 0x63, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x63, 0x61, 0x74, 0x65,

File diff suppressed because it is too large
+ 386 - 272
proto/go/backend/operation/pasture.pb.go


+ 22 - 0
test/mock/mock.go

@@ -0,0 +1,22 @@
+package mock
+
+import (
+	kptservicemock "kpt-tmr-group/module/backend/mock"
+	"kpt-tmr-group/pkg/di"
+
+	"github.com/golang/mock/gomock"
+)
+
+func GetMock(ctrl *gomock.Controller, f interface{}) {
+	container, err := di.New(di.Provide(func() *gomock.Controller { return ctrl }), deps)
+	if err != nil {
+		panic(err)
+	}
+	if err = container.Invoke(f); err != nil {
+		panic(err)
+	}
+}
+
+var deps = di.Provide(
+	kptservicemock.NewMockKptService,
+)

Some files were not shown because too many files changed in this diff