12345678910111213141516171819202122232425262728293031323334353637383940 |
- package sandbox
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // SandboxDraft 沙盘推演草稿表
- type SandboxDraft struct {
- SandboxDraftId int `orm:"column(sandbox_draft_id);pk" description:"沙盘草稿记录id"`
- SandboxId int `description:"沙盘id"`
- Name string `description:"沙盘名称"`
- ChartPermissionId int `description:"品种id"`
- ChartPermissionName string `description:"品种名称"`
- CurrVersion int `description:"当前版本"`
- Content string `description:"沙盘数据"`
- OpUserId int `description:"最近一次编辑操作的用户id"`
- OpUserName string `description:"最近一次编辑的用户名称(冗余字段,避免查表)"`
- CreateTime time.Time `description:"创建时间"`
- }
- // AddSandboxDraft 添加一个新的沙盘草稿
- func AddSandboxDraft(sandboxDraft *SandboxDraft) (err error) {
- o := orm.NewOrmUsingDB("data")
- // 新增草稿
- id, err := o.Insert(sandboxDraft)
- if err != nil {
- return
- }
- sandboxDraft.SandboxDraftId = int(id)
- return
- }
- // GetLastSandboxDraftById 根据沙盘id获取最后一条沙盘草稿详情
- func GetLastSandboxDraftById(sandboxId int) (sandboxDraft *SandboxDraft, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `select * from sandbox_draft where sandbox_id = ? order by sandbox_draft_id desc `
- err = o.Raw(sql, sandboxId).QueryRow(&sandboxDraft)
- return
- }
|