mtfosbot/model/account.go
2018-09-24 19:57:12 +08:00

38 lines
780 B
Go

package model
import (
"database/sql"
"time"
)
// Account - table
type Account struct {
ID string `db:"id" cc:"id"`
Account string `db:"account" cc:"account"`
Password string `db:"password" cc:"-"`
Ctime time.Time `db:"ctime" cc:"ctime"`
Mtime time.Time `db:"mtime" cc:"ctime"`
}
// GetAllAccount -
func GetAllAccount() (accs []*Account, err error) {
err = x.Select(&accs, "select * from public.account order by ctime asc")
if err != nil {
return nil, err
}
return
}
// GetAccount -
func GetAccount(account string) (acc *Account, err error) {
acc = &Account{}
err = x.Get(acc, `select * from "public"."account" where "account" = $1`, account)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, err
}
return
}