作者 lyh

gx复制项目

1 <?php 1 <?php
  2 +/**
  3 + * @remark :
  4 + * @name :CopyProject.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/1/15 14:40
  8 + */
2 9
3 -namespace App\Jobs; 10 +namespace App\Console\Commands\Project;
4 11
5 -use App\Events\CopyProject;  
6 -use App\Events\UpdateHtml;  
7 -use App\Jobs\updateHtmlJob;  
8 use App\Models\Project\After; 12 use App\Models\Project\After;
9 use App\Models\Project\DeployBuild; 13 use App\Models\Project\DeployBuild;
10 use App\Models\Project\DeployOptimize; 14 use App\Models\Project\DeployOptimize;
@@ -14,40 +18,27 @@ use App\Models\Template\Setting; @@ -14,40 +18,27 @@ use App\Models\Template\Setting;
14 use App\Models\User\User as UserModel; 18 use App\Models\User\User as UserModel;
15 use App\Services\ProjectServer; 19 use App\Services\ProjectServer;
16 use Hashids\Hashids; 20 use Hashids\Hashids;
17 -use Illuminate\Bus\Queueable;  
18 -use Illuminate\Contracts\Queue\ShouldQueue;  
19 -use Illuminate\Foundation\Bus\Dispatchable;  
20 -use Illuminate\Queue\InteractsWithQueue;  
21 -use Illuminate\Queue\SerializesModels; 21 +use Illuminate\Console\Command;
22 use Illuminate\Support\Facades\DB; 22 use Illuminate\Support\Facades\DB;
23 use Illuminate\Support\Facades\Log; 23 use Illuminate\Support\Facades\Log;
24 use Illuminate\Support\Facades\Schema; 24 use Illuminate\Support\Facades\Schema;
25 25
26 -class CopyProjectJob implements ShouldQueue 26 +class CopyProject extends Command
27 { 27 {
28 - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;  
29 - public $tries = 3; // 可配置任务重试次数  
30 -  
31 - protected $param;  
32 -  
33 /** 28 /**
34 - * Create a new job instance. 29 + * The name and signature of the console command.
35 * 30 *
36 - * @param CopyImageFile $event  
37 - * @return void 31 + * @var string
38 */ 32 */
39 - public function __construct($data)  
40 - {  
41 - $this->param = $data;  
42 - }  
43 - 33 + protected $signature = 'copy_project';
44 34
45 /** 35 /**
46 - * Handle the event. 36 + * The console command description.
47 * 37 *
48 - * @param UpdateHtml $event  
49 - * @return void 38 + * @var string
50 */ 39 */
  40 + protected $description = 'copy--复制项目';
  41 +
51 public function handle() 42 public function handle()
52 { 43 {
53 $projectModel = new Project(); 44 $projectModel = new Project();
@@ -754,7 +754,7 @@ class ProjectLogic extends BaseLogic @@ -754,7 +754,7 @@ class ProjectLogic extends BaseLogic
754 * @time :2023/11/8 14:23 754 * @time :2023/11/8 14:23
755 */ 755 */
756 public function copyProject(){ 756 public function copyProject(){
757 - CopyProjectJob::dispatch(['project_id'=>$this->param['project_id']]); 757 + NoticeLog::createLog(NoticeLog::TYPE_COPY_PROJECT, ['project_id' => $this->param['project_id']]);
758 return $this->success('项目复制中,请稍后前往初始化项目查看;'); 758 return $this->success('项目复制中,请稍后前往初始化项目查看;');
759 } 759 }
760 760
@@ -13,6 +13,7 @@ class NoticeLog extends Base @@ -13,6 +13,7 @@ class NoticeLog extends Base
13 const TYPE_PROJECT = 'project'; 13 const TYPE_PROJECT = 'project';
14 const TYPE_RANK_DATA = 'rank_data'; 14 const TYPE_RANK_DATA = 'rank_data';
15 const TYPE_INIT_PROJECT = 'init_project'; 15 const TYPE_INIT_PROJECT = 'init_project';
  16 + const TYPE_COPY_PROJECT = 'copy_project';
16 const TYPE_INIT_KEYWORD = 'init_keyword'; 17 const TYPE_INIT_KEYWORD = 'init_keyword';
17 const DELETE_PRODUCT_CATEGORY = 'delete_product_category'; 18 const DELETE_PRODUCT_CATEGORY = 'delete_product_category';
18 const DELETE_BLOG_CATEGORY = 'delete_blog_category'; 19 const DELETE_BLOG_CATEGORY = 'delete_blog_category';