ppt_v2_history.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "time"
  7. )
  8. type PptV2History struct {
  9. Id int `gorm:"primaryKey"`
  10. PptId int `description:"ppt ID"`
  11. TemplateType int `description:"模板类型"`
  12. BackgroundImg string `description:"背景图"`
  13. Title string `description:"标题"`
  14. ReportType string `description:"报告类型"`
  15. PptDate string `description:"选择日期"`
  16. Content string `description:"内容"`
  17. AdminId int `description:"操作人ID"`
  18. AdminRealName string `description:"操作人真实姓名"`
  19. CreateTime time.Time `description:"创建时间"`
  20. CoverContent string `description:"封面内容"`
  21. TitleSetting string `description:"标题设置"`
  22. }
  23. // 获取表名
  24. func (p *PptV2History) TableName() string {
  25. return "ppt_v2_history"
  26. }
  27. func (p *PptV2History) Add() (err error) {
  28. err = global.DmSQL["rddp"].Create(p).Error
  29. return
  30. }
  31. func (p *PptV2History) GetNoContentPageList(condition string, pars []interface{}, startSize, pageSize int) (list []*PptV2History, err error) {
  32. sql := fmt.Sprintf(`SELECT id, ppt_id, template_type, background_img, title, report_type, ppt_date, create_time, admin_id, admin_real_name FROM %s WHERE 1=1 `, p.TableName())
  33. if condition != "" {
  34. sql += condition
  35. }
  36. sql += ` ORDER BY create_time DESC, id DESC LIMIT ?, ?`
  37. pars = append(pars, startSize, pageSize)
  38. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&list).Error
  39. return
  40. }
  41. func (p *PptV2History) GetPageListCount(condition string, pars []interface{}) (count int, err error) {
  42. sql := fmt.Sprintf(`SELECT COUNT(1) AS count FROM %s WHERE 1=1 `, p.TableName())
  43. if condition != "" {
  44. sql += condition
  45. }
  46. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  47. return
  48. }
  49. // 删除接口
  50. func (p *PptV2History) Delete() (err error) {
  51. err = global.DmSQL["rddp"].Delete(p).Error
  52. return
  53. }
  54. // 查询单条记录
  55. func (p *PptV2History) GetById(id int) (item *PptV2History, err error) {
  56. err = global.DmSQL["rddp"].Where("id = ?", id).First(&item).Error
  57. return
  58. }
  59. // PptV2HistoryListItem 定义PPT历史记录列表项的结构体
  60. type PptV2HistoryListItem struct {
  61. Id int `description:"PPT历史记录id"`
  62. PptId int `description:"ppt ID"`
  63. TemplateType int `description:"模板类型"`
  64. BackgroundImg string `description:"背景图"`
  65. Title string `description:"标题"`
  66. ReportType string `description:"报告类型"`
  67. PptDate string `description:"选择日期"`
  68. AdminId int `description:"操作人ID"`
  69. AdminRealName string `description:"操作人真实姓名"`
  70. CreateTime string `description:"创建时间"`
  71. }
  72. type PptV2HistoryListResp struct {
  73. List []*PptV2HistoryListItem
  74. Paging *paging.PagingItem `description:"分页数据"`
  75. }
  76. type DeletePptV2HistoryReq struct {
  77. Id int `description:"PPT历史记录id"`
  78. }