tables.go 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. package datamodel
  2. import (
  3. "strconv"
  4. "time"
  5. xtime "go-common/library/time"
  6. )
  7. // LogTime
  8. // deserialize format "2006-01-02"
  9. // serialize format unix timestamp
  10. type LogTime time.Time
  11. const (
  12. timeLayout = "2006-01-02"
  13. timeLayoutWithQuote = `"2006-01-02"`
  14. )
  15. //MarshalJSON marshal logdate as timestamp
  16. func (t *LogTime) MarshalJSON() ([]byte, error) {
  17. var scratch [64]byte
  18. var dst = strconv.AppendInt(scratch[:0], (*time.Time)(t).Unix(), 10)
  19. return dst, nil
  20. }
  21. //UnmarshalJSON parse timestamp or something like "2006-01-02"
  22. func (t *LogTime) UnmarshalJSON(b []byte) (err error) {
  23. var str = string(b)
  24. if str == "null" {
  25. return nil
  26. }
  27. if len(str) == 0 {
  28. return
  29. }
  30. if str[0] == '"' {
  31. // Fractional seconds are handled implicitly by Parse.
  32. tmp, e := time.ParseInLocation(timeLayoutWithQuote, string(b), time.Local)
  33. if e != nil {
  34. err = e
  35. return
  36. }
  37. *t = LogTime(tmp)
  38. } else {
  39. // parse as timestamp
  40. num, e := strconv.ParseInt(str, 10, 64)
  41. if e != nil {
  42. err = e
  43. return
  44. }
  45. *t = LogTime(time.Unix(num, 0))
  46. }
  47. return
  48. }
  49. //Time export library time
  50. func (t *LogTime) Time() xtime.Time {
  51. return xtime.Time(time.Time(*t).Unix())
  52. }
  53. // see mcn_data.sql for more info
  54. //McnStatisticBaseInfo2 new from data center
  55. type McnStatisticBaseInfo2 struct {
  56. DanmuAll int64 `json:"danmu_all"`
  57. DanmuInc int64 `json:"danmu_inc"`
  58. ReplyAll int64 `json:"reply_all"`
  59. ReplyInc int64 `json:"reply_inc"`
  60. ShareAll int64 `json:"share_all"`
  61. ShareInc int64 `json:"share_inc"`
  62. CoinAll int64 `json:"coin_all"`
  63. CoinInc int64 `json:"coin_inc"`
  64. FavAll int64 `json:"fav_all"`
  65. FavInc int64 `json:"fav_inc"`
  66. LikeAll int64 `json:"like_all"`
  67. LikeInc int64 `json:"like_inc"`
  68. Ctime time.Time `json:"-"`
  69. Mtime time.Time `json:"-"`
  70. }
  71. //DmConMcnArchiveD 投稿数及昨日增量
  72. type DmConMcnArchiveD struct {
  73. McnStatisticBaseInfo2
  74. ID int64 `json:"-"`
  75. SignID int64 `json:"-"`
  76. McnMid int64 `json:"-"`
  77. LogDate LogTime `json:"log_date"`
  78. UpAll int64 `json:"up_all"`
  79. ArchiveAll int64 `json:"archive_all"`
  80. ArchiveInc int64 `json:"archive_inc"`
  81. PlayAll int64 `json:"play_all"`
  82. PlayInc int64 `json:"play_inc"`
  83. FansAll int64 `json:"fans_all"`
  84. FansInc int64 `json:"fans_inc"`
  85. }
  86. //DmConMcnIndexIncD 播放/弹幕/评论/分享/硬币/收藏/点赞数每日增量
  87. type DmConMcnIndexIncD struct {
  88. ID int64 `json:"-"`
  89. SignID int64 `json:"-"`
  90. McnMid int64 `json:"-"`
  91. LogDate LogTime `json:"log_date"`
  92. Value int64 `json:"value"`
  93. Type string `json:"-"`
  94. Ctime time.Time `json:"-"`
  95. Mtime time.Time `json:"-"`
  96. }
  97. //DmConMcnIndexSourceD mcn播放/弹幕/评论/分享/硬币/收藏/点赞来源分区
  98. type DmConMcnIndexSourceD struct {
  99. ID int64 `json:"-"`
  100. SignID int64 `json:"-"`
  101. McnMid int64 `json:"-"`
  102. LogDate LogTime `json:"log_date"`
  103. TypeID int64 `json:"type_id"`
  104. Rank int64 `json:"rank"`
  105. Value int64 `json:"value"`
  106. Type string `json:"-"`
  107. Ctime time.Time `json:"-"`
  108. Mtime time.Time `json:"-"`
  109. TypeName string `json:"type_name"`
  110. }
  111. //DmConMcnPlaySourceD #mcn稿件播放来源占比
  112. type DmConMcnPlaySourceD struct {
  113. ID int64 `json:"-"`
  114. SignID int64 `json:"-"`
  115. McnMid int64 `json:"-"`
  116. LogDate LogTime `json:"log_date"`
  117. Iphone int64 `json:"iphone"`
  118. Android int64 `json:"android"`
  119. Pc int64 `json:"pc"`
  120. H5 int64 `json:"h5"`
  121. Other int64 `json:"other"`
  122. Ctime time.Time `json:"-"`
  123. Mtime time.Time `json:"-"`
  124. }
  125. //DmConMcnFansSexW #游客/粉丝性别占比
  126. type DmConMcnFansSexW struct {
  127. ID int64 `json:"-"`
  128. SignID int64 `json:"-"`
  129. McnMid int64 `json:"-"`
  130. LogDate LogTime `json:"log_date"`
  131. Male int64 `json:"male"`
  132. Female int64 `json:"female"`
  133. Type string `json:"-"`
  134. Ctime time.Time `json:"-"`
  135. Mtime time.Time `json:"-"`
  136. }
  137. //DmConMcnFansAgeW #游客/粉丝年龄分布
  138. type DmConMcnFansAgeW struct {
  139. ID int64 `json:"-"`
  140. SignID int64 `json:"-"`
  141. McnMid int64 `json:"-"`
  142. LogDate LogTime `json:"log_date"`
  143. A int64 `json:"a"` //'0-16岁人数',
  144. B int64 `json:"b"` //'16-25岁人数',
  145. C int64 `json:"c"` //'25-40岁人数',
  146. D int64 `json:"d"` //'40岁以上人数',
  147. Type string `json:"-"` //'粉丝类型,guest、fans',
  148. Ctime time.Time `json:"-"`
  149. Mtime time.Time `json:"-"`
  150. }
  151. //DmConMcnFansPlayWayW 游客/粉丝观看途径
  152. type DmConMcnFansPlayWayW struct {
  153. ID int64 `json:"-"`
  154. SignID int64 `json:"-"`
  155. McnMid int64 `json:"-"`
  156. LogDate LogTime `json:"log_date"`
  157. App int64 `json:"app"`
  158. Pc int64 `json:"pc"`
  159. Outside int64 `json:"outside"`
  160. Other int64 `json:"other"`
  161. Type string `json:"-"`
  162. Ctime time.Time `json:"-"`
  163. Mtime time.Time `json:"-"`
  164. }
  165. //DmConMcnFansAreaW #游客/粉丝地区分布
  166. type DmConMcnFansAreaW struct {
  167. ID int64 `json:"-"`
  168. SignID int64 `json:"-"`
  169. McnMid int64 `json:"-"`
  170. LogDate LogTime `json:"log_date"`
  171. Province string `json:"province"`
  172. User int64 `json:"user"`
  173. Type string `json:"-"`
  174. Ctime time.Time `json:"-"`
  175. Mtime time.Time `json:"-"`
  176. }
  177. //DmConMcnFansTypeW #游客/粉丝倾向分布
  178. type DmConMcnFansTypeW struct {
  179. ID int64 `json:"-"`
  180. SignID int64 `json:"-"`
  181. McnMid int64 `json:"-"`
  182. LogDate LogTime `json:"log_date"`
  183. TypeID int64 `json:"type_id"`
  184. Play int64 `json:"play"`
  185. Type string `json:"-"`
  186. Ctime time.Time `json:"-"`
  187. Mtime time.Time `json:"-"`
  188. TypeName string `json:"type_name"`
  189. }
  190. //DmConMcnFansD #mcn粉丝数相关
  191. type DmConMcnFansD struct {
  192. ID int64 `json:"-"`
  193. SignId int64 `json:"-"`
  194. McnMid int64 `json:"-"`
  195. LogDate LogTime `json:"log_date"`
  196. FansAll int64 `json:"fans_all"`
  197. FansInc int64 `json:"fans_inc"`
  198. ActFans int64 `json:"act_fans"`
  199. FansDecAll int64 `json:"fans_dec_all"`
  200. FansDec int64 `json:"fans_dec"`
  201. ViewFansRate float64 `json:"view_fans_rate"`
  202. ActFansRate float64 `json:"act_fans_rate"`
  203. ReplyFansRate float64 `json:"reply_fans_rate"`
  204. DanmuFansRate float64 `json:"danmu_fans_rate"`
  205. CoinFansRate float64 `json:"coin_fans_rate"`
  206. LikeFansRate float64 `json:"like_fans_rate"`
  207. FavFansRate float64 `json:"fav_fans_rate"`
  208. ShareFansRate float64 `json:"share_fans_rate"`
  209. LiveGiftFansRate float64 `json:"live_gift_fans_rate"`
  210. LiveDanmuFansRate float64 `json:"live_danmu_fans_rate"`
  211. Ctime time.Time `json:"-"`
  212. Mtime time.Time `json:"-"`
  213. }
  214. //DmConMcnFansIncD #mcn粉丝按天增量
  215. type DmConMcnFansIncD struct {
  216. ID int64 `json:"-"`
  217. SignID int64 `json:"-"`
  218. McnMid int64 `json:"-"`
  219. LogDate LogTime `json:"log_date"`
  220. FansInc int64 `json:"fans_inc"`
  221. Ctime time.Time `json:"-"`
  222. Mtime time.Time `json:"-"`
  223. }
  224. //DmConMcnFansDecD #mcn粉丝按天取关数
  225. type DmConMcnFansDecD struct {
  226. ID int64 `json:"-"`
  227. SignID int64 `json:"-"`
  228. McnMid int64 `json:"-"`
  229. LogDate LogTime `json:"log_date"`
  230. FansDec int64 `json:"fans_dec"`
  231. Ctime time.Time `json:"-"`
  232. Mtime time.Time `json:"-"`
  233. }
  234. //DmConMcnFansAttentionWayD #mcn粉丝关注渠道
  235. type DmConMcnFansAttentionWayD struct {
  236. ID int64 `json:"-"`
  237. SignID int64 `json:"-"`
  238. McnMid int64 `json:"-"`
  239. LogDate LogTime `json:"log_date"`
  240. Homepage int64 `json:"homepage"`
  241. Video int64 `json:"video"`
  242. Article int64 `json:"article"`
  243. Music int64 `json:"music"`
  244. Other int64 `json:"other"`
  245. Ctime time.Time `json:"-"`
  246. Mtime time.Time `json:"-"`
  247. }
  248. // DmConMcnFansTagW #游客/粉丝标签地图分布
  249. type DmConMcnFansTagW struct {
  250. ID int64 `json:"-"`
  251. SignID int64 `json:"-"`
  252. McnMid int64 `json:"-"`
  253. LogDate LogTime `json:"log_date"`
  254. TagID int64 `json:"tag_id"`
  255. Play int64 `json:"play"`
  256. Type string `json:"-"`
  257. Ctime time.Time `json:"-"`
  258. Mtime time.Time `json:"-"`
  259. TagName string `json:"tag_name"`
  260. }