作者 Your Name
... ... @@ -34,44 +34,63 @@ class Temp extends Command
*/
protected $description = '临时脚本';
public function handle()
{
$domain_model = new DomainInfo();
$notify_model = new Notify();
$project_model = new Project();
$domain_list = $domain_model->list(['amp_status' => 1]);
foreach ($domain_list as $info) {
if ($info['project_id'] > 0) {
$notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
if (!$notify_info) {
$domain_array = parse_url($info['domain']);
$host = $domain_array['host'] ?? $domain_array['path'];
$host_array = explode('.', $host);
if (count($host_array) <= 2) {
array_unshift($host_array, 'm');
} else {
$host_array[0] = 'm';
}
$amp_domain = implode('.', $host_array);
public function handle(){
ProjectServer::useProject(1515);
$project_info = $project_model->read(['id' => $info['project_id']]);
$products = Product::select(['id','content'])->get();
$notify_model->add([
'project_id' => $info['project_id'],
'type' => 3,
'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
'server_id' => $project_info['serve_id'],
]);
}
}
foreach ($products as $product){
$content = $product->content;
$content = str_replace('<h1','<h2', $content);
$content = str_replace('</h1','</h2', $content);
$product->content = $content;
$product->save();
$this->output('productID:'.$product->id.',success');
}
$this->output('end');
}
// public function handle()
// {
// $domain_model = new DomainInfo();
// $notify_model = new Notify();
// $project_model = new Project();
//
// $domain_list = $domain_model->list(['amp_status' => 1]);
// foreach ($domain_list as $info) {
// if ($info['project_id'] > 0) {
// $notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
// if (!$notify_info) {
//
// $domain_array = parse_url($info['domain']);
// $host = $domain_array['host'] ?? $domain_array['path'];
// $host_array = explode('.', $host);
// if (count($host_array) <= 2) {
// array_unshift($host_array, 'm');
// } else {
// $host_array[0] = 'm';
// }
// $amp_domain = implode('.', $host_array);
//
// $project_info = $project_model->read(['id' => $info['project_id']]);
//
// $notify_model->add([
// 'project_id' => $info['project_id'],
// 'type' => 3,
// 'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
// 'server_id' => $project_info['serve_id'],
// ]);
// }
// }
// }
// }
// public function handle()
// {
// $domain_model = new DomainInfo();
// $server_model = new ServerConfig();
// $project_model = new Project();
//
... ...
... ... @@ -197,14 +197,11 @@ class ImageController extends Controller
if($image_hash !== false){
return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'], $name));
}
//保存路径
$url = $this->config['root'].$this->path;
$image_type = $files->getClientOriginalExtension();
if(strlen($image_type) > 7){
$this->response('不支持当前格式',Code::SYSTEM_ERROR);
}
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
//上传到cos
if($this->upload_location == 0){
$cosService = new CosService();
... ... @@ -321,9 +318,9 @@ class ImageController extends Controller
private function multi(&$files) {
$data = [];
foreach ($files as $file) {
$imageModel = new ImageModel();
$hash = hash_file('sha256', $file->getPathname());
$name = $file->getClientOriginalName();
$imageModel = new ImageModel();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
... ... @@ -336,6 +333,7 @@ class ImageController extends Controller
}
$image_type = $file->getClientOriginalExtension();
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
//同步数据到cos
if($this->upload_location == 0){
$cosService = new CosService();
... ... @@ -345,10 +343,9 @@ class ImageController extends Controller
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($file,$this->path,$fileName);
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
$this->synchronizationImage($fileName,$this->upload_location);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
$hash = $name = '';
}
$this->response('图片资源',Code::SUCCESS,$data);
}
... ...