refactor: Update tenant ID handling across the application

This commit is contained in:
wizardchen
2025-11-25 16:30:54 +08:00
parent 9f6f5f5773
commit 64c44c9e27
78 changed files with 437 additions and 601 deletions
+3 -3
View File
@@ -32,7 +32,7 @@ func (r *tenantRepository) CreateTenant(ctx context.Context, tenant *types.Tenan
}
// GetTenantByID gets tenant by ID
func (r *tenantRepository) GetTenantByID(ctx context.Context, id uint) (*types.Tenant, error) {
func (r *tenantRepository) GetTenantByID(ctx context.Context, id uint64) (*types.Tenant, error) {
var tenant types.Tenant
if err := r.db.WithContext(ctx).Where("id = ?", id).First(&tenant).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
@@ -58,11 +58,11 @@ func (r *tenantRepository) UpdateTenant(ctx context.Context, tenant *types.Tenan
}
// DeleteTenant deletes tenant
func (r *tenantRepository) DeleteTenant(ctx context.Context, id uint) error {
func (r *tenantRepository) DeleteTenant(ctx context.Context, id uint64) error {
return r.db.WithContext(ctx).Where("id = ?", id).Delete(&types.Tenant{}).Error
}
func (r *tenantRepository) AdjustStorageUsed(ctx context.Context, tenantID uint, delta int64) error {
func (r *tenantRepository) AdjustStorageUsed(ctx context.Context, tenantID uint64, delta int64) error {
return r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
var tenant types.Tenant
// 使用悲观锁确保并发安全