修正Song 新增沒有產生 歌手資料
加入歌曲編號也能新增填值 相關資料加上索引 20250509
This commit is contained in:
parent
e7772026ea
commit
d29f026ab1
@ -22,6 +22,7 @@ class ImportSongChunkJob implements ShouldQueue
|
||||
|
||||
protected Collection $rows;
|
||||
protected array $categoryMap = [];
|
||||
protected array $artistCache =[];
|
||||
|
||||
public function __construct(Collection $rows)
|
||||
{
|
||||
@ -99,7 +100,19 @@ class ImportSongChunkJob implements ShouldQueue
|
||||
}
|
||||
}
|
||||
}
|
||||
private function getOrCreateArtistId(string $name): int
|
||||
{
|
||||
if (isset($this->artistCache[$name])) {
|
||||
return $this->artistCache[$name];
|
||||
}
|
||||
|
||||
$artist = Artist::firstOrCreate(
|
||||
['name' => $name],
|
||||
['category' => ArtistCategory::Unset]
|
||||
);
|
||||
|
||||
return $this->artistCache[$name] = $artist->id;
|
||||
}
|
||||
private function parseExcelDate($value): ?string
|
||||
{
|
||||
if (is_numeric($value)) {
|
||||
|
@ -13,6 +13,7 @@ class Song extends Model
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'adddate',
|
||||
'filename',
|
||||
|
@ -13,12 +13,12 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('artists', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->enum('category', ['未定義','男', '女','團','外', '其他'])->default('未定義')->comment('歌星類別');
|
||||
$table->string('name')->comment('歌星名稱');
|
||||
$table->string('simplified')->comment('歌星簡體');
|
||||
$table->string('phonetic_abbr')->comment('歌星注音');
|
||||
$table->string('pinyin_abbr')->comment('歌星拼音');
|
||||
$table->integer('strokes_abbr')->comment('歌星筆劃');
|
||||
$table->enum('category', ['未定義','男', '女','團','外', '其他'])->default('未定義')->index()->comment('歌星類別');
|
||||
$table->string('name')->unique()->comment('歌星名稱');
|
||||
$table->string('simplified')->index()->comment('歌星簡體');
|
||||
$table->string('phonetic_abbr')->index()->comment('歌星注音');
|
||||
$table->string('pinyin_abbr')->index()->comment('歌星拼音');
|
||||
$table->integer('strokes_abbr')->index()->comment('歌星筆劃');
|
||||
$table->tinyInteger('enable')->default(1)->comment('狀態'); // 1,可看,0,不可看
|
||||
$table->timestamps();
|
||||
});
|
||||
|
@ -13,13 +13,13 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('songs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('歌曲編號');
|
||||
$table->text('name')->nullable()->comment('歌曲檔名');
|
||||
$table->string('filename')->comment('歌曲檔名');
|
||||
$table->date('adddate')->comment('新增日期');
|
||||
$table->enum('language_type', ['未定義','國語','台語','英語','日語','粵語','韓語','越語','客語','其他'])->default('未定義')->comment('語別');
|
||||
$table->integer('db_change')->default(0)->comment('DB加減');
|
||||
$table->tinyInteger('vocal')->comment('人聲'); // 0,1
|
||||
$table->enum('situation', ['未定義','浪漫', '柔和','動感','明亮'])->default('未定義')->comment('情境');
|
||||
$table->string('name')->nullable()->index()->comment('歌曲檔名');
|
||||
$table->string('filename')->index()->comment('歌曲檔名');
|
||||
$table->date('adddate')->index()->comment('新增日期');
|
||||
$table->enum('language_type', ['未定義','國語','台語','英語','日語','粵語','韓語','越語','客語','其他'])->default('未定義')->index()->comment('語別');
|
||||
$table->integer('db_change')->default(0)->index()->comment('DB加減');
|
||||
$table->tinyInteger('vocal')->index()->comment('人聲'); // 0,1
|
||||
$table->enum('situation', ['未定義','浪漫', '柔和','動感','明亮'])->default('未定義')->index()->comment('情境');
|
||||
$table->string('copyright01')->nullable()->comment('版權01');
|
||||
$table->string('copyright02')->nullable()->comment('版權02');
|
||||
$table->string('note01')->nullable()->comment('備註01');
|
||||
@ -27,12 +27,12 @@ return new class extends Migration
|
||||
$table->string('note03')->nullable()->comment('備註03');
|
||||
$table->string('note04')->nullable()->comment('備註04');
|
||||
$table->tinyInteger('enable')->default(1)->comment('狀態'); // 1,可看,0,不可看
|
||||
$table->string('simplified')->comment('歌曲簡體');
|
||||
$table->string('phonetic_abbr')->comment('歌曲注音');
|
||||
$table->string('pinyin_abbr')->comment('歌曲拼音');
|
||||
$table->integer('strokes_abbr')->default(0)->comment('歌曲筆劃');
|
||||
$table->integer('song_number')->default(0)->comment('歌曲字數');
|
||||
$table->integer('song_counts')->default(0)->comment('點播次數');
|
||||
$table->string('simplified')->index()->comment('歌曲簡體');
|
||||
$table->string('phonetic_abbr')->index()->comment('歌曲注音');
|
||||
$table->string('pinyin_abbr')->index()->comment('歌曲拼音');
|
||||
$table->integer('strokes_abbr')->default(0)->index()->comment('歌曲筆劃');
|
||||
$table->integer('song_number')->default(0)->index()->comment('歌曲字數');
|
||||
$table->integer('song_counts')->default(0)->index()->comment('點播次數');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@ -48,6 +48,15 @@
|
||||
|
||||
{{-- 檔案上傳 --}}
|
||||
<input type="file" wire:model="file" accept=".csv, .xls, .xlsx" class="mb-4 w-full" />
|
||||
<!-- 上傳中提示 -->
|
||||
<div wire:loading wire:target="file" class="text-sm text-blue-500">
|
||||
檔案上傳中,請稍候...
|
||||
</div>
|
||||
|
||||
<!-- 上傳完成提示 -->
|
||||
<div wire:loading.remove wire:target="file" class="text-sm text-green-600">
|
||||
<x-wireui:icon name="check-circle" class="w-5 h-5 text-green-500" />
|
||||
</div>
|
||||
|
||||
<x-slot name="footer">
|
||||
<div class="flex justify-between w-full">
|
||||
|
@ -144,7 +144,15 @@
|
||||
</div>
|
||||
{{-- 檔案上傳 --}}
|
||||
<input type="file" wire:model="file" accept=".csv, .xls, .xlsx" class="mb-4 w-full" />
|
||||
|
||||
<!-- 上傳中提示 -->
|
||||
<div wire:loading wire:target="file" class="text-sm text-blue-500">
|
||||
檔案上傳中,請稍候...
|
||||
</div>
|
||||
|
||||
<!-- 上傳完成提示 -->
|
||||
<div wire:loading.remove wire:target="file" class="text-sm text-green-600">
|
||||
<x-wireui:icon name="check-circle" class="w-5 h-5 text-green-500" />
|
||||
</div>
|
||||
<x-slot name="footer">
|
||||
<div class="flex justify-between w-full">
|
||||
<x-wireui:button flat label="{{ __('songs.cancel') }}" wire:click="closeModal" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user