referenced_excel_config.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package excel
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type ReferencedExcelConfig struct {
  7. ReferencedExcelConfigId int `orm:"column(referenced_excel_config_id);pk;auto" ` // excel表格配置id
  8. UniqueCode string // 表格唯一编码
  9. ReferencedId int // 被引用的id,报告就是报告id,pptId
  10. FromScene int // 引用类型 1智能研报 2研报列表 3英文研报 4PPT 5英文ppt
  11. Uuid string // 引用唯一标识
  12. WidthList string // 宽度数组
  13. HeightList string // 高度数组
  14. OpUserId int // 当前编辑操作的用户id
  15. OpUserName string // 当前编辑的用户名称(冗余字段,避免查表)
  16. CreateTime time.Time // 创建时间
  17. Content string // 内容
  18. ModifyTime time.Time // 修改时间
  19. }
  20. type ExcelReferencesReq struct {
  21. UniqueCode string `description:"表格唯一编码"`
  22. ReferencedId int `description:"被引用的ID"`
  23. FromScene int `description:"引用类型 1智能研报 2研报列表 3英文研报 4PPT 5英文PPT"`
  24. Uuid string `description:"引用唯一标识"`
  25. WidthList string `description:"宽度数组"`
  26. HeightList string `description:"高度数组"`
  27. }
  28. // add
  29. func AddReferencedExcelConfig(items []*ReferencedExcelConfig) (err error) {
  30. o := orm.NewOrmUsingDB("data")
  31. _, err = o.InsertMulti(len(items), items)
  32. return
  33. }
  34. // getByCode
  35. func GetReferencedExcelConfig(referencedId, fromScene int, uniqueCode, uuid string) (item ReferencedExcelConfig, err error) {
  36. o := orm.NewOrmUsingDB("data")
  37. sql := ` SELECT * FROM referenced_excel_config WHERE referenced_id = ? AND from_scene = ? AND unique_code = ? AND uuid= ? `
  38. err = o.Raw(sql, referencedId, fromScene, uniqueCode, uuid).QueryRow(&item)
  39. return
  40. }
  41. // update
  42. func UpdateReferencedExcelConfig(item *ReferencedExcelConfig) (err error) {
  43. o := orm.NewOrmUsingDB("data")
  44. _, err = o.Update(item, "WidthList", "HeightList", "OpUserId", "OpUserName", "ModifyTime")
  45. return
  46. }
  47. // delete
  48. func DeleteReferencedExcelConfig(uniqueCode string) (err error) {
  49. o := orm.NewOrmUsingDB("data")
  50. sql := `DELETE FROM referenced_excel_config WHERE unique_code=? `
  51. _, err = o.Raw(sql, uniqueCode).Exec()
  52. return
  53. }