From f84b1877ad133a4ed4fe77188ac1099d29c9d1da Mon Sep 17 00:00:00 2001 From: denghy Date: Sat, 29 Dec 2018 17:52:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=9A=84=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Domains/Stats/Exports/AbstractExport.php | 18 ++++++++++++++++++ app/Models/Stats/Export.php | 2 +- ...12_29_112239_create_stats_exports_table.php | 4 +++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Domains/Stats/Exports/AbstractExport.php b/app/Domains/Stats/Exports/AbstractExport.php index d15e610d..b8943194 100644 --- a/app/Domains/Stats/Exports/AbstractExport.php +++ b/app/Domains/Stats/Exports/AbstractExport.php @@ -22,11 +22,14 @@ abstract class AbstractExport implements WithEvents, WithTitle public $sn; + public $tag; + public $filename; public function __construct() { $this->sn = $this->sn(); + $this->tag = $this->tag(); $this->filename = $this->filename(); } @@ -53,6 +56,7 @@ abstract class AbstractExport implements WithEvents, WithTitle { $data = [ 'sn' => $event->getConcernable()->sn, + 'tag' => $event->getConcernable()->tag, 'filename' => $event->getConcernable()->filename, 'filesize' => 0, 'conditions' => $event->getConcernable()->conditions ?: null, @@ -146,4 +150,18 @@ abstract class AbstractExport implements WithEvents, WithTitle return "export/{$filename}.xlsx"; } + + /** + * 类型 + * + * @return void + */ + private function tag() + { + $className = get_class($this); + + $baseName = array_last(explode('\\', $className)); + + return str_replace('Export', '', $baseName); + } } diff --git a/app/Models/Stats/Export.php b/app/Models/Stats/Export.php index a0b0cb79..0afc8f9e 100644 --- a/app/Models/Stats/Export.php +++ b/app/Models/Stats/Export.php @@ -8,7 +8,7 @@ class Export extends Model { protected $table = 'stats_exports'; - protected $fillable = ['id', 'sn', 'filename' , 'filesize', 'conditions', 'status', 'progress']; + protected $fillable = ['id', 'sn', 'tag', 'filename' , 'filesize', 'conditions', 'status', 'progress']; protected $casts = [ 'conditions' => 'array', diff --git a/database/migrations/2018_12_29_112239_create_stats_exports_table.php b/database/migrations/2018_12_29_112239_create_stats_exports_table.php index 6fe76070..b935c65b 100644 --- a/database/migrations/2018_12_29_112239_create_stats_exports_table.php +++ b/database/migrations/2018_12_29_112239_create_stats_exports_table.php @@ -15,7 +15,8 @@ class CreateStatsExportsTable extends Migration { Schema::create('stats_exports', function (Blueprint $table) { $table->increments('id')->comment('自增ID'); - $table->string('sn', 32)->comment('命令编号'); + $table->string('sn', 32)->default('')->comment('命令编号'); + $table->string('tag', 20)->default('')->comment('标记'); $table->string('filename')->default('')->comment('文件名'); $table->integer('filesize')->unsigned()->default(0)->comment('文件大小'); $table->text('conditions')->nullable()->comment('查询条件'); @@ -23,6 +24,7 @@ class CreateStatsExportsTable extends Migration $table->tinyInteger('progress')->unsigned()->default(0)->comment('进度'); $table->timestamps(); $table->unique('sn'); + $table->index('tag'); $table->comment('VD统计导出表'); }); }