feat: 前端分離+功能api化

1. 新增資產管理CRUD、googleOAuth登入
2. 更改原記帳controller
This commit is contained in:
2026-06-25 14:19:07 +08:00
parent 7bb931c97b
commit 85972f950c
70 changed files with 4754 additions and 1520 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Console\Commands;
use App\Jobs\UpdateAssetPriceJob;
use App\Models\InvestmentHolding;
use App\Models\Security;
use Illuminate\Console\Command;
class RefreshAllAssetPrices extends Command
{
// 執行此指令的名稱php artisan asset:refresh-prices
protected $signature = 'asset:refresh-prices';
protected $description = '將全系統所有股票與基金的價格更新任務推入 Queue 佇列';
public function handle()
{
// 🟢 1. 從持倉表中撈出所有使用者「目前有在使用」且「不重複」的股票與基金代號
// 這樣能完美確保 2330 只會被爬一次,不會對證交所造成重複負擔
$uniqueHoldings = Security::select('code', 'type', 'name')
->groupBy('code', 'type', 'name') // 去除重複
->get();
$this->info("全系統共發現 " . $uniqueHoldings->count() . " 檔不重複的現役標的,開始指派更新任務...");
$delaySeconds = 0;
foreach ($uniqueHoldings as $holding) {
UpdateAssetPriceJob::dispatch(
$holding->code,
$holding->type,
$holding->name
)->delay(now()->addSeconds($delaySeconds));
$delaySeconds += 2;
}
$this->info("所有任務皆已成功排入背景 Queue預計花費 {$delaySeconds} 秒消化完畢。");
}
}