english_video.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hz_crm_api/utils"
  6. "strings"
  7. "time"
  8. )
  9. type EnglishVideo struct {
  10. Id int `orm:"column(id);pk;auto" description:"路演视频Id"`
  11. ClassifyIdFirst int `description:"一级分类id"`
  12. ClassifyNameFirst string `description:"一级分类名称"`
  13. ClassifyIdSecond int `description:"二级分类id"`
  14. ClassifyNameSecond string `description:"二级分类名称"`
  15. Title string `description:"标题"`
  16. Abstract string `description:"摘要"`
  17. Author string `description:"作者"`
  18. CreateTime time.Time `description:"创建时间"`
  19. ModifyTime time.Time `description:"修改时间"`
  20. State int `description:"1:未发布,2:已发布"`
  21. PublishTime time.Time `description:"发布时间"`
  22. VideoUrl string `description:"视频文件URL"`
  23. VideoCoverUrl string `description:"视频文件封面地址"`
  24. VideoSeconds string `description:"视频时长"`
  25. VideoCode string `description:"报告唯一编码"`
  26. Pv int `description:"Pv"`
  27. PvEmail int `description:"邮箱PV"`
  28. EmailState int `description:"群发邮件状态: 0-未发送; 1-已发送"`
  29. Overview string `description:"英文概述部分"`
  30. AdminId int `description:"上传视频的管理员账号"`
  31. AdminRealName string `description:"上传视频的管理员姓名"`
  32. }
  33. func AddEnglishVideo(item *EnglishVideo) (err error) {
  34. o := orm.NewOrmUsingDB("rddp")
  35. _, err = o.Insert(item)
  36. return
  37. }
  38. func ModifyEnglishVideoCode(id int, VideoCode string) (err error) {
  39. o := orm.NewOrmUsingDB("rddp")
  40. sql := `UPDATE english_video SET video_code=? WHERE id=? `
  41. _, err = o.Raw(sql, VideoCode, id).Exec()
  42. return
  43. }
  44. type SaveEnglishVideoReq struct {
  45. Id int `description:"路演视频ID"`
  46. ClassifyIdFirst int `description:"一级分类id"`
  47. //ClassifyNameFirst string `description:"一级分类名称"`
  48. ClassifyIdSecond int `description:"二级分类id"`
  49. //ClassifyNameSecond string `description:"二级分类名称"`
  50. Title string `description:"标题"`
  51. Abstract string `description:"摘要"`
  52. Author string `description:"作者"`
  53. State int `description:"状态:1:未发布,2:已发布"`
  54. VideoUrl string `description:"视频文件URL"`
  55. VideoCoverUrl string `description:"视频文件封面地址"`
  56. VideoSeconds string `description:"视频时长"`
  57. Overview string `description:"英文概述部分"`
  58. }
  59. type SaveEnglishVideoResp struct {
  60. Id int `description:"路演视频ID"`
  61. VideoCode string `description:"报告code"`
  62. }
  63. type ElasticEnglishVideoDetail struct {
  64. Id int `description:"路演视频ID"`
  65. ClassifyIdFirst int `description:"一级分类id"`
  66. ClassifyNameFirst string `description:"一级分类名称"`
  67. ClassifyIdSecond int `description:"二级分类id"`
  68. ClassifyNameSecond string `description:"二级分类名称"`
  69. StageStr string `description:"报告期数"`
  70. Title string `description:"标题"`
  71. Abstract string `description:"摘要"`
  72. Author string `description:"作者"`
  73. Frequency string `description:"频度"`
  74. PublishState int `description:"状态:1:未发布,2:已发布"`
  75. BodyContent string `description:"内容"`
  76. ContentSub string `description:"前两段内容"`
  77. CreateTime string `description:"创建时间"`
  78. PublishTime string `description:"发布时间"`
  79. VideoCode string `description:"报告唯一编码"`
  80. Overview string `description:"英文概述部分"`
  81. }
  82. func EditEnglishVideo(item *EnglishVideo, Id int) (err error) {
  83. o := orm.NewOrmUsingDB("rddp")
  84. sql := `UPDATE english_video
  85. SET
  86. classify_id_first =?,
  87. classify_name_first = ?,
  88. classify_id_second = ?,
  89. classify_name_second = ?,
  90. title = ?,
  91. abstract = ?,
  92. state = ?,
  93. modify_time = ?,
  94. overview = ?,
  95. video_url = ?,
  96. video_cover_url = ?,
  97. video_seconds = ?
  98. WHERE id = ? `
  99. _, err = o.Raw(sql, item.ClassifyIdFirst, item.ClassifyNameFirst, item.ClassifyIdSecond, item.ClassifyNameSecond, item.Title,
  100. item.Abstract, item.State, time.Now(), item.Overview, item.VideoUrl, item.VideoCoverUrl, item.VideoSeconds, Id).Exec()
  101. return
  102. }
  103. type EnglishVideoDetail struct {
  104. Id int `description:"路演视频ID"`
  105. ClassifyIdFirst int `description:"一级分类id"`
  106. ClassifyNameFirst string `description:"一级分类名称"`
  107. ClassifyIdSecond int `description:"二级分类id"`
  108. ClassifyNameSecond string `description:"二级分类名称"`
  109. Title string `description:"标题"`
  110. Abstract string `description:"摘要"`
  111. Author string `description:"作者"`
  112. CreateTime string `description:"创建时间"`
  113. ModifyTime string `description:"修改时间"`
  114. State int `description:"1:未发布,2:已发布"`
  115. PublishTime string `description:"发布时间"`
  116. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  117. VideoCode string `description:"报告唯一编码"`
  118. VideoUrl string `description:"视频文件URL"`
  119. VideoCoverUrl string `description:"视频文件封面地址"`
  120. VideoSeconds string `description:"视频时长"`
  121. Pv int `description:"Pv"`
  122. Overview string `description:"英文概述部分"`
  123. }
  124. func GetEnglishVideoById(Id int) (item *EnglishVideoDetail, err error) {
  125. o := orm.NewOrmUsingDB("rddp")
  126. sql := `SELECT * FROM english_video WHERE id=?`
  127. err = o.Raw(sql, Id).QueryRow(&item)
  128. return
  129. }
  130. func GetEnglishVideoItemById(Id int) (item *EnglishVideo, err error) {
  131. o := orm.NewOrmUsingDB("rddp")
  132. sql := `SELECT * FROM english_video WHERE id = ? LIMIT 1`
  133. err = o.Raw(sql, Id).QueryRow(&item)
  134. return
  135. }
  136. type EnglishVideoList struct {
  137. Id int `description:"id"`
  138. ClassifyIdFirst int `description:"一级分类id"`
  139. ClassifyNameFirst string `description:"一级分类名称"`
  140. ClassifyIdSecond int `description:"二级分类id"`
  141. ClassifyNameSecond string `description:"二级分类名称"`
  142. Title string `description:"标题"`
  143. Abstract string `description:"摘要"`
  144. CreateTime string `description:"创建时间"`
  145. ModifyTime string `description:"修改时间"`
  146. State int `description:"1:未发布,2:已发布"`
  147. PublishTime string `description:"发布时间"`
  148. VideoUrl string `description:"视频文件URL"`
  149. VideoCoverUrl string `description:"视频文件封面地址"`
  150. VideoSeconds string `description:"视频时长"`
  151. VideoCode string `description:"报告唯一编码"`
  152. Pv int `description:"Pv"`
  153. ShareUrl string `description:"分享url"`
  154. PvEmail int `description:"邮箱PV"`
  155. EmailState int `description:"群发邮件状态: 0-未发送; 1-已发送"`
  156. EmailAuth bool `description:"是否有权限群发邮件"`
  157. EmailHasFail bool `description:"是否存在邮件发送失败的记录"`
  158. Overview string `description:"英文概述部分"`
  159. AdminId int `description:"上传视频的管理员账号"`
  160. AdminRealName string `description:"上传视频的管理员姓名"`
  161. FullClassifyName string `description:"顶级分类名/父级分类名/当前分类名"`
  162. ClassifyIdRoot int `description:"顶级分类id"`
  163. ClassifyNameRoot string `description:"顶级分类名称"`
  164. }
  165. type EnglishVideoListResp struct {
  166. List []*EnglishVideoList
  167. Paging *paging.PagingItem `description:"分页数据"`
  168. }
  169. type EnglishVideoReq struct {
  170. Id int `description:"路演视频id"`
  171. }
  172. func GetEnglishVideoListCount(condition string, pars []interface{}) (count int, err error) {
  173. //产品权限
  174. oRddp := orm.NewOrmUsingDB("rddp")
  175. sql := `SELECT COUNT(1) AS count FROM english_video WHERE 1=1 `
  176. if condition != "" {
  177. sql += condition
  178. }
  179. err = oRddp.Raw(sql, pars).QueryRow(&count)
  180. return
  181. }
  182. func GetEnglishVideoList(condition string, pars []interface{}, startSize, pageSize int) (items []*EnglishVideoList, err error) {
  183. o := orm.NewOrmUsingDB("rddp")
  184. sql := `SELECT *
  185. FROM english_video WHERE 1=1 `
  186. if condition != "" {
  187. sql += condition
  188. }
  189. sql += `ORDER BY modify_time DESC LIMIT ?,?`
  190. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  191. return
  192. }
  193. func GetEnglishVideoByCondition(condition string, pars []interface{}) (items []*EnglishVideo, err error) {
  194. o := orm.NewOrmUsingDB("rddp")
  195. sql := `SELECT *
  196. FROM english_video WHERE 1=1 `
  197. if condition != "" {
  198. sql += condition
  199. }
  200. _, err = o.Raw(sql, pars).QueryRows(&items)
  201. return
  202. }
  203. func PublishEnglishVideoById(Id int) (err error) {
  204. o := orm.NewOrmUsingDB("rddp")
  205. sql := `UPDATE english_video SET state=2,publish_time=now(),modify_time=NOW() WHERE id = ? `
  206. _, err = o.Raw(sql, Id).Exec()
  207. return
  208. }
  209. func PublishCancelEnglishVideo(Ids int) (err error) {
  210. o := orm.NewOrmUsingDB("rddp")
  211. sql := ` UPDATE english_video SET state=1,publish_time=null WHERE id =? `
  212. _, err = o.Raw(sql, Ids).Exec()
  213. return
  214. }
  215. // DeleteEnglishVideo 删除路演视频
  216. func DeleteEnglishVideo(Id int) (err error) {
  217. o := orm.NewOrmUsingDB("rddp")
  218. sql := ` DELETE FROM english_video WHERE id=? `
  219. _, err = o.Raw(sql, Id).Exec()
  220. return
  221. }
  222. // Update 更新
  223. func (item *EnglishVideo) Update(cols []string) (err error) {
  224. o := orm.NewOrmUsingDB("rddp")
  225. _, err = o.Update(item, cols...)
  226. return
  227. }
  228. // GetEnglishVideoByIds 根据IDs获取英文报告列表
  229. func GetEnglishVideoByIds(Ids []int, fieldArr []string) (list []*EnglishVideo, err error) {
  230. listLen := len(Ids)
  231. if listLen == 0 {
  232. return
  233. }
  234. fields := ` * `
  235. if len(fieldArr) > 0 {
  236. fields = strings.Join(fieldArr, ",")
  237. }
  238. o := orm.NewOrmUsingDB("rddp")
  239. sql := `SELECT ` + fields + ` FROM english_video WHERE id IN (` + utils.GetOrmInReplace(listLen) + `)`
  240. _, err = o.Raw(sql, Ids).QueryRows(&list)
  241. return
  242. }