Browse Source

category: 畜牧分类删除数据同步

Yi 1 year ago
parent
commit
3d8b329a1a

+ 9 - 1
backend/operation/pasture.proto

@@ -268,7 +268,7 @@ message FormulaOptionEnum {
   string label = 2;
 }
 // 牧场端分类数据同步
-message ClassRequest {
+message CategorySyncRequest {
   string key_word = 1;         // 关键字
   int32 pasture_id = 2;        // 牧场id
   int32 parent_id = 3;         // 一类id
@@ -277,4 +277,12 @@ message ClassRequest {
   string number = 6;           // 分类编号
   IsShow.Kind is_show = 7;     // 是否展示
   IsShow.Kind is_delete = 8;   // 是否删除
+  int32 id = 9;                // 牧场端数据id
+}
+
+// 牧场端分类数据删除
+message CategoryDeleteRequest {
+  string key_word = 1;    // 关键字
+  int32 pasture_id = 2;   // 牧场id
+  int32 data_id = 3;
 }

+ 31 - 3
http/handler/pasture/pasture.go

@@ -11,9 +11,9 @@ import (
 	"github.com/gin-gonic/gin"
 )
 
-// ClassSync 牧场分类数据同步
-func ClassSync(c *gin.Context) {
-	var req operationPb.ClassRequest
+// CategorySync 牧场分类数据同步
+func CategorySync(c *gin.Context) {
+	var req operationPb.CategorySyncRequest
 	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
@@ -39,3 +39,31 @@ func ClassSync(c *gin.Context) {
 		Data: &operationPb.Success{Success: true},
 	})
 }
+
+func CategoryDelete(c *gin.Context) {
+	var req operationPb.CategoryDeleteRequest
+	if err := ginutil.BindProto(c, &req); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if err := valid.ValidateStruct(&req,
+		valid.Field(&req.KeyWord, valid.Required),
+		valid.Field(&req.PastureId, valid.Required),
+		valid.Field(&req.DataId, valid.Required),
+	); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if err := middleware.Dependency(c).StoreEventHub.OpsService.CategoryData(c, &req); err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+
+	ginutil.JSONResp(c, &operationPb.CommonOK{
+		Code: http.StatusOK,
+		Msg:  "ok",
+		Data: &operationPb.Success{Success: true},
+	})
+}

+ 2 - 1
http/route/pasture.go

@@ -12,6 +12,7 @@ func PastureAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 			opt(s)
 		}
 
-		s.POST("/group/class/sync", pasture.ClassSync)
+		s.POST("/group/class/sync", pasture.CategorySync)
+		s.POST("/group/class/delete", pasture.CategoryDelete)
 	}
 }

+ 1 - 0
model/cattle_category.go

