favorite.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package favorite
  2. import (
  3. "context"
  4. "go-common/app/service/main/favorite/model"
  5. "go-common/library/net/rpc"
  6. )
  7. const (
  8. _allFolders = "RPC.AllFolders"
  9. _folder = "RPC.Folder"
  10. _folders = "RPC.Folders"
  11. _addFolder = "RPC.AddFolder"
  12. _delFolder = "RPC.DelFolder"
  13. _updateFolder = "RPC.UpdateFolder"
  14. _favorites = "RPC.Favorites"
  15. _add = "RPC.Add"
  16. _del = "RPC.Del"
  17. _multiAdd = "RPC.MultiAdd"
  18. _multiDel = "RPC.MultiDel"
  19. _isFav = "RPC.IsFav"
  20. _isFavs = "RPC.IsFavs"
  21. _isInDefault = "RPC.InDefault"
  22. _isFavedByFid = "RPC.IsFavedByFid"
  23. _cntUserFolders = "RPC.CntUserFolders"
  24. _users = "RPC.Users"
  25. _tlists = "RPC.Tlists"
  26. _recents = "RPC.Recents"
  27. // fav v2
  28. _addVideo = "RPC.AddVideo"
  29. )
  30. const (
  31. _appid = "community.service.favorite"
  32. )
  33. var (
  34. _noRes = &struct{}{}
  35. )
  36. type Service struct {
  37. client *rpc.Client2
  38. }
  39. func New2(c *rpc.ClientConfig) (s *Service) {
  40. s = &Service{}
  41. s.client = rpc.NewDiscoveryCli(_appid, c)
  42. return
  43. }
  44. func (s *Service) AllFolders(c context.Context, arg *model.ArgAllFolders) (res []*model.Folder, err error) {
  45. err = s.client.Call(c, _allFolders, arg, &res)
  46. return
  47. }
  48. func (s *Service) Folder(c context.Context, arg *model.ArgFolder) (res *model.Folder, err error) {
  49. err = s.client.Call(c, _folder, arg, &res)
  50. return
  51. }
  52. func (s *Service) Folders(c context.Context, arg *model.ArgFolders) (res []*model.Folder, err error) {
  53. err = s.client.Call(c, _folders, arg, &res)
  54. return
  55. }
  56. func (s *Service) AddFolder(c context.Context, arg *model.ArgAddFolder) (fid int64, err error) {
  57. err = s.client.Call(c, _addFolder, arg, &fid)
  58. return
  59. }
  60. func (s *Service) UpdateFolder(c context.Context, arg *model.ArgUpdateFolder) (err error) {
  61. err = s.client.Call(c, _updateFolder, arg, _noRes)
  62. return
  63. }
  64. func (s *Service) DelFolder(c context.Context, arg *model.ArgDelFolder) (err error) {
  65. err = s.client.Call(c, _delFolder, arg, _noRes)
  66. return
  67. }
  68. func (s *Service) Favorites(c context.Context, arg *model.ArgFavs) (res *model.Favorites, err error) {
  69. err = s.client.Call(c, _favorites, arg, &res)
  70. return
  71. }
  72. func (s *Service) Add(c context.Context, arg *model.ArgAdd) (err error) {
  73. err = s.client.Call(c, _add, arg, _noRes)
  74. return
  75. }
  76. func (s *Service) Del(c context.Context, arg *model.ArgDel) (err error) {
  77. err = s.client.Call(c, _del, arg, _noRes)
  78. return
  79. }
  80. func (s *Service) MultiAdd(c context.Context, arg *model.ArgMultiAdd) (err error) {
  81. err = s.client.Call(c, _multiAdd, arg, _noRes)
  82. return
  83. }
  84. func (s *Service) MultiDel(c context.Context, arg *model.ArgMultiDel) (err error) {
  85. err = s.client.Call(c, _multiDel, arg, _noRes)
  86. return
  87. }
  88. func (s *Service) InDefault(c context.Context, arg *model.ArgInDefaultFolder) (faved bool, err error) {
  89. err = s.client.Call(c, _isInDefault, arg, &faved)
  90. return
  91. }
  92. func (s *Service) IsFav(c context.Context, arg *model.ArgIsFav) (faved bool, err error) {
  93. err = s.client.Call(c, _isFav, arg, &faved)
  94. return
  95. }
  96. func (s *Service) IsFavedByFid(c context.Context, arg *model.ArgIsFavedByFid) (faved bool, err error) {
  97. err = s.client.Call(c, _isFavedByFid, arg, &faved)
  98. return
  99. }
  100. func (s *Service) CntUserFolders(c context.Context, arg *model.ArgCntUserFolders) (count int, err error) {
  101. err = s.client.Call(c, _cntUserFolders, arg, &count)
  102. return
  103. }
  104. func (s *Service) Users(c context.Context, arg *model.ArgUsers) (res *model.UserList, err error) {
  105. err = s.client.Call(c, _users, arg, &res)
  106. return
  107. }
  108. // AddVideo add video fav.
  109. func (s *Service) AddVideo(c context.Context, arg *model.ArgAddVideo) (err error) {
  110. err = s.client.Call(c, _addVideo, arg, _noRes)
  111. return
  112. }
  113. // IsFavs .
  114. func (s *Service) IsFavs(c context.Context, arg *model.ArgIsFavs) (res map[int64]bool, err error) {
  115. err = s.client.Call(c, _isFavs, arg, &res)
  116. return
  117. }
  118. func (s *Service) Tlists(c context.Context, arg *model.ArgTlists) (res []*model.Partition, err error) {
  119. err = s.client.Call(c, _tlists, arg, &res)
  120. return
  121. }
  122. func (s *Service) Recents(c context.Context, arg *model.ArgRecents) (res []int64, err error) {
  123. err = s.client.Call(c, _recents, arg, &res)
  124. return
  125. }