appointment.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package specialAPIModels
  2. import (
  3. I "devel.mephi.ru/dyokunev/wwwvoip/app/iface"
  4. "github.com/revel/revel"
  5. "voip/app/models"
  6. )
  7. type Appointment struct {
  8. common
  9. PersonId int `json:"person_id,omitempty"`
  10. UnitId int `json:"unit_id,omitempty"`
  11. Name string `json:",omitempty"`
  12. Line string `json:",omitempty"`
  13. Description string `json:",omitempty"`
  14. Room string `json:",omitempty"`
  15. }
  16. type Appointments []Appointment
  17. func (appointments *Appointments) IConvert(apiHost string, affiliateUnit *models.Unit) (I.Slice, error) {
  18. var convertedAppointments models.Appointments
  19. for idx := range *appointments {
  20. appointment := &(*appointments)[idx]
  21. revel.TRACE.Printf("appointment == %v", appointment)
  22. var convertedAppointment models.Appointment
  23. {
  24. personId := appointment.PersonId
  25. unitId := appointment.UnitId
  26. appointmentId := appointment.Id
  27. convertedAppointment = models.Appointment{
  28. SourceAPIHost: &apiHost,
  29. SpecialAPIId: &appointmentId,
  30. SpecialAPIPersonId: &personId,
  31. SpecialAPIUnitId: &unitId,
  32. Name: appointment.Name,
  33. Description: appointment.Description,
  34. LineKey: appointment.Line,
  35. RoomKey: models.Room{RootUnitKey: (*affiliateUnit).CodeStr, Name: appointment.Room}.GetRoomKey(),
  36. StfCardId: -(affiliateUnit.Code.Mid*100000 + appointment.Id%100000),
  37. SecurityLevel0: -50,
  38. SecurityLevel1: -50,
  39. }
  40. }
  41. if convertedAppointment.LineKey == "" {
  42. convertedAppointment.SecurityLevel0 = 111
  43. convertedAppointment.SecurityLevel1 = 111
  44. }
  45. convertedAppointments = append(convertedAppointments, convertedAppointment)
  46. }
  47. return convertedAppointments, nil
  48. }