app_submit.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package http
  2. import (
  3. "context"
  4. "strconv"
  5. "time"
  6. accmdl "go-common/app/interface/main/creative/model/account"
  7. "go-common/app/interface/main/creative/model/archive"
  8. "go-common/app/interface/main/creative/model/faq"
  9. "go-common/app/interface/main/creative/model/watermark"
  10. "go-common/library/ecode"
  11. "go-common/library/log"
  12. bm "go-common/library/net/http/blademaster"
  13. "go-common/library/net/metadata"
  14. "go-common/library/sync/errgroup"
  15. )
  16. func appArcDescFormat(c *bm.Context) {
  17. params := c.Request.Form
  18. ip := metadata.String(c, metadata.RemoteIP)
  19. typeidStr := params.Get("typeid")
  20. cpStr := params.Get("copyright")
  21. lang := params.Get("lang")
  22. // check user
  23. midStr, _ := c.Get("mid")
  24. mid := midStr.(int64)
  25. if mid <= 0 {
  26. c.JSON(nil, ecode.CreativeNotLogin)
  27. return
  28. }
  29. typeid, err := strconv.ParseInt(typeidStr, 10, 16)
  30. if typeid < 0 || err != nil {
  31. typeid = 0
  32. }
  33. copyright, err := strconv.ParseInt(cpStr, 10, 16)
  34. if copyright <= 0 || err != nil {
  35. copyright = archive.CopyrightReprint
  36. }
  37. desc, length, err := arcSvc.DescFormatForApp(c, typeid, copyright, lang, ip)
  38. if err != nil {
  39. c.JSON(nil, err)
  40. return
  41. }
  42. c.JSON(map[string]interface{}{
  43. "desc_length": length,
  44. "desc_format": desc,
  45. }, nil)
  46. }
  47. func appArchivePre(c *bm.Context) {
  48. ip := metadata.String(c, metadata.RemoteIP)
  49. params := c.Request.Form
  50. plat := params.Get("platform")
  51. lang := params.Get("lang")
  52. if lang != "en" {
  53. lang = "ch"
  54. }
  55. midStr, _ := c.Get("mid")
  56. mid := midStr.(int64)
  57. if mid <= 0 {
  58. c.JSON(nil, ecode.CreativeNotLogin)
  59. return
  60. }
  61. var (
  62. err error
  63. mf *accmdl.MyInfo
  64. wm *watermark.Watermark
  65. g = &errgroup.Group{}
  66. ctx = context.TODO()
  67. faqs = make(map[string]*faq.Faq)
  68. recFriends []*accmdl.Friend
  69. lotteryCheck bool
  70. )
  71. g.Go(func() error {
  72. mf, err = accSvc.MyInfo(ctx, mid, ip, time.Now())
  73. if err != nil {
  74. log.Info("accSvc.MyInfo (%d) err(%v)", mid, err)
  75. }
  76. if mf != nil {
  77. mf.Commercial = arcSvc.AllowCommercial(c, mid)
  78. }
  79. return nil
  80. })
  81. g.Go(func() error {
  82. wm, err = wmSvc.WaterMark(ctx, mid)
  83. if err != nil {
  84. log.Info("wmSvc.WaterMark (%d) err(%+v) WaterMark(%+v)", mid, err, wm)
  85. }
  86. if len(wm.URL) == 0 {
  87. wm.State = 1
  88. }
  89. return nil
  90. })
  91. g.Go(func() error {
  92. faqs = faqSvc.Pre(ctx)
  93. return nil
  94. })
  95. g.Go(func() error {
  96. lotteryCheck, _ = dymcSvc.LotteryUserCheck(ctx, mid)
  97. return nil
  98. })
  99. g.Go(func() error {
  100. recFriends, _ = accSvc.RecFollows(ctx, mid)
  101. return nil
  102. })
  103. g.Wait()
  104. uploadinfo, _ := whiteSvc.UploadInfoForMainApp(mf, plat, mid)
  105. mf.DymcLottery = lotteryCheck
  106. c.JSON(map[string]interface{}{
  107. "uploadinfo": uploadinfo,
  108. "typelist": arcSvc.AppTypes(c, lang),
  109. "myinfo": mf,
  110. "arctip": arcSvc.ArcTip,
  111. "activities": arcSvc.Activities(c),
  112. "watermark": wm,
  113. "fav": arcSvc.Fav(c, mid),
  114. "tip": vsSvc.AppManagerTip,
  115. "cus_tip": vsSvc.CusManagerTip,
  116. // common data
  117. "camera_cfg": appSvc.CameraCfg,
  118. "module_show": arcSvc.AppModuleShowMap(mid, lotteryCheck),
  119. "icons": appSvc.Icons(),
  120. "faqs": faqs,
  121. "rec_friends": recFriends,
  122. }, nil)
  123. }