up.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package up
  2. import (
  3. "context"
  4. "go-common/app/interface/main/creative/model/up"
  5. upmdl "go-common/app/service/main/up/model"
  6. "go-common/library/log"
  7. )
  8. const (
  9. StaffWhiteGroupID = 24
  10. )
  11. // ArcUpInfo for main app submit.
  12. func (s *Service) ArcUpInfo(c context.Context, mid int64, ip string) (isAuthor int32, err error) {
  13. res, err := s.up.UpInfo(c, mid, 1, ip)
  14. if err != nil {
  15. log.Error("s.acc.ArcUpInfo(%d) error(%v)", mid, err)
  16. return
  17. }
  18. isAuthor = res.IsAuthor
  19. return
  20. }
  21. // UpSwitch get switch.
  22. func (s *Service) UpSwitch(c context.Context, mid int64, ip string) (res *up.Switch, err error) {
  23. var ups *upmdl.PBUpSwitch
  24. ups, err = s.up.UpSwitch(c, mid, 0, ip)
  25. if err != nil {
  26. log.Error("s.up.UpSwitch mid(%d)|from(%d)|error(%v)", mid, err)
  27. }
  28. if ups == nil {
  29. return
  30. }
  31. pf, err := s.acc.Profile(c, mid, ip)
  32. if err != nil {
  33. log.Error("s.acc.Profile mid(%d)|error(%v)", mid, err)
  34. return
  35. }
  36. show := 0
  37. res = &up.Switch{
  38. State: ups.State,
  39. Show: show,
  40. Face: pf.Face,
  41. }
  42. return
  43. }
  44. // SetUpSwitch set switch.
  45. func (s *Service) SetUpSwitch(c context.Context, mid int64, state, from int, ip string) (res *upmdl.PBSetUpSwitchRes, err error) {
  46. res, err = s.up.SetUpSwitch(c, mid, state, from, ip)
  47. if err != nil {
  48. log.Error("s.up.SetUpSwitch mid(%d)|state(%d)|from(%d)|error(%v)", mid, state, from, err)
  49. }
  50. return
  51. }
  52. // ShowStaff 用户是否能看到联合投稿
  53. func (s *Service) ShowStaff(c context.Context, mid int64) (show bool, err error) {
  54. //如果关了灰度,则展示
  55. if !s.c.StaffConf.IsGray {
  56. show = true
  57. return
  58. }
  59. var (
  60. groups map[int64]*up.SpecialGroup
  61. )
  62. groups = make(map[int64]*up.SpecialGroup)
  63. if groups, err = s.up.UpSpecialGroups(c, mid); err != nil {
  64. log.Error("s.up.UpSpecialGroups(%d) error(%v)", mid, err)
  65. return
  66. }
  67. if _, ok := groups[StaffWhiteGroupID]; ok {
  68. show = true
  69. return
  70. }
  71. return
  72. }