오늘 이슈(TodayIssue) 기능 구현
- TodayIssue 모델 및 마이그레이션 추가 - TodayIssueController, TodayIssueService 구현 - TodayIssueObserverService 및 Observer 패턴 적용 - DailyReportService 연동 - Swagger API 문서 업데이트 - 라우트 추가
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('today_issues', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
|
||||
// 소스 정보
|
||||
$table->string('source_type', 50)->comment('order, bad_debt, stock, expense, tax, approval, client');
|
||||
$table->unsignedBigInteger('source_id')->nullable()->comment('원본 레코드 ID (tax는 null)');
|
||||
|
||||
// 표시 정보
|
||||
$table->string('badge', 50)->comment('수주 성공, 주식 이슈, 직정 제고, 지출예상내역서, 세금 신고, 결재 요청, 기타');
|
||||
$table->string('content', 500)->comment('표시 내용');
|
||||
$table->string('path', 255)->nullable()->comment('이동 경로');
|
||||
$table->boolean('needs_approval')->default(false)->comment('승인 필요 여부');
|
||||
|
||||
// 읽음 상태
|
||||
$table->boolean('is_read')->default(false)->comment('확인 여부');
|
||||
$table->foreignId('read_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('read_at')->nullable();
|
||||
|
||||
// 만료 시간 (오늘의 이슈이므로 당일 자정에 만료)
|
||||
$table->timestamp('expires_at')->nullable()->comment('만료 시간');
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// 인덱스
|
||||
$table->index(['tenant_id', 'is_read', 'created_at']);
|
||||
$table->index(['tenant_id', 'badge']);
|
||||
$table->index(['expires_at']);
|
||||
|
||||
// 중복 방지 (같은 소스에서 같은 이슈 중복 생성 방지)
|
||||
$table->unique(['tenant_id', 'source_type', 'source_id'], 'today_issues_unique_source');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('today_issues');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('today_issues', function (Blueprint $table) {
|
||||
$table->string('notification_type', 50)->nullable()->after('badge')->comment('알림 유형 (sales_order, new_vendor, approval_request, bad_debt, safety_stock, expected_expense, vat_report)');
|
||||
$table->index('notification_type');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('today_issues', function (Blueprint $table) {
|
||||
$table->dropIndex(['notification_type']);
|
||||
$table->dropColumn('notification_type');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user