moto/internal/user/profile.go

18 lines
505 B
Go
Raw Normal View History

2024-12-12 16:24:50 +08:00
package user
import (
"context"
"git.nobla.cn/golang/moto/common/db"
"git.nobla.cn/golang/moto/internal/user/types"
)
func Profile(ctx context.Context, uid string) (profile *types.Profile, err error) {
profile = &types.Profile{}
tx := db.WithContext(ctx)
err = tx.Table("users AS u").
Select("u.uid as id", "u.username", "u.avatar", "u.email", "u.description", "u.role", "r.permissions").
Joins("left join roles AS r on r.id = u.role").Where("u.uid=? ", uid).
First(profile).Error
return
}