🆕授权登陆接口

This commit is contained in:
coward
2024-03-07 11:03:46 +08:00
parent 2ac91bf012
commit 1c0a128855
16 changed files with 336 additions and 175 deletions

34
repository/user.go Normal file
View File

@@ -0,0 +1,34 @@
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
}