ppt_v2.go 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package models
  2. import (
  3. "eta_gn/eta_task/global"
  4. "fmt"
  5. "strings"
  6. "time"
  7. )
  8. // PptV2 表
  9. type PptV2 struct {
  10. PptId int `gorm:"column:ppt_id;primaryKey;autoIncrement:true" description:"ppt的Id"`
  11. TemplateType int `gorm:"column:template_type" description:"模版类型"`
  12. BackgroundImg string `gorm:"column:background_img" description:"背景图片"`
  13. Title string `gorm:"column:title" description:"标题"`
  14. ReportType string `gorm:"column:report_type" description:"报告类型"`
  15. PptDate string `gorm:"column:ppt_date" description:"选择日期"`
  16. Content string `gorm:"column:content" description:"ppt内容"`
  17. PptUrl string `gorm:"column:ppt_url" description:"ppt下载地址"`
  18. PptxUrl string `gorm:"column:pptx_url" description:"pptx下载地址"`
  19. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  20. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  21. AdminId int `gorm:"column:admin_id" description:"系统用户id"`
  22. AdminRealName string `gorm:"column:admin_real_name" description:"系统用户名称"`
  23. PptVersion int8 `gorm:"column:ppt_version" description:"是否ppt的旧版本;1:旧的,2:新的"`
  24. ReportId int `gorm:"column:report_id" description:"关联的报告ID"`
  25. ReportCode string `gorm:"column:report_code" description:"关联的报告code"`
  26. IsShare int8 `gorm:"column:is_share" description:"是否分享,0:不分享,1:分享"`
  27. PublishTime time.Time `gorm:"column:publish_time" description:"发布时间"`
  28. CoverContent string `gorm:"column:cover_content" description:"PPT内容-JSON"`
  29. PptPage int `gorm:"column:ppt_page" description:"PPT页数"`
  30. TitleSetting string `gorm:"column:title_setting" description:"PPT标题设置"`
  31. ClassifyId int `gorm:"column:classify_id" description:"报告分类ID"`
  32. AddType int `gorm:"column:add_type" description:"新增方式:1-新增报告;2-继承报告"`
  33. InheritReportId int `gorm:"column:inherit_report_id" description:"继承的报告ID"`
  34. CollaborateType int `gorm:"column:collaborate_type" description:"协作方式:1-个人;2-多人协作"`
  35. CollaborateUsers string `gorm:"column:collaborate_users" description:"协作人IDs, 英文逗号分隔"`
  36. IsPublicPublish int `gorm:"column:is_public_publish" description:"是否公开发布:1-是;2-否"`
  37. SubmitTime time.Time `gorm:"column:submit_time" description:"提交时间"`
  38. ApproveTime time.Time `gorm:"column:approve_time" description:"审批时间"`
  39. ReportSource int `gorm:"column:report_source" description:"报告来源:1-系统内;2-智力共享"`
  40. OutReportId string `gorm:"column:out_report_id" description:"外部报告ID(或编码)"`
  41. State int `gorm:"column:state" description:"报告状态:1-未发布;2-已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  42. TopicEndTime time.Time `gorm:"column:topic_end_time" description:"课题结束时间"`
  43. }
  44. // PptReportQueryFields 除富文本的常用查询字段
  45. var PptReportQueryFields = []string{
  46. "ppt_id", "title", "classify_id", "ppt_version", "pptx_url", "ppt_page", "title_setting", "state", "report_source", "publish_time", "submit_time", "approve_time", "create_time", "modify_time", "admin_id", "admin_real_name", "collaborate_type", "collaborate_users", "topic_end_time",
  47. }
  48. func (m *PptV2) TableName() string {
  49. return "ppt_v2"
  50. }
  51. func (m *PptV2) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*PptV2, err error) {
  52. fields := strings.Join(fieldArr, ",")
  53. if len(fieldArr) == 0 {
  54. fields = `*`
  55. }
  56. order := `ORDER BY create_time DESC`
  57. if orderRule != "" {
  58. order = ` ORDER BY ` + orderRule
  59. }
  60. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  61. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  62. return
  63. }