Semaphore/models/User.go
Matej Kramny 04d0d9e4f9 Users API, Users UI
- Improved login failing
2016-04-10 19:03:12 +01:00

28 lines
692 B
Go

package models
import (
"time"
"github.com/ansible-semaphore/semaphore/database"
)
type User struct {
ID int `db:"id" json:"id"`
Created time.Time `db:"created" json:"created"`
Username string `db:"username" json:"username" binding:"required"`
Name string `db:"name" json:"name" binding:"required"`
Email string `db:"email" json:"email" binding:"required"`
Password string `db:"password" json:"-"`
}
func FetchUser(userID int) (*User, error) {
var user User
err := database.Mysql.SelectOne(&user, "select * from user where id=?", userID)
return &user, err
}
func init() {
database.Mysql.AddTableWithName(User{}, "user").SetKeys(true, "id")
}