2020-09-30 15:58:22 +08:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gokins/comm"
|
|
|
|
"gokins/model"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Model struct {
|
2020-10-02 16:04:26 +08:00
|
|
|
Id int `xorm:"pk autoincr"`
|
|
|
|
Uid string
|
|
|
|
Title string
|
|
|
|
Desc string
|
|
|
|
Times time.Time
|
|
|
|
Envs string
|
|
|
|
Wrkdir string
|
2020-10-03 22:28:16 +08:00
|
|
|
Clrdir int
|
2020-09-30 15:58:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (Model) TableName() string {
|
|
|
|
return "t_model"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Model) Save() error {
|
|
|
|
var err error
|
|
|
|
if c.Id > 0 {
|
2020-10-03 22:28:16 +08:00
|
|
|
_, err = comm.Db.Cols("title", "desc", "envs", "wrkdir", "clrdir").Where("id=?", c.Id).Update(c)
|
2020-09-30 15:58:22 +08:00
|
|
|
} else {
|
|
|
|
c.Times = time.Now()
|
|
|
|
_, err = comm.Db.Insert(c)
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
func (c *Model) Del(id int) error {
|
|
|
|
m := &model.TModel{Del: 1}
|
|
|
|
_, err := comm.Db.Cols("del").Where("id=?", id).Update(m)
|
|
|
|
return err
|
|
|
|
}
|