subject.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package model
  2. import (
  3. "go-common/library/time"
  4. )
  5. // All const variable used in dm subject
  6. const (
  7. SubTypeVideo = int32(1) // 主题类型
  8. SubStateOpen = int32(0) // 主题打开
  9. SubStateClosed = int32(1) // 主题关闭
  10. AttrSubGuest = uint(0) // 允许游客弹幕
  11. AttrSubSpolier = uint(1) // 允许剧透弹幕
  12. AttrSubMission = uint(2) // 允许活动弹幕
  13. AttrSubAdvance = uint(3) // 允许高级弹幕
  14. // StateProtect protected dm
  15. StateProtect = 2
  16. )
  17. // Subject dm_subject
  18. type Subject struct {
  19. ID int64 `json:"id"`
  20. Type int32 `json:"type"`
  21. Oid int64 `json:"oid"`
  22. Pid int64 `json:"pid"`
  23. Mid int64 `json:"mid"`
  24. State int32 `json:"state"`
  25. Attr int32 `json:"attr"`
  26. ACount int64 `json:"acount"`
  27. Count int64 `json:"count"`
  28. MCount int64 `json:"mcount"`
  29. MoveCnt int64 `json:"move_count"`
  30. Maxlimit int64 `json:"maxlimit"`
  31. Childpool int32 `json:"childpool"`
  32. Ctime time.Time `json:"ctime"`
  33. Mtime time.Time `json:"mtime"`
  34. }
  35. // AttrVal return val of subject'attr
  36. func (s *Subject) AttrVal(bit uint) int32 {
  37. return (s.Attr >> bit) & int32(1)
  38. }
  39. // AttrSet set val of subject'attr
  40. func (s *Subject) AttrSet(v int32, bit uint) {
  41. s.Attr = s.Attr&(^(1 << bit)) | (v << bit)
  42. }