mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-21 07:49:34 +01:00
17fa7bb407
extract some error checking and logging in places where linting needed or errors not checked
27 lines
800 B
Go
27 lines
800 B
Go
package db
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
//User is the model for an entity which has access to the API
|
|
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:"-"`
|
|
Admin bool `db:"admin" json:"admin"`
|
|
External bool `db:"external" json:"external"`
|
|
Alert bool `db:"alert" json:"alert"`
|
|
}
|
|
|
|
//FetchUser retrieves a user from the database by ID
|
|
func FetchUser(userID int) (*User, error) {
|
|
var user User
|
|
|
|
err := Mysql.SelectOne(&user, "select * from user where id=?", userID)
|
|
return &user, err
|
|
}
|