system_basic.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. ValueTypeFixed = 1 // 固定值
  11. ValueTypeRange = 2 // 范围值
  12. SourcePC = "PC"
  13. SourceApp = "MINI"
  14. )
  15. var PregnantCheckNameKeyMap = map[string]string{
  16. PregnantCheckForFirst: "初检",
  17. PregnantCheckForSecond: "复检",
  18. }
  19. var PregnantCheckNameValueMap = map[int32]string{
  20. 1: "pregnant_check_for_first",
  21. 2: "pregnant_check_for_second",
  22. }
  23. type SystemBasic struct {
  24. Id int32 `json:"id"`
  25. PastureId int64 `json:"pastureId"`
  26. Name string `json:"name"`
  27. CategoryName string `json:"categoryName"`
  28. CategoryId int32 `json:"categoryId"`
  29. MinValue int32 `json:"minValue"`
  30. MaxValue int32 `json:"maxValue"`
  31. WeekValue pasturePb.Week_Kind `json:"weekValue"`
  32. ValueType pasturePb.ValueType_Kind `json:"valueType"`
  33. Remarks string `json:"remarks"`
  34. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  35. OperationId int32 `json:"operationId"`
  36. OperationName string `json:"operationName"`
  37. CreatedAt int64 `json:"createdAt"`
  38. UpdatedAt int64 `json:"updatedAt"`
  39. }
  40. func (s *SystemBasic) TableName() string {
  41. return "system_basic"
  42. }
  43. func (s *SystemBasic) EditUpdate(pastureId int64, minValue, maxValue int32, weekValue pasturePb.Week_Kind, currentUser *SystemUser) {
  44. s.MinValue = minValue
  45. s.MaxValue = maxValue
  46. if s.WeekValue > -1 {
  47. s.WeekValue = weekValue
  48. }
  49. s.OperationId = int32(currentUser.Id)
  50. s.OperationName = currentUser.Name
  51. }
  52. type SystemBasicSlice []*SystemBasic
  53. func (s SystemBasicSlice) ToPb() []*pasturePb.BaseDataConfig {
  54. res := make([]*pasturePb.BaseDataConfig, len(s))
  55. for i, v := range s {
  56. res[i] = &pasturePb.BaseDataConfig{
  57. Id: v.Id,
  58. Name: v.Name,
  59. CategoryName: v.CategoryName,
  60. CategoryId: pasturePb.BasicDataCategory_Kind(v.CategoryId),
  61. MinValue: v.MinValue,
  62. MaxValue: v.MaxValue,
  63. WeekValue: v.WeekValue,
  64. ValueType: v.ValueType,
  65. Remarks: v.Remarks,
  66. CreatedAt: int32(v.CreatedAt),
  67. UpdatedAt: int32(v.UpdatedAt),
  68. }
  69. }
  70. return res
  71. }