作者 Your Name
@@ -34,44 +34,63 @@ class Temp extends Command @@ -34,44 +34,63 @@ class Temp extends Command
34 */ 34 */
35 protected $description = '临时脚本'; 35 protected $description = '临时脚本';
36 36
37 - public function handle()  
38 - {  
39 - $domain_model = new DomainInfo();  
40 - $notify_model = new Notify();  
41 - $project_model = new Project();  
42 -  
43 - $domain_list = $domain_model->list(['amp_status' => 1]);  
44 - foreach ($domain_list as $info) {  
45 - if ($info['project_id'] > 0) {  
46 - $notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);  
47 - if (!$notify_info) {  
48 -  
49 - $domain_array = parse_url($info['domain']);  
50 - $host = $domain_array['host'] ?? $domain_array['path'];  
51 - $host_array = explode('.', $host);  
52 - if (count($host_array) <= 2) {  
53 - array_unshift($host_array, 'm');  
54 - } else {  
55 - $host_array[0] = 'm';  
56 - }  
57 - $amp_domain = implode('.', $host_array);  
58 -  
59 - $project_info = $project_model->read(['id' => $info['project_id']]);  
60 -  
61 - $notify_model->add([  
62 - 'project_id' => $info['project_id'],  
63 - 'type' => 3,  
64 - 'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),  
65 - 'server_id' => $project_info['serve_id'],  
66 - ]);  
67 - }  
68 - } 37 + public function handle(){
  38 + ProjectServer::useProject(1515);
  39 +
  40 + $products = Product::select(['id','content'])->get();
  41 +
  42 + foreach ($products as $product){
  43 + $content = $product->content;
  44 + $content = str_replace('<h1','<h2', $content);
  45 + $content = str_replace('</h1','</h2', $content);
  46 +
  47 + $product->content = $content;
  48 + $product->save();
  49 +
  50 + $this->output('productID:'.$product->id.',success');
69 } 51 }
  52 +
  53 + $this->output('end');
70 } 54 }
71 55
72 // public function handle() 56 // public function handle()
73 // { 57 // {
74 // $domain_model = new DomainInfo(); 58 // $domain_model = new DomainInfo();
  59 +// $notify_model = new Notify();
  60 +// $project_model = new Project();
  61 +//
  62 +// $domain_list = $domain_model->list(['amp_status' => 1]);
  63 +// foreach ($domain_list as $info) {
  64 +// if ($info['project_id'] > 0) {
  65 +// $notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
  66 +// if (!$notify_info) {
  67 +//
  68 +// $domain_array = parse_url($info['domain']);
  69 +// $host = $domain_array['host'] ?? $domain_array['path'];
  70 +// $host_array = explode('.', $host);
  71 +// if (count($host_array) <= 2) {
  72 +// array_unshift($host_array, 'm');
  73 +// } else {
  74 +// $host_array[0] = 'm';
  75 +// }
  76 +// $amp_domain = implode('.', $host_array);
  77 +//
  78 +// $project_info = $project_model->read(['id' => $info['project_id']]);
  79 +//
  80 +// $notify_model->add([
  81 +// 'project_id' => $info['project_id'],
  82 +// 'type' => 3,
  83 +// 'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
  84 +// 'server_id' => $project_info['serve_id'],
  85 +// ]);
  86 +// }
  87 +// }
  88 +// }
  89 +// }
  90 +
  91 +// public function handle()
  92 +// {
  93 +// $domain_model = new DomainInfo();
75 // $server_model = new ServerConfig(); 94 // $server_model = new ServerConfig();
76 // $project_model = new Project(); 95 // $project_model = new Project();
77 // 96 //
@@ -197,14 +197,11 @@ class ImageController extends Controller @@ -197,14 +197,11 @@ class ImageController extends Controller
197 if($image_hash !== false){ 197 if($image_hash !== false){
198 return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'], $name)); 198 return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'], $name));
199 } 199 }
200 - //保存路径  
201 - $url = $this->config['root'].$this->path;  
202 $image_type = $files->getClientOriginalExtension(); 200 $image_type = $files->getClientOriginalExtension();
203 if(strlen($image_type) > 7){ 201 if(strlen($image_type) > 7){
204 $this->response('不支持当前格式',Code::SYSTEM_ERROR); 202 $this->response('不支持当前格式',Code::SYSTEM_ERROR);
205 } 203 }
206 $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); 204 $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
207 -  
208 //上传到cos 205 //上传到cos
209 if($this->upload_location == 0){ 206 if($this->upload_location == 0){
210 $cosService = new CosService(); 207 $cosService = new CosService();
@@ -321,9 +318,9 @@ class ImageController extends Controller @@ -321,9 +318,9 @@ class ImageController extends Controller
321 private function multi(&$files) { 318 private function multi(&$files) {
322 $data = []; 319 $data = [];
323 foreach ($files as $file) { 320 foreach ($files as $file) {
324 - $imageModel = new ImageModel();  
325 $hash = hash_file('sha256', $file->getPathname()); 321 $hash = hash_file('sha256', $file->getPathname());
326 $name = $file->getClientOriginalName(); 322 $name = $file->getClientOriginalName();
  323 + $imageModel = new ImageModel();
327 //查看图片是否已上传 324 //查看图片是否已上传
328 $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)]; 325 $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
329 if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){ 326 if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
@@ -336,6 +333,7 @@ class ImageController extends Controller @@ -336,6 +333,7 @@ class ImageController extends Controller
336 } 333 }
337 $image_type = $file->getClientOriginalExtension(); 334 $image_type = $file->getClientOriginalExtension();
338 $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); 335 $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
  336 + $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
339 //同步数据到cos 337 //同步数据到cos
340 if($this->upload_location == 0){ 338 if($this->upload_location == 0){
341 $cosService = new CosService(); 339 $cosService = new CosService();
@@ -345,12 +343,11 @@ class ImageController extends Controller @@ -345,12 +343,11 @@ class ImageController extends Controller
345 $amazonS3Service = new AmazonS3Service(); 343 $amazonS3Service = new AmazonS3Service();
346 $amazonS3Service->uploadFiles($file,$this->path,$fileName); 344 $amazonS3Service->uploadFiles($file,$this->path,$fileName);
347 } 345 }
348 - //批量存储  
349 - $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);  
350 $this->synchronizationImage($fileName,$this->upload_location); 346 $this->synchronizationImage($fileName,$this->upload_location);
351 $data[] = $this->responseData($this->path.'/'.$fileName,$name); 347 $data[] = $this->responseData($this->path.'/'.$fileName,$name);
  348 + $hash = $name = '';
352 } 349 }
353 - $this->response('图片资源',Code::SUCCESS,$data); 350 + $this->response('图片资源',Code::SUCCESS,$data);
354 } 351 }
355 352
356 /** 353 /**