Ana içeriğe geç

Müşteri Yönetimi

Müşteri (tenant) CRUD işlemleri, veritabanı yönetimi, kullanıcı yönetimi ve modül atama.

Base URL: /api/admin/customers Yetkilendirme: Bearer Token (Admin)

Headers:

Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

Müşteri İşlemleri

POST /

Yeni müşteri oluşturur.

Request Body:

{
"name": "Acme Corp",
"slug": "acme-corp",
"domain": "acme.com",
"maxUploadFileSizeMb": 10
}
AlanTipZorunluAçıklama
namestringEvetMüşteri adı
slugstringEvetURL-dostu benzersiz tanımlayıcı
domainstringEvetMüşteri domain adresi
maxUploadFileSizeMbintEvetTenant için maksimum upload boyutu (MB)

Response — 201 Created:

{
"success": true,
"data": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Acme Corp",
"slug": "acme-corp",
"domain": "acme.com",
"apiKey": "generated-api-key",
"isActive": true,
"maxUploadFileSizeMb": 10,
"createdAt": "2026-03-27T10:00:00Z"
}
}

GET /

Tüm müşterileri sayfalanmış olarak listeler.

Query Parametreleri:

ParametreTipVarsayılanAçıklama
pageint1Sayfa numarası
pageSizeint10Sayfa başına kayıt

Response — 200 OK:

{
"success": true,
"data": {
"items": [
{
"id": "3fa85f64-...",
"name": "Acme Corp",
"slug": "acme-corp",
"domain": "acme.com",
"apiKey": "generated-api-key",
"isActive": true,
"maxUploadFileSizeMb": 10,
"createdAt": "2026-03-27T10:00:00Z"
}
],
"page": 1,
"pageSize": 10,
"totalCount": 1,
"totalPages": 1
}
}

GET /{id}

Müşteri detayını (veritabanı bilgisi dahil) getirir.

Response — 200 OK:

{
"success": true,
"data": {
"id": "3fa85f64-...",
"name": "Acme Corp",
"slug": "acme-corp",
"domain": "acme.com",
"apiKey": "generated-api-key",
"isActive": true,
"maxUploadFileSizeMb": 10,
"createdAt": "2026-03-27T10:00:00Z",
"database": {
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"isInitialized": true
}
}
}

PUT /{id}

Müşteri bilgilerini günceller.

Request Body:

{
"name": "Acme Corp Updated",
"domain": "new-acme.com",
"isActive": true,
"maxUploadFileSizeMb": 25
}
AlanTipZorunluAçıklama
namestringEvetMüşteri adı
domainstringEvetDomain adresi
isActivebooleanEvetAktiflik durumu
maxUploadFileSizeMbintEvetTenant maksimum upload boyutu (MB)

Response — 200 OK: CustomerResponse objesi döner.


DELETE /{id}

Müşteriyi siler (soft delete).

Response — 204 No Content


Veritabanı Yönetimi

POST /{id}/database

Müşteri veritabanı bilgilerini kaydeder.

Request Body:

{
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"password": "secret"
}
AlanTipZorunluAçıklama
hoststringEvetVeritabanı sunucusu
portintEvetPort numarası
databaseNamestringEvetVeritabanı adı
usernamestringEvetKullanıcı adı
passwordstringEvetŞifre

Response — 201 Created:

{
"success": true,
"data": {
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"isInitialized": false
}
}

PUT /{id}/database

Veritabanı bilgilerini günceller.

Request Body: SaveDatabaseRequest ile aynı.

Response — 200 OK:

{
"success": true,
"data": {
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"isInitialized": false
}
}

GET /{id}/database

Veritabanı bilgilerini getirir.

Response — 200 OK:

{
"success": true,
"data": {
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"isInitialized": true
}
}

POST /{id}/database/test

Veritabanı bağlantısını test eder.

Response — 200 OK:

{
"success": true,
"data": {
"success": true,
"message": "Baglanti basarili"
}
}

POST /{id}/database/initialize

Tenant veritabanını başlatır (migration + seed data).

uyarı

Bu işlem yalnızca bir kez yapılmalıdır. Veritabanı bağlantı bilgileri önceden kaydedilmiş olmalıdır.

Response — 200 OK:

{
"success": true,
"message": "Veritabanı başarıyla başlatıldı."
}

Kullanıcı Yönetimi

POST /{customerId}/users

Müşteriye yeni tenant kullanıcısı ekler.

Request Body:

{
"email": "user@example.com",
"fullName": "Ali Yılmaz",
"password": "SecurePass123"
}
AlanTipZorunluAçıklama
emailstringEvetE-posta adresi
fullNamestringEvetAd soyad
passwordstringEvetŞifre

Response — 201 Created:

{
"success": true,
"data": {
"id": "3fa85f64-...",
"email": "user@example.com",
"fullName": "Ali Yılmaz",
"isActive": true,
"createdAt": "2026-03-27T10:00:00Z"
}
}

GET /{customerId}/users

Müşteriye ait tüm kullanıcıları listeler.

Response — 200 OK:

{
"success": true,
"data": [
{
"id": "3fa85f64-...",
"email": "user@example.com",
"fullName": "Ali Yılmaz",
"isActive": true,
"createdAt": "2026-03-27T10:00:00Z"
}
]
}

GET /{customerId}/users/{userId}

Belirli bir kullanıcıyı getirir.

Response — 200 OK:

{
"success": true,
"data": {
"id": "3fa85f64-...",
"email": "user@example.com",
"fullName": "Ali Yılmaz",
"isActive": true,
"createdAt": "2026-03-27T10:00:00Z"
}
}

PUT /{customerId}/users/{userId}

Kullanıcı bilgilerini günceller.

Request Body:

{
"email": "updated@example.com",
"fullName": "Ali Yılmaz Updated",
"isActive": true
}

Response — 200 OK: TenantUserResponse objesi döner.


DELETE /{customerId}/users/{userId}

Kullanıcıyı siler (soft delete).

Response — 204 No Content


Modül Yönetimi

GET /{id}/modules

Müşteriye atanmış modülleri listeler.

Response — 200 OK:

{
"success": true,
"data": [
{
"moduleId": "3fa85f64-...",
"moduleName": "Blog",
"moduleCode": "blog",
"isActive": true
}
]
}

POST /{id}/modules

Müşteriye modül atar.

Request Body:

{
"moduleId": "3fa85f64-...",
"isActive": true
}

Response — 201 Created:

{
"success": true,
"data": {
"moduleId": "3fa85f64-...",
"moduleName": "Blog",
"moduleCode": "blog",
"isActive": true
}
}

PUT /{id}/modules/{moduleId}

Modül atamasını günceller.

Query Parametreleri:

ParametreTipAçıklama
isActivebooleanModül aktiflik durumu

Response — 200 OK:

{
"success": true,
"data": {
"moduleId": "3fa85f64-...",
"moduleName": "Blog",
"moduleCode": "blog",
"isActive": false
}
}

Olası Hatalar

KodDurum
401Token eksik veya geçersiz
403Admin yetkisi yok
404Müşteri, veritabanı kaydı, kullanıcı veya modül bulunamadı
409Müşteri slug'ı, kullanıcı email'i veya modül ataması zaten mevcut