fix: issues
This commit is contained in:
@@ -9,6 +9,6 @@ type Controller struct {
|
||||
|
||||
// List
|
||||
func (c *Controller) List(ctx fiber.Ctx) error {
|
||||
return ctx.SendString(ctx.Params("tenant", "no tenant"))
|
||||
return ctx.SendString(ctx.Params("tenant", "no user"))
|
||||
return ctx.JSON(nil)
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ func (svc *Service) TenantHasUser(ctx context.Context, userID, tenantID int64) (
|
||||
|
||||
tbl := table.UsersTenants
|
||||
stmt := tbl.
|
||||
SELECT(COUNT(tbl.ID)).
|
||||
SELECT(COUNT(tbl.ID).AS("cnt")).
|
||||
WHERE(
|
||||
tbl.UserID.EQ(Int64(userID)).AND(
|
||||
tbl.TenantID.EQ(Int64(tenantID)),
|
||||
@@ -169,12 +169,14 @@ func (svc *Service) TenantHasUser(ctx context.Context, userID, tenantID int64) (
|
||||
)
|
||||
log.Debug(stmt.DebugSql())
|
||||
|
||||
var cnt int
|
||||
if err := stmt.QueryContext(ctx, db.FromContext(ctx, svc.db), &cnt); err != nil {
|
||||
var result struct {
|
||||
cnt int64
|
||||
}
|
||||
if err := stmt.QueryContext(ctx, db.FromContext(ctx, svc.db), &result); err != nil {
|
||||
return false, errors.Wrap(err, "failed to query user-tenant relation")
|
||||
}
|
||||
|
||||
return cnt > 0, nil
|
||||
return result.cnt > 0, nil
|
||||
}
|
||||
|
||||
// CreateTenantUser
|
||||
|
||||
Reference in New Issue
Block a user