mirror of
https://gitee.com/shikong-sk/gofiber-study
synced 2025-02-24 07:42:15 +08:00
29 lines
405 B
Go
29 lines
405 B
Go
|
package user
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"gofiber.study.skcks.cn/global"
|
||
|
"gofiber.study.skcks.cn/model/user/models"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
NotExists = errors.New("用户不存在")
|
||
|
)
|
||
|
|
||
|
func GetUserByAccount(account string) (*models.User, error) {
|
||
|
u := &models.User{
|
||
|
Account: account,
|
||
|
}
|
||
|
|
||
|
has, err := global.DataSources.Get(u)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
if !has {
|
||
|
return nil, NotExists
|
||
|
}
|
||
|
|
||
|
return u, nil
|
||
|
}
|