pass.go 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //go:generate reform
  2. //go:generate easyjson -all pass.go
  3. package models
  4. //reform:events_users_view
  5. type Pass struct {
  6. Id int `reform:"UserId"`
  7. Firstname string `reform:"Firstname"`
  8. Lastname string `reform:"Lastname"`
  9. Patronymic *string `reform:"Patronymic"`
  10. PhotoId int `reform:"PhotoID"`
  11. PersonId *int `reform:"person_id"`
  12. EmpGUID *int `reform:"EmpGUID"`
  13. //IsActual bool `reform:"is_actual"`
  14. }
  15. func (pass *Pass) AfterFind() error {
  16. return nil
  17. }
  18. func (pass Pass) PatronymicSafe() string {
  19. if pass.Patronymic == nil {
  20. return ""
  21. }
  22. return *pass.Patronymic
  23. }
  24. func (pass Pass) FixOkRow() *FixOkRow {
  25. var empGUID int
  26. if pass.EmpGUID == nil {
  27. empGUID = 0
  28. } else {
  29. empGUID = *pass.EmpGUID
  30. }
  31. return &FixOkRow{
  32. Id: pass.Id,
  33. EmpGUID: empGUID,
  34. }
  35. }
  36. type Passes []Pass
  37. func (passes Passes) ToMap() map[int]*Pass {
  38. passMap := map[int]*Pass{}
  39. for idx, pass := range passes {
  40. passMap[pass.Id] = &passes[idx]
  41. }
  42. return passMap
  43. }