sandbox_draft.go 2.0 KB

123456789101112131415161718192021222324252627282930
  1. package sandbox
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. type SandboxDraft struct {
  7. SandboxDraftId int `gorm:"primaryKey;column:sandbox_draft_id;type:int(9) unsigned;not null"` // 沙盘草稿记录id
  8. SandboxId int `gorm:"index:idx_sandbox_user_id;column:sandbox_id;type:int(9) unsigned;not null;default:0"` // 沙盘id
  9. Name string `gorm:"column:name;type:varchar(64);not null;default:''"` // 沙盘名称
  10. ChartPermissionId int `gorm:"column:chart_permission_id;type:int(9) unsigned;not null;default:0"` // 品种id
  11. ChartPermissionName string `gorm:"column:chart_permission_name;type:varchar(32);not null;default:''"` // 品种名称(冗余字段,避免列表页查询时再去关联表查询)
  12. CurrVersion int `gorm:"column:curr_version;type:int(9) unsigned;not null;default:0"` // 当前版本
  13. Content string `gorm:"column:content;type:text;not null"` // 沙盘数据
  14. OpUserId int `gorm:"index:idx_sandbox_user_id;column:op_user_id;type:int(10) unsigned;not null;default:0"` // 当前编辑操作的用户id
  15. OpUserName string `gorm:"column:op_user_name;type:varchar(32);not null;default:''"` // 当前编辑的用户名称(冗余字段,避免查表)
  16. CreateTime time.Time `gorm:"column:create_time;type:timestamp;default:CURRENT_TIMESTAMP"` // 沙盘草稿创建时间
  17. }
  18. func AddSandboxDraft(sandboxDraft *SandboxDraft) (err error) {
  19. err = global.DmSQL["data"].Create(sandboxDraft).Error
  20. return
  21. }
  22. func GetLastSandboxDraftById(sandboxId int) (sandboxDraft *SandboxDraft, err error) {
  23. sql := `select * from sandbox_draft where sandbox_id = ? order by sandbox_draft_id desc `
  24. err = global.DmSQL["data"].Raw(sql, sandboxId).First(&sandboxDraft).Error
  25. return
  26. }