audit_result.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. package model
  2. import (
  3. "fmt"
  4. "strconv"
  5. "go-common/library/database/elastic"
  6. "go-common/library/time"
  7. )
  8. const (
  9. _TimeFormat = ("2006-01-02 15:04:05")
  10. _mtimeDesc = "2"
  11. _pubtimeDesc = "1"
  12. _pagesize = 20
  13. )
  14. // EPRes def.
  15. type EPRes struct {
  16. ID int64 `json:"id"`
  17. Title string `json:"title"`
  18. Subtitle string `json:"subtitle"`
  19. STitle string `json:"season_title" gorm:"column:stitle"`
  20. Category int `json:"category"`
  21. SeasonID int `json:"season_id"`
  22. EPID int `json:"epid" gorm:"column:epid"`
  23. State int `json:"state"`
  24. Valid int `json:"valid"`
  25. Reason string `json:"reason"`
  26. }
  27. // EPResDB defines the result structure of ep audit
  28. type EPResDB struct {
  29. EPRes
  30. InjectTime time.Time `json:"inject_time" gorm:"column:inject_time"`
  31. CTime time.Time `json:"ctime" gorm:"column:ctime"`
  32. }
  33. // EPResItem def.
  34. type EPResItem struct {
  35. EPRes
  36. InjectTime string `json:"inject_time"`
  37. CTime string `json:"ctime"`
  38. }
  39. // ToItem def.
  40. func (v *EPResDB) ToItem() *EPResItem {
  41. res := &EPResItem{
  42. EPRes: v.EPRes,
  43. CTime: v.CTime.Time().Format(_TimeFormat),
  44. }
  45. switch v.State {
  46. case 3: // passed
  47. res.State = 1
  48. case 4: // rejected
  49. res.State = 2
  50. default:
  51. res.State = 0
  52. }
  53. if v.InjectTime > 0 {
  54. res.InjectTime = v.InjectTime.Time().Format(_TimeFormat)
  55. }
  56. return res
  57. }
  58. // Page represents the standard page structure
  59. type Page struct {
  60. Num int `json:"num"`
  61. Size int `json:"size"`
  62. Total int `json:"total"`
  63. }
  64. // SnCount def.
  65. type SnCount struct {
  66. Count int
  67. }
  68. // TableName tv_content
  69. func (*EPResDB) TableName() string {
  70. return "tv_content"
  71. }
  72. // EPResultPager def.
  73. type EPResultPager struct {
  74. Items []*EPResItem `json:"items"`
  75. Page *Page `json:"page"`
  76. }
  77. // SeasonRes def.
  78. type SeasonRes struct {
  79. ID int64 `json:"id"`
  80. Title string `json:"title"`
  81. Check int `json:"check"`
  82. Category int `json:"category"`
  83. Valid int `json:"valid"`
  84. Reason string `json:"reason"`
  85. }
  86. // SeasonResDB defines the result structure of ep audit
  87. type SeasonResDB struct {
  88. SeasonRes
  89. InjectTime time.Time `json:"inject_time" gorm:"column:inject_time"`
  90. CTime time.Time `json:"ctime" gorm:"column:ctime"`
  91. }
  92. // SeasonResItem def.
  93. type SeasonResItem struct {
  94. SeasonRes
  95. InjectTime string `json:"inject_time"`
  96. CTime string `json:"ctime"`
  97. }
  98. // ToItem Transforms to item
  99. func (v *SeasonResDB) ToItem() *SeasonResItem {
  100. res := &SeasonResItem{
  101. CTime: v.CTime.Time().Format(_TimeFormat),
  102. SeasonRes: v.SeasonRes,
  103. }
  104. switch v.Check {
  105. case 0: // reject
  106. res.Check = 2
  107. case 1: // passed
  108. res.Check = 1
  109. default:
  110. res.Check = 0
  111. }
  112. if v.InjectTime > 0 {
  113. res.InjectTime = v.InjectTime.Time().Format(_TimeFormat)
  114. }
  115. return res
  116. }
  117. // TableName tv_content
  118. func (*SeasonResDB) TableName() string {
  119. return "tv_ep_season"
  120. }
  121. // SeasonResultPager def.
  122. type SeasonResultPager struct {
  123. Items []*SeasonResItem `json:"items"`
  124. Page *Page `json:"page"`
  125. }
  126. // ReqArcCons def.
  127. type ReqArcCons struct {
  128. Order int `form:"order" json:"order;Min(1)" default:"1"` // 1 default, desc; 2 asc
  129. FirstCat int32 `form:"first_cat"`
  130. SecondCat int32 `form:"second_cat"`
  131. Status string `form:"status"`
  132. Title string `form:"title"`
  133. AVID int64 `form:"avid"`
  134. Pn int `form:"pn" default:"1"`
  135. }
  136. // ReqVideoCons def.
  137. type ReqVideoCons struct {
  138. AVID int64 `form:"avid" validate:"required"`
  139. Order int `form:"order" json:"order;Min(1)" default:"1"` // 1 default, desc; 2 asc
  140. Title string `form:"title"`
  141. CID int64 `form:"cid"`
  142. Status string `form:"status"`
  143. Pn int `form:"pn"`
  144. }
  145. // PageCfg def.
  146. type PageCfg struct {
  147. Pn int `form:"pn" default:"1" json:"pn"`
  148. Ps int `form:"ps" default:"20" json:"ps"`
  149. }
  150. // ReqArcES def.
  151. type ReqArcES struct {
  152. AID string
  153. Mids []int64
  154. Title string
  155. Typeids []int32
  156. Valid string
  157. Result string
  158. MtimeOrder string
  159. PubtimeOrder string
  160. PageCfg
  161. }
  162. // MtimeSort def.
  163. func (v *ReqArcES) MtimeSort() string {
  164. if v.MtimeOrder == _mtimeDesc {
  165. return elastic.OrderDesc
  166. }
  167. return elastic.OrderAsc
  168. }
  169. // PubtimeSort def.
  170. func (v *ReqArcES) PubtimeSort() string {
  171. if v.PubtimeOrder == _pubtimeDesc {
  172. return elastic.OrderDesc
  173. }
  174. return elastic.OrderAsc
  175. }
  176. // FromArcListParam build
  177. func (v *ReqArcES) FromArcListParam(param *ArcListParam, tids []int32) {
  178. v.Title = param.Title
  179. v.Valid = param.Valid
  180. v.MtimeOrder = strconv.Itoa(param.Order)
  181. v.PageCfg = param.PageCfg
  182. v.AID = param.CID
  183. v.Typeids = tids
  184. v.Result = "1"
  185. }
  186. // FromAuditConsult def.
  187. func (v *ReqArcES) FromAuditConsult(param *ReqArcCons, tids []int32) {
  188. v.PubtimeOrder = strconv.Itoa(param.Order)
  189. v.Typeids = tids
  190. v.Result = param.Status
  191. v.Title = param.Title
  192. if param.AVID != 0 {
  193. v.AID = fmt.Sprintf("%d", param.AVID)
  194. }
  195. v.Pn = param.Pn
  196. v.Ps = _pagesize
  197. }
  198. // ArcRes def.
  199. type ArcRes struct {
  200. AVID int64 `json:"avid"`
  201. Title string `json:"title"`
  202. FirstCat string `json:"first_cat"`
  203. SecondCat string `json:"second_cat"`
  204. Status int `json:"status"`
  205. InjectTime string `json:"inject_time"`
  206. PubTime string `json:"pubtime"`
  207. Reason string `json:"reason"`
  208. }
  209. // VideoRes def.
  210. type VideoRes struct {
  211. CID int64 `json:"cid"`
  212. Title string `json:"title"`
  213. Page int `json:"page"`
  214. Status int `json:"status"`
  215. Ctime string `json:"ctime"`
  216. InjectTime string `json:"inject_time"`
  217. Reason string `json:"reason"`
  218. }
  219. // ArcResPager def.
  220. type ArcResPager struct {
  221. Items []*ArcRes `json:"items"`
  222. Page *Page `json:"page"`
  223. }
  224. // VideoResPager def.
  225. type VideoResPager struct {
  226. Items []*VideoRes `json:"items"`
  227. Page *Page `json:"page"`
  228. }
  229. // EsUgcConsult def.
  230. type EsUgcConsult struct {
  231. Fields []string `json:"fields"`
  232. From string `json:"from"`
  233. Highlight bool `json:"highlight"`
  234. Pn int `json:"pn"`
  235. Ps int `json:"ps"`
  236. Where *Where `json:"where,omitempty"`
  237. Order []map[string]string `json:"order"`
  238. }
  239. // Where def.
  240. type Where struct {
  241. Eq map[string]string `json:"eq,omitempty"`
  242. Or map[string][]interface{} `json:"or,omitempty"`
  243. In map[string][]int32 `json:"in,omitempty"`
  244. Range map[string]string `json:"range,omitempty"`
  245. }
  246. // EsArc def.
  247. type EsArc struct {
  248. AID int64 `json:"aid"`
  249. MID int64 `json:"mid"`
  250. Deleted int `json:"deleted"`
  251. Mtime string `json:"mtime"`
  252. Pubtime string `json:"pubtime"`
  253. Result int `json:"result"`
  254. Typeid int32 `json:"typeid"`
  255. Valid int `json:"valid"`
  256. }
  257. // EsUgcResult def.
  258. type EsUgcResult struct {
  259. Result []*EsArc
  260. Page *Page
  261. }