Bladeren bron

enum: 日常枚举数据落库

Yi 1 week geleden
bovenliggende
commit
dc77782348
55 gewijzigde bestanden met toevoegingen van 1266 en 1304 verwijderingen
  1. 2 0
      http/middleware/i18n.go
  2. 105 1
      locales/en.json
  3. 161 1
      locales/zh.json
  4. 16 15
      model/config_abortion_reasons.go
  5. 29 8
      model/config_barn_type.go
  6. 28 15
      model/config_breed_status.go
  7. 16 15
      model/config_calving_level.go
  8. 17 16
      model/config_child_number.go
  9. 13 14
      model/config_cow_death_destination.go
  10. 18 21
      model/config_cow_kind.go
  11. 38 0
      model/config_cow_out_reason.go
  12. 38 0
      model/config_cow_purpose.go
  13. 18 21
      model/config_cow_source.go
  14. 34 8
      model/config_cow_type.go
  15. 38 0
      model/config_death_reason.go
  16. 16 15
      model/config_dystocia_reason.go
  17. 38 0
      model/config_event_category.go
  18. 16 15
      model/config_immunization_conditions.go
  19. 0 37
      model/config_immunization_cow_type.go
  20. 38 0
      model/config_indicators_category.go
  21. 38 0
      model/config_mating_result.go
  22. 16 15
      model/config_pregnant_check_result.go
  23. 16 15
      model/config_sale_cow_analysis_method.go
  24. 17 16
      model/config_same_time_cow_type.go
  25. 17 16
      model/config_same_time_type.go
  26. 17 20
      model/config_transfer_pen_reason.go
  27. 1 1
      module/backend/analysis_cow.go
  28. 1 1
      module/backend/analysis_more.go
  29. 4 4
      module/backend/analysis_other.go
  30. 3 3
      module/backend/calendar.go
  31. 6 6
      module/backend/calendar_more.go
  32. 57 404
      module/backend/config_data.go
  33. 97 363
      module/backend/config_data_base.go
  34. 7 4
      module/backend/config_data_breed.go
  35. 11 11
      module/backend/config_data_extend.go
  36. 16 16
      module/backend/config_data_other.go
  37. 16 16
      module/backend/cow.go
  38. 7 7
      module/backend/dashboard.go
  39. 93 101
      module/backend/enum_map.go
  40. 38 12
      module/backend/enum_options.go
  41. 5 5
      module/backend/event_base.go
  42. 1 1
      module/backend/event_base_more.go
  43. 1 1
      module/backend/event_breed.go
  44. 5 5
      module/backend/event_breed_more.go
  45. 4 4
      module/backend/event_check.go
  46. 14 10
      module/backend/event_cow_log.go
  47. 4 4
      module/backend/event_health.go
  48. 15 15
      module/backend/goods.go
  49. 4 4
      module/backend/indicators.go
  50. 2 2
      module/backend/neck_ring_warning.go
  51. 30 8
      module/backend/pasture.go
  52. 4 4
      module/backend/prescription.go
  53. 3 0
      module/backend/sql.go
  54. 5 1
      module/backend/test_service.go
  55. 12 7
      module/backend/work.go

+ 2 - 0
http/middleware/i18n.go

@@ -115,6 +115,8 @@ func detectLanguage(r *http.Request) string {
 	if acceptLang := r.Header.Get("Accept-Language"); acceptLang != "" {
 		if langs := strings.Split(acceptLang, ","); len(langs) > 0 {
 			return normalizeLanguage(langs[0])
+		} else {
+			return normalizeLanguage(acceptLang)
 		}
 	}
 	// 默认返回中文

+ 105 - 1
locales/en.json

@@ -96,5 +96,109 @@
   "goods.frozenSemenNotExist": "The frozen semen information does not exist!",
   "goods.frozenSemenNotEnough": "Insufficient quantity of frozen semen!",
   "pasture.dealerNotExist": "This dealer information was not found!",
-  "pasture.dealerError": "Dealer data exception!"
+  "pasture.dealerError": "Dealer data exception!",
+  "config.saleCowAnalysisMethod0":"All",
+  "config.saleCowAnalysisMethod1":"Month",
+  "config.saleCowAnalysisMethod2":"Dealer",
+  "config.barnType0": "All",
+  "config.barnType1": "Calve Barn",
+  "config.barnType2": "Weaning Barn",
+  "config.barnType3": "Nurturing Barn",
+  "config.barnType4": "Youth Barn",
+  "config.barnType5": "Lactation Barn",
+  "config.barnType6": "Perinatal Barn",
+  "config.barnType7": "Dry Dairy Barn",
+  "config.barnType8": "Disease Barn",
+  "config.barnType9": "Out Barn",
+  "config.barnType10": "Segregate Barn",
+  "config.barnType11": "Bull Barn",
+  "config.barnType12": "Reserve Barn",
+  "config.breedStatus0": "All",
+  "config.breedStatus1": "UnBreed",
+  "config.breedStatus2": "Breeding",
+  "config.breedStatus3": "Pregnant",
+  "config.breedStatus4": "Empty",
+  "config.breedStatus5": "Calving",
+  "config.breedStatus6": "Abortion",
+  "config.breedStatus7": "NoMating",
+  "config.cowKind0": "All",
+  "config.cowKind1": "Holstein",
+  "config.cowKind2": "Jersey",
+  "config.cowKind3": "Sanhe",
+  "config.cowKind4": "Xinjiang Brown",
+  "config.cowKind5": "Yak",
+  "config.cowKind6": "Simmental",
+  "config.cowKind7": "Angus",
+  "config.cowKind8": "Charolais",
+  "config.cowKind9": "Limousin",
+  "config.cowKind10": "Hereford",
+  "config.cowKind11": "Wagyu",
+  "config.cowKind12": "Huaxi",
+  "config.cowSource0": "All",
+  "config.cowSource1": "Calving",
+  "config.cowSource2": "Transfer In",
+  "config.cowSource3": "Buy",
+  "config.sameTimeCowType0": "All",
+  "config.sameTimeCowType1": "Empty",
+  "config.sameTimeCowType2": "Breeding Calf",
+  "config.sameTimeType0": "All",
+  "config.sameTimeType1": "PG1",
+  "config.sameTimeType2": "PG2",
+  "config.sameTimeType3": "RnGH",
+  "config.sameTimeType4": "TAI",
+  "config.cowType0": "All",
+  "config.cowType1": "Lactating Calf",
+  "config.cowType2": "Weaned Calf",
+  "config.cowType3": "Youth Calf",
+  "config.cowType4": "Fattening Calf",
+  "config.cowType5": "Reserve Calf",
+  "config.cowType6": "Breeding Calf",
+  "config.cowType7": "Bull",
+  "config.immunizationConditions0": "All",
+  "config.immunizationConditions1": "Day Age",
+  "config.immunizationConditions2": "Postpartum days",
+  "config.immunizationConditions3": "Pregnancy days",
+  "config.immunizationConditions4": "Month",
+  "config.immunizationConditions5": "Admission days",
+  "config.immunizationConditions6": "After Other Vaccines",
+  "config.transferPenReason0": "All",
+  "config.transferPenReason1": "Normal Transfer",
+  "config.transferPenReason2": "Feed Transfer",
+  "config.transferPenReason3": "Dry Milk Transfer",
+  "config.transferPenReason4": "Pregnant Transfer",
+  "config.transferPenReason5": "Overantibody Transfer",
+  "config.childNumber0": "All",
+  "config.childNumber1": "One",
+  "config.childNumber2": "Two",
+  "config.childNumber3": "Three",
+  "config.childNumber4": "Four",
+  "config.calvingLevel0": "All",
+  "config.calvingLevel1": "Natural Childbirth",
+  "config.calvingLevel2": "Artificial midwifery(1-2)",
+  "config.calvingLevel3": "Artificial midwifery(3)",
+  "config.calvingLevel4": "Cesarean",
+  "config.dystociaReason0": "All",
+  "config.dystociaReason1": "Malposition",
+  "config.dystociaReason2": "Fetal Overgrowth",
+  "config.dystociaReason3": "Uterine Atony",
+  "config.dystociaReason4": "Pelvic Stenosis",
+  "config.dystociaReason5": "SubHealth",
+  "config.pregnantCheckResult0": "All",
+  "config.pregnantCheckResult1": "Pregnant",
+  "config.pregnantCheckResult2": "UnPregnant",
+  "config.cowDeathDestination0": "All",
+  "config.cowDeathDestination1": "NuisanceLess",
+  "config.cowDeathDestination2": "Slaughterhouse",
+  "config.cowDeathDestination3": "Other",
+  "config.abortion.reasons0": "All",
+  "config.abortion.reasons1": "Mechanical Abortion",
+  "config.abortion.reasons2": "Malnutrition Abortion",
+  "config.abortion.reasons3": "Mycotoxin Abortion",
+  "config.abortion.reasons4": "Habitual abortion",
+  "config.abortion.reasons5": "Brucellosis Abortion",
+  "config.abortion.reasons6": "Inflammatory Abortion",
+  "config.abortion.reasons7": "Heat Stress Abortion",
+  "config.abortion.reasons8": "Infectious Disease Abortion",
+  "config.abortion.reasons19": "Unknown Reason",
+  "config.abortion.reasons20": "Other Reason"
 }

+ 161 - 1
locales/zh.json

@@ -96,5 +96,165 @@
   "goods.frozenSemenNotExist": "该冻精信息不存在!",
   "goods.frozenSemenNotEnough": "冻精数量不足!",
   "pasture.dealerNotExist": "未找到该经销商信息!",
-  "pasture.dealerError": "经销商数据异常!"
+  "pasture.dealerError": "经销商数据异常!",
+  "config.saleCowAnalysisMethod0":"全部",
+  "config.saleCowAnalysisMethod1":"月份",
+  "config.saleCowAnalysisMethod2":"经销商",
+  "config.barnType0": "全部",
+  "config.barnType1": "犊牛牛舍",
+  "config.barnType2": "断奶牛舍",
+  "config.barnType3": "育成牛舍",
+  "config.barnType4": "青年牛舍",
+  "config.barnType5": "泌乳牛舍",
+  "config.barnType6": "围产牛舍",
+  "config.barnType7": "干奶牛舍",
+  "config.barnType8": "病牛牛舍",
+  "config.barnType9": "淘汰牛舍",
+  "config.barnType10": "隔离牛舍",
+  "config.barnType11": "公牛牛舍",
+  "config.barnType12": "后备牛舍",
+  "config.breedStatus0": "全部",
+  "config.breedStatus1": "未配",
+  "config.breedStatus2": "已配未检",
+  "config.breedStatus3": "怀孕",
+  "config.breedStatus4": "空怀",
+  "config.breedStatus5": "产犊",
+  "config.breedStatus6": "流产",
+  "config.breedStatus7": "禁配",
+  "config.cowKind0": "全部",
+  "config.cowKind1": "荷斯坦",
+  "config.cowKind2": "娟姗牛",
+  "config.cowKind3": "三河牛",
+  "config.cowKind4": "新疆褐牛",
+  "config.cowKind5": "牦牛",
+  "config.cowKind6": "西门塔尔牛",
+  "config.cowKind7": "安格斯牛",
+  "config.cowKind8": "夏洛莱牛",
+  "config.cowKind9": "利木赞牛",
+  "config.cowKind10": "海福特牛",
+  "config.cowKind11": "和牛",
+  "config.cowKind12": "华西牛",
+  "config.cowSource0": "全部",
+  "config.cowSource1": "产犊",
+  "config.cowSource2": "调入",
+  "config.cowSource3": "购买",
+  "config.sameTimeCowType0": "全部",
+  "config.sameTimeCowType1": "空怀牛",
+  "config.sameTimeCowType2": "成母牛",
+  "config.sameTimeType0": "全部",
+  "config.sameTimeType1": "PG保健",
+  "config.sameTimeType2": "PG同期",
+  "config.sameTimeType3": "RnGH",
+  "config.sameTimeType4": "配种",
+  "config.cowType0": "全部",
+  "config.cowType1": "犊牛",
+  "config.cowType2": "育成牛",
+  "config.cowType3": "青年牛",
+  "config.cowType4": "育肥牛",
+  "config.cowType5": "后备牛",
+  "config.cowType6": "成母牛",
+  "config.cowType7": "种公牛",
+  "config.immunizationConditions0": "全部",
+  "config.immunizationConditions1": "日龄",
+  "config.immunizationConditions2": "产后天数",
+  "config.immunizationConditions3": "怀孕天数",
+  "config.immunizationConditions4": "月份",
+  "config.immunizationConditions5": "入场天数",
+  "config.immunizationConditions6": "基于其他疫苗之后",
+  "config.transferPenReason0": "全部",
+  "config.transferPenReason1": "正常转群",
+  "config.transferPenReason2": "饲喂转群",
+  "config.transferPenReason3": "干奶转群",
+  "config.transferPenReason4": "怀孕转群",
+  "config.transferPenReason5": "过抗转群",
+  "config.childNumber0": "全部",
+  "config.childNumber1": "单胎",
+  "config.childNumber2": "双胎",
+  "config.childNumber3": "三胎",
+  "config.childNumber4": "四胎",
+  "config.calvingLevel0": "全部",
+  "config.calvingLevel1": "自然分娩",
+  "config.calvingLevel2": "人工助产(1-2人)",
+  "config.calvingLevel3": "人工助产(3人以上)",
+  "config.calvingLevel4": "剖腹产",
+  "config.dystociaReason0": "全部",
+  "config.dystociaReason1": "胎位不正",
+  "config.dystociaReason2": "胎儿过大",
+  "config.dystociaReason3": "子宫收缩无力",
+  "config.dystociaReason4": "盆骨狭小",
+  "config.dystociaReason5": "母牛亚健康状态",
+  "config.pregnantCheckResult0": "全部",
+  "config.pregnantCheckResult1": "有胎",
+  "config.pregnantCheckResult2": "无胎",
+  "config.cowDeathDestination0": "全部",
+  "config.cowDeathDestination1": "无公害处理",
+  "config.cowDeathDestination2": "屠宰场",
+  "config.cowDeathDestination3": "其他",
+  "config.cowOutReason0": "全部",
+  "config.cowOutReason1": "呼吸系统疾病",
+  "config.cowOutReason2": "营养代谢疾病",
+  "config.cowOutReason3": "繁殖疾病",
+  "config.cowOutReason4": "乳房疾病",
+  "config.cowOutReason5": "久配不孕",
+  "config.cowOutReason6": "多次流产",
+  "config.cowOutReason7": "久治不愈",
+  "config.cowOutReason8": "产后瘫痪",
+  "config.cowOutReason9": "乳房炎",
+  "config.cowOutReason10": "蹄病",
+  "config.cowOutReason11": "先天畸形",
+  "config.cowOutReason12": "发育不良",
+  "config.cowOutReason13": "疝气",
+  "config.cowOutReason14": "月龄过大",
+  "config.cowOutReason15": "体重过肥",
+  "config.cowOutReason16": "其他疾病",
+  "config.cowOutReason17": "弱仔",
+  "config.cowOutReason18": "恶癖牛",
+  "config.cowOutReason19": "低产",
+  "config.cowOutReason20": "生长缓慢",
+  "config.cowOutReason99": "其他",
+  "config.cowOutReason100": "未知原因",
+  "config.cowPurpose0": "全部",
+  "config.cowPurpose1": "繁殖",
+  "config.cowPurpose2": "育肥",
+  "config.indicatorsCategory0": "全部",
+  "config.indicatorsCategory1": "基本指标",
+  "config.indicatorsCategory2": "繁殖指标",
+  "config.indicatorsCategory3": "健康指标",
+  "config.indicatorsCategory4": "饲喂指标",
+  "config.indicatorsCategory5": "犊牛指标",
+  "config.indicatorsCategory6": "育肥指标",
+  "config.matingResult0": "全部",
+  "config.matingResult1": "未知",
+  "config.matingResult2": "复配",
+  "config.matingResult3": "怀孕",
+  "config.matingResult4": "空怀",
+  "config.matingResult5": "流产",
+  "config.deathReason0": "全部",
+  "config.deathReason1": "消化性疾病",
+  "config.deathReason2": "呼吸性疾病",
+  "config.deathReason3": "繁殖性疾病",
+  "config.deathReason4": "繁殖性疾病",
+  "config.deathReason5": "繁殖性疾病",
+  "config.deathReason6": "难产",
+  "config.deathReason7": "意外死亡",
+  "config.deathReason8": "热应激",
+  "config.deathReason9": "外伤",
+  "config.deathReason10": "肺炎",
+  "config.deathReason11": "腹泻",
+  "config.deathReason13": "酮病",
+  "config.deathReason14": "酸中毒",
+  "config.deathReason15": "瘤胃积食",
+  "config.deathReason16": "肠扭转",
+  "config.deathReason99": "其他",
+  "config.abortion.reasons0": "全部",
+  "config.abortion.reasons1": "机械性流产",
+  "config.abortion.reasons2": "营养不良流产",
+  "config.abortion.reasons3": "霉菌毒素流产",
+  "config.abortion.reasons4": "习惯性流产",
+  "config.abortion.reasons5": "布病流产",
+  "config.abortion.reasons6": "产道炎症性流产",
+  "config.abortion.reasons7": "热应激流产",
+  "config.abortion.reasons8": "传染病性流产",
+  "config.abortion.reasons19": "未知原因",
+  "config.abortion.reasons20": "其他原因"
 }

