feat: add user_tenant associations

This commit is contained in:
2025-12-16 14:14:58 +08:00
parent d058b7ffda
commit 4722eef72c
9 changed files with 391 additions and 24 deletions

View File

@@ -16,7 +16,7 @@ type user struct{}
func (t *user) FindByID(ctx context.Context, userID int64) (*models.User, error) {
tbl, query := models.UserQuery.QueryContext(ctx)
model, err := query.Where(tbl.ID.Eq(userID)).First()
model, err := query.Preload(tbl.OwnedTenant, tbl.Tenants).Where(tbl.ID.Eq(userID)).First()
if err != nil {
return nil, errors.Wrapf(err, "FindByID failed, %d", userID)
}