system_basic.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. const (
  4. ProactivelyStopBreedingForBackup = "proactively_stop_breeding_for_backup" // 后备牛主动停配
  5. ProactivelyStopBreedingForAdult = "proactively_stop_breeding_for_adult" // 成母牛主动停配
  6. PregnantCheckForFirst = "pregnant_check_for_first" // 初检
  7. PregnantCheckForSecond = "pregnant_check_for_second" // 复检
  8. PregnancyAge = "pregnancy_age" // 怀孕天数
  9. WeaningAge = "weaning_age" // 断奶天数
  10. EstrusWaringDays = "estrus_waring_days" // 发情预警产后天数
  11. DryMilkAge = "dry_milk_age" // 干奶
  12. ValueTypeFixed = 1 // 固定值
  13. ValueTypeRange = 2 // 范围值
  14. SourcePC = "PC"
  15. SourceApp = "MINI"
  16. )
  17. var PregnantCheckNameKeyMap = map[string]string{
  18. PregnantCheckForFirst: "初检",
  19. PregnantCheckForSecond: "复检",
  20. }
  21. var PregnantCheckNameValueMap = map[int32]string{
  22. 1: "pregnant_check_for_first",
  23. 2: "pregnant_check_for_second",
  24. }
  25. type SystemBasic struct {
  26. Id int32 `json:"id"`
  27. PastureId int64 `json:"pastureId"`
  28. Name string `json:"name"`
  29. CategoryName string `json:"categoryName"`
  30. CategoryId pasturePb.BasicDataCategory_Kind `json:"categoryId"`
  31. MinValue int32 `json:"minValue"`
  32. MaxValue int32 `json:"maxValue"`
  33. WeekValue pasturePb.Week_Kind `json:"weekValue"`
  34. ValueType pasturePb.ValueType_Kind `json:"valueType"`
  35. Remarks string `json:"remarks"`
  36. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  37. OperationId int32 `json:"operationId"`
  38. OperationName string `json:"operationName"`
  39. CreatedAt int64 `json:"createdAt"`
  40. UpdatedAt int64 `json:"updatedAt"`
  41. }
  42. func (s *SystemBasic) TableName() string {
  43. return "system_basic"
  44. }
  45. func (s *SystemBasic) EditUpdate(minValue, maxValue int32, weekValue pasturePb.Week_Kind, currentUser *SystemUser) {
  46. s.MinValue = minValue
  47. s.MaxValue = maxValue
  48. if s.WeekValue > -1 {
  49. s.WeekValue = weekValue
  50. }
  51. s.OperationId = int32(currentUser.Id)
  52. s.OperationName = currentUser.Name
  53. }
  54. type SystemBasicSlice []*SystemBasic
  55. func (s SystemBasicSlice) ToPb() []*pasturePb.BaseDataConfig {
  56. res := make([]*pasturePb.BaseDataConfig, len(s))
  57. for i, v := range s {
  58. res[i] = &pasturePb.BaseDataConfig{
  59. Id: v.Id,
  60. Name: v.Name,
  61. CategoryName: v.CategoryName,
  62. CategoryId: v.CategoryId,
  63. MinValue: v.MinValue,
  64. MaxValue: v.MaxValue,
  65. WeekValue: v.WeekValue,
  66. ValueType: v.ValueType,
  67. Remarks: v.Remarks,
  68. CreatedAt: int32(v.CreatedAt),
  69. UpdatedAt: int32(v.UpdatedAt),
  70. }
  71. }
  72. return res
  73. }