dm.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package client
  2. import (
  3. "context"
  4. "go-common/app/interface/main/dm2/model"
  5. "go-common/library/net/rpc"
  6. )
  7. const (
  8. _subjectInfos = "RPC.SubjectInfos"
  9. _editDMState = "RPC.EditDMState"
  10. _editDMPool = "RPC.EditDMPool"
  11. _editDMAttr = "RPC.EditDMAttr"
  12. _addUserFilters = "RPC.AddUserFilters"
  13. _userFilters = "RPC.UserFilters"
  14. _delUserFilters = "RPC.DelUserFilters"
  15. _addUpFilters = "RPC.AddUpFilters"
  16. _upFilters = "RPC.UpFilters"
  17. _banUsers = "RPC.BanUsers"
  18. _cancelBanUsers = "RPC.CancelBanUsers"
  19. _editUpFilters = "RPC.EditUpFilters"
  20. _addGblFilter = "RPC.AddGlobalFilter"
  21. _globalFilters = "RPC.GlobalFilters"
  22. _delGlbFilters = "RPC.DelGlobalFilters"
  23. )
  24. const (
  25. _appid = "community.service.dm"
  26. )
  27. var (
  28. _noArg = &struct{}{}
  29. )
  30. // Service dm rpc client.
  31. type Service struct {
  32. client *rpc.Client2
  33. }
  34. // New new a dm rpc client.
  35. func New(c *rpc.ClientConfig) (s *Service) {
  36. s = &Service{}
  37. s.client = rpc.NewDiscoveryCli(_appid, c)
  38. return
  39. }
  40. // SubjectInfos multi get dm subject info by type and oids.
  41. func (s *Service) SubjectInfos(c context.Context, arg *model.ArgOids) (res map[int64]*model.SubjectInfo, err error) {
  42. err = s.client.Call(c, _subjectInfos, arg, &res)
  43. return
  44. }
  45. // EditDMState update dm state.
  46. // 0:正常、1:删除10:用户删除、11:举报脚本删除
  47. func (s *Service) EditDMState(c context.Context, arg *model.ArgEditDMState) (err error) {
  48. err = s.client.Call(c, _editDMState, arg, _noArg)
  49. return
  50. }
  51. // EditDMAttr update dm attr.
  52. func (s *Service) EditDMAttr(c context.Context, arg *model.ArgEditDMAttr) (err error) {
  53. err = s.client.Call(c, _editDMAttr, arg, _noArg)
  54. return
  55. }
  56. // EditDMPool update dm pool.
  57. // 0:普通弹幕池、1:字幕弹幕池
  58. func (s *Service) EditDMPool(c context.Context, arg *model.ArgEditDMPool) (err error) {
  59. err = s.client.Call(c, _editDMPool, arg, _noArg)
  60. return
  61. }
  62. // AddUserFilters add user filter.
  63. func (s *Service) AddUserFilters(c context.Context, arg *model.ArgAddUserFilters) (res []*model.UserFilter, err error) {
  64. err = s.client.Call(c, _addUserFilters, arg, &res)
  65. return
  66. }
  67. // UserFilters multi get user filters.
  68. func (s *Service) UserFilters(c context.Context, arg *model.ArgMid) (res []*model.UserFilter, err error) {
  69. err = s.client.Call(c, _userFilters, arg, &res)
  70. return
  71. }
  72. // DelUserFilters delete user filters by filter id.
  73. func (s *Service) DelUserFilters(c context.Context, arg *model.ArgDelUserFilters) (affect int64, err error) {
  74. err = s.client.Call(c, _delUserFilters, arg, &affect)
  75. return
  76. }
  77. // AddUpFilters add up filters.
  78. func (s *Service) AddUpFilters(c context.Context, arg *model.ArgAddUpFilters) (err error) {
  79. err = s.client.Call(c, _addUpFilters, arg, &_noArg)
  80. return
  81. }
  82. // UpFilters multi get up filters.
  83. func (s *Service) UpFilters(c context.Context, arg *model.ArgUpFilters) (res []*model.UpFilter, err error) {
  84. err = s.client.Call(c, _upFilters, arg, &res)
  85. return
  86. }
  87. // BanUsers ban user by upper or assist.
  88. func (s *Service) BanUsers(c context.Context, arg *model.ArgBanUsers) (err error) {
  89. err = s.client.Call(c, _banUsers, arg, &_noArg)
  90. return
  91. }
  92. // CancelBanUsers cancel users by upper or assiat.
  93. func (s *Service) CancelBanUsers(c context.Context, arg *model.ArgCancelBanUsers) (err error) {
  94. err = s.client.Call(c, _cancelBanUsers, arg, &_noArg)
  95. return
  96. }
  97. // EditUpFilters edit upper filters.
  98. func (s *Service) EditUpFilters(c context.Context, arg *model.ArgEditUpFilters) (affect int64, err error) {
  99. err = s.client.Call(c, _editUpFilters, arg, &affect)
  100. return
  101. }
  102. // AddGlobalFilter add global filters.
  103. func (s *Service) AddGlobalFilter(c context.Context, arg *model.ArgAddGlobalFilter) (res *model.GlobalFilter, err error) {
  104. err = s.client.Call(c, _addGblFilter, arg, &res)
  105. return
  106. }
  107. // GlobalFilters multi get global filters.
  108. func (s *Service) GlobalFilters(c context.Context, arg *model.ArgGlobalFilters) (res []*model.GlobalFilter, err error) {
  109. err = s.client.Call(c, _globalFilters, arg, &res)
  110. return
  111. }
  112. // DelGlobalFilters delete global filter.
  113. func (s *Service) DelGlobalFilters(c context.Context, arg *model.ArgDelGlobalFilters) (affect int64, err error) {
  114. err = s.client.Call(c, _delGlbFilters, arg, &affect)
  115. return
  116. }