+ 16 - 15
model/config_abortion_reasons.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigAbortionReasons struct {
-	Id        int32                          `json:"id"`
-	PastureId int64                          `json:"pastureId"`
-	Kind      pasturePb.AbortionReasons_Kind `json:"kind"`
-	Zh        string                         `json:"zh"`
-	En        string                         `json:"en"`
-	Remarks   string                         `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind          `json:"is_show"`
-	CreatedAt int64                          `json:"created_at"`
-	UpdatedAt int64                          `json:"updated_at"`
+	Id           int32                          `json:"id"`
+	PastureId    int64                          `json:"pastureId"`
+	Kind         pasturePb.AbortionReasons_Kind `json:"kind"`
+	I18nFieldTag string                         `json:"i18nFieldTag"`
+	Remarks      string                         `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind          `json:"isShow"`
+	CreatedAt    int64                          `json:"createdAt"`
+	UpdatedAt    int64                          `json:"updatedAt"`
 }
 
 func (c *ConfigAbortionReasons) TableName() string {
@@ -20,13 +22,12 @@ func (c *ConfigAbortionReasons) TableName() string {
 
 type ConfigAbortionReasonsSlice []*ConfigAbortionReasons
 
-func (c ConfigAbortionReasonsSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigAbortionReasonsSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 29 - 8
model/config_barn_type.go

@@ -2,15 +2,18 @@ package model
 
 import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
 )
 
 type ConfigPenType struct {
-	Id        int64                 `json:"id"`
-	Name      string                `json:"name"`
-	Remarks   string                `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind `json:"is_show"`
-	CreatedAt int64                 `json:"created_at"`
-	UpdatedAt int64                 `json:"updated_at"`
+	Id           int64                  `json:"id"`
+	PastureId    int64                  `json:"pastureId"`
+	Kind         pasturePb.PenType_Kind `json:"kind"`
+	I18nFieldTag string                 `json:"i18nFieldTag"`
+	Remarks      string                 `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind  `json:"isShow"`
+	CreatedAt    int64                  `json:"createdAt"`
+	UpdatedAt    int64                  `json:"updatedAt"`
 }
 
 func (c *ConfigPenType) TableName() string {
@@ -19,12 +22,15 @@ func (c *ConfigPenType) TableName() string {
 
 type ConfigBarnTypeSlice []*ConfigPenType
 
-func (c ConfigBarnTypeSlice) ToPB() []*pasturePb.SearchBaseConfigList {
+func (c ConfigBarnTypeSlice) ToPB(userModel *UserModel) []*pasturePb.SearchBaseConfigList {
 	res := make([]*pasturePb.SearchBaseConfigList, len(c))
 	for i, d := range c {
+		name, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: d.I18nFieldTag,
+		})
 		res[i] = &pasturePb.SearchBaseConfigList{
 			Id:        int32(d.Id),
-			Name:      d.Name,
+			Name:      name,
 			Remarks:   d.Remarks,
 			IsShow:    d.IsShow,
 			CreatedAt: int32(d.CreatedAt),
@@ -33,3 +39,18 @@ func (c ConfigBarnTypeSlice) ToPB() []*pasturePb.SearchBaseConfigList {
 	}
 	return res
 }
+
+func (c ConfigBarnTypeSlice) ToPB2(userModel *UserModel) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 28 - 15
model/config_breed_status.go

@@ -2,19 +2,18 @@ package model
 
 import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
-	"golang.org/x/text/language"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
 )
 
 type ConfigBreedStatus struct {
-	Id        int64                      `json:"id"`
-	PastureId int64                      `json:"pastureId"`
-	Kind      pasturePb.BreedStatus_Kind `json:"kind"`
-	Zh        string                     `json:"zh"`
-	En        string                     `json:"en"`
-	Remarks   string                     `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind      `json:"isShow"`
-	CreatedAt int64                      `json:"createdAt"`
-	UpdatedAt int64                      `json:"updatedAt"`
+	Id           int64                      `json:"id"`
+	PastureId    int64                      `json:"pastureId"`
+	Kind         pasturePb.BreedStatus_Kind `json:"kind"`
+	I18nFieldTag string                     `json:"i18nFieldTag"`
+	Remarks      string                     `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind      `json:"isShow"`
+	CreatedAt    int64                      `json:"createdAt"`
+	UpdatedAt    int64                      `json:"updatedAt"`
 }
 
 func (c *ConfigBreedStatus) TableName() string {
@@ -23,13 +22,12 @@ func (c *ConfigBreedStatus) TableName() string {
 
 type ConfigBreedStatusSlice []*ConfigBreedStatus
 
-func (c ConfigBreedStatusSlice) ToPB(lang string) []*pasturePb.SearchBaseConfigList {
+func (c ConfigBreedStatusSlice) ToPB(userModel *UserModel) []*pasturePb.SearchBaseConfigList {
 	res := make([]*pasturePb.SearchBaseConfigList, len(c))
 	for i, d := range c {
-		name := d.Zh
-		if lang == language.Chinese.String() {
-			name = d.En
-		}
+		name, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: d.I18nFieldTag,
+		})
 		res[i] = &pasturePb.SearchBaseConfigList{
 			Id:        int32(d.Id),
 			Name:      name,
@@ -41,3 +39,18 @@ func (c ConfigBreedStatusSlice) ToPB(lang string) []*pasturePb.SearchBaseConfigL
 	}
 	return res
 }
+
+func (c ConfigBreedStatusSlice) ToPB2(userModel *UserModel) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 16 - 15
model/config_calving_level.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigCalvingLevel struct {
-	Id        int32                       `json:"id"`
-	PastureId int64                       `json:"pastureId"`
-	Kind      pasturePb.CalvingLevel_Kind `json:"kind"`
-	Zh        string                      `json:"zh"`
-	En        string                      `json:"en"`
-	Remarks   string                      `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind       `json:"is_show"`
-	CreatedAt int64                       `json:"created_at"`
-	UpdatedAt int64                       `json:"updated_at"`
+	Id           int32                       `json:"id"`
+	PastureId    int64                       `json:"pastureId"`
+	Kind         pasturePb.CalvingLevel_Kind `json:"kind"`
+	I18nFieldTag string                      `json:"i18nFieldTag"`
+	Remarks      string                      `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind       `json:"isShow"`
+	CreatedAt    int64                       `json:"createdAt"`
+	UpdatedAt    int64                       `json:"updatedAt"`
 }
 
 func (c *ConfigCalvingLevel) TableName() string {
@@ -20,13 +22,12 @@ func (c *ConfigCalvingLevel) TableName() string {
 
 type ConfigCalvingLevelSlice []*ConfigCalvingLevel
 
-func (c ConfigCalvingLevelSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigCalvingLevelSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 17 - 16
model/config_child_number.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigChildNumber struct {
-	Id        int32                      `json:"id"`
-	PastureId int64                      `json:"pastureId"`
-	Kind      pasturePb.ChildNumber_Kind `json:"kind"`
-	Zh        string                     `json:"zh"`
-	En        string                     `json:"en"`
-	Remarks   string                     `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind      `json:"is_show"`
-	CreatedAt int64                      `json:"created_at"`
-	UpdatedAt int64                      `json:"updated_at"`
+	Id           int32                      `json:"id"`
+	PastureId    int64                      `json:"pastureId"`
+	Kind         pasturePb.ChildNumber_Kind `json:"kind"`
+	I18nFieldTag string                     `json:"i18nFieldTag"`
+	Remarks      string                     `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind      `json:"isShow"`
+	CreatedAt    int64                      `json:"createdAt"`
+	UpdatedAt    int64                      `json:"updatedAt"`
 }
 
 func (c *ConfigChildNumber) TableName() string {
@@ -20,16 +22,15 @@ func (c *ConfigChildNumber) TableName() string {
 
 type ConfigChildNumberSlice []*ConfigChildNumber
 
-func (c ConfigChildNumberSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigChildNumberSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		name, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
-			Label:    label,
+			Label:    name,
 			Disabled: true,
 		})
 	}

+ 13 - 14
model/config_cow_death_destination.go

@@ -2,18 +2,18 @@ package model
 
 import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
 )
 
 type ConfigCowDeathDestination struct {
-	Id        int64                           `json:"id"`
-	PastureId int64                           `json:"pastureId"`
-	Kind      pasturePb.DeathDestination_Kind `json:"kind"`
-	Zh        string                          `json:"zh"`
-	En        string                          `json:"en"`
-	Remarks   string                          `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind           `json:"isShow"`
-	CreatedAt int64                           `json:"createdAt"`
-	UpdatedAt int64                           `json:"updatedAt"`
+	Id           int64                           `json:"id"`
+	PastureId    int64                           `json:"pastureId"`
+	Kind         pasturePb.DeathDestination_Kind `json:"kind"`
+	I18nFieldTag string                          `json:"i18nFieldTag"`
+	Remarks      string                          `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind           `json:"isShow"`
+	CreatedAt    int64                           `json:"createdAt"`
+	UpdatedAt    int64                           `json:"updatedAt"`
 }
 
 func (c *ConfigCowDeathDestination) TableName() string {
@@ -22,13 +22,12 @@ func (c *ConfigCowDeathDestination) TableName() string {
 
 type ConfigCowDeathDestinationSlice []*ConfigCowDeathDestination
 
-func (c ConfigCowDeathDestinationSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigCowDeathDestinationSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 18 - 21
model/config_cow_kind.go

@@ -2,19 +2,18 @@ package model
 
 import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
-	"golang.org/x/text/language"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
 )
 
 type ConfigCowKind struct {
-	Id        int64                  `json:"id"`
-	PastureId int64                  `json:"pastureId"`
-	Kind      pasturePb.CowKind_Kind `json:"kind"`
-	Zh        string                 `json:"zh"`
-	En        string                 `json:"en"`
-	Remarks   string                 `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind  `json:"isShow"`
-	CreatedAt int64                  `json:"createdAt"`
-	UpdatedAt int64                  `json:"updatedAt"`
+	Id           int64                  `json:"id"`
+	PastureId    int64                  `json:"pastureId"`
+	Kind         pasturePb.CowKind_Kind `json:"kind"`
+	I18nFieldTag string                 `json:"i18nFieldTag"`
+	Remarks      string                 `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind  `json:"isShow"`
+	CreatedAt    int64                  `json:"createdAt"`
+	UpdatedAt    int64                  `json:"updatedAt"`
 }
 
 func (c *ConfigCowKind) TableName() string {
@@ -23,16 +22,15 @@ func (c *ConfigCowKind) TableName() string {
 
 type ConfigCowKindSlice []*ConfigCowKind
 
-func (c ConfigCowKindSlice) ToPB(lang string) []*pasturePb.SearchBaseConfigList {
+func (c ConfigCowKindSlice) ToPB(userModel *UserModel) []*pasturePb.SearchBaseConfigList {
 	res := make([]*pasturePb.SearchBaseConfigList, len(c))
 	for i, d := range c {
-		name := d.Zh
-		if lang == language.English.String() {
-			name = d.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: d.I18nFieldTag,
+		})
 		res[i] = &pasturePb.SearchBaseConfigList{
 			Id:        int32(d.Id),
-			Name:      name,
+			Name:      label,
 			Remarks:   d.Remarks,
 			IsShow:    d.IsShow,
 			CreatedAt: int32(d.CreatedAt),
@@ -42,13 +40,12 @@ func (c ConfigCowKindSlice) ToPB(lang string) []*pasturePb.SearchBaseConfigList
 	return res
 }
 
-func (c ConfigCowKindSlice) ToPB2(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigCowKindSlice) ToPB2(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 38 - 0
model/config_cow_out_reason.go

@@ -0,0 +1,38 @@
+package model
+
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
+
+type ConfigCowOutReason struct {
+	Id           int64                     `json:"id"`
+	PastureId    int64                     `json:"pastureId"`
+	Kind         pasturePb.OutReasons_Kind `json:"kind"`
+	I18nFieldTag string                    `json:"i18nFieldTag"`
+	Remarks      string                    `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind     `json:"isShow"`
+	CreatedAt    int64                     `json:"createdAt"`
+	UpdatedAt    int64                     `json:"updatedAt"`
+}
+
+func (c *ConfigCowOutReason) TableName() string {
+	return "config_cow_out_reason"
+}
+
+type ConfigCowOutReasonSlice []*ConfigCowOutReason
+
+func (c ConfigCowOutReasonSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 38 - 0
model/config_cow_purpose.go

@@ -0,0 +1,38 @@
+package model
+
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
+
+type ConfigCowPurpose struct {
+	Id           int64                  `json:"id"`
+	PastureId    int64                  `json:"pastureId"`
+	Kind         pasturePb.Purpose_Kind `json:"kind"`
+	I18nFieldTag string                 `json:"i18nFieldTag"`
+	Remarks      string                 `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind  `json:"isShow"`
+	CreatedAt    int64                  `json:"createdAt"`
+	UpdatedAt    int64                  `json:"updatedAt"`
+}
+
+func (c *ConfigCowPurpose) TableName() string {
+	return "config_cow_purpose"
+}
+
+type ConfigCowPurposeSlice []*ConfigCowPurpose
+
+func (c ConfigCowPurposeSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 18 - 21
model/config_cow_source.go

@@ -2,19 +2,18 @@ package model
 
 import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
-	"golang.org/x/text/language"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
 )
 
 type ConfigCowSource struct {
-	Id        int64                    `json:"id"`
-	PastureId int64                    `json:"pastureId"`
-	Kind      pasturePb.CowSource_Kind `json:"kind"`
-	Zh        string                   `json:"zh"`
-	En        string                   `json:"en"`
-	Remarks   string                   `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind    `json:"isShow"`
-	CreatedAt int64                    `json:"createdAt"`
-	UpdatedAt int64                    `json:"updatedAt"`
+	Id           int64                    `json:"id"`
+	PastureId    int64                    `json:"pastureId"`
+	Kind         pasturePb.CowSource_Kind `json:"kind"`
+	I18nFieldTag string                   `json:"i18nFieldTag"`
+	Remarks      string                   `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind    `json:"isShow"`
+	CreatedAt    int64                    `json:"createdAt"`
+	UpdatedAt    int64                    `json:"updatedAt"`
 }
 
 func (c *ConfigCowSource) TableName() string {
@@ -23,16 +22,15 @@ func (c *ConfigCowSource) TableName() string {
 
 type ConfigCowSourceSlice []*ConfigCowSource
 
-func (c ConfigCowSourceSlice) ToPB(lang string) []*pasturePb.SearchBaseConfigList {
+func (c ConfigCowSourceSlice) ToPB(userModel *UserModel) []*pasturePb.SearchBaseConfigList {
 	res := make([]*pasturePb.SearchBaseConfigList, len(c))
 	for i, d := range c {
-		name := d.Zh
-		if lang == language.English.String() {
-			name = d.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: d.I18nFieldTag,
+		})
 		res[i] = &pasturePb.SearchBaseConfigList{
 			Id:        int32(d.Id),
-			Name:      name,
+			Name:      label,
 			Remarks:   d.Remarks,
 			IsShow:    d.IsShow,
 			CreatedAt: int32(d.CreatedAt),
@@ -42,13 +40,12 @@ func (c ConfigCowSourceSlice) ToPB(lang string) []*pasturePb.SearchBaseConfigLis
 	return res
 }
 
-func (c ConfigCowSourceSlice) ToPB2(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigCowSourceSlice) ToPB2(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 34 - 8
model/config_cow_type.go

@@ -2,15 +2,17 @@ package model
 
 import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
 )
 
 type ConfigCowType struct {
-	Id        int64                 `json:"id"`
-	Name      string                `json:"name"`
-	Remarks   string                `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind `json:"is_show"`
-	CreatedAt int64                 `json:"created_at"`
-	UpdatedAt int64                 `json:"updated_at"`
+	Id           int64                  `json:"id"`
+	Kind         pasturePb.CowType_Kind `json:"kind"`
+	I18nFieldTag string                 `json:"i18nFieldTag"`
+	Remarks      string                 `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind  `json:"isShow"`
+	CreatedAt    int64                  `json:"createdAt"`
+	UpdatedAt    int64                  `json:"updatedAt"`
 }
 
 func (c *ConfigCowType) TableName() string {
@@ -19,12 +21,15 @@ func (c *ConfigCowType) TableName() string {
 
 type ConfigCowTypeSlice []*ConfigCowType
 
-func (c ConfigCowTypeSlice) ToPB() []*pasturePb.SearchBaseConfigList {
+func (c ConfigCowTypeSlice) ToPB(userModel *UserModel) []*pasturePb.SearchBaseConfigList {
 	res := make([]*pasturePb.SearchBaseConfigList, len(c))
 	for i, d := range c {
+		name, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: d.I18nFieldTag,
+		})
 		res[i] = &pasturePb.SearchBaseConfigList{
 			Id:        int32(d.Id),
-			Name:      d.Name,
+			Name:      name,
 			Remarks:   d.Remarks,
 			IsShow:    d.IsShow,
 			CreatedAt: int32(d.CreatedAt),
@@ -33,3 +38,24 @@ func (c ConfigCowTypeSlice) ToPB() []*pasturePb.SearchBaseConfigList {
 	}
 	return res
 }
+
+func (c ConfigCowTypeSlice) ToPB2(userModel *UserModel, optionName string) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+
+		if optionName == "breed" {
+			if v.Kind == pasturePb.CowType_Breeding_Calf || v.Kind == pasturePb.CowType_Reserve_Calf {
+				continue
+			}
+		}
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 38 - 0
model/config_death_reason.go

@@ -0,0 +1,38 @@
+package model
+
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
+
+type ConfigDeathReason struct {
+	Id           int64                      `json:"id"`
+	PastureId    int64                      `json:"pastureId"`
+	Kind         pasturePb.DeathReason_Kind `json:"kind"`
+	I18nFieldTag string                     `json:"i18nFieldTag"`
+	Remarks      string                     `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind      `json:"isShow"`
+	CreatedAt    int64                      `json:"createdAt"`
+	UpdatedAt    int64                      `json:"updatedAt"`
+}
+
+func (c *ConfigDeathReason) TableName() string {
+	return "config_death_reason"
+}
+
+type ConfigDeathReasonSlice []*ConfigDeathReason
+
+func (c ConfigDeathReasonSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 16 - 15
model/config_dystocia_reason.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigDystociaReason struct {
-	Id        int32                         `json:"id"`
-	PastureId int64                         `json:"pastureId"`
-	Kind      pasturePb.DystociaReason_Kind `json:"kind"`
-	Zh        string                        `json:"zh"`
-	En        string                        `json:"en"`
-	Remarks   string                        `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind         `json:"is_show"`
-	CreatedAt int64                         `json:"created_at"`
-	UpdatedAt int64                         `json:"updated_at"`
+	Id           int32                         `json:"id"`
+	PastureId    int64                         `json:"pastureId"`
+	Kind         pasturePb.DystociaReason_Kind `json:"kind"`
+	I18nFieldTag string                        `json:"i18nFieldTag"`
+	Remarks      string                        `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind         `json:"isShow"`
+	CreatedAt    int64                         `json:"createdAt"`
+	UpdatedAt    int64                         `json:"updatedAt"`
 }
 
 func (c *ConfigDystociaReason) TableName() string {
@@ -20,13 +22,12 @@ func (c *ConfigDystociaReason) TableName() string {
 
 type ConfigDystociaReasonSlice []*ConfigDystociaReason
 
-func (c ConfigDystociaReasonSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigDystociaReasonSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 38 - 0
model/config_event_category.go

@@ -0,0 +1,38 @@
+package model
+
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
+
+type ConfigEventCategory struct {
+	Id           int32                        `json:"id"`
+	PastureId    int64                        `json:"pastureId"`
+	Kind         pasturePb.EventCategory_Kind `json:"kind"`
+	I18nFieldTag string                       `json:"i18nFieldTag"`
+	Remarks      string                       `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind        `json:"isShow"`
+	CreatedAt    int64                        `json:"createdAt"`
+	UpdatedAt    int64                        `json:"updatedAt"`
+}
+
+func (c *ConfigEventCategory) TableName() string {
+	return "config_event_category"
+}
+
+type ConfigEventCategorySlice []*ConfigEventCategory
+
+func (c ConfigEventCategorySlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 16 - 15
model/config_immunization_conditions.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigImmunizationConditions struct {
-	Id        int32                                 `json:"id"`
-	PastureId int64                                 `json:"pastureId"`
-	Kind      pasturePb.ImmunizationConditions_Kind `json:"kind"`
-	Zh        string                                `json:"zh"`
-	En        string                                `json:"en"`
-	Remarks   string                                `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind                 `json:"is_show"`
-	CreatedAt int64                                 `json:"created_at"`
-	UpdatedAt int64                                 `json:"updated_at"`
+	Id           int32                                 `json:"id"`
+	PastureId    int64                                 `json:"pastureId"`
+	Kind         pasturePb.ImmunizationConditions_Kind `json:"kind"`
+	I18nFieldTag string                                `json:"i18nFieldTag"`
+	Remarks      string                                `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind                 `json:"isShow"`
+	CreatedAt    int64                                 `json:"createdAt"`
+	UpdatedAt    int64                                 `json:"updatedAt"`
 }
 
 func (c *ConfigImmunizationConditions) TableName() string {
@@ -20,13 +22,12 @@ func (c *ConfigImmunizationConditions) TableName() string {
 
 type ConfigImmunizationConditionsSlice []*ConfigImmunizationConditions
 
-func (c ConfigImmunizationConditionsSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigImmunizationConditionsSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 0 - 37
model/config_immunization_cow_type.go

@@ -1,37 +0,0 @@
-package model
-
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
-
-type ConfigImmunizationCowType struct {
-	Id        int32                  `json:"id"`
-	PastureId int64                  `json:"pastureId"`
-	Kind      pasturePb.CowType_Kind `json:"kind"`
-	Zh        string                 `json:"zh"`
-	En        string                 `json:"en"`
-	Remarks   string                 `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind  `json:"is_show"`
-	CreatedAt int64                  `json:"created_at"`
-	UpdatedAt int64                  `json:"updated_at"`
-}
-
-func (c *ConfigImmunizationCowType) TableName() string {
-	return "config_immunization_cow_type"
-}
-
-type ConfigImmunizationCowTypeSlice []*ConfigImmunizationCowType
-
-func (c ConfigImmunizationCowTypeSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
-	res := make([]*pasturePb.ConfigOptionsList, 0)
-	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
-		res = append(res, &pasturePb.ConfigOptionsList{
-			Value:    int32(v.Kind),
-			Label:    label,
-			Disabled: true,
-		})
-	}
-	return res
-}

+ 38 - 0
model/config_indicators_category.go

@@ -0,0 +1,38 @@
+package model
+
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
+
+type ConfigIndicatorsCategory struct {
+	Id           int64                        `json:"id"`
+	PastureId    int64                        `json:"pastureId"`
+	Kind         pasturePb.IndicatorType_Kind `json:"kind"`
+	I18nFieldTag string                       `json:"i18nFieldTag"`
+	Remarks      string                       `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind        `json:"isShow"`
+	CreatedAt    int64                        `json:"createdAt"`
+	UpdatedAt    int64                        `json:"updatedAt"`
+}
+
+func (c *ConfigIndicatorsCategory) TableName() string {
+	return "config_indicators_category"
+}
+
+type ConfigIndicatorsCategorySlice []*ConfigIndicatorsCategory
+
+func (c ConfigIndicatorsCategorySlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 38 - 0
model/config_mating_result.go

@@ -0,0 +1,38 @@
+package model
+
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
+
+type ConfigMatingResult struct {
+	Id           int64                       `json:"id"`
+	PastureId    int64                       `json:"pastureId"`
+	Kind         pasturePb.MatingResult_Kind `json:"kind"`
+	I18nFieldTag string                      `json:"i18nFieldTag"`
+	Remarks      string                      `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind       `json:"isShow"`
+	CreatedAt    int64                       `json:"createdAt"`
+	UpdatedAt    int64                       `json:"updatedAt"`
+}
+
+func (c *ConfigMatingResult) TableName() string {
+	return "config_mating_result"
+}
+
+type ConfigMatingResultSlice []*ConfigMatingResult
+
+func (c ConfigMatingResultSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, 0)
+	for _, v := range c {
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
+		res = append(res, &pasturePb.ConfigOptionsList{
+			Value:    int32(v.Kind),
+			Label:    label,
+			Disabled: true,
+		})
+	}
+	return res
+}

+ 16 - 15
model/config_pregnant_check_result.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigPregnantCheckResult struct {
-	Id        int32                              `json:"id"`
-	PastureId int64                              `json:"pastureId"`
-	Kind      pasturePb.PregnantCheckResult_Kind `json:"kind"`
-	Zh        string                             `json:"zh"`
-	En        string                             `json:"en"`
-	Remarks   string                             `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind              `json:"is_show"`
-	CreatedAt int64                              `json:"created_at"`
-	UpdatedAt int64                              `json:"updated_at"`
+	Id           int32                              `json:"id"`
+	PastureId    int64                              `json:"pastureId"`
+	Kind         pasturePb.PregnantCheckResult_Kind `json:"kind"`
+	I18nFieldTag string                             `json:"i18nFieldTag"`
+	Remarks      string                             `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind              `json:"is_show"`
+	CreatedAt    int64                              `json:"created_at"`
+	UpdatedAt    int64                              `json:"updated_at"`
 }
 
 func (c *ConfigPregnantCheckResult) TableName() string {
@@ -20,13 +22,12 @@ func (c *ConfigPregnantCheckResult) TableName() string {
 
 type ConfigPregnantCheckResultSlice []*ConfigPregnantCheckResult
 
-func (c ConfigPregnantCheckResultSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigPregnantCheckResultSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 16 - 15
model/config_sale_cow_analysis_method.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigSaleCowAnalysisMethod struct {
-	Id        int32                                `json:"id"`
-	PastureId int64                                `json:"pastureId"`
-	Kind      pasturePb.SaleCowAnalysisMethod_Kind `json:"kind"`
-	Zh        string                               `json:"zh"`
-	En        string                               `json:"en"`
-	Remarks   string                               `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind                `json:"is_show"`
-	CreatedAt int64                                `json:"created_at"`
-	UpdatedAt int64                                `json:"updated_at"`
+	Id           int32                                `json:"id"`
+	PastureId    int64                                `json:"pastureId"`
+	Kind         pasturePb.SaleCowAnalysisMethod_Kind `json:"kind"`
+	I18nFieldTag string                               `json:"i18nFieldTag"`
+	Remarks      string                               `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind                `json:"isShow"`
+	CreatedAt    int64                                `json:"createdAt"`
+	UpdatedAt    int64                                `json:"updatedAt"`
 }
 
 func (c *ConfigSaleCowAnalysisMethod) TableName() string {
@@ -20,13 +22,12 @@ func (c *ConfigSaleCowAnalysisMethod) TableName() string {
 
 type ConfigSaleCowAnalysisMethodSlice []*ConfigSaleCowAnalysisMethod
 
-func (c ConfigSaleCowAnalysisMethodSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigSaleCowAnalysisMethodSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 17 - 16
model/config_same_time_cow_type.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigSameTimeCowType struct {
-	Id        int32                          `json:"id"`
-	PastureId int64                          `json:"pastureId"`
-	Kind      pasturePb.SameTimeCowType_Kind `json:"kind"`
-	Zh        string                         `json:"zh"`
-	En        string                         `json:"en"`
-	Remarks   string                         `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind          `json:"is_show"`
-	CreatedAt int64                          `json:"created_at"`
-	UpdatedAt int64                          `json:"updated_at"`
+	Id           int32                          `json:"id"`
+	PastureId    int64                          `json:"pastureId"`
+	Kind         pasturePb.SameTimeCowType_Kind `json:"kind"`
+	I18nFieldTag string                         `json:"i18nFieldTag"`
+	Remarks      string                         `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind          `json:"isShow"`
+	CreatedAt    int64                          `json:"createdAt"`
+	UpdatedAt    int64                          `json:"updatedAt"`
 }
 
 func (c *ConfigSameTimeCowType) TableName() string {
@@ -20,16 +22,15 @@ func (c *ConfigSameTimeCowType) TableName() string {
 
 type ConfigSameTimeCowTypeSlice []*ConfigSameTimeCowType
 
-func (c ConfigSameTimeCowTypeSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigSameTimeCowTypeSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		name, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
-			Label:    label,
+			Label:    name,
 			Disabled: true,
 		})
 	}

+ 17 - 16
model/config_same_time_type.go

@@ -1,17 +1,19 @@
 package model
 
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+import (
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
+)
 
 type ConfigSameTimeType struct {
-	Id        int32                       `json:"id"`
-	PastureId int64                       `json:"pastureId"`
-	Kind      pasturePb.SameTimeType_Kind `json:"kind"`
-	Zh        string                      `json:"zh"`
-	En        string                      `json:"en"`
-	Remarks   string                      `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind       `json:"is_show"`
-	CreatedAt int64                       `json:"created_at"`
-	UpdatedAt int64                       `json:"updated_at"`
+	Id           int32                       `json:"id"`
+	PastureId    int64                       `json:"pastureId"`
+	Kind         pasturePb.SameTimeType_Kind `json:"kind"`
+	I18nFieldTag string                      `json:"i18nFieldTag"`
+	Remarks      string                      `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind       `json:"isShow"`
+	CreatedAt    int64                       `json:"createdAt"`
+	UpdatedAt    int64                       `json:"updatedAt"`
 }
 
 func (c *ConfigSameTimeType) TableName() string {
@@ -20,16 +22,15 @@ func (c *ConfigSameTimeType) TableName() string {
 
 type ConfigSameTimeTypeSlice []*ConfigSameTimeType
 
-func (c ConfigSameTimeTypeSlice) ToPB(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigSameTimeTypeSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		name, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
-			Label:    label,
+			Label:    name,
 			Disabled: true,
 		})
 	}

+ 17 - 20
model/config_transfer_pen_reason.go

@@ -2,19 +2,18 @@ package model
 
 import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
-	"golang.org/x/text/language"
+	"github.com/nicksnyder/go-i18n/v2/i18n"
 )
 
 type ConfigTransferPenReason struct {
-	Id        int64                            `json:"id"`
-	PastureId int64                            `json:"pastureId"`
-	Kind      pasturePb.TransferPenReason_Kind `json:"kind"`
-	Zh        string                           `json:"zh"`
-	En        string                           `json:"en"`
-	Remarks   string                           `json:"remarks"`
-	IsShow    pasturePb.IsShow_Kind            `json:"isShow"`
-	CreatedAt int64                            `json:"createdAt"`
-	UpdatedAt int64                            `json:"updatedAt"`
+	Id           int64                            `json:"id"`
+	PastureId    int64                            `json:"pastureId"`
+	Kind         pasturePb.TransferPenReason_Kind `json:"kind"`
+	I18nFieldTag string                           `json:"i18nFieldTag"`
+	Remarks      string                           `json:"remarks"`
+	IsShow       pasturePb.IsShow_Kind            `json:"isShow"`
+	CreatedAt    int64                            `json:"createdAt"`
+	UpdatedAt    int64                            `json:"updatedAt"`
 }
 
 func (c *ConfigTransferPenReason) TableName() string {
@@ -23,13 +22,12 @@ func (c *ConfigTransferPenReason) TableName() string {
 
 type ConfigTransferPenReasonSlice []*ConfigTransferPenReason
 
-func (c ConfigTransferPenReasonSlice) ToPB(lang string) []*pasturePb.SearchBaseConfigList {
+func (c ConfigTransferPenReasonSlice) ToPB(userModel *UserModel) []*pasturePb.SearchBaseConfigList {
 	res := make([]*pasturePb.SearchBaseConfigList, len(c))
 	for i, d := range c {
-		name := d.Zh
-		if lang == language.English.String() {
-			name = d.En
-		}
+		name, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: d.I18nFieldTag,
+		})
 		res[i] = &pasturePb.SearchBaseConfigList{
 			Id:        int32(d.Id),
 			Name:      name,
@@ -42,13 +40,12 @@ func (c ConfigTransferPenReasonSlice) ToPB(lang string) []*pasturePb.SearchBaseC
 	return res
 }
 
-func (c ConfigTransferPenReasonSlice) ToPB2(lang string) []*pasturePb.ConfigOptionsList {
+func (c ConfigTransferPenReasonSlice) ToPB2(userModel *UserModel) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, 0)
 	for _, v := range c {
-		label := v.Zh
-		if lang == "en" {
-			label = v.En
-		}
+		label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
+			MessageID: v.I18nFieldTag,
+		})
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,

+ 1 - 1
module/backend/analysis_cow.go

@@ -208,7 +208,7 @@ func (s *StoreEntry) TwentyOnePregnantDetail(ctx context.Context, req *pasturePb
 		return nil, xerr.WithStack(err)
 	}
 
-	cowTypeMap := s.CowTypeMap()
+	cowTypeMap := s.CowTypeMap(userModel)
 	switch req.Type {
 	case pasturePb.TwentyOnePregnantType_ShouldBreed:
 		shouldBreedCowList, _ := s.TwentyOnePregnantShouldBreedList(pastureId, req.CowType, stopBreedingDay, middleDay)

+ 1 - 1
module/backend/analysis_more.go

@@ -72,7 +72,7 @@ func (s *StoreEntry) PenBehaviorDaily(ctx context.Context, req *pasturePb.BarnMo
 			headers = append(headers, v.Name)
 		}
 	} else {
-		behaviorEnumList := s.Behavior("")
+		behaviorEnumList := s.Behavior(userModel, "")
 		for _, v := range behaviorEnumList {
 			headers = append(headers, v.Label)
 		}

+ 4 - 4
module/backend/analysis_other.go

@@ -48,8 +48,8 @@ func (s *StoreEntry) PregnancyReport(ctx context.Context, req *pasturePb.Pregnan
 		return nil, xerr.WithStack(err)
 	}
 
-	pregnantCheckResultMap := s.PregnantCheckResultMap()
-	pregnantCheckMethodMap := s.PregnantCheckMethodMap()
+	pregnantCheckResultMap := s.PregnantCheckResultMap(userModel)
+	pregnantCheckMethodMap := s.PregnantCheckMethodMap(userModel)
 	return &pasturePb.PregnancyReportResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -148,7 +148,7 @@ func (s *StoreEntry) CalvingReport(ctx context.Context, req *pasturePb.CalvingRe
 		}
 	}
 
-	cowKindMap := s.CowKindMap()
+	cowKindMap := s.CowKindMap(userModel)
 	for _, v := range eventCalving1 {
 		if req.AnalysisMethod == pasturePb.CalvingAnalysisMethod_CowKind {
 			v.StatisticMethod = cowKindMap[v.CowKind]
@@ -254,7 +254,7 @@ func (s *StoreEntry) DiseaseCureReport(ctx context.Context, req *pasturePb.Disea
 		case pasturePb.DiseaseAnalysisMethod_Months:
 			v.StatisticMethod = v.Months
 		case pasturePb.DiseaseAnalysisMethod_Disease_Category:
-			diseaseTypeMap := s.DiseaseTypeMap()
+			diseaseTypeMap := s.DiseaseTypeMap(userModel)
 			v.StatisticMethod = diseaseTypeMap[v.DiseaseType]
 		case pasturePb.DiseaseAnalysisMethod_Disease:
 			v.StatisticMethod = v.DiseaseName

+ 3 - 3
module/backend/calendar.go

@@ -168,7 +168,7 @@ func (s *StoreEntry) CalendarToDoList(ctx context.Context, req *pasturePb.Calend
 		dMap[v.CalendarTypeKind] = v.Count
 	}
 
-	list, total := Paginate(calendarToDoList, req, pagination)
+	list, total := s.Paginate(userModel, calendarToDoList, req, pagination)
 	return &pasturePb.CalendarToDoResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -358,8 +358,8 @@ func (s *StoreEntry) SameTimeCowList(ctx context.Context, req *pasturePb.ItemsRe
 		Find(&sameTimeBodyList).Error; err != nil {
 		return nil, xerr.WithStack(err)
 	}
-	breedStatusMap := s.CowBreedStatusMap()
-	sameTimeTypeMap := s.SameTimeTypeMap()
+	breedStatusMap := s.CowBreedStatusMap(userModel)
+	sameTimeTypeMap := s.SameTimeTypeMap(userModel)
 	return &pasturePb.SameTimeItemResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",

+ 6 - 6
module/backend/calendar_more.go

@@ -47,7 +47,7 @@ func (s *StoreEntry) CalvingCowList(ctx context.Context, req *pasturePb.ItemsReq
 		return nil, xerr.WithStack(err)
 	}
 
-	breedStatusMap := s.CowBreedStatusMap()
+	breedStatusMap := s.CowBreedStatusMap(userModel)
 	for _, v := range calvingItems {
 		breedStatusName := ""
 		if breedStatus, ok := breedStatusMap[v.BreedStatus]; ok {
@@ -121,7 +121,7 @@ func (s *StoreEntry) DryMilkCowList(ctx context.Context, req *pasturePb.ItemsReq
 		return nil, xerr.WithStack(err)
 	}
 
-	breedStatusMap := s.CowBreedStatusMap()
+	breedStatusMap := s.CowBreedStatusMap(userModel)
 	for _, v := range dryMilkItems {
 		breedStatusName := ""
 		if breedStatus, ok := breedStatusMap[v.BreedStatus]; ok {
@@ -187,7 +187,7 @@ func (s *StoreEntry) TreatmentCowList(ctx context.Context, req *pasturePb.ItemsR
 		Code: http.StatusOK,
 		Msg:  "ok",
 		Data: &pasturePb.EventCowDiseaseData{
-			List:       model.EventCowDiseaseSlice(diseaseItems).ToPB(s.HealthStatusMap()),
+			List:       model.EventCowDiseaseSlice(diseaseItems).ToPB(s.HealthStatusMap(userModel)),
 			Total:      int32(count),
 			PageSize:   pagination.PageSize,
 			Page:       pagination.Page,
@@ -211,11 +211,11 @@ func (s *StoreEntry) WorkOrderCowList(ctx context.Context, req *pasturePb.ItemsR
 }
 
 // Paginate 函数用于对切片进行分页
-func Paginate(slice []*pasturePb.CalendarToDoList, req *pasturePb.CalendarToDoRequest, pagination *pasturePb.PaginationModel) ([]*pasturePb.CalendarToDoList, int32) {
+func (s *StoreEntry) Paginate(userModel *model.UserModel, slice []*pasturePb.CalendarToDoList, req *pasturePb.CalendarToDoRequest, pagination *pasturePb.PaginationModel) ([]*pasturePb.CalendarToDoList, int32) {
 	newSlice := make([]*pasturePb.CalendarToDoList, 0)
 
 	if req.CalendarType > 0 {
-		calendarTypeName := CalendarTypeMap()[req.CalendarType]
+		calendarTypeName := s.CalendarTypeMap(userModel)[req.CalendarType]
 		if len(calendarTypeName) > 0 {
 			re := regexp.MustCompile(`[a-zA-Z]`) // 使用正则表达式替换匹配的字母为空字符串
 			calendarTypeName = re.ReplaceAllString(calendarTypeName, "")
@@ -307,7 +307,7 @@ func (s *StoreEntry) TaskDetail(ctx context.Context, req *pasturePb.CalendarToDo
 		return nil, xerr.WithStack(err)
 	}
 
-	calendarToDoList, _ = Paginate(calendarToDoList, req, pagination)
+	calendarToDoList, _ = s.Paginate(userModel, calendarToDoList, req, pagination)
 	taskItemsList := make([]*pasturePb.TaskItems, 0)
 	for _, v := range calendarToDoList {
 		if v.CalendarType == pasturePb.CalendarType_Disease {

+ 57 - 404
module/backend/config_data.go

@@ -9,21 +9,41 @@ import (
 	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
 )
 
-func (s *StoreEntry) BarnTypeEnumList(excludeTypes []pasturePb.PenType_Kind) []*pasturePb.ConfigOptionsList {
-	allBarnTypes := s.BarnTypeMap()
+func (s *StoreEntry) BarnTypeEnumList(userModel *model.UserModel, excludeTypes []pasturePb.PenType_Kind, isAll string) []*pasturePb.ConfigOptionsList {
+	dataList := make([]*model.ConfigPenType, 0)
+	pref := s.DB.Model(new(model.ConfigPenType)).
+		Where("is_show =? ", pasturePb.IsShow_Ok).
+		Where("pasture_id =? ", userModel.AppPasture.Id)
+	if isAll == model.IsAllYes {
+		pref = pref.Where("kind >= ?", pasturePb.PenType_Invalid)
+	} else {
+		pref = pref.Where("kind > ?", pasturePb.PenType_Invalid)
+	}
+
+	if err := pref.Order("kind ASC").
+		Find(&dataList).Error; err != nil {
+		zaplog.Error("BarnTypeEnumList", zap.Any("err", err))
+		return make([]*pasturePb.ConfigOptionsList, 0)
+	}
+
+	allBarnTypes := model.ConfigBarnTypeSlice(dataList).ToPB2(userModel)
 	barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
-	for v1 := range allBarnTypes {
+	if len(excludeTypes) == 0 || excludeTypes == nil {
+		return allBarnTypes
+	}
+
+	for _, v1 := range allBarnTypes {
 		var info bool
 		for _, v2 := range excludeTypes {
-			if v1 == v2 {
+			if v1.Value == int32(v2) {
 				info = true
 				break
 			}
 		}
 		if !info {
 			barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
-				Value:    int32(v1),
-				Label:    allBarnTypes[v1],
+				Value:    v1.Value,
+				Label:    v1.Label,
 				Disabled: true,
 			})
 		}
@@ -32,54 +52,23 @@ func (s *StoreEntry) BarnTypeEnumList(excludeTypes []pasturePb.PenType_Kind) []*
 }
 
 func (s *StoreEntry) BreedStatusEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
-	dataList := make([]*model.ConfigSaleCowAnalysisMethod, 0)
-	pref := s.DB.Model(new(model.ConfigSaleCowAnalysisMethod)).
+	dataList := make([]*model.ConfigBreedStatus, 0)
+	pref := s.DB.Model(new(model.ConfigBreedStatus)).
 		Where("is_show =? ", pasturePb.IsShow_Ok).
 		Where("pasture_id =? ", userModel.AppPasture.Id)
 	if isAll == model.IsAllYes {
-		pref = pref.Where("kind >= ?", pasturePb.SaleCowAnalysisMethod_Invalid)
+		pref = pref.Where("kind >= ?", pasturePb.BreedStatus_Invalid)
 	} else {
-		pref = pref.Where("kind > ?", pasturePb.SaleCowAnalysisMethod_Invalid)
+		pref = pref.Where("kind > ?", pasturePb.BreedStatus_Invalid)
 	}
 
 	if err := pref.Order("kind ASC").
 		Find(&dataList).Error; err != nil {
-		zaplog.Error("LactIntervalSymbolEnumList", zap.Any("err", err))
+		zaplog.Error("ConfigBreedStatus", zap.Any("err", err))
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigSaleCowAnalysisMethodSlice(dataList).ToPB(userModel.Language)
-	/*breedStatusList := make([]*pasturePb.ConfigOptionsList, 0)
-	breedStatusList = append(breedStatusList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.BreedStatus_UnBreed),
-		Label:    "未配",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.BreedStatus_Breeding),
-		Label:    "已配未检",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.BreedStatus_Pregnant),
-		Label:    "怀孕",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.BreedStatus_Empty),
-		Label:    "空怀",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.BreedStatus_Calving),
-		Label:    "产犊",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.BreedStatus_Abort),
-		Label:    "流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.BreedStatus_No_Mating),
-		Label:    "禁配",
-		Disabled: true,
-	})
-	return breedStatusList*/
+	return model.ConfigBreedStatusSlice(dataList).ToPB2(userModel)
 }
 
 func (s *StoreEntry) CowKindEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -99,35 +88,7 @@ func (s *StoreEntry) CowKindEnumList(userModel *model.UserModel, isAll string) [
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigCowKindSlice(dataList).ToPB2(userModel.Language)
-
-	/*cowKindList := make([]*pasturePb.ConfigOptionsList, 0)
-	cowKindList = append(cowKindList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowKind_XMTEN),
-		Label:    "西门塔尔牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowKind_AGSN),
-		Label:    "安格斯牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowKind_XNLN),
-		Label:    "夏洛莱牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowKind_LMZN),
-		Label:    "利木赞牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowKind_HFTN),
-		Label:    "海福特牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowKind_HN),
-		Label:    "和牛",
-		Disabled: true,
-	})
-	return cowKindList*/
+	return model.ConfigCowKindSlice(dataList).ToPB2(userModel)
 }
 
 func (s *StoreEntry) CowSourceEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -147,76 +108,27 @@ func (s *StoreEntry) CowSourceEnumList(userModel *model.UserModel, isAll string)
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigCowSourceSlice(dataList).ToPB2(userModel.Language)
-	/*cowSourceList := make([]*pasturePb.ConfigOptionsList, 0)
-	cowSourceList = append(cowSourceList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowSource_Calving),
-		Label:    "产犊",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowSource_Transfer_In),
-		Label:    "调入",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowSource_Buy),
-		Label:    "购买",
-		Disabled: true,
-	})
-	return cowSourceList*/
+	return model.ConfigCowSourceSlice(dataList).ToPB2(userModel)
 }
 
-func (s *StoreEntry) CowTypeEnumList(optionName, isAll string) []*pasturePb.ConfigOptionsList {
-	cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
+func (s *StoreEntry) CowTypeEnumList(userModel *model.UserModel, optionName, isAll string) []*pasturePb.ConfigOptionsList {
+	dataList := make([]*model.ConfigCowType, 0)
+	pref := s.DB.Model(new(model.ConfigCowType)).
+		Where("is_show =? ", pasturePb.IsShow_Ok).
+		Where("pasture_id =? ", userModel.AppPasture.Id)
 	if isAll == model.IsAllYes {
-		cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.CowType_Invalid),
-			Label:    "全部",
-			Disabled: true,
-		})
+		pref = pref.Where("kind >= ?", pasturePb.CowType_Invalid)
+	} else {
+		pref = pref.Where("kind > ?", pasturePb.CowType_Invalid)
 	}
-	if optionName == "breed" {
-		cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.CowType_Reserve_Calf),
-			Label:    "后备牛",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.CowType_Breeding_Calf),
-			Label:    "成母牛",
-			Disabled: true,
-		})
-		return cowTypeList
+
+	if err := pref.Order("kind ASC").
+		Find(&dataList).Error; err != nil {
+		zaplog.Error("CowKindEnumList", zap.Any("err", err))
+		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Lactating_Calf),
-		Label:    "哺乳犊牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Weaned_Calf),
-		Label:    "育成牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Youth_Calf),
-		Label:    "青年牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Fattening_Calf),
-		Label:    "育肥牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Reserve_Calf),
-		Label:    "后备牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Breeding_Calf),
-		Label:    "成母牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Breeding_Bull),
-		Label:    "种公牛",
-		Disabled: true,
-	})
-	return cowTypeList
+	return model.ConfigCowTypeSlice(dataList).ToPB2(userModel, optionName)
 }
 
 func (s *StoreEntry) SameTimeCowTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -236,25 +148,7 @@ func (s *StoreEntry) SameTimeCowTypeEnumList(userModel *model.UserModel, isAll s
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigSameTimeCowTypeSlice(dataList).ToPB(userModel.Language)
-	/*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.SameTimeCowType_Invalid),
-			Label:    "全部",
-			Disabled: true,
-		})
-	}
-	cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.SameTimeCowType_Empty),
-		Label:    "空怀牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.SameTimeCowType_Breeding_Calf),
-		Label:    "成母牛",
-		Disabled: true,
-	})
-	return cowTypeList*/
+	return model.ConfigSameTimeCowTypeSlice(dataList).ToPB(userModel)
 }
 
 func (s *StoreEntry) SameTimeTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -274,84 +168,11 @@ func (s *StoreEntry) SameTimeTypeEnumList(userModel *model.UserModel, isAll stri
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigSameTimeTypeSlice(dataList).ToPB(userModel.Language)
-	/*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.SameTimeType_Invalid),
-			Label:    "全部",
-			Disabled: true,
-		})
-	}
-	cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.SameTimeType_PGBJ),
-		Label:    "PG保健",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.SameTimeType_PGTQ),
-		Label:    "PG同期",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.SameTimeType_RnGH),
-		Label:    "RnGH",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.SameTimeType_TAI),
-		Label:    "TAI输精",
-		Disabled: true,
-	})
-	return cowTypeList*/
+	return model.ConfigSameTimeTypeSlice(dataList).ToPB(userModel)
 }
 
 func (s *StoreEntry) ImmunizationCowTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
-	dataList := make([]*model.ConfigImmunizationCowType, 0)
-	pref := s.DB.Model(new(model.ConfigImmunizationCowType)).
-		Where("is_show =? ", pasturePb.IsShow_Ok).
-		Where("pasture_id =? ", userModel.AppPasture.Id)
-	if isAll == model.IsAllYes {
-		pref = pref.Where("kind >= ?", pasturePb.CowKind_Invalid)
-	} else {
-		pref = pref.Where("kind > ?", pasturePb.CowKind_Invalid)
-	}
-
-	if err := pref.Order("kind ASC").
-		Find(&dataList).Error; err != nil {
-		zaplog.Error("SameTimeTypeEnumList", zap.Any("err", err))
-		return make([]*pasturePb.ConfigOptionsList, 0)
-	}
-
-	return model.ConfigImmunizationCowTypeSlice(dataList).ToPB(userModel.Language)
-	/*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
-	cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Lactating_Calf),
-		Label:    "犊牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Weaned_Calf),
-		Label:    "育成牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Youth_Calf),
-		Label:    "青年牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Fattening_Calf),
-		Label:    "育肥牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Reserve_Calf),
-		Label:    "后备牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Breeding_Calf),
-		Label:    "成母牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CowType_Breeding_Bull),
-		Label:    "种公牛",
-		Disabled: true,
-	})
-	return cowTypeList*/
+	return s.CowTypeEnumList(userModel, "", isAll)
 }
 
 func (s *StoreEntry) ImmunizationConditionsEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -371,37 +192,7 @@ func (s *StoreEntry) ImmunizationConditionsEnumList(userModel *model.UserModel,
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigImmunizationConditionsSlice(dataList).ToPB(userModel.Language)
-	/*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.ImmunizationConditions_Invalid),
-			Label:    "全部",
-			Disabled: true,
-		})
-	}
-	cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.ImmunizationConditions_Days_Age),
-		Label:    "日龄",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.ImmunizationConditions_Days_After_Delivery),
-		Label:    "产后天数",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.ImmunizationConditions_Days_Of_Pregnancy),
-		Label:    "怀孕天数",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.ImmunizationConditions_Admission_Days),
-		Label:    "入场天数",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.ImmunizationConditions_Other_Vaccine_After),
-		Label:    "基于其他疫苗之后",
-		Disabled: true,
-	})
-	return cowTypeList*/
+	return model.ConfigImmunizationConditionsSlice(dataList).ToPB(userModel)
 }
 
 func (s *StoreEntry) TransferPenEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -421,37 +212,7 @@ func (s *StoreEntry) TransferPenEnumList(userModel *model.UserModel, isAll strin
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigTransferPenReasonSlice(dataList).ToPB2(userModel.Language)
-	/*transferPenList := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.TransferPenReason_Invalid),
-			Label:    "全部",
-			Disabled: true,
-		})
-	}
-	transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.TransferPenReason_Normal),
-		Label:    "正常转群",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.TransferPenReason_Feed),
-		Label:    "饲喂转群",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.TransferPenReason_Dry_Milk),
-		Label:    "干奶转群",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.TransferPenReason_Pregnant),
-		Label:    "怀孕转群",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.TransferPenReason_Overantibody),
-		Label:    "过抗转群",
-		Disabled: true,
-	})
-	return transferPenList*/
+	return model.ConfigTransferPenReasonSlice(dataList).ToPB2(userModel)
 }
 
 func (s *StoreEntry) ChildNumberEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -471,36 +232,7 @@ func (s *StoreEntry) ChildNumberEnumList(userModel *model.UserModel, isAll strin
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigChildNumberSlice(dataList).ToPB(userModel.Language)
-
-	/*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.ChildNumber_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-	configOptions = append(configOptions,
-		&pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.ChildNumber_One),
-			Label:    "单胎",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.ChildNumber_Two),
-			Label:    "双胎",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.ChildNumber_Three),
-			Label:    "三胎",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.ChildNumber_Four),
-			Label:    "四胎",
-			Disabled: true,
-		})
-	return configOptions*/
+	return model.ConfigChildNumberSlice(dataList).ToPB(userModel)
 }
 
 func (s *StoreEntry) CalvingLevelEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -520,35 +252,7 @@ func (s *StoreEntry) CalvingLevelEnumList(userModel *model.UserModel, isAll stri
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigCalvingLevelSlice(dataList).ToPB(userModel.Language)
-	/*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.CalvingLevel_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-	configOptions = append(configOptions,
-		&pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.CalvingLevel_Natural_Childbirth),
-			Label:    "自然分娩",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.CalvingLevel_Artificial_Midwifery1),
-			Label:    "人工助产(1-2人)",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.CalvingLevel_Artificial_Midwifery2),
-			Label:    "人工助产(3人以上)",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.CalvingLevel_Caesarean_Section),
-			Label:    "剖腹产",
-			Disabled: true,
-		})
-	return configOptions*/
+	return model.ConfigCalvingLevelSlice(dataList).ToPB(userModel)
 }
 
 func (s *StoreEntry) DystociaReasonEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -568,39 +272,7 @@ func (s *StoreEntry) DystociaReasonEnumList(userModel *model.UserModel, isAll st
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigDystociaReasonSlice(dataList).ToPB(userModel.Language)
-	/*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.DystociaReason_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-	configOptions = append(configOptions,
-		&pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DystociaReason_Malposition),
-			Label:    "胎位不正",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DystociaReason_Fetal_Overgrowth),
-			Label:    "胎儿过大",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DystociaReason_Uterine_Atony),
-			Label:    "子宫收缩无力",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DystociaReason_Pelvic_Stenosis),
-			Label:    "盆骨狭小",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DystociaReason_Sub_Health),
-			Label:    "母牛亚健康状态",
-			Disabled: true,
-		})
-	return configOptions*/
+	return model.ConfigDystociaReasonSlice(dataList).ToPB(userModel)
 }
 
 func (s *StoreEntry) PregnantCheckResultEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -620,24 +292,5 @@ func (s *StoreEntry) PregnantCheckResultEnumList(userModel *model.UserModel, isA
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigPregnantCheckResultSlice(dataList).ToPB(userModel.Language)
-	/*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.PregnantCheckResult_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.PregnantCheckResult_Pregnant),
-		Label:    "有胎",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.PregnantCheckResult_UnPregnant),
-		Label:    "无胎",
-		Disabled: true,
-	})
-	return configOptions*/
+	return model.ConfigPregnantCheckResultSlice(dataList).ToPB(userModel)
 }

+ 97 - 363
module/backend/config_data_base.go

@@ -9,298 +9,87 @@ import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 )
 
-func (s *StoreEntry) OutReasonEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+func (s *StoreEntry) DeathReasonEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
+	dataList := make([]*model.ConfigDeathReason, 0)
+	pref := s.DB.Model(new(model.ConfigDeathReason)).
+		Where("is_show =? ", pasturePb.IsShow_Ok).
+		Where("pasture_id =? ", userModel.AppPasture.Id)
 	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.OutReasons_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
+		pref = pref.Where("kind >= ?", pasturePb.DeathReason_Invalid)
+	} else {
+		pref = pref.Where("kind > ?", pasturePb.DeathReason_Invalid)
 	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Respiratory_System_Disease),
-		Label:    "呼吸系统疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Nutritional_Metabolic_Disease),
-		Label:    "营养代谢疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Breeding_Disease),
-		Label:    "繁殖疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Breast_Disease),
-		Label:    "乳房疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Long_Term_infertility),
-		Label:    "久配不孕",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Multiple_Miscarriages),
-		Label:    "多次流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Long_Treatment_Without_Recovery),
-		Label:    "久治不愈",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Postpartum_Paralysis),
-		Label:    "产后瘫痪",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Mastitis),
-		Label:    "乳房炎",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Hoof_Disease),
-		Label:    "蹄病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Congenital_Malformation),
-		Label:    "先天畸形",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Congenital_Malformation),
-		Label:    "先天畸形",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Dysplasia),
-		Label:    "发育不良",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Hernia),
-		Label:    "疝气",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Excessive_Age),
-		Label:    "月龄过大",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Excessive_Age),
-		Label:    "月龄过大",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Excessive_Weight),
-		Label:    "体重过肥",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Other_Disease),
-		Label:    "其他疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Weak_Child),
-		Label:    "弱仔",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Obsessive_Bull),
-		Label:    "恶癖牛",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Low_Milk),
-		Label:    "低产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Slow_Growing),
-		Label:    "生长缓慢",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Other),
-		Label:    "其他",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Unknown),
-		Label:    "未知原因",
-		Disabled: true,
-	})
-	return configOptions
-}
 
-func (s *StoreEntry) DeathReasonEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.DeathReason_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
+	if err := pref.Order("kind ASC").
+		Find(&dataList).Error; err != nil {
+		zaplog.Error("DeathReasonEnumList", zap.Any("err", err))
+		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Digestive_System_Diseases),
-		Label:    "消化性疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Respiratory_System_Diseases),
-		Label:    "呼吸性疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Reproductive_System_Diseases),
-		Label:    "繁殖性疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Metabolic_System_Diseases),
-		Label:    "代谢性疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Infectious_Diseases),
-		Label:    "传染性疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Difficult_Birth),
-		Label:    "难产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Accident_Dead),
-		Label:    "意外死亡",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Stress),
-		Label:    "应激",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Trauma),
-		Label:    "外伤",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Pneumonia),
-		Label:    "肺炎",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Diarrhea),
-		Label:    "腹泻",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Ketosis),
-		Label:    "酮症",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Acidosis),
-		Label:    "酸中毒",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Rumina_Impaction),
-		Label:    "瘤胃积食",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Intestinal_Torsion),
-		Label:    "肠扭转",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathReason_Other),
-		Label:    "其他",
-		Disabled: true,
-	})
-	return configOptions
+
+	return model.ConfigDeathReasonSlice(dataList).ToPB(userModel)
 }
 
-func (s *StoreEntry) MatingResultEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+func (s *StoreEntry) MatingResultEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
+	dataList := make([]*model.ConfigMatingResult, 0)
+	pref := s.DB.Model(new(model.ConfigMatingResult)).
+		Where("is_show =? ", pasturePb.IsShow_Ok).
+		Where("pasture_id =? ", userModel.AppPasture.Id)
 	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.MatingResult_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
+		pref = pref.Where("kind >= ?", pasturePb.MatingResult_Invalid)
+	} else {
+		pref = pref.Where("kind > ?", pasturePb.MatingResult_Invalid)
 	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.MatingResult_Unknown),
-		Label:    "未知",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.MatingResult_ReMatch),
-		Label:    "复配",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.MatingResult_Pregnant),
-		Label:    "怀孕",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.MatingResult_Empty),
-		Label:    "空怀",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.MatingResult_Abort),
-		Label:    "流产",
-		Disabled: true,
-	})
-	return configOptions
+
+	if err := pref.Order("kind ASC").
+		Find(&dataList).Error; err != nil {
+		zaplog.Error("MatingResultEnumList", zap.Any("err", err))
+		return make([]*pasturePb.ConfigOptionsList, 0)
+	}
+
+	return model.ConfigMatingResultSlice(dataList).ToPB(userModel)
 }
 
-func (s *StoreEntry) EventCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+func (s *StoreEntry) EventCategoryEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
+	dataList := make([]*model.ConfigEventCategory, 0)
+	pref := s.DB.Model(new(model.ConfigEventCategory)).
+		Where("is_show =? ", pasturePb.IsShow_Ok).
+		Where("pasture_id =? ", userModel.AppPasture.Id)
 	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.EventCategory_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
+		pref = pref.Where("kind >= ?", pasturePb.EventCategory_Invalid)
+	} else {
+		pref = pref.Where("kind > ?", pasturePb.EventCategory_Invalid)
 	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.EventCategory_Base),
-		Label:    "基础事件",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.EventCategory_Breed),
-		Label:    "繁殖事件",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.EventCategory_Health),
-		Label:    "兽医事件",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.EventCategory_Other),
-		Label:    "其他事件",
-		Disabled: true,
-	})
-	return configOptions
+
+	if err := pref.Order("kind ASC").
+		Find(&dataList).Error; err != nil {
+		zaplog.Error("EventCategoryEnumList", zap.Any("err", err))
+		return make([]*pasturePb.ConfigOptionsList, 0)
+	}
+
+	return model.ConfigEventCategorySlice(dataList).ToPB(userModel)
 }
 
-func (s *StoreEntry) IndicatorsCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+func (s *StoreEntry) IndicatorsCategoryEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
+	dataList := make([]*model.ConfigIndicatorsCategory, 0)
+	pref := s.DB.Model(new(model.ConfigIndicatorsCategory)).
+		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 >= ?", pasturePb.IndicatorType_Invalid)
+	} else {
+		pref = pref.Where("kind > ?", pasturePb.IndicatorType_Invalid)
 	}
 
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.IndicatorType_Basic),
-		Label:    "基本指标",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.IndicatorType_Breed),
-		Label:    "繁殖指标",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.IndicatorType_Health),
-		Label:    "健康指标",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.IndicatorType_Feed),
-		Label:    "饲喂指标",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.IndicatorType_Calf),
-		Label:    "犊牛指标",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.IndicatorType_Fatten),
-		Label:    "育肥指标",
-		Disabled: true,
-	})
-	return configOptions
+	if err := pref.Order("kind ASC").
+		Find(&dataList).Error; err != nil {
+		zaplog.Error("IndicatorsCategoryEnumList", zap.Any("err", err))
+		return make([]*pasturePb.ConfigOptionsList, 0)
+	}
+
+	return model.ConfigIndicatorsCategorySlice(dataList).ToPB(userModel)
 }
 
-func (s *StoreEntry) IndicatorsDetailsList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) IndicatorsDetailsList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -327,76 +116,44 @@ func (s *StoreEntry) IndicatorsDetailsList(isAll string) []*pasturePb.ConfigOpti
 	return configOptions
 }
 
-func (s *StoreEntry) CowPurposeList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+func (s *StoreEntry) CowPurposeList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
+	dataList := make([]*model.ConfigCowPurpose, 0)
+	pref := s.DB.Model(new(model.ConfigCowPurpose)).
+		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 >= ?", pasturePb.Purpose_Invalid)
+	} else {
+		pref = pref.Where("kind > ?", pasturePb.Purpose_Invalid)
 	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.Purpose_Breeding),
-		Label:    "繁殖",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.Purpose_Fatten),
-		Label:    "育肥",
-		Disabled: true,
-	})
-	return configOptions
+
+	if err := pref.Order("kind ASC").
+		Find(&dataList).Error; err != nil {
+		zaplog.Error("CowPurposeList", zap.Any("err", err))
+		return make([]*pasturePb.ConfigOptionsList, 0)
+	}
+
+	return model.ConfigCowPurposeSlice(dataList).ToPB(userModel)
 }
 
-func (s *StoreEntry) CowOutReasonList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+func (s *StoreEntry) CowOutReasonEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
+	dataList := make([]*model.ConfigCowOutReason, 0)
+	pref := s.DB.Model(new(model.ConfigCowOutReason)).
+		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 >= ?", pasturePb.OutReasons_Invalid)
+	} else {
+		pref = pref.Where("kind > ?", pasturePb.OutReasons_Invalid)
 	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Respiratory_System_Disease),
-		Label:    "呼吸系统疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Nutritional_Metabolic_Disease),
-		Label:    "营养代谢疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Breeding_Disease),
-		Label:    "繁殖疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Breast_Disease),
-		Label:    "乳房疾病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Hoof_Disease),
-		Label:    "蹄病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Low_Milk),
-		Label:    "低产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Slow_Growing),
-		Label:    "生长缓慢",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Slow_Growing),
-		Label:    "生长缓慢",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.OutReasons_Other),
-		Label:    "其他原因",
-		Disabled: true,
-	})
-	return configOptions
+
+	if err := pref.Order("kind ASC").
+		Find(&dataList).Error; err != nil {
+		zaplog.Error("CowOutReasonList", zap.Any("err", err))
+		return make([]*pasturePb.ConfigOptionsList, 0)
+	}
+
+	return model.ConfigCowOutReasonSlice(dataList).ToPB(userModel)
 }
 
 func (s *StoreEntry) CowDeathDestinationList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -405,9 +162,9 @@ func (s *StoreEntry) CowDeathDestinationList(userModel *model.UserModel, isAll s
 		Where("is_show =? ", pasturePb.IsShow_Ok).
 		Where("pasture_id =? ", userModel.AppPasture.Id)
 	if isAll == model.IsAllYes {
-		pref = pref.Where("kind >= ?", pasturePb.PregnantCheckResult_Invalid)
+		pref = pref.Where("kind >= ?", pasturePb.DeathDestination_Invalid)
 	} else {
-		pref = pref.Where("kind > ?", pasturePb.PregnantCheckResult_Invalid)
+		pref = pref.Where("kind > ?", pasturePb.DeathDestination_Invalid)
 	}
 
 	if err := pref.Order("kind ASC").
@@ -416,28 +173,5 @@ func (s *StoreEntry) CowDeathDestinationList(userModel *model.UserModel, isAll s
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigCowDeathDestinationSlice(dataList).ToPB(userModel.Language)
-	/*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(0),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathDestination_NuisanceLess),
-		Label:    "无公害处理",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathDestination_Slaughterhouse),
-		Label:    "屠宰场",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DeathDestination_Other),
-		Label:    "其他",
-		Disabled: true,
-	})
-	return configOptions*/
+	return model.ConfigCowDeathDestinationSlice(dataList).ToPB(userModel)
 }

+ 7 - 4
module/backend/config_data_breed.go

@@ -311,7 +311,7 @@ func (s *StoreEntry) SaleCowAnalysisMethodEnumList(userModel *model.UserModel, i
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigSaleCowAnalysisMethodSlice(dataList).ToPB(userModel.Language)
+	return model.ConfigSaleCowAnalysisMethodSlice(dataList).ToPB(userModel)
 	/*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
 		Value:    int32(pasturePb.SaleCowAnalysisMethod_Months),
@@ -421,7 +421,10 @@ func (s *StoreEntry) CalendarTypeEnumList(userModel *model.UserModel, isAll stri
 	}
 
 	return model.ConfigCalendarTypeSlice(dataList).ToPB(userModel.Language)
-	/*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+}
+
+func CalendarTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
 			Value:    int32(pasturePb.CalendarType_Invalid),
@@ -466,7 +469,7 @@ func (s *StoreEntry) CalendarTypeEnumList(userModel *model.UserModel, isAll stri
 		Label:    "干奶",
 		Disabled: true,
 	})
-	return configOptions*/
+	return configOptions
 }
 
 func (s *StoreEntry) AbortionReasonsEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
@@ -486,7 +489,7 @@ func (s *StoreEntry) AbortionReasonsEnumList(userModel *model.UserModel, isAll s
 		return make([]*pasturePb.ConfigOptionsList, 0)
 	}
 
-	return model.ConfigAbortionReasonsSlice(dataList).ToPB(userModel.Language)
+	return model.ConfigAbortionReasonsSlice(dataList).ToPB(userModel)
 }
 
 func (s *StoreEntry) CalvingAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {

+ 11 - 11
module/backend/config_data_extend.go

@@ -12,7 +12,7 @@ import (
 	"gitee.com/xuyiping_admin/pkg/xerr"
 )
 
-func (s *StoreEntry) WorkOrderSubUnitEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) WorkOrderSubUnitEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
 		Value:    int32(pasturePb.WorkOrderSubscribeUnit_Person),
@@ -26,7 +26,7 @@ func (s *StoreEntry) WorkOrderSubUnitEnumList(isAll string) []*pasturePb.ConfigO
 	return configOptions
 }
 
-func (s *StoreEntry) WorkOrderPriorityEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) WorkOrderPriorityEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
 		Value:    int32(pasturePb.Priority_Low),
@@ -44,7 +44,7 @@ func (s *StoreEntry) WorkOrderPriorityEnumList(isAll string) []*pasturePb.Config
 	return configOptions
 }
 
-func (s *StoreEntry) WorkOrderCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) WorkOrderCategoryEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
 		Value:    int32(pasturePb.WorkOrderCategory_Health),
@@ -70,7 +70,7 @@ func (s *StoreEntry) WorkOrderCategoryEnumList(isAll string) []*pasturePb.Config
 	return configOptions
 }
 
-func (s *StoreEntry) AdmissionStatusEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) AdmissionStatusEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -104,7 +104,7 @@ func (s *StoreEntry) AdmissionStatusEnumList(isAll string) []*pasturePb.ConfigOp
 	return configOptions
 }
 
-func (s *StoreEntry) ForbiddenMatingReasonsEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) ForbiddenMatingReasonsEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -146,7 +146,7 @@ func (s *StoreEntry) ForbiddenMatingReasonsEnumList(isAll string) []*pasturePb.C
 	return configOptions
 }
 
-func (s *StoreEntry) WarningHealthLevel(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) WarningHealthLevel(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -172,7 +172,7 @@ func (s *StoreEntry) WarningHealthLevel(isAll string) []*pasturePb.ConfigOptions
 	return configOptions
 }
 
-func (s *StoreEntry) Behavior(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) Behavior(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -206,7 +206,7 @@ func (s *StoreEntry) Behavior(isAll string) []*pasturePb.ConfigOptionsList {
 	return configOptions
 }
 
-func (s *StoreEntry) HealthStatusEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) HealthStatusEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
@@ -244,7 +244,7 @@ func (s *StoreEntry) HealthStatusEnumList(isAll string) []*pasturePb.ConfigOptio
 	return configOptions
 }
 
-func (s *StoreEntry) MatingWindowPeriodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) MatingWindowPeriodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -270,7 +270,7 @@ func (s *StoreEntry) MatingWindowPeriodEnumList(isAll string) []*pasturePb.Confi
 	return configOptions
 }
 
-func (s *StoreEntry) DataWaringTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) DataWaringTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -314,7 +314,7 @@ func (s *StoreEntry) DataWaringTypeEnumList(isAll string) []*pasturePb.ConfigOpt
 	return configOptions
 }
 
-func (s *StoreEntry) NeckRingErrorEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) NeckRingErrorEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,

+ 16 - 16
module/backend/config_data_other.go

@@ -9,7 +9,7 @@ import (
 	"go.uber.org/zap"
 )
 
-func (s *StoreEntry) PregnantCheckMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) PregnantCheckMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -33,7 +33,7 @@ func (s *StoreEntry) PregnantCheckMethodEnumList(isAll string) []*pasturePb.Conf
 	return configOptions
 }
 
-func (s *StoreEntry) DrugCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) DrugCategoryEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -107,7 +107,7 @@ func (s *StoreEntry) DrugCategoryEnumList(isAll string) []*pasturePb.ConfigOptio
 	return configOptions
 }
 
-func (s *StoreEntry) DrugUsageEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) DrugUsageEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -142,7 +142,7 @@ func (s *StoreEntry) DrugUsageEnumList(isAll string) []*pasturePb.ConfigOptionsL
 	return configOptions
 }
 
-func (s *StoreEntry) UnitEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) UnitEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	configOptions = append(configOptions,
 		&pasturePb.ConfigOptionsList{
@@ -189,7 +189,7 @@ func (s *StoreEntry) UnitEnumList(isAll string) []*pasturePb.ConfigOptionsList {
 	return configOptions
 }
 
-func (s *StoreEntry) ExposeEstrusTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) ExposeEstrusTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -217,7 +217,7 @@ func (s *StoreEntry) ExposeEstrusTypeEnumList(isAll string) []*pasturePb.ConfigO
 	return configOptions
 }
 
-func (s *StoreEntry) FrozenSemenTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) FrozenSemenTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -240,11 +240,11 @@ func (s *StoreEntry) FrozenSemenTypeEnumList(isAll string) []*pasturePb.ConfigOp
 	return configOptions
 }
 
-func (s *StoreEntry) BullNumberEnumList(isAll string, pastureId int64) []*pasturePb.BullOptionsList {
+func (s *StoreEntry) BullNumberEnumList(userModel *model.UserModel, isAll string) []*pasturePb.BullOptionsList {
 	frozenSemenList := make([]*model.FrozenSemen, 0)
 	bullNumberList := make([]*pasturePb.BullOptionsList, 0)
 	if err := s.DB.Model(new(model.FrozenSemen)).
-		Where("pasture_id = ?", pastureId).
+		Where("pasture_id = ?", userModel.AppPasture.Id).
 		Where("quantity > 0").
 		Group("bull_id").
 		Find(&frozenSemenList).Error; err != nil {
@@ -261,7 +261,7 @@ func (s *StoreEntry) BullNumberEnumList(isAll string, pastureId int64) []*pastur
 	return bullNumberList
 }
 
-func (s *StoreEntry) WeekEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) WeekEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	configOptions = append(configOptions,
 		&pasturePb.ConfigOptionsList{
@@ -296,7 +296,7 @@ func (s *StoreEntry) WeekEnumList(isAll string) []*pasturePb.ConfigOptionsList {
 	return configOptions
 }
 
-func (s *StoreEntry) MonthEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) MonthEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	for v := 1; v <= 31; v++ {
 		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
@@ -308,7 +308,7 @@ func (s *StoreEntry) MonthEnumList(isAll string) []*pasturePb.ConfigOptionsList
 	return configOptions
 }
 
-func (s *StoreEntry) WorkOrderFrequencyEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) WorkOrderFrequencyEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
 		Value:    int32(pasturePb.WorkOrderFrequency_None),
@@ -330,7 +330,7 @@ func (s *StoreEntry) WorkOrderFrequencyEnumList(isAll string) []*pasturePb.Confi
 	return configOptions
 }
 
-func (s *StoreEntry) OutTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) OutTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -352,7 +352,7 @@ func (s *StoreEntry) OutTypeEnumList(isAll string) []*pasturePb.ConfigOptionsLis
 	return configOptions
 }
 
-func (s *StoreEntry) AuditStatusEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) AuditStatusEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -386,7 +386,7 @@ func (s *StoreEntry) AuditStatusEnumList(isAll string) []*pasturePb.ConfigOption
 	return configOptions
 }
 
-func (s *StoreEntry) PregnantCheckNameEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) PregnantCheckNameEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -408,7 +408,7 @@ func (s *StoreEntry) PregnantCheckNameEnumList(isAll string) []*pasturePb.Config
 	return configOptions
 }
 
-func (s *StoreEntry) UnMatingReasonsEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) UnMatingReasonsEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,
@@ -442,7 +442,7 @@ func (s *StoreEntry) UnMatingReasonsEnumList(isAll string) []*pasturePb.ConfigOp
 	return configOptions
 }
 
-func (s *StoreEntry) EventTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+func (s *StoreEntry) EventTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions,

+ 16 - 16
module/backend/cow.go

@@ -57,13 +57,13 @@ func (s *StoreEntry) Detail(ctx context.Context, req *pasturePb.SearchEventReque
 		}
 	}
 
-	cowTypeMap := s.CowTypeMap()
-	breedStatusMap := s.CowBreedStatusMap()
-	cowKindMap := s.CowKindMap()
-	cowSourceMap := s.CowSourceMap()
-	admissionStatusMap := s.AdmissionStatusMap()
-	healthStatusMap := s.HealthStatusMap()
-	purposeMap := s.PurposeMap()
+	cowTypeMap := s.CowTypeMap(userModel)
+	breedStatusMap := s.CowBreedStatusMap(userModel)
+	cowKindMap := s.CowKindMap(userModel)
+	cowSourceMap := s.CowSourceMap(userModel)
+	admissionStatusMap := s.AdmissionStatusMap(userModel)
+	healthStatusMap := s.HealthStatusMap(userModel)
+	purposeMap := s.PurposeMap(userModel)
 	systemBasic, err := s.GetSystemBasicByName(ctx, userModel.AppPasture.Id, model.PregnancyAge)
 	if err != nil {
 		messageId, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
@@ -159,13 +159,13 @@ func (s *StoreEntry) List(ctx context.Context, req *pasturePb.SearchEventRequest
 		return nil, xerr.WithStack(err)
 	}
 
-	cowTypeMap := s.CowTypeMap()
-	breedStatusMap := s.CowBreedStatusMap()
-	cowKindMap := s.CowKindMap()
-	cowSourceMap := s.CowSourceMap()
-	admissionStatusMap := s.AdmissionStatusMap()
-	healthStatusMap := s.HealthStatusMap()
-	purposeMap := s.PurposeMap()
+	cowTypeMap := s.CowTypeMap(userModel)
+	breedStatusMap := s.CowBreedStatusMap(userModel)
+	cowKindMap := s.CowKindMap(userModel)
+	cowSourceMap := s.CowSourceMap(userModel)
+	admissionStatusMap := s.AdmissionStatusMap(userModel)
+	healthStatusMap := s.HealthStatusMap(userModel)
+	purposeMap := s.PurposeMap(userModel)
 	return &pasturePb.SearchCowListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -216,7 +216,7 @@ func (s *StoreEntry) EventList(ctx context.Context, req *pasturePb.SearchCowEven
 		return nil, xerr.WithStack(err)
 	}
 
-	eventCategoryMap := s.EventCategoryMap()
+	eventCategoryMap := s.EventCategoryMap(userModel)
 	return &pasturePb.CowEventListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -277,7 +277,7 @@ func (s *StoreEntry) BehaviorCurve(ctx context.Context, req *pasturePb.CowBehavi
 	q1, q3 := s.CowIQR(cowInfo, req.CurveName, dayRange, data.DateTimeList)
 	data.IQR3 = q3
 	data.IQR1 = q1
-	eventMapList := s.EventTypeMap()
+	eventMapList := s.EventTypeMap(userModel)
 	for k, v := range eventMapList {
 		if k == pasturePb.EventType_Enter || k == pasturePb.EventType_Body_Score || k == pasturePb.EventType_Birth ||
 			k == pasturePb.EventType_Weaning || k == pasturePb.EventType_Sale || k == pasturePb.EventType_Weight ||

+ 7 - 7
module/backend/dashboard.go

@@ -190,13 +190,13 @@ func (s *StoreEntry) DataWarningPop(ctx context.Context, req *pasturePb.WarningD
 		zaplog.Error("UpdateWarningData", zap.Any("err", err), zap.Any("query", query), zap.Any("params", params))
 	}
 
-	cowTypeMap := s.CowTypeMap()
-	breedStatusMap := s.CowBreedStatusMap()
-	cowKindMap := s.CowKindMap()
-	cowSourceMap := s.CowSourceMap()
-	admissionStatusMap := s.AdmissionStatusMap()
-	healthStatusMap := s.HealthStatusMap()
-	purposeMap := s.PurposeMap()
+	cowTypeMap := s.CowTypeMap(userModel)
+	breedStatusMap := s.CowBreedStatusMap(userModel)
+	cowKindMap := s.CowKindMap(userModel)
+	cowSourceMap := s.CowSourceMap(userModel)
+	admissionStatusMap := s.AdmissionStatusMap(userModel)
+	healthStatusMap := s.HealthStatusMap(userModel)
+	purposeMap := s.PurposeMap(userModel)
 	resp.Data.Total = int32(count)
 	systemBasic, err := s.GetSystemBasicByName(ctx, userModel.AppPasture.Id, model.PregnancyAge)
 	if err != nil {

+ 93 - 101
module/backend/enum_map.go

@@ -6,135 +6,143 @@ import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 )
 
-func (s *StoreEntry) DrugCategoryMaps() map[pasturePb.DrugCategory_Kind]string {
+func (s *StoreEntry) DrugCategoryMaps(userModel *model.UserModel) map[pasturePb.DrugCategory_Kind]string {
 	res := make(map[pasturePb.DrugCategory_Kind]string)
-	for _, v := range s.DrugCategoryEnumList("") {
+	for _, v := range s.DrugCategoryEnumList(userModel, "") {
 		res[pasturePb.DrugCategory_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) DrugUsageMaps() map[pasturePb.DrugUsage_Kind]string {
+func (s *StoreEntry) DrugUsageMaps(userModel *model.UserModel) map[pasturePb.DrugUsage_Kind]string {
 	res := make(map[pasturePb.DrugUsage_Kind]string)
-	for _, v := range s.DrugUsageEnumList("") {
+	for _, v := range s.DrugUsageEnumList(userModel, "") {
 		res[pasturePb.DrugUsage_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) ExposeEstrusTypeMap() map[pasturePb.ExposeEstrusType_Kind]string {
+func (s *StoreEntry) ExposeEstrusTypeMap(userModel *model.UserModel) map[pasturePb.ExposeEstrusType_Kind]string {
 	res := make(map[pasturePb.ExposeEstrusType_Kind]string)
-	for _, v := range s.ExposeEstrusTypeEnumList("") {
+	for _, v := range s.ExposeEstrusTypeEnumList(userModel, "") {
 		res[pasturePb.ExposeEstrusType_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) FrozenSemenTypeMap() map[pasturePb.FrozenSemenType_Kind]string {
+func (s *StoreEntry) FrozenSemenTypeMap(userModel *model.UserModel) map[pasturePb.FrozenSemenType_Kind]string {
 	res := make(map[pasturePb.FrozenSemenType_Kind]string)
-	for _, v := range s.FrozenSemenTypeEnumList("") {
+	for _, v := range s.FrozenSemenTypeEnumList(userModel, "") {
 		res[pasturePb.FrozenSemenType_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) UnitMap() map[pasturePb.Unit_Kind]string {
+func (s *StoreEntry) UnitMap(userModel *model.UserModel) map[pasturePb.Unit_Kind]string {
 	res := make(map[pasturePb.Unit_Kind]string)
-	for _, v := range s.UnitEnumList("") {
+	for _, v := range s.UnitEnumList(userModel, "") {
 		res[pasturePb.Unit_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) WeekMap() map[pasturePb.Week_Kind]string {
+func (s *StoreEntry) WeekMap(userModel *model.UserModel) map[pasturePb.Week_Kind]string {
 	res := make(map[pasturePb.Week_Kind]string)
-	for _, v := range s.WeekEnumList("") {
+	for _, v := range s.WeekEnumList(userModel, "") {
 		res[pasturePb.Week_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) MonthMap() map[int32]string {
+func (s *StoreEntry) MonthMap(userModel *model.UserModel) map[int32]string {
 	res := make(map[int32]string)
-	for _, v := range s.MonthEnumList("") {
+	for _, v := range s.MonthEnumList(userModel, "") {
 		res[v.Value] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) CowTypeMap() map[pasturePb.CowType_Kind]string {
+func (s *StoreEntry) CowTypeMap(userModel *model.UserModel) map[pasturePb.CowType_Kind]string {
 	res := make(map[pasturePb.CowType_Kind]string)
 	optionName, isAll := "", ""
-	for _, v := range s.CowTypeEnumList(optionName, isAll) {
+	for _, v := range s.CowTypeEnumList(userModel, optionName, isAll) {
 		res[pasturePb.CowType_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) CowBreedStatusMap() map[pasturePb.BreedStatus_Kind]string {
+func (s *StoreEntry) CowBreedStatusMap(userModel *model.UserModel) map[pasturePb.BreedStatus_Kind]string {
 	res := make(map[pasturePb.BreedStatus_Kind]string)
-	for _, v := range s.BreedStatusEnumList() {
+	for _, v := range s.BreedStatusEnumList(userModel, "") {
 		res[pasturePb.BreedStatus_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) CowKindMap() map[pasturePb.CowKind_Kind]string {
+func (s *StoreEntry) CowKindMap(userModel *model.UserModel) map[pasturePb.CowKind_Kind]string {
 	res := make(map[pasturePb.CowKind_Kind]string)
-	for _, v := range s.CowKindEnumList() {
+	for _, v := range s.CowKindEnumList(userModel, "") {
 		res[pasturePb.CowKind_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) CowSourceMap() map[pasturePb.CowSource_Kind]string {
+func (s *StoreEntry) CowSourceMap(userModel *model.UserModel) map[pasturePb.CowSource_Kind]string {
 	res := make(map[pasturePb.CowSource_Kind]string)
-	for _, v := range s.CowSourceEnumList() {
+	for _, v := range s.CowSourceEnumList(userModel, "") {
 		res[pasturePb.CowSource_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) WorkOrderCategoryMap() map[pasturePb.WorkOrderCategory_Kind]string {
+func (s *StoreEntry) WorkOrderCategoryMap(userModel *model.UserModel) map[pasturePb.WorkOrderCategory_Kind]string {
 	res := make(map[pasturePb.WorkOrderCategory_Kind]string)
-	for _, v := range s.WorkOrderCategoryEnumList("") {
+	for _, v := range s.WorkOrderCategoryEnumList(userModel, "") {
 		res[pasturePb.WorkOrderCategory_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) WorkOrderFrequencyMap() map[pasturePb.WorkOrderFrequency_Kind]string {
+func (s *StoreEntry) WorkOrderFrequencyMap(userModel *model.UserModel) map[pasturePb.WorkOrderFrequency_Kind]string {
 	res := make(map[pasturePb.WorkOrderFrequency_Kind]string)
-	for _, v := range s.WorkOrderFrequencyEnumList("") {
+	for _, v := range s.WorkOrderFrequencyEnumList(userModel, "") {
 		res[pasturePb.WorkOrderFrequency_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) WorkOrderSubUnitMap() map[pasturePb.WorkOrderSubscribeUnit_Kind]string {
+func (s *StoreEntry) WorkOrderSubUnitMap(userModel *model.UserModel) map[pasturePb.WorkOrderSubscribeUnit_Kind]string {
 	res := make(map[pasturePb.WorkOrderSubscribeUnit_Kind]string)
-	for _, v := range s.WorkOrderSubUnitEnumList("") {
+	for _, v := range s.WorkOrderSubUnitEnumList(userModel, "") {
 		res[pasturePb.WorkOrderSubscribeUnit_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) WorkOrderPriorityMap() map[pasturePb.Priority_Kind]string {
+func (s *StoreEntry) WorkOrderPriorityMap(userModel *model.UserModel) map[pasturePb.Priority_Kind]string {
 	res := make(map[pasturePb.Priority_Kind]string)
-	for _, v := range s.WorkOrderPriorityEnumList("") {
+	for _, v := range s.WorkOrderPriorityEnumList(userModel, "") {
 		res[pasturePb.Priority_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) SameTimeCowTypeMap() map[pasturePb.SameTimeCowType_Kind]string {
+func (s *StoreEntry) SameTimeCowTypeMap(userModel *model.UserModel) map[pasturePb.SameTimeCowType_Kind]string {
 	res := make(map[pasturePb.SameTimeCowType_Kind]string)
-	for _, v := range s.SameTimeCowTypeEnumList("") {
+	for _, v := range s.SameTimeCowTypeEnumList(userModel, "") {
 		res[pasturePb.SameTimeCowType_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
+func (s *StoreEntry) CalendarTypeMap(userModel *model.UserModel) map[pasturePb.CalendarType_Kind]string {
+	res := make(map[pasturePb.CalendarType_Kind]string)
+	for _, v := range s.CalendarTypeEnumList(userModel, "") {
+		res[pasturePb.CalendarType_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
 func CalendarTypeMap() map[pasturePb.CalendarType_Kind]string {
 	res := make(map[pasturePb.CalendarType_Kind]string)
 	for _, v := range CalendarTypeEnumList("") {
@@ -151,41 +159,41 @@ func (s *StoreEntry) AbortionReasonsMap(userModel *model.UserModel) map[pastureP
 	return res
 }
 
-func (s *StoreEntry) PregnantCheckMethodMap() map[pasturePb.PregnantCheckMethod_Kind]string {
+func (s *StoreEntry) PregnantCheckMethodMap(userModel *model.UserModel) map[pasturePb.PregnantCheckMethod_Kind]string {
 	res := make(map[pasturePb.PregnantCheckMethod_Kind]string)
-	for _, v := range s.PregnantCheckMethodEnumList("") {
+	for _, v := range s.PregnantCheckMethodEnumList(userModel, "") {
 		res[pasturePb.PregnantCheckMethod_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) PregnantCheckResultMap() map[pasturePb.PregnantCheckResult_Kind]string {
+func (s *StoreEntry) PregnantCheckResultMap(userModel *model.UserModel) map[pasturePb.PregnantCheckResult_Kind]string {
 	res := make(map[pasturePb.PregnantCheckResult_Kind]string)
-	for _, v := range s.PregnantCheckResultEnumList("") {
+	for _, v := range s.PregnantCheckResultEnumList(userModel, "") {
 		res[pasturePb.PregnantCheckResult_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) HealthStatusMap() map[pasturePb.HealthStatus_Kind]string {
+func (s *StoreEntry) HealthStatusMap(userModel *model.UserModel) map[pasturePb.HealthStatus_Kind]string {
 	res := make(map[pasturePb.HealthStatus_Kind]string)
-	for _, v := range s.HealthStatusEnumList("") {
+	for _, v := range s.HealthStatusEnumList(userModel, "") {
 		res[pasturePb.HealthStatus_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) PurposeMap() map[pasturePb.Purpose_Kind]string {
+func (s *StoreEntry) PurposeMap(userModel *model.UserModel) map[pasturePb.Purpose_Kind]string {
 	res := make(map[pasturePb.Purpose_Kind]string)
-	for _, v := range s.CowPurposeList("") {
+	for _, v := range s.CowPurposeList(userModel, "") {
 		res[pasturePb.Purpose_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) DiseaseTypeMap() map[int32]string {
+func (s *StoreEntry) DiseaseTypeMap(userModel *model.UserModel) map[int32]string {
 	res := make(map[int32]string)
-	for _, v := range s.diseaseTypeEnumList("") {
+	for _, v := range s.diseaseTypeEnumList(userModel, "") {
 		res[v.Value] = v.Label
 	}
 	return res
@@ -203,177 +211,161 @@ func (s *StoreEntry) MultiFactorAnalysisMethodMap() map[pasturePb.MultiFactorAna
 	}
 }
 
-func (s *StoreEntry) NeckRingIsBindMap() map[pasturePb.NeckRingIsBind_Kind]string {
+func (s *StoreEntry) NeckRingIsBindMap(userModel *model.UserModel) map[pasturePb.NeckRingIsBind_Kind]string {
 	res := make(map[pasturePb.NeckRingIsBind_Kind]string)
-	for _, v := range s.NeckRingIsBindEnumList("") {
+	for _, v := range s.NeckRingIsBindEnumList(userModel, "") {
 		res[pasturePb.NeckRingIsBind_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) NeckRingStatusMap() map[pasturePb.NeckRingStatus_Kind]string {
+func (s *StoreEntry) NeckRingStatusMap(userModel *model.UserModel) map[pasturePb.NeckRingStatus_Kind]string {
 	res := make(map[pasturePb.NeckRingStatus_Kind]string)
-	for _, v := range s.NeckRingStatusEnumList("") {
+	for _, v := range s.NeckRingStatusEnumList(userModel, "") {
 		res[pasturePb.NeckRingStatus_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) SaleCowAnalysisMap() map[pasturePb.SaleCowAnalysisMethod_Kind]string {
+func (s *StoreEntry) SaleCowAnalysisMap(userModel *model.UserModel) map[pasturePb.SaleCowAnalysisMethod_Kind]string {
 	res := make(map[pasturePb.SaleCowAnalysisMethod_Kind]string)
-	for _, v := range s.SaleCowAnalysisMethodEnumList("") {
+	for _, v := range s.SaleCowAnalysisMethodEnumList(userModel, "") {
 		res[pasturePb.SaleCowAnalysisMethod_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) OutTypeMap() map[pasturePb.OutType_Kind]string {
+func (s *StoreEntry) OutTypeMap(userModel *model.UserModel) map[pasturePb.OutType_Kind]string {
 	res := make(map[pasturePb.OutType_Kind]string)
-	for _, v := range s.OutTypeEnumList("") {
+	for _, v := range s.OutTypeEnumList(userModel, "") {
 		res[pasturePb.OutType_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) AuditStatusMap() map[pasturePb.AuditStatus_Kind]string {
+func (s *StoreEntry) AuditStatusMap(userModel *model.UserModel) map[pasturePb.AuditStatus_Kind]string {
 	res := make(map[pasturePb.AuditStatus_Kind]string)
-	for _, v := range s.AuditStatusEnumList("") {
+	for _, v := range s.AuditStatusEnumList(userModel, "") {
 		res[pasturePb.AuditStatus_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) AdmissionStatusMap() map[pasturePb.AdmissionStatus_Kind]string {
+func (s *StoreEntry) AdmissionStatusMap(userModel *model.UserModel) map[pasturePb.AdmissionStatus_Kind]string {
 	res := make(map[pasturePb.AdmissionStatus_Kind]string)
-	for _, v := range s.AdmissionStatusEnumList("") {
+	for _, v := range s.AdmissionStatusEnumList(userModel, "") {
 		res[pasturePb.AdmissionStatus_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) SameTimeTypeMap() map[pasturePb.SameTimeType_Kind]string {
+func (s *StoreEntry) SameTimeTypeMap(userModel *model.UserModel) map[pasturePb.SameTimeType_Kind]string {
 	res := make(map[pasturePb.SameTimeType_Kind]string)
-	for _, v := range s.SameTimeTypeEnumList("") {
+	for _, v := range s.SameTimeTypeEnumList(userModel, "") {
 		res[pasturePb.SameTimeType_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) EventTypeMap() map[pasturePb.EventType_Kind]string {
+func (s *StoreEntry) EventTypeMap(userModel *model.UserModel) map[pasturePb.EventType_Kind]string {
 	res := make(map[pasturePb.EventType_Kind]string)
-	for _, v := range s.EventTypeEnumList("") {
+	for _, v := range s.EventTypeEnumList(userModel, "") {
 		res[pasturePb.EventType_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) CalvingLevelMap() map[pasturePb.CalvingLevel_Kind]string {
+func (s *StoreEntry) CalvingLevelMap(userModel *model.UserModel) map[pasturePb.CalvingLevel_Kind]string {
 	res := make(map[pasturePb.CalvingLevel_Kind]string)
-	for _, v := range s.CalvingLevelEnumList("") {
+	for _, v := range s.CalvingLevelEnumList(userModel, "") {
 		res[pasturePb.CalvingLevel_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) DystociaReasonMap() map[pasturePb.DystociaReason_Kind]string {
+func (s *StoreEntry) DystociaReasonMap(userModel *model.UserModel) map[pasturePb.DystociaReason_Kind]string {
 	res := make(map[pasturePb.DystociaReason_Kind]string)
-	for _, v := range s.DystociaReasonEnumList("") {
+	for _, v := range s.DystociaReasonEnumList(userModel, "") {
 		res[pasturePb.DystociaReason_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) DeadReasonMap() map[pasturePb.DeathReason_Kind]string {
+func (s *StoreEntry) DeadReasonMap(userModel *model.UserModel) map[pasturePb.DeathReason_Kind]string {
 	res := make(map[pasturePb.DeathReason_Kind]string)
-	for _, v := range s.DeathReasonEnumList("") {
+	for _, v := range s.DeathReasonEnumList(userModel, "") {
 		res[pasturePb.DeathReason_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) OutReasonMap() map[pasturePb.OutReasons_Kind]string {
-	res := make(map[pasturePb.OutReasons_Kind]string)
-	for _, v := range s.OutReasonEnumList("") {
-		res[pasturePb.OutReasons_Kind(v.Value)] = v.Label
-	}
-	return res
-}
-
-func (s *StoreEntry) MatingResultMap() map[pasturePb.MatingResult_Kind]string {
+func (s *StoreEntry) MatingResultMap(userModel *model.UserModel) map[pasturePb.MatingResult_Kind]string {
 	res := make(map[pasturePb.MatingResult_Kind]string)
-	for _, v := range s.MatingResultEnumList("") {
+	for _, v := range s.MatingResultEnumList(userModel, "") {
 		res[pasturePb.MatingResult_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) EventCategoryMap() map[pasturePb.EventCategory_Kind]string {
+func (s *StoreEntry) EventCategoryMap(userModel *model.UserModel) map[pasturePb.EventCategory_Kind]string {
 	res := make(map[pasturePb.EventCategory_Kind]string)
-	for _, v := range s.EventCategoryEnumList("") {
+	for _, v := range s.EventCategoryEnumList(userModel, "") {
 		res[pasturePb.EventCategory_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) GroupTransferReasonMap() map[int32]string {
+func (s *StoreEntry) GroupTransferReasonMap(userModel *model.UserModel) map[int32]string {
 	res := make(map[int32]string)
-	for _, v := range s.TransferPenEnumList("") {
+	for _, v := range s.TransferPenEnumList(userModel, "") {
 		res[v.Value] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) BarnTypeMap() map[pasturePb.PenType_Kind]string {
-	return map[pasturePb.PenType_Kind]string{
-		pasturePb.PenType_Lactating_Calves: "哺乳牛舍",
-		pasturePb.PenType_Weaned_Calves:    "断奶牛舍",
-		pasturePb.PenType_Youth:            "青年牛舍",
-		pasturePb.PenType_Nurturing:        "育成牛舍",
-		pasturePb.PenType_Lactation:        "成母牛舍",
-		pasturePb.PenType_Peripartum:       "围产牛舍",
-		pasturePb.PenType_Dry_Milking:      "干奶牛舍",
-		pasturePb.PenType_Sick_Cow:         "病牛牛舍",
-		pasturePb.PenType_Out:              "淘汰牛舍",
-		pasturePb.PenType_Segregate:        "隔离牛舍",
-		pasturePb.PenType_Bull:             "公牛牛舍",
+func (s *StoreEntry) BarnTypeMap(userModel *model.UserModel) map[pasturePb.PenType_Kind]string {
+	res := make(map[pasturePb.PenType_Kind]string)
+	for _, v := range s.BarnTypeEnumList(userModel, nil, "") {
+		res[pasturePb.PenType_Kind(v.Value)] = v.Label
 	}
+	return res
 }
 
-func (s *StoreEntry) UnMatingReasonsMap() map[pasturePb.UnMatingReasons_Kind]string {
+func (s *StoreEntry) UnMatingReasonsMap(userModel *model.UserModel) map[pasturePb.UnMatingReasons_Kind]string {
 	res := make(map[pasturePb.UnMatingReasons_Kind]string)
-	for _, v := range s.UnMatingReasonsEnumList("") {
+	for _, v := range s.UnMatingReasonsEnumList(userModel, "") {
 		res[pasturePb.UnMatingReasons_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) ForbiddenMatingReasonsMap() map[pasturePb.ForbiddenMatingReasons_Kind]string {
+func (s *StoreEntry) ForbiddenMatingReasonsMap(userModel *model.UserModel) map[pasturePb.ForbiddenMatingReasons_Kind]string {
 	res := make(map[pasturePb.ForbiddenMatingReasons_Kind]string)
-	for _, v := range s.ForbiddenMatingReasonsEnumList("") {
+	for _, v := range s.ForbiddenMatingReasonsEnumList(userModel, "") {
 		res[pasturePb.ForbiddenMatingReasons_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) CowOutReasonsMap() map[pasturePb.OutReasons_Kind]string {
+func (s *StoreEntry) CowOutReasonsMap(userModel *model.UserModel) map[pasturePb.OutReasons_Kind]string {
 	res := make(map[pasturePb.OutReasons_Kind]string)
-	for _, v := range s.CowOutReasonList("") {
+	for _, v := range s.CowOutReasonEnumList(userModel, "") {
 		res[pasturePb.OutReasons_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) CowDeathDestinationMap() map[pasturePb.DeathDestination_Kind]string {
+func (s *StoreEntry) CowDeathDestinationMap(userModel *model.UserModel) map[pasturePb.DeathDestination_Kind]string {
 	res := make(map[pasturePb.DeathDestination_Kind]string)
-	for _, v := range s.CowDeathDestinationList("") {
+	for _, v := range s.CowDeathDestinationList(userModel, "") {
 		res[pasturePb.DeathDestination_Kind(v.Value)] = v.Label
 	}
 	return res
 }
 
-func (s *StoreEntry) WarningHealthLevelMap() map[pasturePb.WarningHealthLevel_Kind]string {
+func (s *StoreEntry) WarningHealthLevelMap(userModel *model.UserModel) map[pasturePb.WarningHealthLevel_Kind]string {
 	res := make(map[pasturePb.WarningHealthLevel_Kind]string)
-	for _, v := range s.WarningHealthLevel("") {
+	for _, v := range s.WarningHealthLevel(userModel, "") {
 		res[pasturePb.WarningHealthLevel_Kind(v.Value)] = v.Label
 	}
 	return res

+ 38 - 12
module/backend/enum_options.go

@@ -25,7 +25,7 @@ func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOpti
 	return &pasturePb.ConfigOptionsListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
-		Data: s.BarnTypeEnumList(excludeTypes),
+		Data: s.BarnTypeEnumList(userModel, excludeTypes, ""),
 	}, nil
 }
 
@@ -51,7 +51,7 @@ func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int, isAll str
 		excludeTypes = append(excludeTypes, pasturePb.PenType_Dry_Milking, pasturePb.PenType_Peripartum)
 	}
 
-	barnTypeList := s.BarnTypeEnumList(excludeTypes)
+	barnTypeList := s.BarnTypeEnumList(userModel, excludeTypes, "")
 	return &pasturePb.ConfigOptionsListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -129,41 +129,62 @@ func (s *StoreEntry) PrescriptionOptions(ctx context.Context) (*pasturePb.Config
 }
 
 func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
 	return &pasturePb.ConfigOptionsListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
-		Data: s.BreedStatusEnumList(),
+		Data: s.BreedStatusEnumList(userModel, ""),
 	}, nil
 }
 func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
 	return &pasturePb.ConfigOptionsListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
-		Data: s.CowKindEnumList(),
+		Data: s.CowKindEnumList(userModel, ""),
 	}, nil
 }
 
 func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
 	return &pasturePb.ConfigOptionsListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
-		Data: s.CowSourceEnumList(),
+		Data: s.CowSourceEnumList(userModel, ""),
 	}, nil
 }
 
 func (s *StoreEntry) CowTypeOptions(ctx context.Context, optionName, isAll string) (*pasturePb.ConfigOptionsListResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
 	return &pasturePb.ConfigOptionsListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
-		Data: s.CowTypeEnumList(optionName, isAll),
+		Data: s.CowTypeEnumList(userModel, optionName, isAll),
 	}, nil
 }
 
 func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
 	return &pasturePb.ConfigOptionsListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
-		Data: s.TransferPenEnumList(""),
+		Data: s.TransferPenEnumList(userModel, ""),
 	}, nil
 }
 
@@ -236,15 +257,20 @@ func (s *StoreEntry) BullOptions(ctx context.Context) (*pasturePb.BullOptionsLis
 	return &pasturePb.BullOptionsListResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
-		Data: s.BullNumberEnumList("", userModel.AppPasture.Id),
+		Data: s.BullNumberEnumList(userModel, ""),
 	}, nil
 }
 
 func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName, isAll string) (*pasturePb.ConfigOptionsListResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
 	if optionsName == "" {
 		return nil, xerr.New("optionsName is empty")
 	}
-	getConfigFuncMap := map[string]func(isAll string) []*pasturePb.ConfigOptionsList{
+	getConfigFuncMap := map[string]func(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList{
 		"childNumber":                s.ChildNumberEnumList,
 		"calvingLevel":               s.CalvingLevelEnumList,
 		"dystociaReason":             s.DystociaReasonEnumList,
@@ -281,13 +307,13 @@ func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName, i
 		"pregnantCheckName":          s.PregnantCheckNameEnumList,
 		"unMatingReasons":            s.UnMatingReasonsEnumList,
 		"evenType":                   s.EventTypeEnumList,
-		"outReason":                  s.OutReasonEnumList,
+		"outReason":                  s.CowOutReasonEnumList,
 		"deathReason":                s.DeathReasonEnumList,
 		"categoryKind":               s.EventCategoryEnumList,
 		"indicatorsDetails":          s.IndicatorsDetailsList,
 		"purposeKind":                s.CowPurposeList,
 		"forbiddenMatingReasons":     s.ForbiddenMatingReasonsEnumList,
-		"cowOutReason":               s.CowOutReasonList,
+		"cowOutReason":               s.CowOutReasonEnumList,
 		"deathDestination":           s.CowDeathDestinationList,
 		"warningHealthLevel":         s.WarningHealthLevel,
 		"behavior":                   s.Behavior,
@@ -301,7 +327,7 @@ func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName, i
 		return nil, fmt.Errorf("invalid optionsName: %s", optionsName)
 	}
 
-	configOptions := getConfigFunc(isAll)
+	configOptions := getConfigFunc(userModel, isAll)
 	if configOptions == nil {
 		return nil, fmt.Errorf("failed to retrieve configOptions for %s", optionsName)
 	}

+ 5 - 5
module/backend/event_base.go

@@ -70,10 +70,10 @@ func (s *StoreEntry) EnterList(ctx context.Context, req *pasturePb.SearchEventRe
 	}
 
 	penMap := s.PenMap(ctx, userModel.AppPasture.Id)
-	breedStatusMap := s.CowBreedStatusMap()
-	cowSourceMap := s.CowSourceMap()
-	cowTypeMap := s.CowTypeMap()
-	cowKindMap := s.CowKindMap()
+	breedStatusMap := s.CowBreedStatusMap(userModel)
+	cowSourceMap := s.CowSourceMap(userModel)
+	cowTypeMap := s.CowTypeMap(userModel)
+	cowKindMap := s.CowKindMap(userModel)
 
 	return &pasturePb.SearchEnterEventResponse{
 		Code: http.StatusOK,
@@ -237,7 +237,7 @@ func (s *StoreEntry) CreateGroupTransfer(ctx context.Context, req *pasturePb.Tra
 		return xerr.Custom("一次最多只能转移50头牛")
 	}
 
-	transferReasonMap := s.GroupTransferReasonMap()
+	transferReasonMap := s.GroupTransferReasonMap(userModel)
 	penMap := s.PenMap(ctx, userModel.AppPasture.Id)
 
 	if err = s.DB.Transaction(func(tx *gorm.DB) error {

+ 1 - 1
module/backend/event_base_more.go

@@ -201,7 +201,7 @@ func (s *StoreEntry) CowSaleCreate(ctx context.Context, req *pasturePb.EventCowS
 	}
 
 	if req.SalesType == pasturePb.SalesType_Out {
-		if name, ok := s.CowOutReasonsMap()[req.OutReasonsKind]; ok {
+		if name, ok := s.CowOutReasonsMap(userModel)[req.OutReasonsKind]; ok {
 			req.OutReasonsName = name
 		}
 	}

+ 1 - 1
module/backend/event_breed.go

@@ -357,7 +357,7 @@ func (s *StoreEntry) SameTimeList(
 		return nil, xerr.WithStack(err)
 	}
 
-	sameTimeTypeMap := s.SameTimeTypeMap()
+	sameTimeTypeMap := s.SameTimeTypeMap(userModel)
 	return &pasturePb.SearchSameTimeResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",

+ 5 - 5
module/backend/event_breed_more.go

@@ -49,8 +49,8 @@ func (s *StoreEntry) PregnantCheckList(ctx context.Context, req *pasturePb.Searc
 		return nil, xerr.WithStack(err)
 	}
 
-	pregnantCheckResultMap := s.PregnantCheckResultMap()
-	pregnantCheckMethodMap := s.PregnantCheckMethodMap()
+	pregnantCheckResultMap := s.PregnantCheckResultMap(userModel)
+	pregnantCheckMethodMap := s.PregnantCheckMethodMap(userModel)
 	return &pasturePb.EventPregnantCheckResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -75,7 +75,7 @@ func (s *StoreEntry) PregnantCheckCreateBatch(ctx context.Context, req *pastureP
 	}
 
 	abortionReasonsMap := s.AbortionReasonsMap(userModel)
-	matingResultMap := s.MatingResultMap()
+	matingResultMap := s.MatingResultMap(userModel)
 
 	if err = s.DB.Transaction(func(tx *gorm.DB) error {
 		for _, item := range pregnantCheckBatchModelList {
@@ -319,7 +319,7 @@ func (s *StoreEntry) MatingList(ctx context.Context, req *pasturePb.SearchEventR
 		return nil, xerr.WithStack(err)
 	}
 
-	exposeEstrusTypeMap := s.ExposeEstrusTypeMap()
+	exposeEstrusTypeMap := s.ExposeEstrusTypeMap(userModel)
 	return &pasturePb.EventMatingResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -474,7 +474,7 @@ func (s *StoreEntry) NaturalEstrusToMating(ctx context.Context, tx *gorm.DB, use
 		}
 
 		// 更新牛只配种结果日志
-		if err = s.UpdateMatingResultEventCowLogByCowId(ctx, item.Cow.Id, s.MatingResultMap()[pasturePb.MatingResult_Empty]); err != nil {
+		if err = s.UpdateMatingResultEventCowLogByCowId(ctx, item.Cow.Id, s.MatingResultMap(userModel)[pasturePb.MatingResult_Empty]); err != nil {
 			zaplog.Error("MatingCreate", zap.Any("UpdateEventCowLogByCowId", err), zap.Any("cow", item.Cow))
 		}
 	}

+ 4 - 4
module/backend/event_check.go

@@ -356,7 +356,7 @@ func (s *StoreEntry) EstrusCheckDataCheck(ctx context.Context, userModel *model.
 	if req.ExposeEstrusType == pasturePb.ExposeEstrusType_Neck_Ring {
 		exposeEstrusType = pasturePb.ExposeEstrusType_Neck_Ring
 	}
-	unMatingReasonsMap := s.UnMatingReasonsMap()
+	unMatingReasonsMap := s.UnMatingReasonsMap(userModel)
 
 	res := &model.EventEstrusBatch{
 		ExposeEstrusType: exposeEstrusType,
@@ -534,7 +534,7 @@ func (s *StoreEntry) AbortionEventDataCheck(ctx context.Context, userModel *mode
 
 func (s *StoreEntry) ForbiddenMatingCheck(ctx context.Context, userModel *model.UserModel, items []*pasturePb.ForbiddenMatingItem) ([]*model.EventForbiddenMatingItem, error) {
 	res := make([]*model.EventForbiddenMatingItem, 0)
-	forbiddenMatingReasonsMap := s.ForbiddenMatingReasonsMap()
+	forbiddenMatingReasonsMap := s.ForbiddenMatingReasonsMap(userModel)
 	for _, v := range items {
 		cowInfo, err := s.GetCowInfoByEarNumber(ctx, userModel.AppPasture.Id, v.EarNumber)
 		if err != nil {
@@ -608,7 +608,7 @@ func (s *StoreEntry) DeathCheck(ctx context.Context, userModel *model.UserModel,
 			return nil, xerr.Customf(messageId)
 		}
 
-		if name, ok := s.DeadReasonMap()[item.DeathReasonKind]; ok {
+		if name, ok := s.DeadReasonMap(userModel)[item.DeathReasonKind]; ok {
 			item.DeathReasonName = name
 		}
 
@@ -621,7 +621,7 @@ func (s *StoreEntry) DeathCheck(ctx context.Context, userModel *model.UserModel,
 			return nil, xerr.Customf(messageId)
 		}
 
-		if name, ok := s.CowDeathDestinationMap()[item.DeathDestinationKind]; ok {
+		if name, ok := s.CowDeathDestinationMap(userModel)[item.DeathDestinationKind]; ok {
 			item.DeathDestinationName = name
 		}
 

+ 14 - 10
module/backend/event_cow_log.go

@@ -17,13 +17,17 @@ import (
 )
 
 func (s *StoreEntry) SubmitEventLog(ctx context.Context, pastureId int64, cow *model.Cow, eventType pasturePb.EventType_Kind, req interface{}) *model.EventCowLog {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil
+	}
 	var (
 		desc, remarks    = "", ""
-		eventTypeName    = s.EventTypeMap()[eventType]
+		eventTypeName    = s.EventTypeMap(userModel)[eventType]
 		eventAt          = int64(0)
 		eventCategoryMap = s.eventCategoryMap()
 		penMap           = s.PenMap(ctx, pastureId)
-		cowTypeMap       = s.CowTypeMap()
+		cowTypeMap       = s.CowTypeMap(userModel)
 		operationUser    = &model.SystemUser{}
 	)
 
@@ -32,7 +36,7 @@ func (s *StoreEntry) SubmitEventLog(ctx context.Context, pastureId int64, cow *m
 		data := req.(*pasturePb.EventEnterRequest)
 		eventAt = int64(data.EnterAt)
 		remarks = data.Remarks
-		sourceMap := s.CowSourceMap()
+		sourceMap := s.CowSourceMap(userModel)
 		operationUser.Id = int64(data.OperationId)
 		operationUser.Name = data.OperationName
 		sex := "公"
@@ -61,15 +65,15 @@ func (s *StoreEntry) SubmitEventLog(ctx context.Context, pastureId int64, cow *m
 		data := req.(*PregnantCheckBatchModel)
 		eventAt = int64(data.PregnantCheckAt)
 		if data.PregnantCheckResult == pasturePb.PregnantCheckResult_Pregnant {
-			desc += fmt.Sprintf("孕检方式: %s; 孕检结果: %s", s.PregnantCheckMethodMap()[data.PregnantCheckMethod], s.MatingResultMap()[pasturePb.MatingResult_Pregnant])
+			desc += fmt.Sprintf("孕检方式: %s; 孕检结果: %s", s.PregnantCheckMethodMap(userModel)[data.PregnantCheckMethod], s.MatingResultMap(userModel)[pasturePb.MatingResult_Pregnant])
 		}
 		if data.PregnantCheckResult == pasturePb.PregnantCheckResult_UnPregnant {
-			desc += fmt.Sprintf("孕检方式: %s", s.PregnantCheckMethodMap()[data.PregnantCheckMethod])
+			desc += fmt.Sprintf("孕检方式: %s", s.PregnantCheckMethodMap(userModel)[data.PregnantCheckMethod])
 			if cow.BreedStatus == pasturePb.BreedStatus_Abort {
-				desc += fmt.Sprintf("; 复检结果: %s", s.MatingResultMap()[pasturePb.MatingResult_Abort])
+				desc += fmt.Sprintf("; 复检结果: %s", s.MatingResultMap(userModel)[pasturePb.MatingResult_Abort])
 			}
 			if cow.BreedStatus == pasturePb.BreedStatus_Empty {
-				desc += fmt.Sprintf("; 孕检结果: %s", s.MatingResultMap()[pasturePb.MatingResult_Empty])
+				desc += fmt.Sprintf("; 孕检结果: %s", s.MatingResultMap(userModel)[pasturePb.MatingResult_Empty])
 			}
 		}
 		operationUser.Id = data.OperationUser.Id
@@ -82,16 +86,16 @@ func (s *StoreEntry) SubmitEventLog(ctx context.Context, pastureId int64, cow *m
 		if data.IsMating == pasturePb.IsShow_Ok {
 			isMating = "是"
 		}
-		desc = fmt.Sprintf("发情揭发方式:%s;是否配种:%s;", s.ExposeEstrusTypeMap()[data.ExposeEstrusType], isMating)
+		desc = fmt.Sprintf("发情揭发方式:%s;是否配种:%s;", s.ExposeEstrusTypeMap(userModel)[data.ExposeEstrusType], isMating)
 		operationUser.Id = data.OperationId
 		operationUser.Name = data.OperationName
 		remarks = data.Remarks
 	case pasturePb.EventType_Calving:
 		data := req.(*pasturePb.EventCalving)
 		eventAt = int64(data.CalvingAt)
-		desc = fmt.Sprintf("怀孕天数:%d;难产等级: %s;产子数量: %d;", cow.PregnancyAge, s.CalvingLevelMap()[data.CalvingLevel], data.ChildNumber)
+		desc = fmt.Sprintf("怀孕天数:%d;难产等级: %s;产子数量: %d;", cow.PregnancyAge, s.CalvingLevelMap(userModel)[data.CalvingLevel], data.ChildNumber)
 		if data.CalvingLevel > pasturePb.CalvingLevel_Natural_Childbirth {
-			desc += fmt.Sprintf("难产原因: %s", s.DystociaReasonMap()[data.DystociaReason])
+			desc += fmt.Sprintf("难产原因: %s", s.DystociaReasonMap(userModel)[data.DystociaReason])
 		}
 		ly, qy, die := 0, 0, 0
 		earNumber := ""

+ 4 - 4
module/backend/event_health.go

@@ -65,7 +65,7 @@ func (s *StoreEntry) CowDiseaseList(ctx context.Context, req *pasturePb.SearchEv
 		return nil, xerr.WithStack(err)
 	}
 
-	healthStatusMap := s.HealthStatusMap()
+	healthStatusMap := s.HealthStatusMap(userModel)
 	return &pasturePb.EventCowDiseaseResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -229,7 +229,7 @@ func (s *StoreEntry) CowDiseaseCreate(ctx context.Context, req *pasturePb.EventC
 		}
 		// 3. 创建治疗记录
 		if len(prescriptionDetail) > 0 {
-			diseaseTypeMap := s.DiseaseTypeMap()
+			diseaseTypeMap := s.DiseaseTypeMap(userModel)
 			newCowTreatmentRequest := &pasturePb.CowTreatmentRequest{
 				CowId:              req.CowId,
 				PrescriptionId:     prescription.Id,
@@ -443,7 +443,7 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
 	}
 
 	// 处方详情
-	unitMap := s.UnitMap()
+	unitMap := s.UnitMap(userModel)
 	prescriptionDetail := make([]*pasturePb.PrescriptionDrugsList, len(prescriptionDrugs))
 	for i, v := range prescriptionDrugs {
 		prescriptionDetail[i] = &pasturePb.PrescriptionDrugsList{
@@ -467,7 +467,7 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
 	if req.TreatmentResult == pasturePb.TreatmentResult_Dead {
 		healthStatus = pasturePb.HealthStatus_Dead
 	}
-	diseaseTypeMap := s.DiseaseTypeMap()
+	diseaseTypeMap := s.DiseaseTypeMap(userModel)
 	newEventCowTreatment := model.NewEventCowTreatment(pastureId, prescription, req, diseaseTypeMap, operationUser, userModel.SystemUser)
 
 	if err = s.DB.Transaction(func(tx *gorm.DB) error {

+ 15 - 15
module/backend/goods.go

@@ -61,9 +61,9 @@ func (s *StoreEntry) DrugsCreateOrUpdate(ctx context.Context, req *pasturePb.Sea
 		return xerr.WithStack(err)
 	}
 
-	req.CategoryName = s.DrugCategoryMaps()[req.CategoryId]
-	req.UnitName = s.UnitMap()[req.Unit]
-	req.UsageName = s.DrugUsageMaps()[req.Usage]
+	req.CategoryName = s.DrugCategoryMaps(userModel)[req.CategoryId]
+	req.UnitName = s.UnitMap(userModel)[req.Unit]
+	req.UsageName = s.DrugUsageMaps(userModel)[req.Usage]
 
 	newDrugs := model.NewDrugs(userModel.AppPasture.Id, req, userModel.SystemUser)
 	if req.Id <= 0 {
@@ -98,7 +98,7 @@ func (s *StoreEntry) MedicalEquipmentList(ctx context.Context, req *pasturePb.Se
 		return nil, xerr.WithStack(err)
 	}
 
-	unitMap := s.UnitMap()
+	unitMap := s.UnitMap(userModel)
 	return &pasturePb.SearchMedicalEquipmentResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -304,8 +304,8 @@ func (s *StoreEntry) NeckRingList(ctx context.Context, req *pasturePb.SearchNeck
 		return nil, xerr.WithStack(err)
 	}
 
-	neckRingIsBindMap := s.NeckRingIsBindMap()
-	neckRingStatusMap := s.NeckRingStatusMap()
+	neckRingIsBindMap := s.NeckRingIsBindMap(userModel)
+	neckRingStatusMap := s.NeckRingStatusMap(userModel)
 	return &pasturePb.SearchNeckRingResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -430,7 +430,7 @@ func (s *StoreEntry) OutboundApply(ctx context.Context, req *pasturePb.OutboundA
 		})
 		return xerr.Custom(messageId)
 	}
-	unitMap := s.UnitMap()
+	unitMap := s.UnitMap(userModel)
 	if err = s.DB.Transaction(func(tx *gorm.DB) error {
 		if req.Id > 0 {
 			if err = tx.Model(new(model.Outbound)).
@@ -503,8 +503,8 @@ func (s *StoreEntry) OutboundList(ctx context.Context, req *pasturePb.SearchOutb
 		return nil, xerr.WithStack(err)
 	}
 
-	outTypeMap := s.OutTypeMap()
-	auditStatusMap := s.AuditStatusMap()
+	outTypeMap := s.OutTypeMap(userModel)
+	auditStatusMap := s.AuditStatusMap(userModel)
 
 	return &pasturePb.SearchOutboundApplyResponse{
 		Code: http.StatusOK,
@@ -620,8 +620,8 @@ func (s *StoreEntry) OutboundDetail(ctx context.Context, id int64) (*pasturePb.O
 	if err != nil {
 		return nil, xerr.WithStack(err)
 	}
-	outTypeMap := s.OutTypeMap()
-	auditStatusMap := s.AuditStatusMap()
+	outTypeMap := s.OutTypeMap(userModel)
+	auditStatusMap := s.AuditStatusMap(userModel)
 	applicantAtFormat, examineAtFormat := "", ""
 	if outbound.ApplicantAt > 0 {
 		applicantAtFormat = time.Unix(outbound.ApplicantAt, 0).Local().Format(model.LayoutTime)
@@ -630,7 +630,7 @@ func (s *StoreEntry) OutboundDetail(ctx context.Context, id int64) (*pasturePb.O
 		examineAtFormat = time.Unix(outbound.ExamineAt, 0).Local().Format(model.LayoutTime)
 	}
 
-	unitMap := s.UnitMap()
+	unitMap := s.UnitMap(userModel)
 	return &pasturePb.OutboundDetailResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -723,8 +723,8 @@ func (s *StoreEntry) FrozenSemenList(ctx context.Context, req *pasturePb.FrozenS
 		return nil, xerr.WithStack(err)
 	}
 
-	frozenSemenTypeMap := s.FrozenSemenTypeMap()
-	unitMap := s.UnitMap()
+	frozenSemenTypeMap := s.FrozenSemenTypeMap(userModel)
+	unitMap := s.UnitMap(userModel)
 
 	return &pasturePb.FrozenSemenResponse{
 		Code: http.StatusOK,
@@ -744,7 +744,7 @@ func (s *StoreEntry) FrozenSemenCreate(ctx context.Context, req *pasturePb.Searc
 		return xerr.WithStack(err)
 	}
 
-	req.CowKindName = s.CowKindMap()[req.CowKind]
+	req.CowKindName = s.CowKindMap(userModel)[req.CowKind]
 	if req.Id > 0 {
 		histData := &model.FrozenSemen{}
 		if err = s.DB.Model(new(model.FrozenSemen)).

+ 4 - 4
module/backend/indicators.go

@@ -123,7 +123,7 @@ func (s *StoreEntry) LongTermInfertility(ctx context.Context, req *pasturePb.Lon
 		return nil, xerr.WithStack(err)
 	}
 
-	breedStatusMap := s.CowBreedStatusMap()
+	breedStatusMap := s.CowBreedStatusMap(userModel)
 	return &pasturePb.LongTermInfertilityResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -219,8 +219,8 @@ func (s *StoreEntry) AlreadySale(ctx context.Context, req *pasturePb.AlreadySale
 		cowMap[v.Id] = v
 	}
 
-	sourceMap := s.CowSourceMap()
-	cowKindMap := s.CowKindMap()
+	sourceMap := s.CowSourceMap(userModel)
+	cowKindMap := s.CowKindMap(userModel)
 	result.Data.Total = int32(len(eventSaleCowList))
 	result.Data.List = model.EventSaleCowSlice(eventSaleCowList).ToPB(eventSaleMap, cowKindMap, cowMap, sourceMap)
 	return result, nil
@@ -272,7 +272,7 @@ func (s *StoreEntry) CanSale(ctx context.Context, req *pasturePb.CanSalesReportR
 	if len(cowList) <= 0 {
 		return result, nil
 	}
-	cowKindMap := s.CowKindMap()
+	cowKindMap := s.CowKindMap(userModel)
 	result.Data.Total = int32(count)
 	result.Data.List = model.CowSlice(cowList).CanSaleToPB(cowKindMap)
 	return result, nil

+ 2 - 2
module/backend/neck_ring_warning.go

@@ -153,8 +153,8 @@ func (s *StoreEntry) NeckRingWarningHealthCowList(ctx context.Context, req *past
 		return nil, xerr.WithStack(err)
 	}
 
-	warningHealthLevelMap := s.WarningHealthLevelMap()
-	healthStatusMap := s.HealthStatusMap()
+	warningHealthLevelMap := s.WarningHealthLevelMap(userModel)
+	healthStatusMap := s.HealthStatusMap(userModel)
 	cowMap := make(map[int64]*model.Cow)
 	eventLogMap := make(map[int64]string)
 	cowIds := make([]int64, 0)

+ 30 - 8
module/backend/pasture.go

@@ -40,7 +40,7 @@ func (s *StoreEntry) SearchBarnList(ctx context.Context, req *pasturePb.SearchNa
 	}
 
 	//configBarnTypeList := make([]*model.ConfigPenType, 0)
-	barnTypeMap := s.BarnTypeMap()
+	barnTypeMap := s.BarnTypeMap(userModel)
 	return &pasturePb.SearchBarnResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -90,6 +90,11 @@ func (s *StoreEntry) CreateOrUpdateBarn(ctx context.Context, req *pasturePb.Sear
 }
 
 func (s *StoreEntry) SearchBarnTypeList(ctx context.Context, req *pasturePb.SearchNameRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchBaseConfigResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
 	barnTypeList := make([]*model.ConfigPenType, 0)
 	var count int64 = 0
 
@@ -107,7 +112,7 @@ func (s *StoreEntry) SearchBarnTypeList(ctx context.Context, req *pasturePb.Sear
 		Code: http.StatusOK,
 		Msg:  "ok",
 		Data: &pasturePb.SearchBaseConfigData{
-			List:     model.ConfigBarnTypeSlice(barnTypeList).ToPB(),
+			List:     model.ConfigBarnTypeSlice(barnTypeList).ToPB(userModel),
 			Total:    int32(count),
 			PageSize: pagination.PageSize,
 			Page:     pagination.Page,
@@ -159,7 +164,7 @@ func (s *StoreEntry) SearchBreedStatusList(ctx context.Context, req *pasturePb.S
 		Code: http.StatusOK,
 		Msg:  "ok",
 		Data: &pasturePb.SearchBaseConfigData{
-			List:     model.ConfigBreedStatusSlice(breedStatusList).ToPB(userModel.Language),
+			List:     model.ConfigBreedStatusSlice(breedStatusList).ToPB(userModel),
 			Total:    int32(count),
 			PageSize: pagination.PageSize,
 			Page:     pagination.Page,
@@ -190,6 +195,10 @@ func (s *StoreEntry) CreateOrUpdateBreedStatus(ctx context.Context, req *pasture
 }
 
 func (s *StoreEntry) SearchCowKindList(ctx context.Context, req *pasturePb.SearchNameRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchBaseConfigResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
 	configCowKindList := make([]*model.ConfigCowKind, 0)
 	var count int64 = 0
 
@@ -207,7 +216,7 @@ func (s *StoreEntry) SearchCowKindList(ctx context.Context, req *pasturePb.Searc
 		Code: http.StatusOK,
 		Msg:  "ok",
 		Data: &pasturePb.SearchBaseConfigData{
-			List:     model.ConfigCowKindSlice(configCowKindList).ToPB(),
+			List:     model.ConfigCowKindSlice(configCowKindList).ToPB(userModel),
 			Total:    int32(count),
 			PageSize: pagination.PageSize,
 			Page:     pagination.Page,
@@ -286,6 +295,11 @@ func (s *StoreEntry) CreateOrUpdateCowStatus(ctx context.Context, req *pasturePb
 }
 
 func (s *StoreEntry) SearchCowTypeList(ctx context.Context, req *pasturePb.SearchNameRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchBaseConfigResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
 	configCowTypeList := make([]*model.ConfigCowType, 0)
 	var count int64 = 0
 
@@ -303,7 +317,7 @@ func (s *StoreEntry) SearchCowTypeList(ctx context.Context, req *pasturePb.Searc
 		Code: http.StatusOK,
 		Msg:  "ok",
 		Data: &pasturePb.SearchBaseConfigData{
-			List:     model.ConfigCowTypeSlice(configCowTypeList).ToPB(),
+			List:     model.ConfigCowTypeSlice(configCowTypeList).ToPB(userModel),
 			Total:    int32(count),
 			PageSize: pagination.PageSize,
 			Page:     pagination.Page,
@@ -334,6 +348,10 @@ func (s *StoreEntry) CreateOrUpdateCowType(ctx context.Context, req *pasturePb.S
 }
 
 func (s *StoreEntry) SearchTransferPenReasonList(ctx context.Context, req *pasturePb.SearchNameRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchBaseConfigResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
 	configTransferPenReasonList := make([]*model.ConfigTransferPenReason, 0)
 	var count int64 = 0
 
@@ -342,7 +360,7 @@ func (s *StoreEntry) SearchTransferPenReasonList(ctx context.Context, req *pastu
 		pref.Where("name like ?", fmt.Sprintf("%s%s%s", "%", req.Name, "%"))
 	}
 
-	if err := pref.Order("id desc").Count(&count).Limit(int(pagination.PageSize)).Offset(int(pagination.PageOffset)).
+	if err = pref.Order("id desc").Count(&count).Limit(int(pagination.PageSize)).Offset(int(pagination.PageOffset)).
 		Find(&configTransferPenReasonList).Error; err != nil {
 		return nil, xerr.WithStack(err)
 	}
@@ -351,7 +369,7 @@ func (s *StoreEntry) SearchTransferPenReasonList(ctx context.Context, req *pastu
 		Code: http.StatusOK,
 		Msg:  "ok",
 		Data: &pasturePb.SearchBaseConfigData{
-			List:     model.ConfigTransferPenReasonSlice(configTransferPenReasonList).ToPB(),
+			List:     model.ConfigTransferPenReasonSlice(configTransferPenReasonList).ToPB(userModel),
 			Total:    int32(count),
 			PageSize: pagination.PageSize,
 			Page:     pagination.Page,
@@ -382,6 +400,10 @@ func (s *StoreEntry) CreateOrUpdateTransferPenReason(ctx context.Context, req *p
 }
 
 func (s *StoreEntry) SearchCowSourceList(ctx context.Context, req *pasturePb.SearchNameRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchBaseConfigResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
 	configCowSourceList := make([]*model.ConfigCowSource, 0)
 	var count int64 = 0
 
@@ -399,7 +421,7 @@ func (s *StoreEntry) SearchCowSourceList(ctx context.Context, req *pasturePb.Sea
 		Code: http.StatusOK,
 		Msg:  "ok",
 		Data: &pasturePb.SearchBaseConfigData{
-			List:     model.ConfigCowSourceSlice(configCowSourceList).ToPB(),
+			List:     model.ConfigCowSourceSlice(configCowSourceList).ToPB(userModel),
 			Total:    int32(count),
 			PageSize: pagination.PageSize,
 			Page:     pagination.Page,

+ 4 - 4
module/backend/prescription.go

@@ -68,8 +68,8 @@ func (s *StoreEntry) SearchSameTimeList(ctx context.Context, req *pasturePb.Sear
 		return nil, xerr.WithStack(err)
 	}
 
-	weekMap := s.WeekMap()
-	sameTimeCowTypeMap := s.SameTimeCowTypeMap()
+	weekMap := s.WeekMap(userModel)
+	sameTimeCowTypeMap := s.SameTimeCowTypeMap(userModel)
 	systemUser, _ := s.SystemUserList(ctx, pastureId)
 	return &pasturePb.SameTimeResponse{
 		Code: http.StatusOK,
@@ -453,8 +453,8 @@ func (s *StoreEntry) ImmunizationSetList(ctx context.Context, req *pasturePb.Imm
 		return nil, xerr.WithStack(err)
 	}
 
-	CowTypeOptions := s.ImmunizationCowTypeEnumList("")
-	conditionsOptions := s.ImmunizationConditionsEnumList("")
+	CowTypeOptions := s.ImmunizationCowTypeEnumList(userModel, "")
+	conditionsOptions := s.ImmunizationConditionsEnumList(userModel, "")
 	return &pasturePb.SearchImmunizationResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",

+ 3 - 0
module/backend/sql.go

@@ -32,6 +32,8 @@ func (s *StoreEntry) GetUserModel(ctx context.Context) (*model.UserModel, error)
 		return nil, xerr.WithStack(err)
 	}
 
+	currentUserLanguage := s.GetCurrentUserLanguage(ctx)
+
 	systemUserPastureIds := strings.Split(systemUser.PastureIds, ",")
 	if len(systemUserPastureIds) == 0 {
 		message, _ := i18nTemplate.Localize(&i18n.LocalizeConfig{
@@ -58,6 +60,7 @@ func (s *StoreEntry) GetUserModel(ctx context.Context) (*model.UserModel, error)
 		SystemUser:      systemUser,
 		AppPasture:      appPasture,
 		LanguageContent: i18nTemplate,
+		Language:        currentUserLanguage,
 	}, nil
 }
 

+ 5 - 1
module/backend/test_service.go

@@ -128,6 +128,10 @@ func (s *StoreEntry) UpdateCowPen(ctx context.Context, pagination *pasturePb.Pag
 }
 
 func (s *StoreEntry) PastureInit(ctx context.Context, pastureId int64) error {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return xerr.WithStack(err)
+	}
 	if pastureId <= 0 {
 		return xerr.New("pastureId invalid")
 	}
@@ -150,7 +154,7 @@ func (s *StoreEntry) PastureInit(ctx context.Context, pastureId int64) error {
 		return xerr.Customf("该牧场已初始化:%d", pastureId)
 	}
 
-	dataWaringTypeEnumList := s.DataWaringTypeEnumList("all")
+	dataWaringTypeEnumList := s.DataWaringTypeEnumList(userModel, "all")
 	dataWarningList := model.DataWarningInitData(pastureId, dataWaringTypeEnumList)
 
 	if err := s.DB.Transaction(func(tx *gorm.DB) error {

+ 12 - 7
module/backend/work.go

@@ -18,6 +18,11 @@ import (
 )
 
 func (s *StoreEntry) OrderList(ctx context.Context, req *pasturePb.SearchWorkOrderRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchWorkOrderResponse, error) {
+	userModel, err := s.GetUserModel(ctx)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
 	workOrderList := make([]*model.WorkOrderMaster, 0)
 	var count int64 = 0
 
@@ -51,11 +56,11 @@ func (s *StoreEntry) OrderList(ctx context.Context, req *pasturePb.SearchWorkOrd
 		return nil, xerr.WithStack(err)
 	}
 
-	priorityMap := s.WorkOrderPriorityMap()
-	frequencyMap := s.WorkOrderFrequencyMap()
-	subscribeUnitMap := s.WorkOrderSubUnitMap()
-	weekMap := s.WeekMap()
-	monthMap := s.MonthMap()
+	priorityMap := s.WorkOrderPriorityMap(userModel)
+	frequencyMap := s.WorkOrderFrequencyMap(userModel)
+	subscribeUnitMap := s.WorkOrderSubUnitMap(userModel)
+	weekMap := s.WeekMap(userModel)
+	monthMap := s.MonthMap(userModel)
 	return &pasturePb.SearchWorkOrderResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -76,7 +81,7 @@ func (s *StoreEntry) OrderCreateOrUpdate(ctx context.Context, req *pasturePb.Wor
 	if err != nil {
 		return xerr.WithStack(err)
 	}
-	workOrderCategoryMap := s.WorkOrderCategoryMap()
+	workOrderCategoryMap := s.WorkOrderCategoryMap(userModel)
 	systemUserList, _ := s.SystemUserList(ctx, userModel.AppPasture.Id)
 	newWorkOrderMaster := model.NewWorkOrderMaster(userModel.AppPasture.Id, req, userModel.SystemUser, systemUserList, workOrderCategoryMap)
 	if req.Id <= 0 {
@@ -278,7 +283,7 @@ func (s *StoreEntry) UserWorkOrderList(ctx context.Context, workOrderStatus past
 		mMap[workOrderMaster.Id] = workOrderMaster
 	}
 
-	priorityMap := s.WorkOrderPriorityMap()
+	priorityMap := s.WorkOrderPriorityMap(userModel)
 
 	return &pasturePb.UserWorkOrderResponse{
 		Code: http.StatusOK,