archive_result.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package archive
  2. // Result is archive model.
  3. type Result struct {
  4. Aid int64 `json:"aid"`
  5. Mid int64 `json:"mid"`
  6. TypeID int16 `json:"tid"`
  7. Title string `json:"title"`
  8. Author string `json:"author"`
  9. Cover string `json:"cover"`
  10. Tag string `json:"tag"`
  11. Duration int64 `json:"duration"`
  12. Copyright int8 `json:"copyright"`
  13. Desc string `json:"desc"`
  14. Round int8 `json:"round"`
  15. Forward int64 `json:"forward"`
  16. Attribute int32 `json:"attribute"`
  17. HumanRank int `json:"humanrank"`
  18. Access int16 `json:"access"`
  19. State int8 `json:"state"`
  20. Reason string `json:"reject_reason"`
  21. PTime string `json:"ptime"`
  22. CTime string `json:"ctime"`
  23. MTime string `json:"mtime"`
  24. Dynamic string `json:"dynamic"`
  25. }
  26. // IsNormal check archive is open.
  27. func (a *Result) IsNormal() bool {
  28. return a.State >= StateOpen || a.State == StateForbidFixed
  29. }
  30. // NotAllowUp check archive is or not allow update state.
  31. func (a *Result) NotAllowUp() bool {
  32. return a.State == StateForbidUpDelete || a.State == StateForbidLater || a.State == StateForbidLock || a.State == StateForbidPolice
  33. }
  34. // IsForbid check archive state forbid by admin or delete.
  35. func (a *Result) IsForbid() bool {
  36. return a.State == StateForbidUpDelete || a.State == StateForbidRecicle || a.State == StateForbidPolice || a.State == StateForbidLock || a.State == StateForbidLater || a.State == StateForbidXcodeFail
  37. }
  38. // AttrVal get attribute value.
  39. func (a *Result) AttrVal(bit uint) int32 {
  40. return (a.Attribute >> bit) & int32(1)
  41. }
  42. // AttrSet set attribute value.
  43. func (a *Result) AttrSet(v int32, bit uint) {
  44. a.Attribute = a.Attribute&(^(1 << bit)) | (v << bit)
  45. }
  46. // WithAttr set attribute value with a attr value.
  47. func (a *Result) WithAttr(attr Attr) {
  48. a.Attribute = a.Attribute | int32(attr)
  49. }