|
@@ -155,6 +155,14 @@ func (s *StoreEntry) SearchGroupPastureList(ctx context.Context, req *operationP
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
+func (s *StoreEntry) GroupPastureList(ctx context.Context) ([]*model.GroupPasture, error) {
|
|
|
+ groupPastureList := make([]*model.GroupPasture, 0)
|
|
|
+ if err := s.DB.Model(new(model.GroupPasture)).Where("is_delete = ? ", operationPb.IsShow_OK).Find(&groupPastureList).Error; err != nil {
|
|
|
+ return nil, xerr.WithStack(err)
|
|
|
+ }
|
|
|
+ return groupPastureList, nil
|
|
|
+}
|
|
|
+
|
|
|
func (s *StoreEntry) DeleteGroupPasture(ctx context.Context, pastureId int64) error {
|
|
|
groupPasture := &model.GroupPasture{
|
|
|
Id: pastureId,
|
|
@@ -225,7 +233,6 @@ func (s *StoreEntry) AddCattleCategory(ctx context.Context, req *operationPb.Add
|
|
|
zaplog.Error("AddCattleCategory", zap.Any("CategoryDistribution", err))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return nil
|
|
|
}
|
|
|
|
|
@@ -507,16 +514,16 @@ func (s *StoreEntry) SearchForageCategoryList(ctx context.Context, req *operatio
|
|
|
|
|
|
// CategoryDistribution 饲料分类和畜牧分类下发
|
|
|
func (s *StoreEntry) CategoryDistribution(ctx context.Context, url string, req *model.CategoryRequest) error {
|
|
|
- groupList, err := s.SearchGroupPastureList(ctx, &operationPb.SearchPastureRequest{})
|
|
|
+ groupList, err := s.GroupPastureList(ctx)
|
|
|
if err != nil {
|
|
|
return xerr.WithStack(err)
|
|
|
}
|
|
|
wg := sync.WaitGroup{}
|
|
|
- wg.Add(len(groupList.Data.List))
|
|
|
- for _, v := range groupList.Data.List {
|
|
|
- go func(data *operationPb.AddPastureRequest) {
|
|
|
+ wg.Add(len(groupList))
|
|
|
+ for _, v := range groupList {
|
|
|
+ go func(data *model.GroupPasture) {
|
|
|
res := &model.PastureCommonResponse{}
|
|
|
- req.PastureId = data.Id
|
|
|
+ req.PastureId = int32(data.Id)
|
|
|
if err = s.PastureHttpClient(ctx, url, int64(data.Id), req, res); err != nil {
|
|
|
zaplog.Error("CategoryDistribution",
|
|
|
zap.Any("url", url),
|
|
@@ -542,16 +549,16 @@ func (s *StoreEntry) CategoryDistribution(ctx context.Context, url string, req *
|
|
|
|
|
|
// CategoryDelete 饲料分类和畜牧分类删除
|
|
|
func (s *StoreEntry) CategoryDelete(ctx context.Context, url string, req *model.CategoryDeleteRequest) error {
|
|
|
- groupList, err := s.SearchGroupPastureList(ctx, &operationPb.SearchPastureRequest{})
|
|
|
+ groupList, err := s.GroupPastureList(ctx)
|
|
|
if err != nil {
|
|
|
return xerr.WithStack(err)
|
|
|
}
|
|
|
wg := sync.WaitGroup{}
|
|
|
- wg.Add(len(groupList.Data.List))
|
|
|
- for _, v := range groupList.Data.List {
|
|
|
- go func(data *operationPb.AddPastureRequest) {
|
|
|
+ wg.Add(len(groupList))
|
|
|
+ for _, v := range groupList {
|
|
|
+ go func(data *model.GroupPasture) {
|
|
|
res := &model.PastureCommonResponse{}
|
|
|
- req.PastureId = data.Id
|
|
|
+ req.PastureId = int32(data.Id)
|
|
|
if err = s.PastureHttpClient(ctx, url, int64(data.Id), req, res); err != nil {
|
|
|
zaplog.Error("CategoryDistribution",
|
|
|
zap.Any("url", url),
|