article.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. package model
  2. import (
  3. "fmt"
  4. "regexp"
  5. "strconv"
  6. "strings"
  7. account "go-common/app/service/main/account/model"
  8. xtime "go-common/library/time"
  9. )
  10. // Const .
  11. const (
  12. // State
  13. StateAutoLock = -11
  14. StateLock = -10
  15. StateReject = -3
  16. StatePending = -2
  17. StateOpen = 0
  18. StateOpenPending = 2
  19. StateOpenReject = 3
  20. StateAutoPass = 4
  21. StateRePending = 5 // 重复编辑待审
  22. StateReReject = 6 // 重复编辑未通过
  23. StateRePass = 7 // 重复编辑通过
  24. // groups for creation center.
  25. GroupAll = 0 // except draft and deleted. 0 2 -2 3 -3 -10
  26. GroupPending = 1 // -2 2
  27. GroupPassed = 2 // 0
  28. GroupUnpassed = 3 // -10 -3 3
  29. NoLikeState = 0
  30. LikeState = 1
  31. DislikeState = 2
  32. // Templates
  33. TemplateText = 1
  34. TemplateSingleImg = 2
  35. TemplateMultiImg = 3
  36. TemplateSingleBigImg = 4
  37. // Attributes
  38. //AttrBitNoDistribute 禁止分发(空间/分区/动态)
  39. AttrBitNoDistribute = uint(1)
  40. //AttrBitNoRegion 禁止在分区页显示
  41. AttrBitNoRegion = uint(2)
  42. //AttrBitNoRank 禁止排行
  43. AttrBitNoRank = uint(3)
  44. // Author
  45. // AuthorStatePass 过审
  46. AuthorStateReject = -1
  47. AuthorStatePending = 0
  48. AuthorStatePass = 1
  49. AuthorStateClose = 2
  50. // AuthorStateIgnore = 3
  51. )
  52. var cleanURLRegexp = regexp.MustCompile(`^.+hdslb.com`)
  53. var bfsRegexp = regexp.MustCompile(`^https?://.{1,6}\.hdslb+\.com/.+(?:jpg|gif|png|webp|jpeg)$`)
  54. // Categories for sorting category.
  55. type Categories []*Category
  56. func (as Categories) Len() int { return len(as) }
  57. func (as Categories) Less(i, j int) bool {
  58. return as[i].Position < as[j].Position
  59. }
  60. func (as Categories) Swap(i, j int) { as[i], as[j] = as[j], as[i] }
  61. // StatMsg means article's stat message in databus.
  62. type StatMsg struct {
  63. View *int64 `json:"view"`
  64. Like *int64 `json:"like"`
  65. Dislike *int64 `json:"dislike"`
  66. Favorite *int64 `json:"fav"`
  67. Reply *int64 `json:"reply"`
  68. Share *int64 `json:"share"`
  69. Coin *int64 `json:"coin"`
  70. Aid int64 `json:"aid"`
  71. Mid int64 `json:"mid"`
  72. IP string `json:"ip"`
  73. CheatInfo *CheatInfo `json:"cheat_info"`
  74. }
  75. func (sm *StatMsg) String() (res string) {
  76. if sm == nil {
  77. res = "<nil>"
  78. return
  79. }
  80. res = fmt.Sprintf("aid: %v, mid: %v, ip: %v, view(%s) likes(%s) dislike(%s) favorite(%s) reply(%s) share(%s) coin(%s)", sm.Aid, sm.Mid, sm.IP, formatPInt(sm.View), formatPInt(sm.Like), formatPInt(sm.Dislike), formatPInt(sm.Favorite), formatPInt(sm.Reply), formatPInt(sm.Share), formatPInt(sm.Coin))
  81. return
  82. }
  83. // CheatInfo .
  84. type CheatInfo struct {
  85. Valid string `json:"valid"`
  86. Client string `json:"client"`
  87. Cvid string `json:"cvid"`
  88. Mid string `json:"mid"`
  89. Lv string `json:"lv"`
  90. Ts string `json:"ts"`
  91. IP string `json:"ip"`
  92. UA string `json:"ua"`
  93. Refer string `json:"refer"`
  94. Sid string `json:"sid"`
  95. Buvid string `json:"buvid"`
  96. DeviceID string `json:"device_id"`
  97. Build string `json:"build"`
  98. Reason string `json:"reason"`
  99. }
  100. func formatPInt(s *int64) (res string) {
  101. if s == nil {
  102. return "<nil>"
  103. }
  104. return fmt.Sprintf("%d", *s)
  105. }
  106. // DraftMsg means article's draft message in databus.
  107. type DraftMsg struct {
  108. Aid int64 `json:"aid"`
  109. Mid int64 `json:"mid"`
  110. }
  111. // Draft draft struct.
  112. type Draft struct {
  113. *Article
  114. Tags []string `json:"tags"`
  115. ListID int64 `json:"list_id"`
  116. List *List `json:"list"`
  117. }
  118. // Metas Metas
  119. type Metas []*Meta
  120. func (as Metas) Len() int { return len(as) }
  121. func (as Metas) Less(i, j int) bool {
  122. var it, jt xtime.Time
  123. if as[i] != nil {
  124. it = as[i].PublishTime
  125. }
  126. if as[j] != nil {
  127. jt = as[j].PublishTime
  128. }
  129. return it > jt
  130. }
  131. func (as Metas) Swap(i, j int) { as[i], as[j] = as[j], as[i] }
  132. // CreationArtsType creation article-list type's count.
  133. type CreationArtsType struct {
  134. All int `json:"all"`
  135. Audit int `json:"audit"`
  136. Passed int `json:"passed"`
  137. NotPassed int `json:"not_passed"`
  138. }
  139. // ArtPage article page.
  140. type ArtPage struct {
  141. Pn int `json:"pn"`
  142. Ps int `json:"ps"`
  143. Total int `json:"total"`
  144. }
  145. // CreationArts creation article list.
  146. type CreationArts struct {
  147. Articles []*Meta `json:"articles"`
  148. Type *CreationArtsType `json:"type"`
  149. Page *ArtPage `json:"page"`
  150. }
  151. // Drafts draft list.
  152. type Drafts struct {
  153. Drafts []*Draft `json:"drafts"`
  154. Page *ArtPage `json:"page"`
  155. }
  156. // UpArtMetas article list.
  157. type UpArtMetas struct {
  158. Articles []*Meta `json:"articles"`
  159. Pn int `json:"pn"`
  160. Ps int `json:"ps"`
  161. Count int `json:"count"`
  162. }
  163. // UpArtMetasLists .
  164. type UpArtMetasLists struct {
  165. *UpArtMetas
  166. UpLists UpLists `json:"up_lists"`
  167. }
  168. // IsNormal judge whether article's state is normal.
  169. func (a *Meta) IsNormal() bool {
  170. return (a != nil) && (a.State >= StateOpen)
  171. }
  172. // IsNormal judge article state.
  173. func (a *Article) IsNormal() bool {
  174. if (a == nil) || (a.Meta == nil) {
  175. return false
  176. }
  177. return a.Meta.IsNormal()
  178. }
  179. // AttrVal gets attr val by bit.
  180. func (a *Meta) AttrVal(bit uint) bool {
  181. return ((a.Attributes>>bit)&int32(1) == 1)
  182. }
  183. // AttrSet sets attr value by bit.
  184. func (a *Meta) AttrSet(v int32, bit uint) {
  185. a.Attributes = a.Attributes&(^(1 << bit)) | (v << bit)
  186. }
  187. // Strong fill blank images and tags
  188. func (a *Meta) Strong() *Meta {
  189. if a.ImageURLs == nil {
  190. a.ImageURLs = []string{}
  191. }
  192. if a.OriginImageURLs == nil {
  193. a.OriginImageURLs = []string{}
  194. }
  195. if a.Tags == nil {
  196. a.Tags = []*Tag{}
  197. }
  198. return a
  199. }
  200. // AuthorPermission recode of article_authors table.
  201. type AuthorPermission struct {
  202. State int `json:"state"`
  203. Rtime xtime.Time `json:"rtime"`
  204. }
  205. // Favorite user favorite list.
  206. type Favorite struct {
  207. *Meta
  208. FavoriteTime int64 `json:"favorite_time"`
  209. Valid bool `json:"valid"`
  210. }
  211. // Page model
  212. type Page struct {
  213. Pn int `json:"pn"`
  214. Ps int `json:"ps"`
  215. Total int `json:"total"`
  216. }
  217. // RecommendArt model
  218. type RecommendArt struct {
  219. Meta
  220. Recommend
  221. }
  222. // RecommendArtWithLike model
  223. type RecommendArtWithLike struct {
  224. RecommendArt
  225. LikeState int `json:"like_state"`
  226. }
  227. // MetaWithLike meta with like
  228. type MetaWithLike struct {
  229. Meta
  230. LikeState int `json:"like_state"`
  231. }
  232. // Recommend model
  233. type Recommend struct {
  234. ArticleID int64 `json:"article_id,omitempty"`
  235. Position int `json:"-"`
  236. EndTime int64 `json:"-"`
  237. Rec bool `json:"rec"`
  238. RecFlag bool `json:"rec_flag"`
  239. RecText string `json:"rec_text"`
  240. RecImageURL string `json:"rec_image_url"`
  241. RecImageStartTime int64 `json:"-"`
  242. RecImageEndTime int64 `json:"-"`
  243. }
  244. // ViewInfo model
  245. type ViewInfo struct {
  246. Like int8 `json:"like"`
  247. Attention bool `json:"attention"`
  248. Favorite bool `json:"favorite"`
  249. Coin int64 `json:"coin"`
  250. Stats Stats `json:"stats"`
  251. Title string `json:"title"`
  252. BannerURL string `json:"banner_url"`
  253. Mid int64 `json:"mid"`
  254. AuthorName string `json:"author_name"`
  255. IsAuthor bool `json:"is_author"`
  256. ImageURLs []string `json:"image_urls"`
  257. OriginImageURLs []string `json:"origin_image_urls"`
  258. Shareable bool `json:"shareable"`
  259. ShowLaterWatch bool `json:"show_later_watch"`
  260. ShowSmallWindow bool `json:"show_small_window"`
  261. InList bool `json:"in_list"`
  262. Pre int64 `json:"pre"`
  263. Next int64 `json:"next"`
  264. }
  265. // Group2State mapping creation group to
  266. func Group2State(group int) (states []int64) {
  267. switch group {
  268. case GroupPassed:
  269. states = []int64{StateOpen, StateAutoPass, StateRePass, StateReReject}
  270. case GroupPending:
  271. states = []int64{StatePending, StateOpenPending, StateRePending}
  272. case GroupUnpassed:
  273. states = []int64{StateReject, StateOpenReject, StateLock, StateAutoLock}
  274. case GroupAll:
  275. fallthrough
  276. default:
  277. states = []int64{StateOpen, StatePending, StateOpenPending, StateReject, StateOpenReject, StateLock, StateAutoPass, StateAutoLock, StateRePending, StateRePass, StateReReject}
  278. }
  279. return
  280. }
  281. // CompleteURL adds host on path.
  282. func CompleteURL(path string) (url string) {
  283. if path == "" {
  284. // url = "http://static.hdslb.com/images/transparent.gif"
  285. return
  286. }
  287. url = path
  288. if strings.Index(path, "//") == 0 || strings.Index(path, "http://") == 0 || strings.Index(path, "https://") == 0 {
  289. return
  290. }
  291. url = "https://i0.hdslb.com" + url
  292. return
  293. }
  294. // CleanURL cuts host.
  295. func CleanURL(url string) (path string) {
  296. path = string(cleanURLRegexp.ReplaceAll([]byte(url), nil))
  297. return
  298. }
  299. // CompleteURLs .
  300. func CompleteURLs(paths []string) (urls []string) {
  301. for _, v := range paths {
  302. urls = append(urls, CompleteURL(v))
  303. }
  304. return
  305. }
  306. // CleanURLs .
  307. func CleanURLs(urls []string) (paths []string) {
  308. for _, v := range urls {
  309. paths = append(paths, CleanURL(v))
  310. }
  311. return
  312. }
  313. // Recommends model
  314. type Recommends [][]*Recommend
  315. func (as Recommends) Len() int { return len(as) }
  316. func (as Recommends) Less(i, j int) bool {
  317. return as[i][0].Position > as[j][0].Position
  318. }
  319. func (as Recommends) Swap(i, j int) { as[i], as[j] = as[j], as[i] }
  320. // RecommendHome .
  321. type RecommendHome struct {
  322. RecommendPlus
  323. Categories []*Category `json:"categories"`
  324. IP string `json:"ip"`
  325. }
  326. // RecommendPlus .
  327. type RecommendPlus struct {
  328. Banners []*Banner `json:"banners"`
  329. Articles []*RecommendArtWithLike `json:"articles"`
  330. Ranks []*RankMeta `json:"ranks"`
  331. Hotspots []*Hotspot `json:"hotspots"`
  332. }
  333. // Banner struct
  334. type Banner struct {
  335. ID int `json:"id"`
  336. Plat int8 `json:"-"`
  337. Position int `json:"index"`
  338. Title string `json:"title"`
  339. Image string `json:"image"`
  340. URL string `json:"url"`
  341. Build int `json:"-"`
  342. Condition string `json:"-"`
  343. Rule string `json:"-"`
  344. ResID int `json:"resource_id"`
  345. ServerType int `json:"server_type"`
  346. CmMark int `json:"cm_mark"`
  347. IsAd bool `json:"is_ad"`
  348. RequestID string `json:"request_id"`
  349. }
  350. // ConvertPlat convert plat from resource
  351. func ConvertPlat(p int8) (plat int8) {
  352. switch p {
  353. case 0: // resource iphone
  354. plat = PlatPC
  355. case 1: // resource iphone
  356. plat = PlatIPhone
  357. case 2: // resource android
  358. plat = PlatAndroid
  359. case 3: // resource pad
  360. plat = PlatIPad
  361. case 4: // resource iphoneg
  362. plat = PlatIPhoneI
  363. case 5: // resource androidg
  364. plat = PlatAndroidG
  365. case 6: // resource padg
  366. plat = PlatIPadI
  367. case 7: // resource h5
  368. plat = PlatH5
  369. case 8: // resource androidi
  370. plat = PlatAndroidI
  371. }
  372. return
  373. }
  374. // BannerRule .
  375. type BannerRule struct {
  376. Area string `json:"area"`
  377. Hash string `json:"hash"`
  378. Build int `json:"build"`
  379. Condition string `json:"conditions"`
  380. Channel string `json:"channel"`
  381. }
  382. // NoDistributeAttr check if no distribute
  383. func NoDistributeAttr(attr int32) bool {
  384. meta := Meta{Attributes: attr}
  385. return meta.AttrVal(AttrBitNoDistribute)
  386. }
  387. // NoRegionAttr check if no region
  388. func NoRegionAttr(attr int32) bool {
  389. meta := Meta{Attributes: attr}
  390. return meta.AttrVal(AttrBitNoRegion)
  391. }
  392. // AuthorLimit .
  393. type AuthorLimit struct {
  394. Limit int `json:"limit"`
  395. State int `json:"state"`
  396. Rtime xtime.Time `json:"rtime"`
  397. }
  398. // Forbid .
  399. func (a *AuthorLimit) Forbid() bool {
  400. // state -1 未通过 0待审 1通过 2关闭 3忽略
  401. if a == nil {
  402. return false
  403. }
  404. if a.State == AuthorStatePass {
  405. return false
  406. }
  407. return true
  408. }
  409. // Pass .
  410. func (a *AuthorLimit) Pass() bool {
  411. return (a != nil) && (a.State == AuthorStatePass)
  412. }
  413. // Notice notice
  414. type Notice struct {
  415. ID int64 `json:"id"`
  416. Title string `json:"title"`
  417. Content string `json:"content"`
  418. URL string `json:"url"`
  419. Plat int `json:"-"`
  420. Condition int `json:"-"`
  421. Build int `json:"-"`
  422. }
  423. // MoreArts .
  424. type MoreArts struct {
  425. Articles []*Meta `json:"articles"`
  426. Total int `json:"total"`
  427. ReadCount int64 `json:"read_count"`
  428. Author *AccountCard `json:"author"`
  429. Attention bool `json:"attention"`
  430. }
  431. // AccountCard .
  432. type AccountCard struct {
  433. Mid string `json:"mid"`
  434. Name string `json:"name"`
  435. Approve bool `json:"approve"`
  436. Sex string `json:"sex"`
  437. Rank string `json:"rank"`
  438. Face string `json:"face"`
  439. DisplayRank string `json:"DisplayRank"`
  440. Regtime int64 `json:"regtime"`
  441. Spacesta int `json:"spacesta"`
  442. Birthday string `json:"birthday"`
  443. Place string `json:"place"`
  444. Description string `json:"description"`
  445. Article int `json:"article"`
  446. Attentions []int64 `json:"attentions"`
  447. Fans int `json:"fans"`
  448. Friend int `json:"friend"`
  449. Attention int `json:"attention"`
  450. Sign string `json:"sign"`
  451. LevelInfo struct {
  452. Cur int `json:"current_level"`
  453. Min int `json:"current_min"`
  454. NowExp int `json:"current_exp"`
  455. NextExp interface{} `json:"next_exp"`
  456. } `json:"level_info"`
  457. Pendant struct {
  458. Pid int `json:"pid"`
  459. Name string `json:"name"`
  460. Image string `json:"image"`
  461. Expire int `json:"expire"`
  462. } `json:"pendant"`
  463. Nameplate struct {
  464. Nid int `json:"nid"`
  465. Name string `json:"name"`
  466. Image string `json:"image"`
  467. ImageSmall string `json:"image_small"`
  468. Level string `json:"level"`
  469. Condition string `json:"condition"`
  470. } `json:"nameplate"`
  471. OfficialVerify struct {
  472. Type int `json:"type"`
  473. Desc string `json:"desc"`
  474. } `json:"official_verify"`
  475. Vip struct {
  476. Type int `json:"vipType"`
  477. DueDate int64 `json:"vipDueDate"`
  478. DueRemark string `json:"dueRemark"`
  479. AccessStatus int `json:"accessStatus"`
  480. VipStatus int `json:"vipStatus"`
  481. VipStatusWarn string `json:"vipStatusWarn"`
  482. } `json:"vip"`
  483. }
  484. // FromCard from account card.
  485. func (ac *AccountCard) FromCard(card *account.Card) {
  486. ac.Mid = strconv.FormatInt(card.Mid, 10)
  487. ac.Name = card.Name
  488. // ac.Approve =
  489. ac.Sex = card.Sex
  490. ac.Rank = strconv.FormatInt(int64(card.Rank), 10)
  491. ac.Face = card.Face
  492. ac.DisplayRank = strconv.FormatInt(int64(card.Rank), 10)
  493. // ac.Regtime =
  494. // ac.Spacesta =
  495. // ac.Birthday =
  496. // ac.Place =
  497. // ac.Description =
  498. // ac.Article =
  499. ac.Attentions = []int64{}
  500. // ac.Fans =
  501. // ac.Friend =
  502. // ac.Attention =
  503. ac.Sign = card.Sign
  504. ac.LevelInfo.Cur = int(card.Level)
  505. ac.Pendant.Pid = card.Pendant.Pid
  506. ac.Pendant.Name = card.Pendant.Name
  507. ac.Pendant.Image = card.Pendant.Image
  508. ac.Pendant.Expire = card.Pendant.Expire
  509. ac.Nameplate.Nid = card.Nameplate.Nid
  510. ac.Nameplate.Name = card.Nameplate.Name
  511. ac.Nameplate.Image = card.Nameplate.Image
  512. ac.Nameplate.ImageSmall = card.Nameplate.ImageSmall
  513. ac.Nameplate.Level = card.Nameplate.Level
  514. ac.Nameplate.Condition = card.Nameplate.Condition
  515. if card.Official.Role == 0 {
  516. ac.OfficialVerify.Type = -1
  517. } else {
  518. if card.Official.Role <= 2 {
  519. ac.OfficialVerify.Type = 0
  520. } else {
  521. ac.OfficialVerify.Type = 1
  522. }
  523. ac.OfficialVerify.Desc = card.Official.Title
  524. }
  525. ac.Vip.Type = int(card.Vip.Type)
  526. ac.Vip.VipStatus = int(card.Vip.Status)
  527. ac.Vip.DueDate = card.Vip.DueDate
  528. }
  529. // FromProfileStat .
  530. func (ac *AccountCard) FromProfileStat(card *account.ProfileStat) {
  531. ac.Mid = strconv.FormatInt(card.Mid, 10)
  532. ac.Name = card.Name
  533. // ac.Approve =
  534. ac.Sex = card.Sex
  535. ac.Rank = strconv.FormatInt(int64(card.Rank), 10)
  536. ac.Face = card.Face
  537. ac.DisplayRank = strconv.FormatInt(int64(card.Rank), 10)
  538. // ac.Regtime =
  539. // ac.Spacesta =
  540. // ac.Birthday =
  541. // ac.Place =
  542. // ac.Description =
  543. // ac.Article =
  544. ac.Attentions = []int64{}
  545. ac.Fans = int(card.Follower)
  546. // ac.Friend =
  547. // ac.Attention =
  548. ac.Sign = card.Sign
  549. ac.LevelInfo.Cur = int(card.Level)
  550. ac.Pendant.Pid = card.Pendant.Pid
  551. ac.Pendant.Name = card.Pendant.Name
  552. ac.Pendant.Image = card.Pendant.Image
  553. ac.Pendant.Expire = card.Pendant.Expire
  554. ac.Nameplate.Nid = card.Nameplate.Nid
  555. ac.Nameplate.Name = card.Nameplate.Name
  556. ac.Nameplate.Image = card.Nameplate.Image
  557. ac.Nameplate.ImageSmall = card.Nameplate.ImageSmall
  558. ac.Nameplate.Level = card.Nameplate.Level
  559. ac.Nameplate.Condition = card.Nameplate.Condition
  560. if card.Official.Role == 0 {
  561. ac.OfficialVerify.Type = -1
  562. } else {
  563. if card.Official.Role <= 2 {
  564. ac.OfficialVerify.Type = 0
  565. } else {
  566. ac.OfficialVerify.Type = 1
  567. }
  568. ac.OfficialVerify.Desc = card.Official.Title
  569. }
  570. ac.Vip.Type = int(card.Vip.Type)
  571. ac.Vip.VipStatus = int(card.Vip.Status)
  572. ac.Vip.DueDate = card.Vip.DueDate
  573. }
  574. // NoticeState .
  575. type NoticeState map[string]bool
  576. // 数据库为tinyint 长度必须小于7 字段只能追加
  577. var _noticeStates = []string{"lead", "new"}
  578. // NewNoticeState .
  579. func NewNoticeState(value int64) (res NoticeState) {
  580. res = make(map[string]bool)
  581. for i, name := range _noticeStates {
  582. res[name] = ((value>>uint(i))&int64(1) == 1)
  583. }
  584. return
  585. }
  586. // ToInt64 .
  587. func (n NoticeState) ToInt64() (res int64) {
  588. for i, name := range _noticeStates {
  589. if n[name] {
  590. res = res | (1 << uint(i))
  591. }
  592. }
  593. return
  594. }
  595. // Activity .
  596. type Activity struct {
  597. ActURL string `json:"act_url"`
  598. Author string `json:"author"`
  599. Cover string `json:"cover"`
  600. Ctime string `json:"ctime"`
  601. Dic string `json:"dic"`
  602. Etime string `json:"etime"`
  603. Flag string `json:"flag"`
  604. H5Cover string `json:"h5_cover"`
  605. ID int64 `json:"id"`
  606. Letime string `json:"letime"`
  607. Level string `json:"level"`
  608. Lstime string `json:"lstime"`
  609. Mtime string `json:"mtime"`
  610. Name string `json:"name"`
  611. Oid int64 `json:"oid"`
  612. State int64 `json:"state"`
  613. Stime string `json:"stime"`
  614. Tags string `json:"tags"`
  615. Type int64 `json:"type"`
  616. Uetime string `json:"uetime"`
  617. Ustime string `json:"ustime"`
  618. }
  619. // SkyHorseResp response
  620. type SkyHorseResp struct {
  621. Code int `json:"code"`
  622. Data []struct {
  623. ID int64 `json:"id"`
  624. AvFeature string `json:"av_feature"`
  625. } `json:"data"`
  626. UserFeature string `json:"user_feature"`
  627. }
  628. // CheckBFSImage check bfs file
  629. func CheckBFSImage(src string) bool {
  630. return bfsRegexp.MatchString(src)
  631. }
  632. // FillDefaultImage .
  633. func (l *List) FillDefaultImage(image string) {
  634. if l != nil && l.ImageURL == "" {
  635. l.ImageURL = image
  636. }
  637. }
  638. // Articles .
  639. type Articles struct {
  640. *Article
  641. Pre int64 `json:"pre"`
  642. Next int64 `json:"next"`
  643. }
  644. // ArticleViewList .
  645. type ArticleViewList struct {
  646. Position int `json:"position"`
  647. Aids []int64 `json:"articles_id"`
  648. From string `json:"from"`
  649. Mid int64 `json:"mid"`
  650. Build int `json:"build"`
  651. Buvid string `json:"buvid"`
  652. Plat int8 `json:"plat"`
  653. }
  654. // TagArts .
  655. type TagArts struct {
  656. Tid int64 `json:"tid"`
  657. Aids []int64 `json:"aids"`
  658. }
  659. // MediaResp .
  660. type MediaResp struct {
  661. Code int `json:"code"`
  662. Message string `json:"message"`
  663. Result *MediaResult `json:"result"`
  664. }
  665. // MediaResult .
  666. type MediaResult struct {
  667. Score int32 `json:"score"`
  668. Media struct {
  669. MediaID int64 `json:"media_id"`
  670. Title string `json:"title"`
  671. Cover string `json:"cover"`
  672. Area string `json:"area"`
  673. TypeID int32 `json:"type_id"`
  674. TypeName string `json:"type_name"`
  675. } `json:"media"`
  676. }