feat: user models definition

This commit is contained in:
David 2021-07-28 19:20:56 +08:00
parent a1f5741c01
commit 61067995bf
1 changed files with 41 additions and 0 deletions

41
models/user.go Normal file
View File

@ -0,0 +1,41 @@
package models
import (
"log"
"time"
"xorm.io/builder"
)
type User struct {
User_id int64
User_name string
Examiner_count string
Password string
Id_card string
Address string
Tel string
Email string
Login_time time.Time
Exist_time time.Time
Online_time float64
Subject_name string
Status int64
UserType int64
IsDistribute int64
}
func initUserModels() {
err := x.Sync2(new(User))
if err != nil {
log.Println(err)
}
}
func (u *User) GetUser(id int64) error {
has, err := x.Where(builder.Eq{"user_id": id}).Get(u)
if !has || err != nil {
log.Println("could not found user")
}
return err
}