reply.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. package mcnmodel
  2. import (
  3. "sort"
  4. mcnadminmodel "go-common/app/admin/main/mcn/model"
  5. "go-common/app/interface/main/mcn/model"
  6. "go-common/app/interface/main/mcn/model/datamodel"
  7. arcgrpc "go-common/app/service/main/archive/api"
  8. "go-common/library/time"
  9. )
  10. // McnGetStateReply .
  11. type McnGetStateReply struct {
  12. State int8 `json:"state"`
  13. RejectReason string `json:"reject_reason"`
  14. }
  15. // CommonReply reply with nothing, base struct
  16. type CommonReply struct{}
  17. //Sorter can sort
  18. type Sorter interface {
  19. Sort()
  20. }
  21. // McnGetBindReply .
  22. type McnGetBindReply struct {
  23. BindID int64 `json:"bind_id" gorm:"column:bind_id"`
  24. CompanyName string `json:"company_name" gorm:"column:company_name"`
  25. McnMid uint32 `json:"mcn_mid" gorm:"column:mcn_mid"`
  26. McnName string `json:"mcn_name"`
  27. UpAuthLink string `json:"up_auth_link" gorm:"column:up_auth_link"`
  28. OldPerm uint32 `json:"-" gorm:"column:old_permission"`
  29. NewPerm uint32 `json:"-" gorm:"column:new_permission"`
  30. OldPermission mcnadminmodel.Permits `json:"old_permission"`
  31. NewPermission mcnadminmodel.Permits `json:"new_permission"`
  32. }
  33. //Finish call this before send
  34. func (s *McnGetBindReply) Finish() {
  35. s.OldPermission.SetAttrPermitVal(s.OldPerm)
  36. s.NewPermission.SetAttrPermitVal(s.NewPerm)
  37. }
  38. // McnGetDataSummaryReply .
  39. type McnGetDataSummaryReply struct {
  40. datamodel.McnStatisticBaseInfo2
  41. IsNull bool `json:"is_null"` // 缓存用来标记
  42. UpCount int64 `json:"up_count"`
  43. UpCountDiff int64 `json:"-"`
  44. FansCountAccumulate int64 `json:"fans_count_accumulate"`
  45. FansCountDiff int64 `json:"fans_count_diff"`
  46. PlayCountAccumulate int64 `json:"play_count_accumulate"`
  47. PlayCountDiff int64 `json:"play_count_diff"`
  48. ArchiveCountAccumulate int64 `json:"archive_count_accumulate"`
  49. ArchiveCountDiff int64 `json:"archive_count_diff"`
  50. GenerateDate time.Time `json:"generate_date"`
  51. }
  52. // CopyFrom .
  53. func (m *McnGetDataSummaryReply) CopyFrom(v *McnDataSummary) {
  54. if v == nil {
  55. return
  56. }
  57. m.UpCount = int64(v.UpCount)
  58. m.FansCountAccumulate = int64(v.FansCountAccumulate)
  59. m.PlayCountAccumulate = int64(v.PlayCountAccumulate)
  60. m.ArchiveCountAccumulate = int64(v.ArchiveCountAccumulate)
  61. m.GenerateDate = v.GenerateDate
  62. }
  63. //CopyFromDmConMcnArchiveD .
  64. func (m *McnGetDataSummaryReply) CopyFromDmConMcnArchiveD(v *datamodel.DmConMcnArchiveD) {
  65. if v == nil {
  66. return
  67. }
  68. m.UpCount = v.UpAll
  69. // m.UpCountDiff 不再使用了。
  70. m.ArchiveCountAccumulate = v.ArchiveAll
  71. m.ArchiveCountDiff = v.ArchiveInc
  72. m.PlayCountAccumulate = v.PlayAll
  73. m.PlayCountDiff = v.PlayInc
  74. m.FansCountAccumulate = v.FansAll
  75. m.FansCountDiff = v.FansInc
  76. m.McnStatisticBaseInfo2 = v.McnStatisticBaseInfo2
  77. m.GenerateDate = v.LogDate.Time()
  78. }
  79. // CalcDiff .
  80. func (m *McnGetDataSummaryReply) CalcDiff(lastDay *McnDataSummary) {
  81. if lastDay == nil {
  82. return
  83. }
  84. m.UpCountDiff = m.UpCount - int64(lastDay.UpCount)
  85. m.FansCountDiff = m.FansCountAccumulate - int64(lastDay.FansCountAccumulate)
  86. m.PlayCountDiff = m.PlayCountAccumulate - int64(lastDay.PlayCountAccumulate)
  87. m.ArchiveCountDiff = m.ArchiveCountAccumulate - int64(lastDay.ArchiveCountAccumulate)
  88. }
  89. // McnUpDataInfo mcn data
  90. type McnUpDataInfo struct {
  91. McnDataUp
  92. ActiveTid int16 `json:"active_tid"`
  93. TidName string `json:"tid_name"`
  94. BeginDate time.Time `json:"begin_date" gorm:"column:begin_date"`
  95. EndDate time.Time `json:"end_date" gorm:"column:end_date"`
  96. State int8 `json:"state" gorm:"column:state"`
  97. Name string `json:"name"`
  98. Permission uint32 `gorm:"column:permission" json:"-"`
  99. PublicationPrice int64 `gorm:"column:publication_price" json:"publication_price"` // 单位:1/1000 元
  100. Permits mcnadminmodel.Permits `json:"permits"`
  101. }
  102. // HideData if state is not right, hide the data
  103. func (m *McnUpDataInfo) HideData(hideDate bool) {
  104. m.FansIncreaseMonth = 0
  105. m.PlayCount = 0
  106. m.ArchiveCount = 0
  107. m.FansIncreaseAccumulate = 0
  108. m.FansCount = 0
  109. m.FansCountActive = 0
  110. if hideDate {
  111. m.BeginDate = 0
  112. m.EndDate = 0
  113. }
  114. }
  115. //Finish call finish before send out
  116. func (m *McnUpDataInfo) Finish() {
  117. m.Permits.SetAttrPermitVal(m.Permission)
  118. }
  119. // McnBindUpApplyReply .
  120. type McnBindUpApplyReply struct {
  121. BindID int64 `json:"bind_id"`
  122. }
  123. // McnGetUpListReply list
  124. type McnGetUpListReply struct {
  125. Result []*McnUpDataInfo `json:"result"`
  126. model.PageResult
  127. }
  128. //Finish call finish before send out
  129. func (m *McnGetUpListReply) Finish() {
  130. for _, v := range m.Result {
  131. v.Finish()
  132. }
  133. }
  134. // McnExistReply exist
  135. type McnExistReply struct {
  136. Exist int `json:"exist"`
  137. }
  138. // McnGetAccountReply reply
  139. type McnGetAccountReply struct {
  140. Mid int64 `json:"mid"`
  141. Name string `json:"name"`
  142. }
  143. // McnGetMcnOldInfoReply req
  144. type McnGetMcnOldInfoReply struct {
  145. CompanyName string `json:"company_name"`
  146. CompanyLicenseID string `json:"company_license_id"`
  147. ContactName string `json:"contact_name"`
  148. ContactTitle string `json:"contact_title"`
  149. ContactIdcard string `json:"contact_idcard"`
  150. ContactPhone string `json:"contact_phone"`
  151. }
  152. // Copy .
  153. func (m *McnGetMcnOldInfoReply) Copy(v *McnSign) {
  154. if v == nil {
  155. return
  156. }
  157. m.CompanyName = v.CompanyName
  158. m.CompanyLicenseID = v.CompanyLicenseID
  159. m.ContactName = v.ContactName
  160. m.ContactTitle = v.ContactTitle
  161. m.ContactIdcard = v.ContactIdcard
  162. m.ContactPhone = v.ContactPhone
  163. }
  164. // RankDataInterface 用来取排行用的数据
  165. type RankDataInterface interface {
  166. GetTid() int16
  167. GetDataType() DataType
  168. GetValue() int64
  169. }
  170. // RankDataBase 基本排行信息
  171. type RankDataBase struct {
  172. Tid int16 `json:"tid"`
  173. DataType DataType `json:"data_type"`
  174. }
  175. // GetTid .
  176. func (r *RankDataBase) GetTid() int16 {
  177. return r.Tid
  178. }
  179. // GetDataType .
  180. func (r *RankDataBase) GetDataType() DataType {
  181. return r.DataType
  182. }
  183. // RankUpFansInfo reply info
  184. type RankUpFansInfo struct {
  185. RankDataBase
  186. Mid int64 `json:"mid"`
  187. UpFaceLink string `json:"up_face_link"`
  188. Name string `json:"name"`
  189. FansIncrease int64 `json:"fans_increase"`
  190. FansAccumulate int64 `json:"fans_accumulate"`
  191. TidName string `json:"tid_name"`
  192. }
  193. // GetValue .
  194. func (r *RankUpFansInfo) GetValue() int64 {
  195. return r.FansIncrease
  196. }
  197. // Copy copy from rank up .
  198. func (r *RankUpFansInfo) Copy(v *McnRankUpFan) {
  199. if v == nil {
  200. return
  201. }
  202. r.DataType = v.DataType
  203. r.Tid = v.ActiveTid
  204. r.Mid = v.UpMid
  205. r.FansIncrease = v.Value1
  206. r.FansAccumulate = v.Value2
  207. }
  208. // McnGetRankUpFansReply reply
  209. type McnGetRankUpFansReply struct {
  210. Result []RankDataInterface `json:"result"` // 按顺序进行排名
  211. TypeList []*TidnameInfo `json:"type_list"`
  212. }
  213. // RankArchiveLikeInfo archive like rank info
  214. type RankArchiveLikeInfo struct {
  215. RankDataBase
  216. ArchiveID int64 `json:"archive_id"` // 稿件ID
  217. ArchiveTitle string `json:"archive_title"`
  218. Pic string `json:"pic"` // 封面
  219. TidName string `json:"tid_name"`
  220. LikesIncrease int64 `json:"likes_increase"`
  221. LikesAccumulate int64 `json:"likes_accumulate"`
  222. PlayIncrease int64 `json:"play_increase"`
  223. Ctime time.Time `json:"ctime"`
  224. Author arcgrpc.Author `json:"author"` // up主信息
  225. Stat arcgrpc.Stat `json:"stat"` // 统计信息
  226. }
  227. // GetValue .
  228. func (r *RankArchiveLikeInfo) GetValue() int64 {
  229. return r.LikesIncrease
  230. }
  231. // CopyFromDB .
  232. func (r *RankArchiveLikeInfo) CopyFromDB(v *McnRankArchiveLike) {
  233. if v == nil {
  234. return
  235. }
  236. r.ArchiveID = v.ArchiveID
  237. r.LikesIncrease = v.LikeCount
  238. r.Tid = v.Tid
  239. r.DataType = v.DataType
  240. r.PlayIncrease = v.PlayIncr
  241. }
  242. // CopyFromArchive copy from archive info from archive service
  243. func (r *RankArchiveLikeInfo) CopyFromArchive(v *arcgrpc.Arc) {
  244. if v == nil {
  245. return
  246. }
  247. r.ArchiveTitle = v.Title
  248. r.Pic = v.Pic
  249. r.Ctime = v.Ctime
  250. r.TidName = v.TypeName
  251. r.Author = v.Author
  252. r.Stat = v.Stat
  253. r.Tid = int16(v.TypeID)
  254. r.LikesAccumulate = int64(v.Stat.Like)
  255. }
  256. // TidnameInfo tid name
  257. type TidnameInfo struct {
  258. Tid int16 `json:"tid"`
  259. Name string `json:"name"`
  260. }
  261. // McnGetRecommendPoolInfo recomend info
  262. type McnGetRecommendPoolInfo struct {
  263. UpMid int64 `json:"up_mid"`
  264. FansCount int64 `json:"fans_count"`
  265. FansCountIncreaseMonth int64 `json:"fans_count_increase_month"`
  266. ArchiveCount int64 `json:"archive_count"`
  267. ActiveTid int16 `json:"active_tid"`
  268. UpName string `json:"up_name"`
  269. TidName string `json:"tid_name"`
  270. }
  271. // Copy copy from db
  272. func (m *McnGetRecommendPoolInfo) Copy(v *McnUpRecommendPool) {
  273. if v == nil {
  274. return
  275. }
  276. m.UpMid = v.UpMid
  277. m.FansCount = v.FansCount
  278. m.FansCountIncreaseMonth = v.FansCountIncreaseMonth
  279. m.ArchiveCount = v.ArchiveCount
  280. m.ActiveTid = v.ActiveTid
  281. }
  282. // McnGetRecommendPoolReply result
  283. type McnGetRecommendPoolReply struct {
  284. model.PageResult
  285. Result []*McnGetRecommendPoolInfo `json:"result"`
  286. }
  287. // McnGetRecommendPoolTidListReply result
  288. type McnGetRecommendPoolTidListReply struct {
  289. Result []*TidnameInfo `json:"result"`
  290. }
  291. // --------------------------- 三期需求
  292. // McnGetIndexIncReply 播放/弹幕/评论/分享/硬币/收藏/点赞数每日增量
  293. type McnGetIndexIncReply struct {
  294. Result []*datamodel.DmConMcnIndexIncD `json:"result"`
  295. }
  296. //McnGetIndexSourceReply 播放/弹幕/评论/分享/硬币/收藏/点赞来源分区
  297. type McnGetIndexSourceReply struct {
  298. Result []*datamodel.DmConMcnIndexSourceD `json:"result"`
  299. }
  300. //Sort sort
  301. func (s *McnGetIndexSourceReply) Sort() {
  302. sort.Slice(s.Result, func(i, j int) bool {
  303. return s.Result[i].Value > s.Result[j].Value
  304. })
  305. }
  306. //McnGetPlaySourceReply #mcn稿件播放来源占比
  307. type McnGetPlaySourceReply struct {
  308. datamodel.DmConMcnPlaySourceD
  309. }
  310. // McnGetMcnFansReply mcn粉丝基本数据
  311. type McnGetMcnFansReply struct {
  312. datamodel.DmConMcnFansD
  313. }
  314. //McnGetMcnFansIncReply mcn粉丝按天增量
  315. type McnGetMcnFansIncReply struct {
  316. Result []*datamodel.DmConMcnFansIncD `json:"result"`
  317. }
  318. //McnGetMcnFansDecReply mcn粉丝按天取关数
  319. type McnGetMcnFansDecReply struct {
  320. Result []*datamodel.DmConMcnFansDecD `json:"result"`
  321. }
  322. //McnGetMcnFansAttentionWayReply mcn粉丝关注渠道
  323. type McnGetMcnFansAttentionWayReply struct {
  324. datamodel.DmConMcnFansAttentionWayD
  325. }
  326. // McnGetBaseFansAttrReply # mcn 性别占比 + 观众年龄 + 观看途径
  327. type McnGetBaseFansAttrReply struct {
  328. FansSex *datamodel.DmConMcnFansSexW `json:"fans_sex"`
  329. FansAge *datamodel.DmConMcnFansAgeW `json:"fans_age"`
  330. FansPlayWay *datamodel.DmConMcnFansPlayWayW `json:"fans_play_way"`
  331. }
  332. // McnGetFansAreaReply 游客/粉丝地区分布
  333. type McnGetFansAreaReply struct {
  334. Result []*datamodel.DmConMcnFansAreaW `json:"result"`
  335. }
  336. //Sort sort.
  337. func (s *McnGetFansAreaReply) Sort() {
  338. sort.Slice(s.Result, func(i, j int) bool {
  339. return s.Result[i].User > s.Result[j].User
  340. })
  341. }
  342. // McnGetFansTypeReply 游客/粉丝倾向分布
  343. type McnGetFansTypeReply struct {
  344. Result []*datamodel.DmConMcnFansTypeW `json:"result"`
  345. }
  346. //Sort sort.
  347. func (s *McnGetFansTypeReply) Sort() {
  348. sort.Slice(s.Result, func(i, j int) bool {
  349. return s.Result[i].Play > s.Result[j].Play
  350. })
  351. }
  352. // McnGetFansTagReply 游客/粉丝标签地图分布
  353. type McnGetFansTagReply struct {
  354. Result []*datamodel.DmConMcnFansTagW `json:"result"`
  355. }
  356. // ----------------------------- 4期需求
  357. //McnChangePermitReply .
  358. type McnChangePermitReply = McnBindUpApplyReply
  359. //McnGetUpPermitReply 4.2
  360. type McnGetUpPermitReply struct {
  361. Old *mcnadminmodel.Permits `json:"old"`
  362. New *mcnadminmodel.Permits `json:"new"`
  363. ContractLink string `json:"contract_link"`
  364. }
  365. // McnPublicationPriceChangeReply 4.4
  366. type McnPublicationPriceChangeReply = CommonReply
  367. // McnBaseInfoReply .
  368. type McnBaseInfoReply struct {
  369. ID int64 `json:"id"`
  370. McnMid int64 `json:"mcn_mid"`
  371. CompanyName string `json:"company_name"`
  372. CompanyLicenseID string `json:"company_license_id"`
  373. CompanyLicenseLink string `json:"company_license_link"`
  374. ContractLink string `json:"contract_link"`
  375. ContactName string `json:"contact_name"`
  376. ContactTitle string `json:"contact_title"`
  377. ContactIdcard string `json:"contact_idcard"`
  378. ContactPhone string `json:"contact_phone"`
  379. BeginDate time.Time `json:"begin_date"`
  380. EndDate time.Time `json:"end_date"`
  381. RejectReason string `json:"reject_reason"`
  382. RejectTime time.Time `json:"reject_time"`
  383. State model.MCNSignState `json:"state"`
  384. Permission uint32 `json:"permission"`
  385. Ctime time.Time `json:"ctime"`
  386. Mtime time.Time `json:"mtime"`
  387. SignPayInfo []*SignPayInfoReply `json:"sign_pay_info"`
  388. Permits *mcnadminmodel.Permits `json:"permits"` // 权限集合
  389. }
  390. // SignPayInfoReply .
  391. type SignPayInfoReply struct {
  392. State mcnadminmodel.MCNPayState `json:"-"`
  393. DueDate time.Time `json:"due_date"`
  394. PayValue int64 `json:"pay_value"` // thousand bit
  395. }
  396. // AttrPermitVal get Permission all.
  397. func (m *McnBaseInfoReply) AttrPermitVal() {
  398. m.Permits = &mcnadminmodel.Permits{}
  399. m.Permits.SetAttrPermitVal(m.Permission)
  400. }
  401. // CopyFromMcnInfo .
  402. func (m *McnBaseInfoReply) CopyFromMcnInfo(v *McnSign) {
  403. if v == nil {
  404. return
  405. }
  406. m.ID = v.ID
  407. m.McnMid = v.McnMid
  408. m.CompanyName = v.CompanyName
  409. m.CompanyLicenseID = v.CompanyLicenseID
  410. m.CompanyLicenseLink = v.CompanyLicenseLink
  411. m.ContractLink = v.ContractLink
  412. m.ContactName = v.ContactName
  413. m.ContactTitle = v.ContactTitle
  414. m.ContactIdcard = v.ContactIdcard
  415. m.ContactPhone = v.ContactPhone
  416. m.BeginDate = v.BeginDate
  417. m.EndDate = v.EndDate
  418. m.RejectReason = v.RejectReason
  419. m.RejectTime = v.RejectTime
  420. m.State = v.State
  421. m.Permission = v.Permission
  422. m.Ctime = v.Ctime
  423. m.Mtime = v.Mtime
  424. m.AttrPermitVal()
  425. }