space.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. package space
  2. import (
  3. "context"
  4. "strconv"
  5. "time"
  6. "go-common/app/interface/main/app-interface/model"
  7. "go-common/app/interface/main/app-interface/model/audio"
  8. "go-common/app/interface/main/app-interface/model/bangumi"
  9. "go-common/app/interface/main/app-interface/model/bplus"
  10. "go-common/app/interface/main/app-interface/model/community"
  11. "go-common/app/interface/main/app-interface/model/favorite"
  12. "go-common/app/interface/main/app-interface/model/shop"
  13. "go-common/app/interface/main/app-interface/model/space"
  14. article "go-common/app/interface/openplatform/article/model"
  15. account "go-common/app/service/main/account/model"
  16. "go-common/app/service/main/archive/api"
  17. thumbup "go-common/app/service/main/thumbup/model"
  18. "go-common/library/ecode"
  19. "go-common/library/log"
  20. "go-common/library/sync/errgroup"
  21. "github.com/pkg/errors"
  22. )
  23. const (
  24. _shopName = "的店铺"
  25. _businessLike = "archive"
  26. )
  27. // Space aggregation space data.
  28. func (s *Service) Space(c context.Context, mid, vmid int64, plat int8, build int, pn, ps int, platform, device, mobiApp, name string, now time.Time) (sp *space.Space, err error) {
  29. if _, ok := s.BlackList[vmid]; ok {
  30. err = ecode.NothingFound
  31. return
  32. }
  33. sp = &space.Space{}
  34. // get card
  35. card, err := s.card(c, vmid, name)
  36. if err != nil {
  37. if ecode.String(errors.Cause(err).Error()) == ecode.UserNotExist || vmid < 1 {
  38. err = ecode.NothingFound
  39. return
  40. }
  41. sp.Card = &space.Card{Mid: strconv.FormatInt(vmid, 10)}
  42. log.Error("%+v", err)
  43. } else if card == nil {
  44. log.Warn("space mid(%d) vmid(%d) name(%s) plat(%s) device(%s) card is nil", mid, vmid, name, platform, device)
  45. err = ecode.NothingFound
  46. return
  47. } else {
  48. if card.Mid == "" {
  49. err = ecode.NothingFound
  50. return
  51. }
  52. if vmid > 0 && card.Mid != strconv.FormatInt(vmid, 10) {
  53. err = ecode.NothingFound
  54. return
  55. }
  56. if vmid < 1 {
  57. if vmid, _ = strconv.ParseInt(card.Mid, 10, 64); vmid < 1 {
  58. err = ecode.NothingFound
  59. return
  60. }
  61. }
  62. sp.Card = card
  63. // ignore some card field
  64. sp.Card.Rank = ""
  65. sp.Card.DisplayRank = ""
  66. sp.Card.Regtime = 0
  67. sp.Card.Spacesta = 0
  68. sp.Card.Birthday = ""
  69. sp.Card.Place = ""
  70. sp.Card.Article = 0
  71. sp.Card.Friend = 0
  72. sp.Card.Attentions = nil
  73. sp.Card.Pendant.Pid = 0
  74. sp.Card.Pendant.Image = ""
  75. sp.Card.Pendant.Expire = 0
  76. sp.Card.Nameplate.Nid = 0
  77. sp.Card.Nameplate.Name = ""
  78. sp.Card.Nameplate.Image = ""
  79. sp.Card.Nameplate.ImageSmall = ""
  80. sp.Card.Nameplate.Level = ""
  81. sp.Card.Nameplate.Condition = ""
  82. }
  83. // space
  84. g, ctx := errgroup.WithContext(c)
  85. g.Go(func() error {
  86. sp.Space, _ = s.spcDao.SpaceMob(ctx, mid, vmid, platform, device)
  87. return nil
  88. })
  89. g.Go(func() error {
  90. sp.Card.FansGroup, _ = s.bplusDao.GroupsCount(ctx, mid, vmid)
  91. return nil
  92. })
  93. g.Go(func() (err error) {
  94. cardm, err := s.audioDao.Card(ctx, vmid)
  95. if err != nil {
  96. log.Error("%+v", err)
  97. err = nil
  98. return
  99. }
  100. if card, ok := cardm[vmid]; ok && card.Type == 1 && card.Status == 1 {
  101. sp.Card.Audio = 1
  102. }
  103. return
  104. })
  105. if vmid == mid {
  106. g.Go(func() (err error) {
  107. if sp.Card.FansUnread, err = s.relDao.FollowersUnread(ctx, vmid); err != nil {
  108. log.Error("%+v", err)
  109. err = nil
  110. }
  111. return
  112. })
  113. }
  114. g.Go(func() (err error) {
  115. cert, err := s.audioDao.UpperCert(ctx, vmid)
  116. if err != nil {
  117. log.Error("%+v", err)
  118. err = nil
  119. return
  120. }
  121. if cert == nil || cert.Cert == nil || cert.Cert.Type == -1 || cert.Cert.Desc == "" {
  122. return
  123. }
  124. if sp.Card.OfficialVerify.Type == -1 {
  125. sp.Card.OfficialVerify.Type = int8(cert.Cert.Type)
  126. }
  127. if sp.Card.OfficialVerify.Desc != "" {
  128. sp.Card.OfficialVerify.Desc = sp.Card.OfficialVerify.Desc + "、" + cert.Cert.Desc
  129. } else {
  130. sp.Card.OfficialVerify.Desc = cert.Cert.Desc
  131. }
  132. return
  133. })
  134. // iOS蓝版 强行去除充电模块
  135. if model.IsIPhone(plat) && (build >= 7000 && build <= 8000) {
  136. sp.Elec = nil
  137. } else {
  138. // elec rank
  139. g.Go(func() (err error) {
  140. info, err := s.elecDao.Info(ctx, vmid, mid)
  141. if err != nil {
  142. log.Error("%+v", err)
  143. err = nil
  144. return
  145. }
  146. if info != nil {
  147. info.Show = true
  148. sp.Elec = info
  149. }
  150. return
  151. })
  152. }
  153. g.Go(func() error {
  154. rel, _ := s.accDao.RichRelations3(ctx, mid, vmid)
  155. // -999:无关系, -1:我已经拉黑该用户, 0:我悄悄关注了该用户, 1:我公开关注了该用户
  156. // 1- 悄悄关注 2 关注 6-好友 128-拉黑
  157. if rel == 1 {
  158. sp.Relation = 0
  159. } else if rel == 2 || rel == 6 {
  160. sp.Relation = 1
  161. } else if rel >= 128 {
  162. sp.Relation = -1
  163. } else {
  164. sp.Relation = -999
  165. }
  166. return nil
  167. })
  168. g.Go(func() (err error) {
  169. if sp.Medal, err = s.liveDao.MedalStatus(ctx, vmid); err != nil {
  170. log.Error("%+v", err)
  171. err = nil
  172. }
  173. return
  174. })
  175. // g.Go(func() (err error) {
  176. // if sp.Attention, err = s.relDao.Attention(ctx, mid, vmid); err != nil {
  177. // log.Error("%+v", err)
  178. // err = nil
  179. // }
  180. // return
  181. // })
  182. g.Go(func() (err error) {
  183. if sp.Live, err = s.liveDao.Live(ctx, vmid, platform); err != nil {
  184. log.Error("%+v", err)
  185. err = nil
  186. }
  187. return
  188. })
  189. sp.Tab = &space.Tab{}
  190. // up archives
  191. g.Go(func() error {
  192. sp.Archive = s.UpArcs(ctx, vmid, pn, ps, now)
  193. if sp.Archive != nil && len(sp.Archive.Item) > 0 {
  194. sp.Tab.Archive = true
  195. }
  196. return nil
  197. })
  198. g.Go(func() (err error) {
  199. if sp.Tab.Dynamic, err = s.bplusDao.Dynamic(ctx, vmid); err != nil {
  200. log.Error("%+v", err)
  201. err = nil
  202. }
  203. return
  204. })
  205. g.Go(func() error {
  206. sp.Article = s.UpArticles(ctx, vmid, 0, 3)
  207. if sp.Article != nil && len(sp.Article.Item) != 0 {
  208. sp.Tab.Article = true
  209. }
  210. return nil
  211. })
  212. g.Go(func() error {
  213. sp.Clip = s.upClips(ctx, vmid)
  214. if sp.Clip != nil && len(sp.Clip.Item) != 0 {
  215. sp.Tab.Clip = true
  216. }
  217. return nil
  218. })
  219. g.Go(func() error {
  220. sp.Album = s.upAlbums(ctx, vmid)
  221. if sp.Album != nil && len(sp.Album.Item) != 0 {
  222. sp.Tab.Album = true
  223. }
  224. return nil
  225. })
  226. g.Go(func() error {
  227. sp.Audios = s.audios(ctx, vmid, 1, 3)
  228. if sp.Audios != nil && len(sp.Audios.Item) != 0 {
  229. sp.Tab.Audios = true
  230. }
  231. return nil
  232. })
  233. g.Go(func() (err error) {
  234. var info *shop.Info
  235. if info, err = s.shopDao.Info(ctx, vmid, mobiApp, device, build); err != nil {
  236. log.Error("%+v", err)
  237. err = nil
  238. return
  239. }
  240. if info != nil && info.Shop != nil && info.Shop.Status == 2 {
  241. sp.Tab.Shop = true
  242. sp.Shop = &space.Shop{ID: info.Shop.ID, Name: info.Shop.Name + _shopName}
  243. }
  244. return
  245. })
  246. if sp.Setting, err = s.spcDao.Setting(c, vmid); err != nil {
  247. log.Error("%+v", err)
  248. err = nil
  249. }
  250. if sp.Setting == nil {
  251. err = g.Wait()
  252. return
  253. }
  254. g.Go(func() error {
  255. sp.Favourite = s.favFolders(ctx, mid, vmid, sp.Setting, plat, build, mobiApp)
  256. if sp.Favourite != nil && len(sp.Favourite.Item) != 0 {
  257. sp.Tab.Favorite = true
  258. }
  259. return nil
  260. })
  261. g.Go(func() error {
  262. sp.Season = s.Bangumi(ctx, mid, vmid, sp.Setting, pn, ps)
  263. if sp.Season != nil && len(sp.Season.Item) != 0 {
  264. sp.Tab.Bangumi = true
  265. }
  266. return nil
  267. })
  268. g.Go(func() error {
  269. sp.CoinArc = s.CoinArcs(ctx, mid, vmid, sp.Setting, pn, ps)
  270. if sp.CoinArc != nil && len(sp.CoinArc.Item) != 0 {
  271. sp.Tab.Coin = true
  272. }
  273. return nil
  274. })
  275. g.Go(func() error {
  276. sp.LikeArc = s.LikeArcs(ctx, mid, vmid, sp.Setting, pn, ps)
  277. if sp.LikeArc != nil && len(sp.LikeArc.Item) != 0 {
  278. sp.Tab.Like = true
  279. }
  280. return nil
  281. })
  282. err = g.Wait()
  283. return
  284. }
  285. // UpArcs get upload archive .
  286. func (s *Service) UpArcs(c context.Context, uid int64, pn, ps int, now time.Time) (res *space.ArcList) {
  287. var (
  288. arcs []*api.Arc
  289. err error
  290. )
  291. res = &space.ArcList{Item: []*space.ArcItem{}}
  292. if res.Count, err = s.arcDao.UpCount2(c, uid); err != nil {
  293. log.Error("%+v", err)
  294. }
  295. if arcs, err = s.arcDao.UpArcs3(c, uid, pn, ps); err != nil {
  296. log.Error("%+v", err)
  297. return
  298. }
  299. if len(arcs) != 0 {
  300. res.Item = make([]*space.ArcItem, 0, len(arcs))
  301. for _, v := range arcs {
  302. si := &space.ArcItem{}
  303. si.FromArc(v)
  304. res.Item = append(res.Item, si)
  305. }
  306. }
  307. return
  308. }
  309. // UpArticles get article.
  310. func (s *Service) UpArticles(c context.Context, uid int64, pn, ps int) (res *space.ArticleList) {
  311. res = &space.ArticleList{Item: []*space.ArticleItem{}, Lists: []*article.List{}}
  312. g, ctx := errgroup.WithContext(c)
  313. g.Go(func() (err error) {
  314. var ams []*article.Meta
  315. if ams, res.Count, err = s.artDao.UpArticles(ctx, uid, pn, ps); err != nil {
  316. return err
  317. }
  318. if len(ams) != 0 {
  319. res.Item = make([]*space.ArticleItem, 0, len(ams))
  320. for _, v := range ams {
  321. if v.AttrVal(article.AttrBitNoDistribute) {
  322. continue
  323. }
  324. si := &space.ArticleItem{}
  325. si.FromArticle(v)
  326. res.Item = append(res.Item, si)
  327. }
  328. }
  329. return err
  330. })
  331. g.Go(func() (err error) {
  332. var lists []*article.List
  333. lists, res.ListsCount, err = s.artDao.UpLists(c, uid)
  334. if err != nil {
  335. return err
  336. }
  337. if len(lists) > 0 {
  338. res.Lists = lists
  339. }
  340. return err
  341. })
  342. if err := g.Wait(); err != nil {
  343. log.Error("%+v", err)
  344. }
  345. return
  346. }
  347. // favFolders get favorite folders
  348. func (s *Service) favFolders(c context.Context, mid, vmid int64, setting *space.Setting, plat int8, build int, mobiApp string) (res *space.FavList) {
  349. const (
  350. _oldAndroidBuild = 427100
  351. _oldIOSBuild = 3910
  352. )
  353. var (
  354. fs []*favorite.Folder
  355. err error
  356. )
  357. res = &space.FavList{Item: []*favorite.Folder{}}
  358. if mid != vmid {
  359. if setting == nil {
  360. setting, err = s.spcDao.Setting(c, vmid)
  361. if err != nil {
  362. log.Error("%+v", err)
  363. return
  364. }
  365. }
  366. if setting.FavVideo != 1 {
  367. return
  368. }
  369. }
  370. var mediaList bool
  371. // 双端版本号限制,符合此条件显示为“默认收藏夹”:
  372. // iPhone <5.36.1(8300) 或iPhone>5.36.1(8300)
  373. // Android <5360001或Android>5361000
  374. // 双端版本号限制,符合此条件显示为“默认播单”:
  375. // iPhone=5.36.1(8300)
  376. // 5360001 <=Android <=5361000
  377. if (plat == model.PlatIPhone && build == 8300) || (plat == model.PlatAndroid && build >= 5360001 && build <= 5361000) {
  378. mediaList = true
  379. }
  380. if fs, err = s.favDao.Folders(c, mid, vmid, mobiApp, build, mediaList); err != nil {
  381. log.Error("%+v", err)
  382. return
  383. }
  384. for _, v := range fs {
  385. if ((plat == model.PlatAndroid || plat == model.PlatAndroidG) && build <= _oldAndroidBuild) || ((plat == model.PlatIPhone || plat == model.PlatIPhoneI) && build <= _oldIOSBuild) {
  386. v.Videos = v.Cover
  387. v.Cover = nil
  388. }
  389. }
  390. res.Item = fs
  391. res.Count = len(fs)
  392. return
  393. }
  394. // Bangumi get concern season
  395. func (s *Service) Bangumi(c context.Context, mid, vmid int64, setting *space.Setting, pn, ps int) (res *space.BangumiList) {
  396. var (
  397. seasons []*bangumi.Season
  398. err error
  399. )
  400. res = &space.BangumiList{Item: []*space.BangumiItem{}}
  401. if mid != vmid {
  402. if setting == nil {
  403. setting, err = s.spcDao.Setting(c, vmid)
  404. if err != nil {
  405. log.Error("%+v", err)
  406. return
  407. }
  408. }
  409. if setting.Bangumi != 1 {
  410. return
  411. }
  412. }
  413. if seasons, res.Count, err = s.bgmDao.Concern(c, mid, vmid, pn, ps); err != nil {
  414. log.Error("%+v", err)
  415. return
  416. }
  417. if len(seasons) != 0 {
  418. res.Item = make([]*space.BangumiItem, 0, len(seasons))
  419. for _, v := range seasons {
  420. si := &space.BangumiItem{}
  421. si.FromSeason(v)
  422. res.Item = append(res.Item, si)
  423. }
  424. }
  425. return
  426. }
  427. // Community get community
  428. func (s *Service) Community(c context.Context, uid int64, pn, ps int, ak, platform string) (res *space.CommuList) {
  429. var (
  430. comm []*community.Community
  431. err error
  432. )
  433. res = &space.CommuList{Item: []*space.CommItem{}}
  434. if comm, res.Count, err = s.commDao.Community(c, uid, ak, platform, pn, ps); err != nil {
  435. log.Error("%+v", err)
  436. return
  437. }
  438. if len(comm) != 0 {
  439. res.Item = make([]*space.CommItem, 0, len(comm))
  440. for _, v := range comm {
  441. si := &space.CommItem{}
  442. si.FromCommunity(v)
  443. res.Item = append(res.Item, si)
  444. }
  445. }
  446. return
  447. }
  448. // CoinArcs get coin archives.
  449. func (s *Service) CoinArcs(c context.Context, mid, vmid int64, setting *space.Setting, pn, ps int) (res *space.ArcList) {
  450. var (
  451. coins []*api.Arc
  452. err error
  453. )
  454. res = &space.ArcList{Item: []*space.ArcItem{}}
  455. if mid != vmid {
  456. if setting == nil {
  457. setting, err = s.spcDao.Setting(c, vmid)
  458. if err != nil {
  459. log.Error("%+v", err)
  460. return
  461. }
  462. }
  463. if setting.CoinsVideo != 1 {
  464. return
  465. }
  466. }
  467. if coins, res.Count, err = s.coinDao.CoinList(c, vmid, pn, ps); err != nil {
  468. log.Error("%+v", err)
  469. return
  470. }
  471. if len(coins) != 0 {
  472. res.Item = make([]*space.ArcItem, 0, len(coins))
  473. for _, v := range coins {
  474. si := &space.ArcItem{}
  475. si.FromCoinArc(v)
  476. res.Item = append(res.Item, si)
  477. }
  478. }
  479. return
  480. }
  481. // LikeArcs get like archives.
  482. func (s *Service) LikeArcs(c context.Context, mid, vmid int64, setting *space.Setting, pn, ps int) (res *space.ArcList) {
  483. var (
  484. likes []*thumbup.ItemLikeRecord
  485. err error
  486. )
  487. res = &space.ArcList{Item: []*space.ArcItem{}}
  488. if mid != vmid {
  489. if setting == nil {
  490. setting, err = s.spcDao.Setting(c, vmid)
  491. if err != nil {
  492. log.Error("%+v", err)
  493. return
  494. }
  495. }
  496. if setting.LikesVideo != 1 {
  497. return
  498. }
  499. }
  500. if likes, res.Count, err = s.thumbupDao.UserTotalLike(c, vmid, _businessLike, pn, ps); err != nil {
  501. log.Error("%+v", err)
  502. return
  503. }
  504. if len(likes) != 0 {
  505. aids := make([]int64, 0, len(likes))
  506. for _, v := range likes {
  507. aids = append(aids, v.MessageID)
  508. }
  509. var as map[int64]*api.Arc
  510. if as, err = s.arcDao.Archives2(c, aids); err != nil {
  511. log.Error("%+v", err)
  512. return
  513. }
  514. if len(as) == 0 {
  515. return
  516. }
  517. res.Item = make([]*space.ArcItem, 0, len(as))
  518. for _, v := range likes {
  519. if a, ok := as[v.MessageID]; ok {
  520. si := &space.ArcItem{}
  521. si.FromLikeArc(a)
  522. res.Item = append(res.Item, si)
  523. }
  524. }
  525. }
  526. return
  527. }
  528. func (s *Service) upClips(c context.Context, uid int64) (res *space.ClipList) {
  529. var (
  530. clips []*bplus.Clip
  531. err error
  532. )
  533. res = &space.ClipList{Item: []*space.Item{}}
  534. if clips, res.Count, err = s.bplusDao.AllClip(c, uid, 200); err != nil {
  535. log.Error("%+v", err)
  536. return
  537. }
  538. if len(clips) != 0 {
  539. res.Item = make([]*space.Item, 0, len(clips))
  540. for k, v := range clips {
  541. si := &space.Item{}
  542. si.FromClip(v)
  543. res.Item = append(res.Item, si)
  544. if k == 1 {
  545. break
  546. }
  547. }
  548. }
  549. return
  550. }
  551. func (s *Service) upAlbums(c context.Context, uid int64) (res *space.AlbumList) {
  552. var (
  553. album []*bplus.Album
  554. err error
  555. )
  556. res = &space.AlbumList{Item: []*space.Item{}}
  557. if album, res.Count, err = s.bplusDao.AllAlbum(c, uid, 6); err != nil {
  558. log.Error("%+v", err)
  559. return
  560. }
  561. if len(album) != 0 {
  562. res.Item = make([]*space.Item, 0, len(album))
  563. for k, v := range album {
  564. si := &space.Item{}
  565. si.FromAlbum(v)
  566. res.Item = append(res.Item, si)
  567. if k == 5 {
  568. break
  569. }
  570. }
  571. }
  572. return
  573. }
  574. // card get card by mid, vmid or name.
  575. func (s *Service) card(c context.Context, vmid int64, name string) (scard *space.Card, err error) {
  576. scard = &space.Card{}
  577. var profile *account.ProfileStat
  578. if vmid > 0 {
  579. profile, err = s.accDao.Profile3(c, vmid)
  580. } else if name != "" {
  581. profile, err = s.accDao.ProfileByName3(c, name)
  582. }
  583. if err != nil {
  584. err = errors.Wrapf(err, "%v,%v", vmid, name)
  585. return
  586. }
  587. scard.Mid = strconv.FormatInt(profile.Mid, 10)
  588. scard.Name = profile.Name
  589. // scard.Approve =
  590. scard.Sex = profile.Sex
  591. scard.Rank = strconv.FormatInt(int64(profile.Rank), 10)
  592. scard.Face = profile.Face
  593. scard.DisplayRank = strconv.FormatInt(int64(profile.Rank), 10)
  594. // scard.Regtime =
  595. if profile.Silence == 1 {
  596. scard.Spacesta = -2
  597. }
  598. // scard.Birthday =
  599. // scard.Place =
  600. scard.Description = profile.Official.Desc
  601. scard.Article = 0
  602. scard.Attentions = []int64{}
  603. scard.Fans = int(profile.Follower)
  604. // scard.Friend = profile.Following
  605. scard.Attention = int(profile.Following)
  606. scard.Sign = profile.Sign
  607. scard.LevelInfo.Cur = profile.Level
  608. scard.LevelInfo.Min = profile.LevelExp.Min
  609. scard.LevelInfo.NowExp = profile.LevelExp.NowExp
  610. scard.LevelInfo.NextExp = profile.LevelExp.NextExp
  611. if profile.LevelExp.NextExp == -1 {
  612. scard.LevelInfo.NextExp = "--"
  613. }
  614. scard.Pendant.Pid = profile.Pendant.Pid
  615. scard.Pendant.Name = profile.Pendant.Name
  616. scard.Pendant.Image = profile.Pendant.Image
  617. scard.Pendant.Expire = profile.Pendant.Expire
  618. scard.OfficialVerify.Role = profile.Official.Role
  619. scard.OfficialVerify.Title = profile.Official.Title
  620. if profile.Official.Role == 0 {
  621. scard.OfficialVerify.Type = -1
  622. } else {
  623. if profile.Official.Role <= 2 {
  624. scard.OfficialVerify.Type = 0
  625. } else {
  626. scard.OfficialVerify.Type = 1
  627. }
  628. scard.OfficialVerify.Desc = profile.Official.Title
  629. }
  630. scard.Vip.Type = int(profile.Vip.Type)
  631. scard.Vip.VipStatus = int(profile.Vip.Status)
  632. scard.Vip.DueDate = profile.Vip.DueDate
  633. // scard.FansGroup =
  634. // scard.Audio =
  635. // scard.FansUnread =
  636. return
  637. }
  638. // audios
  639. func (s *Service) audios(c context.Context, mid int64, pn, ps int) (res *space.AudioList) {
  640. var (
  641. audios []*audio.Audio
  642. err error
  643. )
  644. res = &space.AudioList{Item: []*space.AudioItem{}}
  645. if audios, res.Count, err = s.audioDao.Audios(c, mid, pn, ps); err != nil {
  646. log.Error("%+v", err)
  647. return
  648. }
  649. if len(audios) != 0 {
  650. res.Item = make([]*space.AudioItem, 0, len(audios))
  651. for _, v := range audios {
  652. si := &space.AudioItem{}
  653. si.FromAudio(v)
  654. res.Item = append(res.Item, si)
  655. }
  656. }
  657. return
  658. }
  659. // Report func
  660. func (s *Service) Report(c context.Context, mid int64, reason, ak string) (err error) {
  661. return s.spcDao.Report(c, mid, reason, ak)
  662. }