You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/astaxie/beego/orm"
|
|
)
|
|
|
|
type TyhoonListItem struct {
|
|
Enname string `json:"enname" orm:"size(20)"`
|
|
Isactive string `json:"isactive" orm:"size(20)"`
|
|
Name string `json:"name" orm:"size(20)"`
|
|
Warnlevel string `json:"warnlevel" orm:"size(20)"`
|
|
Endtime string `json:"endtime" orm:"size(20)"`
|
|
Starttime string `json:"starttime" orm:"size(20)"`
|
|
Tfid string `json:"tfid" orm:"pk;size(20)"`
|
|
}
|
|
|
|
func TyhoonListItemAdd(item *TyhoonListItem) (int64, error) {
|
|
return orm.NewOrm().Insert(item)
|
|
}
|
|
|
|
func TyhoonListItemUpdate(item *TyhoonListItem) bool {
|
|
o := orm.NewOrm()
|
|
if num, err := o.Update(item); err == nil {
|
|
fmt.Println(num)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func TyhoonListItemDel(item *TyhoonListItem) (int64, error) {
|
|
return orm.NewOrm().Delete(item)
|
|
}
|
|
|
|
func GetTyhoonListItem(item *TyhoonListItem) *TyhoonListItem {
|
|
var tyhoonListItem TyhoonListItem
|
|
o := orm.NewOrm()
|
|
err := o.QueryTable(new(TyhoonListItem)).Filter("tfid",item.Tfid).One(&tyhoonListItem)
|
|
if err == nil {
|
|
return &tyhoonListItem
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func GetTyhoonListItemList() []*TyhoonListItem {
|
|
items := make([]*TyhoonListItem, 0)
|
|
orm.NewOrm().QueryTable(new(TyhoonListItem)).All(&items)
|
|
return items
|
|
} |