35 lines
711 B
Go
35 lines
711 B
Go
package repository
|
|
|
|
import (
|
|
"wireguard-dashboard/client"
|
|
"wireguard-dashboard/model/entity"
|
|
)
|
|
|
|
type user struct{}
|
|
|
|
func User() user {
|
|
return user{}
|
|
}
|
|
|
|
// GetUserById
|
|
// @description: 根据id获取用户信息
|
|
// @receiver r
|
|
// @param id
|
|
// @return *entity.User
|
|
// @return error
|
|
func (r user) GetUserById(id string) (data *entity.User, err error) {
|
|
err = client.DB.Where("id = ?", id).First(&data).Error
|
|
return
|
|
}
|
|
|
|
// GetUserByAccount
|
|
// @description: 通过账户号获取用户信息
|
|
// @receiver r
|
|
// @param account
|
|
// @return data
|
|
// @return err
|
|
func (r user) GetUserByAccount(account string) (data *entity.User, err error) {
|
|
err = client.DB.Where("account = ?", account).First(&data).Error
|
|
return
|
|
}
|