audience.go 779 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package jpushclient
  2. const (
  3. TAG = "tag"
  4. TAG_AND = "tag_and"
  5. ALIAS = "alias"
  6. ID = "registration_id"
  7. )
  8. type Audience struct {
  9. Object interface{}
  10. audience map[string][]string
  11. }
  12. func (this *Audience) All() {
  13. this.Object = "all"
  14. }
  15. func (this *Audience) SetID(ids []string) {
  16. this.set(ID, ids)
  17. }
  18. func (this *Audience) SetTag(tags []string) {
  19. this.set(TAG, tags)
  20. }
  21. func (this *Audience) SetTagAnd(tags []string) {
  22. this.set(TAG_AND, tags)
  23. }
  24. func (this *Audience) SetAlias(alias []string) {
  25. this.set(ALIAS, alias)
  26. }
  27. func (this *Audience) set(key string, v []string) {
  28. if this.audience == nil {
  29. this.audience = make(map[string][]string)
  30. this.Object = this.audience
  31. }
  32. //v, ok = this.audience[key]
  33. //if ok {
  34. // return
  35. //}
  36. this.audience[key] = v
  37. }