|
@@ -8,137 +8,194 @@ import (
|
|
|
"go.uber.org/zap"
|
|
|
)
|
|
|
|
|
|
-func (s *StoreEntry) LactEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) LactEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ configLactList := make([]*model.ConfigLact, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigLact)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
if isAll == model.IsAllYes {
|
|
|
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(0),
|
|
|
- Label: "全部",
|
|
|
- Disabled: true,
|
|
|
- })
|
|
|
+ pref = pref.Where("kind >= ?", 0)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", 0)
|
|
|
}
|
|
|
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(1),
|
|
|
- Label: "1",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(2),
|
|
|
- Label: "2",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(3),
|
|
|
- Label: "3",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(4),
|
|
|
- Label: ">3",
|
|
|
- Disabled: true,
|
|
|
- })
|
|
|
- return configOptions
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&configLactList).Error; err != nil {
|
|
|
+ zaplog.Error("LactEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigLactSlice(configLactList).ToPB(userModel.Language)
|
|
|
+ /*
|
|
|
+ configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(1),
|
|
|
+ Label: "1",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(2),
|
|
|
+ Label: "2",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(3),
|
|
|
+ Label: "3",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(4),
|
|
|
+ Label: ">3",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return configOptions
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) DiseaseAnalysisMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) DiseaseAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigDiseaseAnalysisMethod, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigDiseaseAnalysisMethod)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
if isAll == model.IsAllYes {
|
|
|
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.DiseaseAnalysisMethod_Invalid),
|
|
|
- Label: "全部",
|
|
|
- Disabled: true,
|
|
|
- })
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.DiseaseAnalysisMethod_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.DiseaseAnalysisMethod_Invalid)
|
|
|
}
|
|
|
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.DiseaseAnalysisMethod_Months),
|
|
|
- Label: "按月份",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.DiseaseAnalysisMethod_Disease_Category),
|
|
|
- Label: "疾病分类",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.DiseaseAnalysisMethod_Disease),
|
|
|
- Label: "疾病名称",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.DiseaseAnalysisMethod_Operator),
|
|
|
- Label: "兽医",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.DiseaseAnalysisMethod_Prescription),
|
|
|
- Label: "处方",
|
|
|
- Disabled: true,
|
|
|
- })
|
|
|
- return configOptions
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("DiseaseAnalysisMethodEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigDiseaseAnalysisMethodSlice(dataList).ToPB(userModel.Language)
|
|
|
+ /*
|
|
|
+ configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.DiseaseAnalysisMethod_Months),
|
|
|
+ Label: "按月份",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.DiseaseAnalysisMethod_Disease_Category),
|
|
|
+ Label: "疾病分类",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.DiseaseAnalysisMethod_Disease),
|
|
|
+ Label: "疾病名称",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.DiseaseAnalysisMethod_Operator),
|
|
|
+ Label: "兽医",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.DiseaseAnalysisMethod_Prescription),
|
|
|
+ Label: "处方",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return configOptions
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) diseaseTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+func (s *StoreEntry) diseaseTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
configDiseaseTypeList := make([]*model.ConfigDiseaseType, 0)
|
|
|
- configOptionsList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
- if err := s.DB.Where("is_show = ?", pasturePb.IsShow_Ok).Find(&configDiseaseTypeList).Error; err != nil {
|
|
|
+ if err := s.DB.Model(new(model.ConfigDiseaseType)).
|
|
|
+ Where("pasture_id = ?", userModel.AppPasture.Id).
|
|
|
+ Where("is_show = ?", pasturePb.IsShow_Ok).
|
|
|
+ Find(&configDiseaseTypeList).Error; err != nil {
|
|
|
zaplog.Error("diseaseTypeEnumList", zap.Any("Find", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
}
|
|
|
|
|
|
- for _, v := range configDiseaseTypeList {
|
|
|
- configOptionsList = append(configOptionsList, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(v.Id),
|
|
|
- Label: v.Name,
|
|
|
- Disabled: true,
|
|
|
- })
|
|
|
- }
|
|
|
- return configOptionsList
|
|
|
+ return model.ConfigDiseaseTypeSlice(configDiseaseTypeList).ToPB3(userModel.Language)
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) SingleFactorAnalysisMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Cycle),
|
|
|
- Label: "按周期分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Months),
|
|
|
- Label: "按月份分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Mating_Times),
|
|
|
- Label: "按配种次数分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Method),
|
|
|
- Label: "按配种方式分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Company),
|
|
|
- Label: "按育种公司分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Operation),
|
|
|
- Label: "按兽医人员分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Mating_Interval),
|
|
|
- Label: "按配种间隔分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Bull),
|
|
|
- Label: "按公牛号分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Cycle),
|
|
|
- Label: "按配种周期分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Week),
|
|
|
- Label: "按星期分析",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.SingleFactorAnalysisMethod_Lact),
|
|
|
- Label: "按胎次分析",
|
|
|
- Disabled: true,
|
|
|
- })
|
|
|
- return configOptions
|
|
|
+func (s *StoreEntry) SingleFactorAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigSingleFactorAnalysisMethod, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigSingleFactorAnalysisMethod)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
+ if isAll == model.IsAllYes {
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.DiseaseAnalysisMethod_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.DiseaseAnalysisMethod_Invalid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("SingleFactorAnalysisMethodEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigSingleFactorAnalysisMethodSlice(dataList).ToPB(userModel.Language)
|
|
|
+
|
|
|
+ /*
|
|
|
+ func (s *StoreEntry) SingleFactorAnalysisMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Cycle),
|
|
|
+ Label: "按周期分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Months),
|
|
|
+ Label: "按月份分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Mating_Times),
|
|
|
+ Label: "按配种次数分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Method),
|
|
|
+ Label: "按配种方式分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Company),
|
|
|
+ Label: "按育种公司分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Operation),
|
|
|
+ Label: "按兽医人员分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Mating_Interval),
|
|
|
+ Label: "按配种间隔分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Bull),
|
|
|
+ Label: "按公牛号分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Cycle),
|
|
|
+ Label: "按配种周期分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Week),
|
|
|
+ Label: "按星期分析",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.SingleFactorAnalysisMethod_Lact),
|
|
|
+ Label: "按胎次分析",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return configOptions
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) LactIntervalSymbolEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) LactIntervalSymbolEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigLactIntervalSymbol, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigLactIntervalSymbol)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
+ if isAll == model.IsAllYes {
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.CompareSymbol_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.CompareSymbol_Invalid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("LactIntervalSymbolEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigLactIntervalSymbolSlice(dataList).ToPB(userModel.Language)
|
|
|
+
|
|
|
+ /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
Value: int32(pasturePb.CompareSymbol_Less_Than),
|
|
|
Label: "<",
|
|
@@ -176,11 +233,28 @@ func (s *StoreEntry) LactIntervalSymbolEnumList(isAll string) []*pasturePb.Confi
|
|
|
Label: "不包含",
|
|
|
Disabled: true,
|
|
|
})
|
|
|
- return configOptions
|
|
|
+ return configOptions*/
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) MultiFactorAnalysisMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) MultiFactorAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigMultiFactorAnalysisMethod, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigMultiFactorAnalysisMethod)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
+ if isAll == model.IsAllYes {
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.CompareSymbol_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.CompareSymbol_Invalid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("LactIntervalSymbolEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigMultiFactorAnalysisMethodSlice(dataList).ToPB(userModel.Language)
|
|
|
+ /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
Value: int32(pasturePb.MultiFactorAnalysisMethod_Months),
|
|
|
Label: "月份",
|
|
@@ -217,11 +291,28 @@ func (s *StoreEntry) MultiFactorAnalysisMethodEnumList(isAll string) []*pastureP
|
|
|
Props: "exposeEstrusType",
|
|
|
Disabled: true,
|
|
|
})
|
|
|
- return configOptions
|
|
|
+ return configOptions*/
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) SaleCowAnalysisMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) SaleCowAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigSaleCowAnalysisMethod, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigSaleCowAnalysisMethod)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
+ if isAll == model.IsAllYes {
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.CompareSymbol_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.CompareSymbol_Invalid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("LactIntervalSymbolEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigSaleCowAnalysisMethodSlice(dataList).ToPB(userModel.Language)
|
|
|
+ /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
Value: int32(pasturePb.SaleCowAnalysisMethod_Months),
|
|
|
Label: "月份",
|
|
@@ -231,11 +322,28 @@ func (s *StoreEntry) SaleCowAnalysisMethodEnumList(isAll string) []*pasturePb.Co
|
|
|
Label: "经销商",
|
|
|
Disabled: true,
|
|
|
})
|
|
|
- return configOptions
|
|
|
+ return configOptions*/
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) NeckRingIsBindEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) NeckRingIsBindEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigNeckRingIsBind, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigNeckRingStatus)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
+ if isAll == model.IsAllYes {
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.NeckRingIsBind_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.NeckRingIsBind_Invalid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("NeckRingIsBindEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigNeckRingIsBindSlice(dataList).ToPB(userModel.Language)
|
|
|
+ /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
if isAll == model.IsAllYes {
|
|
|
configOptions = append(configOptions,
|
|
|
&pasturePb.ConfigOptionsList{
|
|
@@ -253,11 +361,28 @@ func (s *StoreEntry) NeckRingIsBindEnumList(isAll string) []*pasturePb.ConfigOpt
|
|
|
Label: "未绑定",
|
|
|
Disabled: true,
|
|
|
})
|
|
|
- return configOptions
|
|
|
+ return configOptions*/
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) NeckRingStatusEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) NeckRingStatusEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigNeckRingStatus, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigNeckRingStatus)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
+ if isAll == model.IsAllYes {
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.NeckRingStatus_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.NeckRingStatus_Invalid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("NeckRingStatusEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigNeckRingStatusSlice(dataList).ToPB(userModel.Language)
|
|
|
+ /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
if isAll == model.IsAllYes {
|
|
|
configOptions = append(configOptions,
|
|
|
&pasturePb.ConfigOptionsList{
|
|
@@ -275,11 +400,28 @@ func (s *StoreEntry) NeckRingStatusEnumList(isAll string) []*pasturePb.ConfigOpt
|
|
|
Label: "异常",
|
|
|
Disabled: true,
|
|
|
})
|
|
|
- return configOptions
|
|
|
+ return configOptions*/
|
|
|
}
|
|
|
|
|
|
-func CalendarTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) CalendarTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigCalendarType, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigCalendarType)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
+ if isAll == model.IsAllYes {
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.CalendarType_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.CalendarType_Invalid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("CalendarTypeEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ return model.ConfigCalendarTypeSlice(dataList).ToPB(userModel.Language)
|
|
|
+ /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
if isAll == model.IsAllYes {
|
|
|
configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
Value: int32(pasturePb.CalendarType_Invalid),
|
|
@@ -324,11 +466,11 @@ func CalendarTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
Label: "干奶",
|
|
|
Disabled: true,
|
|
|
})
|
|
|
- return configOptions
|
|
|
+ return configOptions*/
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) AbortionReasonsEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- /*configAbortionReasonList := make([]*model.ConfigAbortionReasons, 0)
|
|
|
+func (s *StoreEntry) AbortionReasonsEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigAbortionReasons, 0)
|
|
|
pref := s.DB.Model(new(model.ConfigAbortionReasons)).
|
|
|
Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
@@ -339,66 +481,33 @@ func (s *StoreEntry) AbortionReasonsEnumList(isAll string) []*pasturePb.ConfigOp
|
|
|
}
|
|
|
|
|
|
if err := pref.Order("kind ASC").
|
|
|
- Find(&configAbortionReasonList).Error; err != nil {
|
|
|
- return nil, xerr.WithStack(err)
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("AbortionReasonsEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
}
|
|
|
|
|
|
- return model.ConfigAbortionReasonsSlice(configAbortionReasonList).ToPB(userModel.Language)*/
|
|
|
+ return model.ConfigAbortionReasonsSlice(dataList).ToPB(userModel.Language)
|
|
|
+}
|
|
|
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+func (s *StoreEntry) CalvingAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
+ dataList := make([]*model.ConfigCalvingAnalysisMethod, 0)
|
|
|
+ pref := s.DB.Model(new(model.ConfigCalvingAnalysisMethod)).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok).
|
|
|
+ Where("pasture_id =? ", userModel.AppPasture.Id)
|
|
|
if isAll == model.IsAllYes {
|
|
|
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Invalid),
|
|
|
- Label: "全部",
|
|
|
- Disabled: true,
|
|
|
- })
|
|
|
+ pref = pref.Where("kind >= ?", pasturePb.CalvingAnalysisMethod_Invalid)
|
|
|
+ } else {
|
|
|
+ pref = pref.Where("kind > ?", pasturePb.CalvingAnalysisMethod_Invalid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := pref.Order("kind ASC").
|
|
|
+ Find(&dataList).Error; err != nil {
|
|
|
+ zaplog.Error("CalvingAnalysisMethodEnumList", zap.Any("err", err))
|
|
|
+ return make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
}
|
|
|
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Mechanical_Abortion),
|
|
|
- Label: "机械性流产",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Malnutrition_Abortion),
|
|
|
- Label: "营养不良流产",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Mycotoxin_Abortion),
|
|
|
- Label: "霉菌毒素流产",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Habitual_Abortion),
|
|
|
- Label: "习惯性流产",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Brucellosis_Abortion),
|
|
|
- Label: "布病流产",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Inflammatory_Abortion),
|
|
|
- Label: "产道炎症性流产",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Heat_Stress_Abortion),
|
|
|
- Label: "热应激流产",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Infectious_Abortion),
|
|
|
- Label: "传染病性流产",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Unknown),
|
|
|
- Label: "未知原因",
|
|
|
- Disabled: true,
|
|
|
- }, &pasturePb.ConfigOptionsList{
|
|
|
- Value: int32(pasturePb.AbortionReasons_Other),
|
|
|
- Label: "其他",
|
|
|
- Disabled: true,
|
|
|
- })
|
|
|
- return configOptions
|
|
|
-}
|
|
|
|
|
|
-func (s *StoreEntry) CalvingAnalysisMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ return model.ConfigCalvingAnalysisMethodSlice(dataList).ToPB(userModel.Language)
|
|
|
+ /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
if isAll == model.IsAllYes {
|
|
|
configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
|
|
|
Value: int32(pasturePb.CalvingAnalysisMethod_Invalid),
|
|
@@ -415,5 +524,5 @@ func (s *StoreEntry) CalvingAnalysisMethodEnumList(isAll string) []*pasturePb.Co
|
|
|
Label: "按照品种统计",
|
|
|
Disabled: true,
|
|
|
})
|
|
|
- return configOptions
|
|
|
+ return configOptions*/
|
|
|
}
|