@@ -11,6 +11,7 @@ type CattleCategory struct {
 	ParentName  string                                `json:"parent_name"`
 	PastureId   int64                                 `json:"pasture_id"`
 	PastureName string                                `json:"pasture_name"`
+	DataId      int64                                 `json:"data_id"`
 	Name        string                                `json:"name"`
 	Number      string                                `json:"number"`
 	IsShow      operationPb.IsShow_Kind               `json:"is_show"`

+ 1 - 0
model/forage_category.go

@@ -11,6 +11,7 @@ type ForageCategory struct {
 	ParentName  string                                `json:"parent_name"`
 	PastureId   int64                                 `json:"pasture_id"`
 	PastureName string                                `json:"pasture_name"`
+	DataId      int64                                 `json:"data_id"`
 	Name        string                                `json:"name"`
 	Number      string                                `json:"number"`
 	IsShow      operationPb.IsShow_Kind               `json:"is_show"`

+ 2 - 1
module/backend/interface.go

@@ -161,5 +161,6 @@ type WxAppletService interface {
 }
 
 type PastureSyncService interface {
-	CategoryData(ctx context.Context, req *operationPb.ClassRequest) error
+	CategorySyncData(ctx context.Context, req *operationPb.CategorySyncRequest) error
+	CategoryDeleteData(ctx context.Context, req *operationPb.CategoryDeleteRequest) error
 }

+ 39 - 14
module/backend/pasture_sync_service.go

@@ -11,12 +11,13 @@ import (
 )
 
 const (
-	FeedCategory = "feed"
-	CowCategory  = "cow"
+	FeedCategory       = "feed"
+	FeedCategoryDelete = "feed_delete"
+	CowCategory        = "cow"
+	CowCategoryDelete  = "cow_delete"
 )
 
-func (s *StoreEntry) CategoryData(ctx context.Context, req *operationPb.ClassRequest) error {
-
+func (s *StoreEntry) CategorySyncData(ctx context.Context, req *operationPb.CategorySyncRequest) error {
 	pastureDetail, err := s.GetGroupPastureListById(ctx, int64(req.PastureId))
 	if err != nil {
 		return xerr.WithStack(err)
@@ -26,9 +27,8 @@ func (s *StoreEntry) CategoryData(ctx context.Context, req *operationPb.ClassReq
 		history := &model.ForageCategory{}
 		if err = s.DB.Model(new(model.ForageCategory)).
 			Where("pasture_id = ?", req.PastureId).
-			Where("is_delete = ?", operationPb.IsShow_NO).
+			Where("data_id = ?", req.Id).
 			Where("data_source = ? ", operationPb.DataSource_FROM_PASTURE).
-			Where("parent_id = ?", req.ParentId).Where("name = ?", req.Name).
 			First(history).Error; err != nil {
 			if !errors.Is(err, gorm.ErrRecordNotFound) {
 				return xerr.WithStack(err)
@@ -36,9 +36,11 @@ func (s *StoreEntry) CategoryData(ctx context.Context, req *operationPb.ClassReq
 		}
 		if history.IsShow == operationPb.IsShow_OK && history.Id > 0 {
 			if err = s.DB.Model(new(model.ForageCategory)).Where("id = ?", history.Id).Updates(map[string]interface{}{
-				"number":    req.Number,
-				"is_show":   req.IsShow,
-				"is_delete": req.IsDelete,
+				"number":      req.Number,
+				"is_show":     req.IsShow,
+				"parent_id":   req.ParentId,
+				"parent_name": req.ParentName,
+				"name":        req.Name,
 			}).Error; err != nil {
 				return xerr.WithStack(err)
 			}
@@ -52,9 +54,8 @@ func (s *StoreEntry) CategoryData(ctx context.Context, req *operationPb.ClassReq
 		history := &model.CattleCategory{}
 		if err = s.DB.Model(new(model.CattleCategory)).
 			Where("pasture_id = ?", req.PastureId).
-			Where("is_delete = ?", operationPb.IsShow_NO).
+			Where("data_id = ?", req.Id).
 			Where("data_source = ? ", operationPb.DataSource_FROM_PASTURE).
-			Where("parent_id = ?", req.ParentId).Where("name = ?", req.Name).
 			First(history).Error; err != nil {
 			if !errors.Is(err, gorm.ErrRecordNotFound) {
 				return xerr.WithStack(err)
@@ -62,9 +63,11 @@ func (s *StoreEntry) CategoryData(ctx context.Context, req *operationPb.ClassReq
 		}
 		if history.IsShow == operationPb.IsShow_OK && history.Id > 0 {
 			if err = s.DB.Model(new(model.CattleCategory)).Where("id = ?", history.Id).Updates(map[string]interface{}{
-				"number":    req.Number,
-				"is_show":   req.IsShow,
-				"is_delete": req.IsDelete,
+				"number":      req.Number,
+				"is_show":     req.IsShow,
+				"parent_id":   req.ParentId,
+				"parent_name": req.ParentName,
+				"name":        req.Name,
 			}).Error; err != nil {
 				return xerr.WithStack(err)
 			}
@@ -77,3 +80,25 @@ func (s *StoreEntry) CategoryData(ctx context.Context, req *operationPb.ClassReq
 
 	return nil
 }
+
+func (s *StoreEntry) CategoryDeleteData(ctx context.Context, req *operationPb.CategoryDeleteRequest) error {
+	var modelValue interface{}
+	switch req.KeyWord {
+	case FeedCategoryDelete:
+		modelValue = new(model.ForageCategory)
+	case CowCategoryDelete:
+		modelValue = new(model.CattleCategory)
+	}
+	if modelValue == nil {
+		return nil
+	}
+
+	if err := s.DB.Model(modelValue).Where("data_id = ?", req.DataId).
+		Where("pasture_id = ?", req.PastureId).Where("data_source = ?", operationPb.DataSource_FROM_PASTURE).
+		Updates(map[string]interface{}{
+			"is_delete": operationPb.IsShow_OK,
+		}).Error; err != nil {
+		return xerr.WithStack(err)
+	}
+	return nil
+}

+ 174 - 81
proto/go/backend/operation/pasture.pb.go

@@ -2571,7 +2571,7 @@ func (x *FormulaOptionEnum) GetLabel() string {
 }
 
 // 牧场端分类数据同步
-type ClassRequest struct {
+type CategorySyncRequest struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
@@ -2584,10 +2584,11 @@ type ClassRequest struct {
 	Number     string      `protobuf:"bytes,6,opt,name=number,proto3" json:"number,omitempty"`                                                         // 分类编号
 	IsShow     IsShow_Kind `protobuf:"varint,7,opt,name=is_show,json=isShow,proto3,enum=backend.operation.IsShow_Kind" json:"is_show,omitempty"`       // 是否展示
 	IsDelete   IsShow_Kind `protobuf:"varint,8,opt,name=is_delete,json=isDelete,proto3,enum=backend.operation.IsShow_Kind" json:"is_delete,omitempty"` // 是否删除
+	Id         int32       `protobuf:"varint,9,opt,name=id,proto3" json:"id,omitempty"`                                                                // 牧场端数据id
 }
 
-func (x *ClassRequest) Reset() {
-	*x = ClassRequest{}
+func (x *CategorySyncRequest) Reset() {
+	*x = CategorySyncRequest{}
 	if protoimpl.UnsafeEnabled {
 		mi := &file_backend_operation_pasture_proto_msgTypes[34]
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -2595,13 +2596,13 @@ func (x *ClassRequest) Reset() {
 	}
 }
 
-func (x *ClassRequest) String() string {
+func (x *CategorySyncRequest) String() string {
 	return protoimpl.X.MessageStringOf(x)
 }
 
-func (*ClassRequest) ProtoMessage() {}
+func (*CategorySyncRequest) ProtoMessage() {}
 
-func (x *ClassRequest) ProtoReflect() protoreflect.Message {
+func (x *CategorySyncRequest) ProtoReflect() protoreflect.Message {
 	mi := &file_backend_operation_pasture_proto_msgTypes[34]
 	if protoimpl.UnsafeEnabled && x != nil {
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -2613,67 +2614,138 @@ func (x *ClassRequest) ProtoReflect() protoreflect.Message {
 	return mi.MessageOf(x)
 }
 
-// Deprecated: Use ClassRequest.ProtoReflect.Descriptor instead.
-func (*ClassRequest) Descriptor() ([]byte, []int) {
+// Deprecated: Use CategorySyncRequest.ProtoReflect.Descriptor instead.
+func (*CategorySyncRequest) Descriptor() ([]byte, []int) {
 	return file_backend_operation_pasture_proto_rawDescGZIP(), []int{34}
 }
 
-func (x *ClassRequest) GetKeyWord() string {
+func (x *CategorySyncRequest) GetKeyWord() string {
 	if x != nil {
 		return x.KeyWord
 	}
 	return ""
 }
 
-func (x *ClassRequest) GetPastureId() int32 {
+func (x *CategorySyncRequest) GetPastureId() int32 {
 	if x != nil {
 		return x.PastureId
 	}
 	return 0
 }
 
-func (x *ClassRequest) GetParentId() int32 {
+func (x *CategorySyncRequest) GetParentId() int32 {
 	if x != nil {
 		return x.ParentId
 	}
 	return 0
 }
 
-func (x *ClassRequest) GetParentName() string {
+func (x *CategorySyncRequest) GetParentName() string {
 	if x != nil {
 		return x.ParentName
 	}
 	return ""
 }
 
-func (x *ClassRequest) GetName() string {
+func (x *CategorySyncRequest) GetName() string {
 	if x != nil {
 		return x.Name
 	}
 	return ""
 }
 
-func (x *ClassRequest) GetNumber() string {
+func (x *CategorySyncRequest) GetNumber() string {
 	if x != nil {
 		return x.Number
 	}
 	return ""
 }
 
-func (x *ClassRequest) GetIsShow() IsShow_Kind {
+func (x *CategorySyncRequest) GetIsShow() IsShow_Kind {
 	if x != nil {
 		return x.IsShow
 	}
 	return IsShow_INVALID
 }
 
-func (x *ClassRequest) GetIsDelete() IsShow_Kind {
+func (x *CategorySyncRequest) GetIsDelete() IsShow_Kind {
 	if x != nil {
 		return x.IsDelete
 	}
 	return IsShow_INVALID
 }
 
+func (x *CategorySyncRequest) GetId() int32 {
+	if x != nil {
+		return x.Id
+	}
+	return 0
+}
+
+// 牧场端分类数据删除
+type CategoryDeleteRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	KeyWord   string `protobuf:"bytes,1,opt,name=key_word,json=keyWord,proto3" json:"key_word,omitempty"`        // 关键字
+	PastureId int32  `protobuf:"varint,2,opt,name=pasture_id,json=pastureId,proto3" json:"pasture_id,omitempty"` // 牧场id
+	DataId    int32  `protobuf:"varint,3,opt,name=data_id,json=dataId,proto3" json:"data_id,omitempty"`
+}
+
+func (x *CategoryDeleteRequest) Reset() {
+	*x = CategoryDeleteRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_backend_operation_pasture_proto_msgTypes[35]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *CategoryDeleteRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CategoryDeleteRequest) ProtoMessage() {}
+
+func (x *CategoryDeleteRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_backend_operation_pasture_proto_msgTypes[35]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use CategoryDeleteRequest.ProtoReflect.Descriptor instead.
+func (*CategoryDeleteRequest) Descriptor() ([]byte, []int) {
+	return file_backend_operation_pasture_proto_rawDescGZIP(), []int{35}
+}
+
+func (x *CategoryDeleteRequest) GetKeyWord() string {
+	if x != nil {
+		return x.KeyWord
+	}
+	return ""
+}
+
+func (x *CategoryDeleteRequest) GetPastureId() int32 {
+	if x != nil {
+		return x.PastureId
+	}
+	return 0
+}
+
+func (x *CategoryDeleteRequest) GetDataId() int32 {
+	if x != nil {
+		return x.DataId
+	}
+	return 0
+}
+
 var File_backend_operation_pasture_proto protoreflect.FileDescriptor
 
 var file_backend_operation_pasture_proto_rawDesc = []byte{
@@ -3131,27 +3203,35 @@ var file_backend_operation_pasture_proto_rawDesc = []byte{
 	0x70, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
 	0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12,
 	0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
-	0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0xa8, 0x02, 0x0a, 0x0c, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x52,
-	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x77, 0x6f,
-	0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x57, 0x6f, 0x72,
-	0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x73, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x69, 0x64, 0x18,
-	0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x73, 0x74, 0x75, 0x72, 0x65, 0x49, 0x64,
-	0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20,
-	0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a,
-	0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12,
-	0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
-	0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x07, 0x69, 0x73,
-	0x5f, 0x73, 0x68, 0x6f, 0x77, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x62, 0x61,
-	0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2e, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
-	0x49, 0x73, 0x53, 0x68, 0x6f, 0x77, 0x2e, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x06, 0x69, 0x73, 0x53,
-	0x68, 0x6f, 0x77, 0x12, 0x3b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65,
-	0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64,
-	0x2e, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x49, 0x73, 0x53, 0x68, 0x6f,
-	0x77, 0x2e, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x08, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
-	0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x3b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50,
-	0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0xbf, 0x02, 0x0a, 0x13, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f,
+	0x72, 0x79, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a,
+	0x08, 0x6b, 0x65, 0x79, 0x5f, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x07, 0x6b, 0x65, 0x79, 0x57, 0x6f, 0x72, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x73, 0x74,
+	0x75, 0x72, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61,
+	0x73, 0x74, 0x75, 0x72, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e,
+	0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x72, 0x65,
+	0x6e, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6e,
+	0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e,
+	0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d,
+	0x62, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65,
+	0x72, 0x12, 0x37, 0x0a, 0x07, 0x69, 0x73, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x18, 0x07, 0x20, 0x01,
+	0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2e, 0x6f, 0x70, 0x65,
+	0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x49, 0x73, 0x53, 0x68, 0x6f, 0x77, 0x2e, 0x4b, 0x69,
+	0x6e, 0x64, 0x52, 0x06, 0x69, 0x73, 0x53, 0x68, 0x6f, 0x77, 0x12, 0x3b, 0x0a, 0x09, 0x69, 0x73,
+	0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e,
+	0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2e, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f,
+	0x6e, 0x2e, 0x49, 0x73, 0x53, 0x68, 0x6f, 0x77, 0x2e, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x08, 0x69,
+	0x73, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x09, 0x20,
+	0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x6a, 0x0a, 0x15, 0x43, 0x61, 0x74, 0x65, 0x67,
+	0x6f, 0x72, 0x79, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+	0x12, 0x19, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x57, 0x6f, 0x72, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70,
+	0x61, 0x73, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
+	0x09, 0x70, 0x61, 0x73, 0x74, 0x75, 0x72, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x64, 0x61,
+	0x74, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x64, 0x61, 0x74,
+	0x61, 0x49, 0x64, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x3b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69,
+	0x6f, 0x6e, 0x50, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -3166,7 +3246,7 @@ func file_backend_operation_pasture_proto_rawDescGZIP() []byte {
 	return file_backend_operation_pasture_proto_rawDescData
 }
 
-var file_backend_operation_pasture_proto_msgTypes = make([]protoimpl.MessageInfo, 35)
+var file_backend_operation_pasture_proto_msgTypes = make([]protoimpl.MessageInfo, 36)
 var file_backend_operation_pasture_proto_goTypes = []interface{}{
 	(*AddPastureRequest)(nil),            // 0: backend.operation.AddPastureRequest
 	(*SearchPastureRequest)(nil),         // 1: backend.operation.SearchPastureRequest
@@ -3202,49 +3282,50 @@ var file_backend_operation_pasture_proto_goTypes = []interface{}{
 	(*IsShowEnum)(nil),                   // 31: backend.operation.IsShowEnum
 	(*FormulaTypeEnum)(nil),              // 32: backend.operation.FormulaTypeEnum
 	(*FormulaOptionEnum)(nil),            // 33: backend.operation.FormulaOptionEnum
-	(*ClassRequest)(nil),                 // 34: backend.operation.ClassRequest
-	(IsShow_Kind)(0),                     // 35: backend.operation.IsShow.Kind
-	(*PaginationModel)(nil),              // 36: backend.operation.PaginationModel
-	(CattleCategoryParent_Kind)(0),       // 37: backend.operation.CattleCategoryParent.Kind
-	(ForageCategoryParent_Kind)(0),       // 38: backend.operation.ForageCategoryParent.Kind
-	(ForageSource_Kind)(0),               // 39: backend.operation.ForageSource.Kind
-	(ForagePlanType_Kind)(0),             // 40: backend.operation.ForagePlanType.Kind
-	(JumpDelaType_Kind)(0),               // 41: backend.operation.JumpDelaType.Kind
-	(FormulaType_Kind)(0),                // 42: backend.operation.FormulaType.Kind
+	(*CategorySyncRequest)(nil),          // 34: backend.operation.CategorySyncRequest
+	(*CategoryDeleteRequest)(nil),        // 35: backend.operation.CategoryDeleteRequest
+	(IsShow_Kind)(0),                     // 36: backend.operation.IsShow.Kind
+	(*PaginationModel)(nil),              // 37: backend.operation.PaginationModel
+	(CattleCategoryParent_Kind)(0),       // 38: backend.operation.CattleCategoryParent.Kind
+	(ForageCategoryParent_Kind)(0),       // 39: backend.operation.ForageCategoryParent.Kind
+	(ForageSource_Kind)(0),               // 40: backend.operation.ForageSource.Kind
+	(ForagePlanType_Kind)(0),             // 41: backend.operation.ForagePlanType.Kind
+	(JumpDelaType_Kind)(0),               // 42: backend.operation.JumpDelaType.Kind
+	(FormulaType_Kind)(0),                // 43: backend.operation.FormulaType.Kind
 }
 var file_backend_operation_pasture_proto_depIdxs = []int32{
-	35, // 0: backend.operation.AddPastureRequest.is_show:type_name -> backend.operation.IsShow.Kind
-	36, // 1: backend.operation.SearchPastureRequest.pagination:type_name -> backend.operation.PaginationModel
+	36, // 0: backend.operation.AddPastureRequest.is_show:type_name -> backend.operation.IsShow.Kind
+	37, // 1: backend.operation.SearchPastureRequest.pagination:type_name -> backend.operation.PaginationModel
 	3,  // 2: backend.operation.SearchPastureResponse.data:type_name -> backend.operation.SearchPastureData
 	0,  // 3: backend.operation.SearchPastureData.list:type_name -> backend.operation.AddPastureRequest
-	35, // 4: backend.operation.IsShowGroupPasture.is_show:type_name -> backend.operation.IsShow.Kind
-	37, // 5: backend.operation.AddCattleCategoryRequest.parent_id:type_name -> backend.operation.CattleCategoryParent.Kind
-	35, // 6: backend.operation.AddCattleCategoryRequest.is_show:type_name -> backend.operation.IsShow.Kind
-	35, // 7: backend.operation.IsShowCattleCategory.is_show:type_name -> backend.operation.IsShow.Kind
-	35, // 8: backend.operation.SearchCattleCategoryRequest.is_show:type_name -> backend.operation.IsShow.Kind
-	36, // 9: backend.operation.SearchCattleCategoryRequest.pagination:type_name -> backend.operation.PaginationModel
+	36, // 4: backend.operation.IsShowGroupPasture.is_show:type_name -> backend.operation.IsShow.Kind
+	38, // 5: backend.operation.AddCattleCategoryRequest.parent_id:type_name -> backend.operation.CattleCategoryParent.Kind
+	36, // 6: backend.operation.AddCattleCategoryRequest.is_show:type_name -> backend.operation.IsShow.Kind
+	36, // 7: backend.operation.IsShowCattleCategory.is_show:type_name -> backend.operation.IsShow.Kind
+	36, // 8: backend.operation.SearchCattleCategoryRequest.is_show:type_name -> backend.operation.IsShow.Kind
+	37, // 9: backend.operation.SearchCattleCategoryRequest.pagination:type_name -> backend.operation.PaginationModel
 	10, // 10: backend.operation.SearchCattleCategoryResponse.data:type_name -> backend.operation.SearchCattleCategoryData
 	6,  // 11: backend.operation.SearchCattleCategoryData.list:type_name -> backend.operation.AddCattleCategoryRequest
-	38, // 12: backend.operation.AddForageCategoryRequest.parent_id:type_name -> backend.operation.ForageCategoryParent.Kind
-	35, // 13: backend.operation.AddForageCategoryRequest.is_show:type_name -> backend.operation.IsShow.Kind
-	35, // 14: backend.operation.IsShowForageCategory.is_show:type_name -> backend.operation.IsShow.Kind
-	35, // 15: backend.operation.SearchForageCategoryRequest.is_show:type_name -> backend.operation.IsShow.Kind
-	36, // 16: backend.operation.SearchForageCategoryRequest.pagination:type_name -> backend.operation.PaginationModel
+	39, // 12: backend.operation.AddForageCategoryRequest.parent_id:type_name -> backend.operation.ForageCategoryParent.Kind
+	36, // 13: backend.operation.AddForageCategoryRequest.is_show:type_name -> backend.operation.IsShow.Kind
+	36, // 14: backend.operation.IsShowForageCategory.is_show:type_name -> backend.operation.IsShow.Kind
+	36, // 15: backend.operation.SearchForageCategoryRequest.is_show:type_name -> backend.operation.IsShow.Kind
+	37, // 16: backend.operation.SearchForageCategoryRequest.pagination:type_name -> backend.operation.PaginationModel
 	15, // 17: backend.operation.SearchForageCategoryResponse.data:type_name -> backend.operation.SearchForageCategoryData
 	11, // 18: backend.operation.SearchForageCategoryData.list:type_name -> backend.operation.AddForageCategoryRequest
-	39, // 19: backend.operation.AddForageRequest.forage_source_id:type_name -> backend.operation.ForageSource.Kind
-	40, // 20: backend.operation.AddForageRequest.plan_type_id:type_name -> backend.operation.ForagePlanType.Kind
-	41, // 21: backend.operation.AddForageRequest.jump_delay:type_name -> backend.operation.JumpDelaType.Kind
-	35, // 22: backend.operation.AddForageRequest.confirm_start:type_name -> backend.operation.IsShow.Kind
-	35, // 23: backend.operation.AddForageRequest.jmp:type_name -> backend.operation.IsShow.Kind
-	35, // 24: backend.operation.AddForageRequest.is_show:type_name -> backend.operation.IsShow.Kind
-	35, // 25: backend.operation.SearchForageListRequest.is_show:type_name -> backend.operation.IsShow.Kind
-	41, // 26: backend.operation.SearchForageListRequest.jump_delay:type_name -> backend.operation.JumpDelaType.Kind
-	36, // 27: backend.operation.SearchForageListRequest.pagination:type_name -> backend.operation.PaginationModel
+	40, // 19: backend.operation.AddForageRequest.forage_source_id:type_name -> backend.operation.ForageSource.Kind
+	41, // 20: backend.operation.AddForageRequest.plan_type_id:type_name -> backend.operation.ForagePlanType.Kind
+	42, // 21: backend.operation.AddForageRequest.jump_delay:type_name -> backend.operation.JumpDelaType.Kind
+	36, // 22: backend.operation.AddForageRequest.confirm_start:type_name -> backend.operation.IsShow.Kind
+	36, // 23: backend.operation.AddForageRequest.jmp:type_name -> backend.operation.IsShow.Kind
+	36, // 24: backend.operation.AddForageRequest.is_show:type_name -> backend.operation.IsShow.Kind
+	36, // 25: backend.operation.SearchForageListRequest.is_show:type_name -> backend.operation.IsShow.Kind
+	42, // 26: backend.operation.SearchForageListRequest.jump_delay:type_name -> backend.operation.JumpDelaType.Kind
+	37, // 27: backend.operation.SearchForageListRequest.pagination:type_name -> backend.operation.PaginationModel
 	19, // 28: backend.operation.ForageListSortRequest.list:type_name -> backend.operation.ForageListSort
 	22, // 29: backend.operation.SearchForageListResponse.data:type_name -> backend.operation.SearchForageList
 	16, // 30: backend.operation.SearchForageList.list:type_name -> backend.operation.AddForageRequest
-	35, // 31: backend.operation.IsShowForage.is_show:type_name -> backend.operation.IsShow.Kind
+	36, // 31: backend.operation.IsShowForage.is_show:type_name -> backend.operation.IsShow.Kind
 	25, // 32: backend.operation.ForageEnumListResponse.data:type_name -> backend.operation.ForageEnumList
 	26, // 33: backend.operation.ForageEnumList.forage_source:type_name -> backend.operation.ForageSourceEnum
 	27, // 34: backend.operation.ForageEnumList.forage_plan_type:type_name -> backend.operation.ForagePlanTypeEnum
@@ -3261,15 +3342,15 @@ var file_backend_operation_pasture_proto_depIdxs = []int32{
 	33, // 45: backend.operation.ForageEnumList.price_materials_type:type_name -> backend.operation.FormulaOptionEnum
 	33, // 46: backend.operation.ForageEnumList.jump_type:type_name -> backend.operation.FormulaOptionEnum
 	33, // 47: backend.operation.ForageEnumList.statistics_type:type_name -> backend.operation.FormulaOptionEnum
-	39, // 48: backend.operation.ForageSourceEnum.value:type_name -> backend.operation.ForageSource.Kind
-	40, // 49: backend.operation.ForagePlanTypeEnum.value:type_name -> backend.operation.ForagePlanType.Kind
-	41, // 50: backend.operation.JumpDelaTypeEnum.value:type_name -> backend.operation.JumpDelaType.Kind
-	37, // 51: backend.operation.CattleParentCategoryEnum.value:type_name -> backend.operation.CattleCategoryParent.Kind
-	38, // 52: backend.operation.ForageParentCategoryEnum.value:type_name -> backend.operation.ForageCategoryParent.Kind
-	35, // 53: backend.operation.IsShowEnum.value:type_name -> backend.operation.IsShow.Kind
-	42, // 54: backend.operation.FormulaTypeEnum.value:type_name -> backend.operation.FormulaType.Kind
-	35, // 55: backend.operation.ClassRequest.is_show:type_name -> backend.operation.IsShow.Kind
-	35, // 56: backend.operation.ClassRequest.is_delete:type_name -> backend.operation.IsShow.Kind
+	40, // 48: backend.operation.ForageSourceEnum.value:type_name -> backend.operation.ForageSource.Kind
+	41, // 49: backend.operation.ForagePlanTypeEnum.value:type_name -> backend.operation.ForagePlanType.Kind
+	42, // 50: backend.operation.JumpDelaTypeEnum.value:type_name -> backend.operation.JumpDelaType.Kind
+	38, // 51: backend.operation.CattleParentCategoryEnum.value:type_name -> backend.operation.CattleCategoryParent.Kind
+	39, // 52: backend.operation.ForageParentCategoryEnum.value:type_name -> backend.operation.ForageCategoryParent.Kind
+	36, // 53: backend.operation.IsShowEnum.value:type_name -> backend.operation.IsShow.Kind
+	43, // 54: backend.operation.FormulaTypeEnum.value:type_name -> backend.operation.FormulaType.Kind
+	36, // 55: backend.operation.CategorySyncRequest.is_show:type_name -> backend.operation.IsShow.Kind
+	36, // 56: backend.operation.CategorySyncRequest.is_delete:type_name -> backend.operation.IsShow.Kind
 	57, // [57:57] is the sub-list for method output_type
 	57, // [57:57] is the sub-list for method input_type
 	57, // [57:57] is the sub-list for extension type_name
@@ -3694,7 +3775,19 @@ func file_backend_operation_pasture_proto_init() {
 			}
 		}
 		file_backend_operation_pasture_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*ClassRequest); i {
+			switch v := v.(*CategorySyncRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_backend_operation_pasture_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*CategoryDeleteRequest); i {
 			case 0:
 				return &v.state
 			case 1:
@@ -3712,7 +3805,7 @@ func file_backend_operation_pasture_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_backend_operation_pasture_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   35,
+			NumMessages:   36,
 			NumExtensions: 0,
 			NumServices:   0,
 		},