Browse Source

cattle: 畜牧分类

Yi 1 year ago
parent
commit
bf52174e72
2 changed files with 25 additions and 28 deletions
  1. 0 1
      model/pasture_data.go
  2. 25 27
      module/backend/pasture_service.go

+ 0 - 1
model/pasture_data.go

@@ -58,7 +58,6 @@ type CategoryRequest struct {
 	ParentId   int32  `json:"parent_id"`
 	ParentName string `json:"parent_name"`
 	Name       string `json:"name"`
-	Id         int32  `json:"id"`
 	Number     string `json:"number"`
 	IsShow     int32  `json:"is_show"`
 	GroupId    int32  `json:"group_id"`

+ 25 - 27
module/backend/pasture_service.go

@@ -108,7 +108,6 @@ func (s *StoreEntry) EditGroupPasture(ctx context.Context, req *operationPb.AddP
 		Address:      req.Address,
 		Domain:       req.Domain,
 	}
-
 	if err := s.DB.Model(new(model.GroupPasture)).Omit("is_show", "password").
 		Where("id = ?", req.Id).
 		Updates(updateData).Error; err != nil {
@@ -229,7 +228,6 @@ func (s *StoreEntry) AddCattleCategory(ctx context.Context, req *operationPb.Add
 			ParentId:   int32(req.ParentId),
 			ParentName: req.ParentName,
 			Name:       req.Name,
-			Id:         int32(req.Id),
 			Number:     req.Number,
 			IsShow:     int32(req.IsShow),
 			GroupId:    int32(cattleCategory.Id),
@@ -266,7 +264,6 @@ func (s *StoreEntry) EditCattleCategory(ctx context.Context, req *operationPb.Ad
 			ParentId:   int32(req.ParentId),
 			ParentName: req.ParentName,
 			Name:       req.Name,
-			Id:         int32(req.Id),
 			Number:     req.Number,
 			IsShow:     int32(req.IsShow),
 			GroupId:    int32(req.Id),
@@ -295,7 +292,6 @@ func (s *StoreEntry) IsShowCattleCategory(ctx context.Context, req *operationPb.
 			ParentId:   int32(cattleCategory.ParentId),
 			ParentName: cattleCategory.ParentName,
 			Name:       cattleCategory.Name,
-			Id:         req.CattleCategoryId,
 			Number:     cattleCategory.Number,
 			IsShow:     int32(req.IsShow),
 			GroupId:    int32(cattleCategory.Id),
@@ -376,7 +372,6 @@ func (s *StoreEntry) AddForageCategory(ctx context.Context, req *operationPb.Add
 			ParentId:   int32(req.ParentId),
 			ParentName: req.ParentName,
 			Name:       req.Name,
-			Id:         int32(req.Id),
 			Number:     req.Number,
 			IsShow:     int32(req.IsShow),
 			GroupId:    int32(forageCategory.Id),
@@ -412,7 +407,6 @@ func (s *StoreEntry) EditForageCategory(ctx context.Context, req *operationPb.Ad
 			ParentId:   int32(req.ParentId),
 			ParentName: req.ParentName,
 			Name:       req.Name,
-			Id:         int32(req.Id),
 			Number:     req.Number,
 			IsShow:     int32(req.IsShow),
 			GroupId:    int32(req.Id),
@@ -442,7 +436,6 @@ func (s *StoreEntry) IsShowForageCategory(ctx context.Context, req *operationPb.
 			ParentId:   int32(forageCategory.ParentId),
 			ParentName: forageCategory.ParentName,
 			Name:       forageCategory.Name,
-			Id:         req.ForageCategoryId,
 			Number:     forageCategory.Number,
 			IsShow:     int32(req.IsShow),
 			GroupId:    int32(forageCategory.Id),
@@ -471,7 +464,7 @@ func (s *StoreEntry) DeleteForageCategory(ctx context.Context, forageCategoryId
 			GroupId:  int32(forageCategory.Id),
 			IsDelete: int32(operationPb.IsShow_OK),
 		}
-		if err = s.CategoryDelete(ctx, model.CattleCategoryDeleteURl, body); err != nil {
+		if err = s.CategoryDelete(ctx, model.ForageCategoryDeleteURl, body); err != nil {
 			zaplog.Error("DeleteForageCategory", zap.Any("CategoryDelete", err), zap.Any("body", body))
 		}
 	}
@@ -756,25 +749,30 @@ func (s *StoreEntry) ForageEnumList(ctx context.Context) *operationPb.ForageEnum
 		})
 
 	// 畜牧类别
-	res.Data.CattleParentCategory = append(res.Data.CattleParentCategory, &operationPb.CattleParentCategoryEnum{
-		Value: operationPb.CattleCategoryParent_LACTATION_CAW,
-		Label: "泌乳牛",
-	}, &operationPb.CattleParentCategoryEnum{
-		Value: operationPb.CattleCategoryParent_FATTEN_CAW,
-		Label: "育肥牛",
-	}, &operationPb.CattleParentCategoryEnum{
-		Value: operationPb.CattleCategoryParent_RESERVE_CAW,
-		Label: "后备牛",
-	}, &operationPb.CattleParentCategoryEnum{
-		Value: operationPb.CattleCategoryParent_DRY_CAW,
-		Label: "干奶牛",
-	}, &operationPb.CattleParentCategoryEnum{
-		Value: operationPb.CattleCategoryParent_PERINATAL_CAW,
-		Label: "围产牛",
-	}, &operationPb.CattleParentCategoryEnum{
-		Value: operationPb.CattleCategoryParent_OTHER_CAW,
-		Label: "其他",
-	})
+	res.Data.CattleParentCategory = append(res.Data.CattleParentCategory,
+		&operationPb.CattleParentCategoryEnum{
+			Value: operationPb.CattleCategoryParent_INVALID,
+			Label: "所有",
+		},
+		&operationPb.CattleParentCategoryEnum{
+			Value: operationPb.CattleCategoryParent_LACTATION_CAW,
+			Label: "泌乳牛",
+		}, &operationPb.CattleParentCategoryEnum{
+			Value: operationPb.CattleCategoryParent_FATTEN_CAW,
+			Label: "育肥牛",
+		}, &operationPb.CattleParentCategoryEnum{
+			Value: operationPb.CattleCategoryParent_RESERVE_CAW,
+			Label: "后备牛",
+		}, &operationPb.CattleParentCategoryEnum{
+			Value: operationPb.CattleCategoryParent_DRY_CAW,
+			Label: "干奶牛",
+		}, &operationPb.CattleParentCategoryEnum{
+			Value: operationPb.CattleCategoryParent_PERINATAL_CAW,
+			Label: "围产牛",
+		}, &operationPb.CattleParentCategoryEnum{
+			Value: operationPb.CattleCategoryParent_OTHER_CAW,
+			Label: "其他",
+		})
 
 	// 饲料类别
 	res.Data.ForageParentCategory = append(res.Data.ForageParentCategory, &operationPb.ForageParentCategoryEnum{