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.
24 lines
396 B
24 lines
396 B
package models
|
|
|
|
import (
|
|
"github.com/jinzhu/gorm"
|
|
_ "github.com/jinzhu/gorm/dialects/mysql"
|
|
)
|
|
type User struct {
|
|
gorm.Model
|
|
Id int64
|
|
Name string
|
|
Password string
|
|
}
|
|
func CreateUser(name string,password string){
|
|
user:=&User{
|
|
Name:name,
|
|
Password: password,
|
|
}
|
|
DB.Create(user)
|
|
}
|
|
func FindUser(username string)User{
|
|
var user User
|
|
DB.Where("name = ?", username).First(&user)
|
|
return user
|
|
} |