creator_arc.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. package http
  2. import (
  3. "context"
  4. "strconv"
  5. "time"
  6. appMdl "go-common/app/interface/main/creative/model/app"
  7. "go-common/app/interface/main/creative/model/archive"
  8. "go-common/app/interface/main/creative/model/article"
  9. "go-common/app/interface/main/creative/model/danmu"
  10. "go-common/app/interface/main/creative/model/data"
  11. "go-common/app/interface/main/creative/model/elec"
  12. "go-common/app/interface/main/creative/model/operation"
  13. "go-common/app/interface/main/creative/model/order"
  14. "go-common/app/interface/main/creative/model/search"
  15. artmdl "go-common/app/interface/openplatform/article/model"
  16. "go-common/library/ecode"
  17. "go-common/library/log"
  18. bm "go-common/library/net/http/blademaster"
  19. "go-common/library/net/metadata"
  20. "go-common/library/sync/errgroup"
  21. )
  22. func creatorMy(c *bm.Context) {
  23. ip := metadata.String(c, metadata.RemoteIP)
  24. // check user
  25. midStr, _ := c.Get("mid")
  26. mid := midStr.(int64)
  27. if mid <= 0 {
  28. c.JSON(nil, ecode.CreativeNotLogin)
  29. return
  30. }
  31. mf, err := accSvc.MyInfo(c, mid, ip, time.Now())
  32. if err != nil {
  33. c.JSON(nil, err)
  34. return
  35. }
  36. c.JSON(map[string]interface{}{
  37. "myinfo": mf,
  38. "viewinfo": whiteSvc.Viewinfo(mf),
  39. }, nil)
  40. }
  41. func creatorIndex(c *bm.Context) {
  42. ip := metadata.String(c, metadata.RemoteIP)
  43. req := c.Request
  44. params := req.Form
  45. ck := c.Request.Header.Get("cookie")
  46. ak := params.Get("access_key")
  47. // check user
  48. midStr, _ := c.Get("mid")
  49. mid := midStr.(int64)
  50. if mid <= 0 {
  51. c.JSON(nil, ecode.CreativeNotLogin)
  52. return
  53. }
  54. // get data
  55. var (
  56. stat *data.Stat
  57. elecStat *elec.UserState
  58. elecBal *elec.Balance
  59. elecEarnings *elec.Earnings
  60. archives []*archive.ArcVideoAudit
  61. banner []*operation.BannerCreator
  62. replies *search.Replies
  63. articles []*article.Meta
  64. artStat artmdl.UpStat
  65. dmRecent *danmu.DmRecent
  66. creatorDataShow *data.CreatorDataShow
  67. g = &errgroup.Group{}
  68. ctx = context.TODO()
  69. )
  70. g.Go(func() error {
  71. stat, _ = dataSvc.NewStat(ctx, mid, ip)
  72. if stat != nil {
  73. stat.Day30 = nil
  74. stat.Arcs = nil
  75. }
  76. return nil
  77. })
  78. g.Go(func() error {
  79. if arcs, err := arcSvc.WebArchives(ctx, mid, 0, "", "", "is_pubing,pubed,not_pubed", ip, 1, 2, 0); err == nil && arcs.Archives != nil {
  80. archives = arcs.Archives
  81. } else {
  82. archives = make([]*archive.ArcVideoAudit, 0)
  83. }
  84. return nil
  85. })
  86. g.Go(func() error {
  87. elecStat, _ = elecSvc.UserState(ctx, mid, ip, ak, ck)
  88. elecEarnings = &elec.Earnings{}
  89. if elecStat != nil && elecStat.State == "2" {
  90. elecEarnings.State = 1
  91. elecBal, _ = elecSvc.Balance(ctx, mid, ip)
  92. if elecBal != nil && elecBal.Wallet != nil {
  93. elecEarnings.Balance = elecBal.Wallet.SponsorBalance //充电数量
  94. }
  95. if elecBal != nil && elecBal.BpayAcc != nil {
  96. elecEarnings.Brokerage = elecBal.BpayAcc.Brokerage //贝壳数量
  97. }
  98. }
  99. return nil
  100. })
  101. g.Go(func() error {
  102. _, banner, _ = operSvc.AppBanner(ctx)
  103. return nil
  104. })
  105. g.Go(func() error {
  106. if arts, err := artSvc.Articles(ctx, mid, 1, 2, 0, 0, 0, ip); err == nil && arts != nil && len(arts.Articles) != 0 {
  107. articles = arts.Articles
  108. } else {
  109. articles = []*article.Meta{}
  110. }
  111. return nil
  112. })
  113. g.Go(func() error {
  114. replies, _ = replySvc.AppIndexReplies(ctx, ak, ck, mid, 0, 0, 0, search.All, 0, "", "", "", ip, 1, 10)
  115. if replies == nil {
  116. replies = &search.Replies{}
  117. }
  118. return nil
  119. })
  120. g.Go(func() error {
  121. artStat, _ = artSvc.ArticleStat(ctx, mid, ip)
  122. return nil
  123. })
  124. g.Go(func() error {
  125. dmRecent, _ = danmuSvc.Recent(ctx, mid, 1, 2, ip)
  126. return nil
  127. })
  128. g.Wait()
  129. creatorDataShow = &data.CreatorDataShow{}
  130. if len(archives) > 0 {
  131. creatorDataShow.Archive = 1
  132. }
  133. if len(articles) > 0 {
  134. creatorDataShow.Article = 1
  135. }
  136. c.JSON(map[string]interface{}{
  137. "archives": archives,
  138. "archive_stat": stat,
  139. "elec_earnings": elecEarnings,
  140. "order_earnings": &order.OasisEarnings{},
  141. "growth_earnings": &order.GrowthEarnings{},
  142. "banner": banner,
  143. "articles": articles,
  144. "replies": replies,
  145. "article_stat": artStat,
  146. "data_show": creatorDataShow,
  147. "danmu": dmRecent.List,
  148. }, nil)
  149. }
  150. func creatorArchives(c *bm.Context) {
  151. params := c.Request.Form
  152. pageStr := params.Get("pn")
  153. psStr := params.Get("ps")
  154. order := params.Get("order")
  155. tidStr := params.Get("tid")
  156. keyword := params.Get("keyword")
  157. class := params.Get("class")
  158. ip := metadata.String(c, metadata.RemoteIP)
  159. // check user
  160. midStr, _ := c.Get("mid")
  161. mid := midStr.(int64)
  162. if mid <= 0 {
  163. c.JSON(nil, ecode.CreativeNotLogin)
  164. return
  165. }
  166. // check params
  167. pn, _ := strconv.Atoi(pageStr)
  168. if pn <= 0 {
  169. pn = 1
  170. }
  171. ps, _ := strconv.Atoi(psStr)
  172. if ps <= 0 || ps > 50 {
  173. ps = 10
  174. }
  175. tid, _ := strconv.ParseInt(tidStr, 10, 16)
  176. if tid <= 0 {
  177. tid = 0
  178. }
  179. arc, err := arcSvc.WebArchives(c, mid, int16(tid), keyword, order, class, ip, pn, ps, 0)
  180. if err != nil {
  181. c.JSON(nil, err)
  182. return
  183. }
  184. c.JSON(arc, nil)
  185. }
  186. func creatorEarnings(c *bm.Context) {
  187. params := c.Request.Form
  188. ip := metadata.String(c, metadata.RemoteIP)
  189. ck := c.Request.Header.Get("cookie")
  190. ak := params.Get("access_key")
  191. midStr, _ := c.Get("mid")
  192. mid := midStr.(int64)
  193. if mid <= 0 {
  194. c.JSON(nil, ecode.CreativeNotLogin)
  195. return
  196. }
  197. var (
  198. elecStat *elec.UserState
  199. elecBal *elec.Balance
  200. elecEarnings *elec.Earnings
  201. g = &errgroup.Group{}
  202. ctx = context.TODO()
  203. )
  204. g.Go(func() error {
  205. elecStat, _ = elecSvc.UserState(ctx, mid, ip, ak, ck)
  206. elecEarnings = &elec.Earnings{}
  207. if elecStat != nil && elecStat.State == "2" {
  208. elecEarnings.State = 1
  209. elecBal, _ = elecSvc.Balance(c, mid, ip)
  210. if elecBal != nil && elecBal.Wallet != nil {
  211. elecEarnings.Balance = elecBal.Wallet.SponsorBalance //充电数量
  212. }
  213. if elecBal != nil && elecBal.BpayAcc != nil {
  214. elecEarnings.Brokerage = elecBal.BpayAcc.Brokerage //贝壳数量
  215. }
  216. }
  217. return nil
  218. })
  219. g.Wait()
  220. cw := appMdl.EarningsCopyWriter{
  221. Elec: "每月6日结算为贝壳,6-10日可在PC上进行提现",
  222. Growth: "每月1日结算为贝壳,6-10日可在PC上进行提现",
  223. Oasis: "请在PC上进行接单、投稿操作",
  224. }
  225. c.JSON(map[string]interface{}{
  226. "elec_earnings": elecEarnings,
  227. "order_earnings": &order.OasisEarnings{},
  228. "growth_earnings": &order.GrowthEarnings{},
  229. "copywriter": cw,
  230. }, nil)
  231. }
  232. func creatorViewArc(c *bm.Context) {
  233. req := c.Request
  234. params := c.Request.Form
  235. aidStr := params.Get("aid")
  236. tidStr := params.Get("typeid")
  237. title := params.Get("title")
  238. filename := params.Get("filename")
  239. desc := params.Get("desc")
  240. cover := params.Get("cover")
  241. ip := metadata.String(c, metadata.RemoteIP)
  242. cookie := req.Header.Get("cookie")
  243. ak := params.Get("access_key")
  244. // check user
  245. midStr, _ := c.Get("mid")
  246. mid := midStr.(int64)
  247. if mid <= 0 {
  248. c.JSON(nil, ecode.CreativeNotLogin)
  249. return
  250. }
  251. aid, err := strconv.ParseInt(aidStr, 10, 64)
  252. if err != nil {
  253. log.Error("strconv.ParseInt(%s) error(%v)", aidStr, err)
  254. c.JSON(nil, ecode.RequestErr)
  255. return
  256. }
  257. av, err := arcSvc.View(c, mid, aid, ip, archive.PlatformAndroid)
  258. if err != nil {
  259. c.JSON(nil, err)
  260. return
  261. }
  262. if av == nil {
  263. c.JSON(nil, ecode.NothingFound)
  264. return
  265. }
  266. tid, _ := strconv.ParseInt(tidStr, 10, 16)
  267. if tid < 0 {
  268. tid = 0
  269. }
  270. ptags, _ := dataSvc.TagsWithChecked(c, mid, uint16(tid), title, filename, desc, cover, archive.TagPredictFromAPP)
  271. elecArc, _ := elecSvc.ArchiveState(c, aid, mid, ip)
  272. elecStat, _ := elecSvc.UserState(c, mid, ip, ak, cookie)
  273. if elecArc == nil {
  274. elecArc = &elec.ArcState{}
  275. }
  276. c.JSON(map[string]interface{}{
  277. "archive": av.Archive,
  278. "videos": av.Videos,
  279. "predict_tag": ptags,
  280. "arc_elec": elecArc,
  281. "user_elec": elecStat,
  282. }, nil)
  283. }
  284. func creatorVideoQuit(c *bm.Context) {
  285. params := c.Request.Form
  286. cidStr := params.Get("cid")
  287. ip := metadata.String(c, metadata.RemoteIP)
  288. // check user
  289. midStr, _ := c.Get("mid")
  290. mid := midStr.(int64)
  291. if mid <= 0 {
  292. c.JSON(nil, ecode.CreativeNotLogin)
  293. return
  294. }
  295. cid, err := strconv.ParseInt(cidStr, 10, 64)
  296. if err != nil {
  297. log.Error("strconv.ParseInt(%s) error(%v)", cidStr, err)
  298. c.JSON(nil, ecode.RequestErr)
  299. return
  300. }
  301. vq, err := dataSvc.AppVideoQuitPoints(c, cid, mid, ip)
  302. if err != nil {
  303. c.JSON(nil, err)
  304. return
  305. }
  306. c.JSON(vq, nil)
  307. }
  308. func creatorBanner(c *bm.Context) {
  309. params := c.Request.Form
  310. pnStr := params.Get("pn")
  311. psStr := params.Get("ps")
  312. // check user
  313. midStr, _ := c.Get("mid")
  314. mid := midStr.(int64)
  315. if mid <= 0 {
  316. c.JSON(nil, ecode.CreativeNotLogin)
  317. return
  318. }
  319. pn, err := strconv.Atoi(pnStr)
  320. if err != nil || pn <= 0 {
  321. pn = 1
  322. }
  323. ps, err := strconv.Atoi(psStr)
  324. if err != nil || ps <= 0 || ps > 20 {
  325. ps = 20
  326. }
  327. oper, err := operSvc.CreatorOperationList(c, pn, ps)
  328. if err != nil {
  329. c.JSON(nil, err)
  330. return
  331. }
  332. c.JSON(oper, nil)
  333. }
  334. func creatorArchiveData(c *bm.Context) {
  335. params := c.Request.Form
  336. aidStr := params.Get("aid")
  337. ip := metadata.String(c, metadata.RemoteIP)
  338. // check user
  339. midStr, _ := c.Get("mid")
  340. mid := midStr.(int64)
  341. if mid <= 0 {
  342. c.JSON(nil, ecode.CreativeNotLogin)
  343. return
  344. }
  345. aid, err := strconv.ParseInt(aidStr, 10, 64)
  346. if err != nil {
  347. log.Error("strconv.ParseInt(%s) error(%v)", aidStr, err)
  348. c.JSON(nil, ecode.RequestErr)
  349. return
  350. }
  351. arcStat, err := dataSvc.ArchiveStat(c, aid, mid, ip)
  352. if err != nil {
  353. c.JSON(nil, err)
  354. return
  355. }
  356. _, vds, _ := arcSvc.Videos(c, mid, aid, ip)
  357. arcStat.Videos = vds
  358. c.JSON(arcStat, nil)
  359. }
  360. func creatorDelArc(c *bm.Context) {
  361. params := c.Request.Form
  362. aidStr := params.Get("aid")
  363. ip := metadata.String(c, metadata.RemoteIP)
  364. // check user
  365. midStr, _ := c.Get("mid")
  366. mid := midStr.(int64)
  367. if mid <= 0 {
  368. c.JSON(nil, ecode.CreativeNotLogin)
  369. return
  370. }
  371. aid, err := strconv.ParseInt(aidStr, 10, 64)
  372. if err != nil {
  373. log.Error("strconv.ParseInt(%s) error(%v)", aidStr, err)
  374. c.JSON(nil, ecode.RequestErr)
  375. return
  376. }
  377. c.JSON(nil, arcSvc.Del(c, mid, aid, ip))
  378. }
  379. func creatorArcTagInfo(c *bm.Context) {
  380. params := c.Request.Form
  381. tagNameStr := params.Get("tag_name")
  382. midStr, _ := c.Get("mid")
  383. mid := midStr.(int64)
  384. if mid <= 0 {
  385. c.JSON(nil, ecode.CreativeNotLogin)
  386. return
  387. }
  388. if len(tagNameStr) == 0 {
  389. log.Error("tagNameStr len zero (%s)", tagNameStr)
  390. c.JSON(nil, ecode.RequestErr)
  391. return
  392. }
  393. code, msg := arcSvc.TagCheck(c, mid, tagNameStr)
  394. c.JSON(map[string]interface{}{
  395. "code": code,
  396. "msg": msg,
  397. }, nil)
  398. }
  399. func creatorReplyList(c *bm.Context) {
  400. req := c.Request
  401. params := req.Form
  402. midStr, _ := c.Get("mid")
  403. mid := midStr.(int64)
  404. if mid <= 0 {
  405. c.JSON(nil, ecode.CreativeNotLogin)
  406. return
  407. }
  408. isReport, err := strconv.Atoi(params.Get("is_report"))
  409. if err != nil {
  410. isReport = 0
  411. }
  412. tp, err := strconv.Atoi(params.Get("type"))
  413. if err != nil {
  414. tp = 1
  415. }
  416. oid, err := strconv.ParseInt(params.Get("oid"), 10, 64)
  417. if err != nil {
  418. oid = 0
  419. }
  420. pn, err := strconv.Atoi(params.Get("pn"))
  421. if err != nil || pn < 1 {
  422. pn = 1
  423. }
  424. ps, err := strconv.Atoi(params.Get("ps"))
  425. if err != nil || ps <= 10 || ps > 100 {
  426. ps = 10
  427. }
  428. p := &search.ReplyParam{
  429. Ak: params.Get("access_key"),
  430. Ck: c.Request.Header.Get("cookie"),
  431. OMID: mid,
  432. OID: oid,
  433. Pn: pn,
  434. Ps: ps,
  435. IP: metadata.String(c, metadata.RemoteIP),
  436. IsReport: int8(isReport),
  437. Type: int8(tp),
  438. FilterCtime: params.Get("filter"),
  439. Kw: params.Get("keyword"),
  440. Order: params.Get("order"),
  441. }
  442. replies, err := replySvc.Replies(c, p)
  443. if err != nil {
  444. c.JSON(nil, err)
  445. return
  446. }
  447. c.JSONMap(map[string]interface{}{
  448. "data": replies.Result,
  449. "pager": map[string]int{
  450. "pn": p.Pn,
  451. "ps": p.Ps,
  452. "total": replies.Total,
  453. },
  454. }, nil)
  455. }
  456. func creatorPre(c *bm.Context) {
  457. ip := metadata.String(c, metadata.RemoteIP)
  458. params := c.Request.Form
  459. lang := params.Get("lang")
  460. if lang != "en" {
  461. lang = "ch"
  462. }
  463. // check user
  464. midStr, _ := c.Get("mid")
  465. mid := midStr.(int64)
  466. if mid <= 0 {
  467. c.JSON(nil, ecode.CreativeNotLogin)
  468. return
  469. }
  470. mf, err := accSvc.MyInfo(c, mid, ip, time.Now())
  471. if err != nil {
  472. c.JSON(nil, err)
  473. return
  474. }
  475. mf.Commercial = arcSvc.AllowCommercial(c, mid)
  476. tpl, _ := tplSvc.Templates(c, mid)
  477. c.JSON(map[string]interface{}{
  478. "uploadinfo": whiteSvc.UploadInfoForCreator(mf, mid),
  479. "typelist": arcSvc.AppTypes(c, lang),
  480. "myinfo": mf,
  481. "template": tpl,
  482. }, nil)
  483. }
  484. func creatorPredictTag(c *bm.Context) {
  485. params := c.Request.Form
  486. tidStr := params.Get("typeid")
  487. title := params.Get("title")
  488. filename := params.Get("filename")
  489. desc := params.Get("desc")
  490. cover := params.Get("cover")
  491. // check user
  492. midStr, _ := c.Get("mid")
  493. mid := midStr.(int64)
  494. if mid <= 0 {
  495. c.JSON(nil, ecode.CreativeNotLogin)
  496. return
  497. }
  498. tid, _ := strconv.ParseInt(tidStr, 10, 16)
  499. if tid < 0 {
  500. tid = 0
  501. }
  502. ptags, _ := dataSvc.TagsWithChecked(c, mid, uint16(tid), title, filename, desc, cover, archive.TagPredictFromAPP)
  503. c.JSON(ptags, nil)
  504. }
  505. func creatorDataArchive(c *bm.Context) {
  506. ip := metadata.String(c, metadata.RemoteIP)
  507. req := c.Request
  508. params := req.Form
  509. tyStr := params.Get("type")
  510. tmidStr := params.Get("tmid")
  511. // check user
  512. midStr, _ := c.Get("mid")
  513. mid := midStr.(int64)
  514. if mid <= 0 {
  515. c.JSON(nil, ecode.CreativeNotLogin)
  516. return
  517. }
  518. tmid, _ := strconv.ParseInt(tmidStr, 10, 64)
  519. if tmid > 0 && dataSvc.IsWhite(mid) {
  520. mid = tmid
  521. }
  522. // check params
  523. ty, err := strconv.Atoi(tyStr)
  524. if err != nil {
  525. c.JSON(nil, ecode.RequestErr)
  526. return
  527. }
  528. if _, ok := data.IncrTy(int8(ty)); !ok {
  529. c.JSON(nil, ecode.RequestErr)
  530. return
  531. }
  532. var (
  533. arcStat []*data.ThirtyDay
  534. archives []*archive.ArcVideoAudit
  535. show int
  536. g = &errgroup.Group{}
  537. ctx = context.TODO()
  538. )
  539. log.Info("creatorDataArchive mid(%d) type(%d) access", mid, ty)
  540. g.Go(func() error {
  541. arcStat, err = dataSvc.ThirtyDayArchive(ctx, mid, int8(ty))
  542. return nil
  543. })
  544. g.Go(func() error {
  545. if arcs, err := arcSvc.WebArchives(ctx, mid, 0, "", "", "is_pubing,pubed,not_pubed", ip, 1, 2, 0); err == nil && arcs.Archives != nil {
  546. archives = arcs.Archives
  547. } else {
  548. archives = make([]*archive.ArcVideoAudit, 0)
  549. }
  550. return nil
  551. })
  552. g.Wait()
  553. if len(archives) > 0 {
  554. show = 1
  555. }
  556. if arcStat == nil {
  557. log.Info("creatorDataArchive mid(%d) type(%d) arcStat nil", mid, ty)
  558. }
  559. c.JSON(map[string]interface{}{
  560. "archive_stat": arcStat,
  561. "show": show,
  562. }, nil)
  563. }
  564. func creatorDataArticle(c *bm.Context) {
  565. ip := metadata.String(c, metadata.RemoteIP)
  566. req := c.Request
  567. params := req.Form
  568. tmidStr := params.Get("tmid")
  569. midStr, _ := c.Get("mid")
  570. mid := midStr.(int64)
  571. if mid <= 0 {
  572. c.JSON(nil, ecode.CreativeNotLogin)
  573. return
  574. }
  575. tmid, _ := strconv.ParseInt(tmidStr, 10, 64)
  576. if tmid > 0 && dataSvc.IsWhite(mid) {
  577. mid = tmid
  578. }
  579. var (
  580. artStat []*artmdl.ThirtyDayArticle
  581. articles []*article.Meta
  582. show int
  583. g = &errgroup.Group{}
  584. ctx = context.TODO()
  585. )
  586. g.Go(func() error {
  587. artStat, _ = dataSvc.ThirtyDayArticle(ctx, mid, ip)
  588. return nil
  589. })
  590. g.Go(func() error {
  591. if arts, err := artSvc.Articles(ctx, mid, 1, 2, 0, 0, 0, ip); err == nil && arts != nil && len(arts.Articles) != 0 {
  592. articles = arts.Articles
  593. } else {
  594. articles = []*article.Meta{}
  595. }
  596. return nil
  597. })
  598. g.Wait()
  599. if len(articles) > 0 {
  600. show = 1
  601. }
  602. c.JSON(map[string]interface{}{
  603. "article_stat": artStat,
  604. "show": show,
  605. }, nil)
  606. }
  607. func creatorDescFormat(c *bm.Context) {
  608. params := c.Request.Form
  609. ip := metadata.String(c, metadata.RemoteIP)
  610. typeidStr := params.Get("typeid")
  611. cpStr := params.Get("copyright")
  612. lang := params.Get("lang")
  613. // check user
  614. midStr, _ := c.Get("mid")
  615. mid := midStr.(int64)
  616. if mid <= 0 {
  617. c.JSON(nil, ecode.CreativeNotLogin)
  618. return
  619. }
  620. typeid, err := strconv.ParseInt(typeidStr, 10, 16)
  621. if typeid < 0 || err != nil {
  622. typeid = 0
  623. }
  624. copyright, err := strconv.ParseInt(cpStr, 10, 16)
  625. if copyright <= 0 || err != nil {
  626. copyright = archive.CopyrightReprint
  627. }
  628. desc, length, err := arcSvc.DescFormatForApp(c, typeid, copyright, lang, ip)
  629. if err != nil {
  630. c.JSON(nil, err)
  631. return
  632. }
  633. c.JSON(map[string]interface{}{
  634. "desc_length": length,
  635. "desc_format": desc,
  636. }, nil)
  637. }