正在显示
1 个修改的文件
包含
70 行增加
和
0 行删除
app/Console/Commands/EditPage.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :EditPage.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/11/13 10:06 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands; | ||
| 11 | + | ||
| 12 | +use App\Models\Project\Project; | ||
| 13 | +use App\Models\RouteMap\RouteMap; | ||
| 14 | +use App\Models\Template\BCustomTemplate; | ||
| 15 | +use App\Services\ProjectServer; | ||
| 16 | +use Illuminate\Console\Command; | ||
| 17 | +use Illuminate\Support\Facades\DB; | ||
| 18 | + | ||
| 19 | +class EditPage extends Command | ||
| 20 | +{ | ||
| 21 | + /** | ||
| 22 | + * The name and signature of the console command. | ||
| 23 | + * | ||
| 24 | + * @var string | ||
| 25 | + */ | ||
| 26 | + protected $signature = 'edit_page'; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * The console command description. | ||
| 30 | + * | ||
| 31 | + * @var string | ||
| 32 | + */ | ||
| 33 | + protected $description = '修复单页面路由数据'; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Create a new command instance. | ||
| 37 | + * | ||
| 38 | + * @return void | ||
| 39 | + */ | ||
| 40 | + public function __construct() | ||
| 41 | + { | ||
| 42 | + parent::__construct(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * @return bool | ||
| 47 | + */ | ||
| 48 | + public function handle() | ||
| 49 | + { | ||
| 50 | + //获取所有项目 | ||
| 51 | + $projectModel = new Project(); | ||
| 52 | + $list = $projectModel->list(['type'=>['in',[1,2,3,4]]]); | ||
| 53 | + | ||
| 54 | + try { | ||
| 55 | + foreach ($list as $v){ | ||
| 56 | + echo date('Y-m-d H:i:s') . ' start: '. $v['id'] . PHP_EOL; | ||
| 57 | + ProjectServer::useProject($v['id']); | ||
| 58 | + BCustomTemplate::where('url', 'like', '%-tag%') | ||
| 59 | + ->update(['url' => DB::raw("REPLACE(url, '-tag', '')")]); | ||
| 60 | + RouteMap::where('url', 'like', '%-tag%')->where('source','page') | ||
| 61 | + ->update(['url' => DB::raw("REPLACE(url, '-tag', '')")]); | ||
| 62 | + DB::disconnect('custom_mysql'); | ||
| 63 | + } | ||
| 64 | + }catch (\Exception $e){ | ||
| 65 | + echo date('Y-m-d H:i:s') . ' error: ->' . $e->getMessage() . PHP_EOL; | ||
| 66 | + } | ||
| 67 | + echo date('Y-m-d H:i:s') . ' end: down' . PHP_EOL; | ||
| 68 | + return true; | ||
| 69 | + } | ||
| 70 | +} |
-
请 注册 或 登录 后发表评论