model.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package model
  2. //RecPoolConf 投放配置
  3. type RecPoolConf struct {
  4. ID int64 `json:"id"`
  5. Name string `json:"name"`
  6. Type int64 `json:"type"`
  7. Rule string `json:"rules"`
  8. Priority int64 `json:"priority"`
  9. Percent float64 `json:"percent"`
  10. TruePercent float64 `json:"true_percent"`
  11. ModuleType int64 `json:"module_type"`
  12. Position int64 `json:"position"`
  13. }
  14. //RecRoomInfo 房间信息
  15. type RecRoomInfo struct {
  16. Uid int64 `json:"uid"`
  17. Title string `json:"title"`
  18. PopularityCount int64 `json:"popularity_count"`
  19. KeyFrame string `josn:"Keyframe"`
  20. Cover string `josn:"cover"`
  21. ParentAreaID int64 `json:"parent_area_id"`
  22. ParentAreaName string `json:"parent_area_name"`
  23. AreaID int64 `json:"area_id"`
  24. AreaName string `josn:"area_name"`
  25. }
  26. //NewRecPoolConf 创建
  27. func NewRecPoolConf() *RecPoolConf {
  28. return &RecPoolConf{}
  29. }
  30. //NewRecRoomInfo 创建
  31. func NewRecRoomInfo() *RecRoomInfo {
  32. return &RecRoomInfo{}
  33. }
  34. //RecPoolSlice 配置
  35. type RecPoolSlice []*RecPoolConf
  36. //Len 返回长度
  37. func (R RecPoolSlice) Len() int {
  38. return len(R)
  39. }
  40. //Less 根据优先级降序排序
  41. func (R RecPoolSlice) Less(i, j int) bool {
  42. return R[i].Priority > R[j].Priority
  43. }
  44. //Swap 交换数据
  45. func (R RecPoolSlice) Swap(i, j int) {
  46. R[i], R[j] = R[j], R[i]
  47. }