moto/internal/organize/profile.go

18 lines
513 B
Go
Raw Normal View History

2024-12-12 17:39:04 +08:00
package organize
2024-12-12 16:24:50 +08:00
import (
"context"
"git.nobla.cn/golang/moto/common/db"
2024-12-12 17:39:04 +08:00
"git.nobla.cn/golang/moto/internal/organize/types"
2024-12-12 16:24:50 +08:00
)
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
}