You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-fly/models/visitors.go

31 lines
572 B

package models
import "github.com/jinzhu/gorm"
type Visitor struct {
gorm.Model
Name string
Avator string
SourceIp string
ToId string
VisitorId string
}
func CreateVisitor(name string,avator string,sourceIp string,toId string,visitorId string){
old:=FindVisitorByVistorId(visitorId)
if old.Name!=""{
return
}
v:=&Visitor{
Name:name,
Avator: avator,
SourceIp:sourceIp,
ToId:toId,
VisitorId: visitorId,
}
DB.Create(v)
}
func FindVisitorByVistorId(visitorId string)Visitor{
var v Visitor
DB.Where("visitor_id = ?", visitorId).First(&v)
return v
}