excel_draft.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ExcelDraft 沙盘推演草稿表
  7. type ExcelDraft struct {
  8. ExcelDraftId int `orm:"column(excel_draft_id);pk" description:"excel表格草稿记录id"`
  9. ExcelId int `description:"excel表格id"`
  10. Name string `description:"excel表格名称"`
  11. Content string `description:"excel数据"`
  12. OpUserId int `description:"最近一次编辑操作的用户id"`
  13. OpUserName string `description:"最近一次编辑的用户名称(冗余字段,避免查表)"`
  14. CreateTime time.Time `description:"创建时间"`
  15. }
  16. // AddExcelDraft 添加一个新的excel表格草稿
  17. func AddExcelDraft(excelDraft *ExcelDraft) (err error) {
  18. o := orm.NewOrmUsingDB("data")
  19. // 新增草稿
  20. id, err := o.Insert(excelDraft)
  21. if err != nil {
  22. return
  23. }
  24. excelDraft.ExcelDraftId = int(id)
  25. return
  26. }
  27. // GetLastExcelDraftById 根据沙盘id获取最后一条沙盘草稿详情
  28. func GetLastExcelDraftById(excelId int) (excelDraft *ExcelDraft, err error) {
  29. o := orm.NewOrmUsingDB("data")
  30. sql := `select * from excel_draft where excel_id = ? order by excel_draft_id desc `
  31. err = o.Raw(sql, excelId).QueryRow(&excelDraft)
  32. return
  33. }