package models import ( "github.com/astaxie/beego/orm" ) func init() { orm.RegisterModelWithPrefix("cm_", new(Ip)) } type Ip struct { Id string `orm:"pk" json:"id"` Ip string `json:"ip"` Updatetime string `json:"updatetime"` } func GetIpById(id string) string { ipModel := new(Ip) err := orm.NewOrm().QueryTable(new(Ip)).Filter("id", id).One(ipModel) if err != nil { return "" } return ipModel.Ip }