up_switch.go 684 B

123456789101112131415161718192021222324252627282930313233
  1. package model
  2. const (
  3. // Open is open switch
  4. Open = 1
  5. // Close is close switch
  6. Close = 0
  7. )
  8. //UpSwitch for db.
  9. type UpSwitch struct {
  10. ID int64 `json:"id"`
  11. MID int64 `json:"mid"`
  12. Attribute int `json:"attribute"`
  13. }
  14. // AttrSet set attribute.
  15. func (u *UpSwitch) AttrSet(v int, bit uint8) {
  16. u.Attribute = u.Attribute&(^(1 << bit)) | (v << bit)
  17. }
  18. // AttrVal get attribute.
  19. func (u *UpSwitch) AttrVal(bit uint8) int {
  20. return (u.Attribute >> bit) & int(1)
  21. }
  22. // Const State
  23. const (
  24. // AttrPlayer flow up window 's switch of attribute bit
  25. AttrPlayer = uint8(0)
  26. // AttrHonorWeekly honor weekly subscription 's switch of attribute bit
  27. AttrHonorWeekly = uint8(1)
  28. )