data.go 805 B

1234567891011121314151617181920212223242526272829303132
  1. package v1
  2. import (
  3. "encoding/json"
  4. v1pb "go-common/app/interface/live/app-room/api/http/v1"
  5. "go-common/app/interface/live/app-room/model"
  6. )
  7. //HistoryData 历史数据处理
  8. func HistoryData(data *v1pb.HistoryResp) map[string][]*model.History {
  9. var result = make(map[string][]*model.History)
  10. result["admin"] = make([]*model.History, 0, 10)
  11. result["room"] = make([]*model.History, 0, 10)
  12. for i := 0; i < len(data.Admin); i++ {
  13. var h = &model.History{}
  14. err := json.Unmarshal([]byte(data.Admin[i]), h)
  15. if err != nil {
  16. break
  17. }
  18. result["admin"] = append(result["admin"], h)
  19. }
  20. for i := 0; i < len(data.Room); i++ {
  21. var h = &model.History{}
  22. err := json.Unmarshal([]byte(data.Room[i]), h)
  23. if err != nil {
  24. break
  25. }
  26. result["room"] = append(result["room"], h)
  27. }
  28. return result
  29. }