en_video_cover.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // EnglishVideoCover 英文研报视频封面库
  8. type EnglishVideoCover struct {
  9. Id int `orm:"column(id);pk;auto" description:"封面ID"`
  10. CoverName string `description:"封面名称"`
  11. CoverUrl string `description:"封面图地址"`
  12. IsDeleted int `description:"是否已删除 0-否 1-是"`
  13. CreateTime time.Time `description:"创建时间"`
  14. ModifyTime time.Time `description:"修改时间"`
  15. DeleteTime time.Time `description:"删除时间"`
  16. }
  17. func (item *EnglishVideoCover) TableName() string {
  18. return "english_video_cover"
  19. }
  20. func (item *EnglishVideoCover) Add() (err error) {
  21. o := orm.NewOrmUsingDB("rddp")
  22. _, err = o.Insert(item)
  23. return
  24. }
  25. func (item *EnglishVideoCover) Update(cols []string) (err error) {
  26. o := orm.NewOrmUsingDB("rddp")
  27. _, err = o.Update(item, cols...)
  28. return
  29. }
  30. // GetEnglishVideoCoverById 主键获取封面
  31. func GetEnglishVideoCoverById(coverId int) (item *EnglishVideoCover, err error) {
  32. o := orm.NewOrmUsingDB("rddp")
  33. sql := `SELECT * FROM english_video_cover WHERE id = ? AND is_deleted = 0 LIMIT 1`
  34. err = o.Raw(sql, coverId).QueryRow(&item)
  35. return
  36. }
  37. // GetEnglishVideoCoverPageList 获取封面库分页列表
  38. func GetEnglishVideoCoverPageList(condition string, pars []interface{}, orderRule string, startSize, pageSize int) (total int, list []*EnglishVideoCover, err error) {
  39. o := orm.NewOrmUsingDB("rddp")
  40. sql := `SELECT * FROM english_video_cover WHERE is_deleted = 0 `
  41. sql += condition
  42. if orderRule == "" {
  43. orderRule = ` ORDER BY modify_time DESC`
  44. }
  45. sql += orderRule
  46. totalSQL := `SELECT COUNT(1) total FROM (` + sql + `) z`
  47. if err = o.Raw(totalSQL, pars).QueryRow(&total); err != nil {
  48. return
  49. }
  50. sql += ` LIMIT ?,?`
  51. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  52. return
  53. }
  54. // DeleteEnglishVideoCover 删除封面
  55. func DeleteEnglishVideoCover(coverId int) (err error) {
  56. o := orm.NewOrmUsingDB("rddp")
  57. sql := `UPDATE english_video_cover SET is_deleted = 1, delete_time = NOW() WHERE id = ? LIMIT 1`
  58. _, err = o.Raw(sql, coverId).Exec()
  59. return
  60. }
  61. type EnglishVideoCoverListResp struct {
  62. Paging *paging.PagingItem
  63. List []*EnglishVideoCoverItem `description:"列表数据"`
  64. }
  65. type EnglishVideoCoverItem struct {
  66. Id int `description:"封面ID"`
  67. CoverName string `description:"封面名称"`
  68. CoverUrl string `description:"封面图地址"`
  69. CreateTime string `description:"提问时间"`
  70. ModifyTime string `description:"修改时间"`
  71. }
  72. type EnglishVideoCoverSaveReq struct {
  73. Id int `description:"封面ID"`
  74. CoverName string `description:"封面名称"`
  75. CoverUrl string `description:"封面图地址"`
  76. }
  77. type EnglishVideoCoverOptionReq struct {
  78. Id int `description:"封面图ID"`
  79. }