作者 lyh

gx

@@ -28,6 +28,10 @@ use App\Models\Project\MinorLanguages; @@ -28,6 +28,10 @@ use App\Models\Project\MinorLanguages;
28 use App\Models\Project\Project; 28 use App\Models\Project\Project;
29 use App\Models\RouteMap\RouteMap; 29 use App\Models\RouteMap\RouteMap;
30 use App\Models\Template\BCustomTemplate; 30 use App\Models\Template\BCustomTemplate;
  31 +use App\Models\Template\BTemplate;
  32 +use App\Models\Template\BTemplateCom;
  33 +use App\Models\Template\BTemplateCommon;
  34 +use App\Models\Template\Setting;
31 use App\Models\WebSetting\WebSettingService; 35 use App\Models\WebSetting\WebSettingService;
32 use App\Services\AmazonS3Service; 36 use App\Services\AmazonS3Service;
33 use App\Services\ProjectServer; 37 use App\Services\ProjectServer;
@@ -52,84 +56,80 @@ class Demo extends Command @@ -52,84 +56,80 @@ class Demo extends Command
52 * @var string 56 * @var string
53 */ 57 */
54 protected $description = 'demo'; 58 protected $description = 'demo';
55 -  
56 - public function s(){ 59 + /**
  60 + * Execute the job.
  61 + *
  62 + * @return void
  63 + */
  64 + public function handle()
  65 + {
57 $projectModel = new Project(); 66 $projectModel = new Project();
58 - $list = $projectModel->list(['id'=>181]); 67 + $list = $projectModel->list(['delete_status'=>0]);
  68 + $data = [];
59 foreach ($list as $v){ 69 foreach ($list as $v){
60 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 70 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
61 ProjectServer::useProject($v['id']); 71 ProjectServer::useProject($v['id']);
62 - $this->initSearch($v['id']); 72 + $this->saveTemplateCom();
63 DB::disconnect('custom_mysql'); 73 DB::disconnect('custom_mysql');
64 } 74 }
65 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 75 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
66 } 76 }
67 77
68 - /**  
69 - * @remark :创建search页面  
70 - * @name :initSearch  
71 - * @author :lyh  
72 - * @method :post  
73 - * @time :2024/4/25 11:35  
74 - */  
75 - public function initSearch($project_id){  
76 - $bCustomTemplateModel = new BCustomTemplate();  
77 - $info = $bCustomTemplateModel->read(['url'=>'search']);  
78 - if($info === false){  
79 - $time = date('Y-m-d H:i:s');  
80 - $info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();  
81 - if(empty($info)) {  
82 - $data = [  
83 - 'project_id' => $project_id,  
84 - 'name' => 'search',  
85 - 'status' => 1,  
86 - 'url' => 'search',  
87 - 'html' => '',  
88 - 'html_style' =>'search',  
89 - 'title' => 'search',  
90 - 'description' => 'Sorry. The page has either moved or cannot be found.',  
91 - 'created_at' => $time, 'updated_at' => $time];  
92 - $id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data);  
93 - //路由  
94 - $info = DB::connection('custom_mysql')->table('gl_route_map')->first();  
95 - if(empty($info)) {  
96 - $data = ['project_id' => $project_id, 'source' => RouteMap::SOURCE_PAGE, 'source_id' => $id, 'route' => 'search', 'created_at' => $time, 'updated_at' => $time];  
97 - DB::connection('custom_mysql')->table('gl_route_map')->insert($data); 78 + public function saveTemplateCom($project_id){
  79 + //获取当前项目选择的模版
  80 + $settingModel = new Setting();
  81 + $settingInfo = $settingModel->read(['project_id'=>$project_id]);
  82 + if($settingInfo !== false){
  83 + $templateCommonModel = new BTemplateCommon();
  84 + $commonList = $templateCommonModel->list(['id'=>1,'template_id'=>$settingModel['template_id'],'is_custom'=>0]);
  85 + if(!empty($commonList)){
  86 + foreach ($commonList as $v){
  87 + $typeArr = [1, 2, 3];
  88 + foreach ($typeArr as $type){
  89 + if($type == 1){
  90 + $headData = [
  91 + 'project_id'=>$v['project_id'],
  92 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  93 + 'common_type'=>1,
  94 + 'template_id'=>$v['template_id'],
  95 + 'html'=>$v['head_html'],
  96 + 'html_style'=>$v['head_css'],
  97 + 'is_custom'=>$v['is_custom'],
  98 + 'is_list'=>$v['list']
  99 + ];
  100 + $templateComModel = new BTemplateCom();
  101 + $templateComModel->add($headData);
  102 + }elseif ($type == 2){
  103 + $footerData = [
  104 + 'project_id'=>$v['project_id'],
  105 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  106 + 'common_type'=>2,
  107 + 'template_id'=>$v['template_id'],
  108 + 'html'=>$v['footer_html'],
  109 + 'html_style'=>$v['footer_css'],
  110 + 'is_custom'=>$v['is_custom'],
  111 + 'is_list'=>$v['is_list']
  112 + ];
  113 + $templateComModel = new BTemplateCom();
  114 + $templateComModel->add($footerData);
  115 + }elseif ($type == 3){
  116 + $otherData = [
  117 + 'project_id'=>$v['project_id'],
  118 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  119 + 'common_type'=>3,
  120 + 'template_id'=>$v['template_id'],
  121 + 'html'=>$v['other'],
  122 + 'html_style'=>null,
  123 + 'is_custom'=>$v['is_custom'],
  124 + 'is_list'=>$v['is_list']
  125 + ];
  126 + $templateComModel = new BTemplateCom();
  127 + $templateComModel->add($otherData);
  128 + }
  129 + }
98 } 130 }
99 } 131 }
100 } 132 }
101 return true; 133 return true;
102 } 134 }
103 -  
104 - /**  
105 - * Execute the job.  
106 - *  
107 - * @return void  
108 - */  
109 - public function handle()  
110 - {  
111 - $this->param['project_id'] = 181;  
112 - $imageModel = new ImageModel();  
113 - //获取当前项目的所有图片  
114 - $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);  
115 - if(!empty($imageList)){  
116 - $amazonS3Service = new AmazonS3Service();  
117 - foreach ($imageList as $k => $v){  
118 - $amazonS3Service->syncImageFiles(getImageUrl($v['path']));  
119 - $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);  
120 - }  
121 - }  
122 -  
123 - $fileModel = new FileModel();  
124 - $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);  
125 - if(!empty($fileList)){  
126 - $amazonS3Service = new AmazonS3Service();  
127 - foreach ($fileList as $k => $v){  
128 - echo date('Y-m-d H:i:s') . '执行的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;  
129 - $amazonS3Service->syncImageFiles(getFileUrl($v['path']));  
130 - $fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);  
131 - }  
132 - }  
133 - return true;  
134 - }  
135 } 135 }