feat(api): add AI text-to-deck generation, wallet deposit structure, and profile/notification endpoints
Fills the gaps between the admin panel screens and the backend: a full free-text + slide-count + language -> AI-generated presentation flow with new slide-cloning logic in TemplateFillService, a "my presentations" list endpoint, a swappable payment-gateway structure for wallet top-ups (fake driver for now), and avatar upload / public-profile toggle / account deletion / password change / notification preference endpoints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
38
app/Http/Resources/NotificationPreferenceResource.php
Normal file
38
app/Http/Resources/NotificationPreferenceResource.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\NotificationPreference;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
schema: 'NotificationPreference',
|
||||
properties: [
|
||||
new OA\Property(property: 'comment_on_presentation', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'form_reply', type: 'boolean', example: false),
|
||||
new OA\Property(property: 'new_follower', type: 'boolean', example: false),
|
||||
new OA\Property(property: 'news_announcements', type: 'boolean', example: false),
|
||||
new OA\Property(property: 'weekly_product_updates', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'weekly_blog_digest', type: 'boolean', example: false),
|
||||
]
|
||||
)]
|
||||
/** @mixin NotificationPreference */
|
||||
class NotificationPreferenceResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'comment_on_presentation' => $this->comment_on_presentation,
|
||||
'form_reply' => $this->form_reply,
|
||||
'new_follower' => $this->new_follower,
|
||||
'news_announcements' => $this->news_announcements,
|
||||
'weekly_product_updates' => $this->weekly_product_updates,
|
||||
'weekly_blog_digest' => $this->weekly_blog_digest,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,20 @@ use OpenApi\Attributes as OA;
|
||||
schema: 'TemplateGeneration',
|
||||
properties: [
|
||||
new OA\Property(property: 'uuid', type: 'string', example: '9d6f0b1e-9a3a-4f0a-8a1a-6c9a2e5b3d10'),
|
||||
new OA\Property(property: 'title', type: 'string', example: 'گزارش فروش سال ۱۴۰۴'),
|
||||
new OA\Property(property: 'source', type: 'string', example: 'ai_text'),
|
||||
new OA\Property(property: 'source_label', type: 'string', example: 'ساخت با هوش مصنوعی از متن'),
|
||||
new OA\Property(property: 'language', type: 'string', example: 'fa', nullable: true),
|
||||
new OA\Property(property: 'slide_count', type: 'integer', example: 10, nullable: true),
|
||||
new OA\Property(
|
||||
property: 'template',
|
||||
properties: [
|
||||
new OA\Property(property: 'title', type: 'string'),
|
||||
new OA\Property(property: 'slug', type: 'string'),
|
||||
],
|
||||
type: 'object',
|
||||
nullable: true
|
||||
),
|
||||
new OA\Property(property: 'status', type: 'string', example: 'completed'),
|
||||
new OA\Property(property: 'status_label', type: 'string', example: 'تکمیل شده'),
|
||||
new OA\Property(property: 'error_message', type: 'string', example: null, nullable: true),
|
||||
@@ -28,6 +42,15 @@ class TemplateGenerationResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'title' => $this->title ?: $this->template?->title,
|
||||
'source' => $this->source->value,
|
||||
'source_label' => $this->source->label(),
|
||||
'language' => $this->language,
|
||||
'slide_count' => $this->slide_count,
|
||||
'template' => $this->template ? [
|
||||
'title' => $this->template->title,
|
||||
'slug' => $this->template->slug,
|
||||
] : null,
|
||||
'status' => $this->status->value,
|
||||
'status_label' => $this->status->label(),
|
||||
'error_message' => $this->error_message,
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Resources;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
@@ -15,6 +16,8 @@ use OpenApi\Attributes as OA;
|
||||
new OA\Property(property: 'username', type: 'string', example: 'ali'),
|
||||
new OA\Property(property: 'email', type: 'string', format: 'email', example: 'ali@example.com'),
|
||||
new OA\Property(property: 'mobile', type: 'string', example: '09123456789'),
|
||||
new OA\Property(property: 'avatar_url', type: 'string', example: 'https://example.com/storage/avatars/1.png', nullable: true),
|
||||
new OA\Property(property: 'is_public', type: 'boolean', example: false),
|
||||
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
|
||||
]
|
||||
)]
|
||||
@@ -32,6 +35,8 @@ class UserResource extends JsonResource
|
||||
'username' => $this->username,
|
||||
'email' => $this->email,
|
||||
'mobile' => $this->mobile,
|
||||
'avatar_url' => $this->avatar_path ? Storage::disk('public')->url($this->avatar_path) : null,
|
||||
'is_public' => $this->is_public,
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
38
app/Http/Resources/WalletDepositResource.php
Normal file
38
app/Http/Resources/WalletDepositResource.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\WalletDeposit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
schema: 'WalletDeposit',
|
||||
properties: [
|
||||
new OA\Property(property: 'id', type: 'integer', example: 1),
|
||||
new OA\Property(property: 'amount', type: 'integer', example: 500000),
|
||||
new OA\Property(property: 'status', type: 'string', example: 'pending'),
|
||||
new OA\Property(property: 'status_label', type: 'string', example: 'در انتظار پرداخت'),
|
||||
new OA\Property(property: 'gateway', type: 'string', example: 'fake'),
|
||||
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
|
||||
]
|
||||
)]
|
||||
/** @mixin WalletDeposit */
|
||||
class WalletDepositResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'amount' => $this->amount,
|
||||
'status' => $this->status->value,
|
||||
'status_label' => $this->status->label(),
|
||||
'gateway' => $this->gateway,
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user