作者 lyh

gx

... ... @@ -37,12 +37,14 @@ class HandleNewsText extends Command
*
* @return void
*/
protected $project_id = 0;
public function handle()
{
$projectModel = new Project();
$list = $projectModel->list(['id'=>1618]);
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
$data = [];
foreach ($list as $v){
$this->project_id = $v['id'];
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
DB::connection('custom_mysql')->statement('DROP TABLE IF EXISTS gl_news_copy');
... ... @@ -50,11 +52,13 @@ class HandleNewsText extends Command
DB::connection('custom_mysql')->statement('INSERT INTO gl_news_copy SELECT * FROM gl_news');
$newsModel = new News();
$news_list = $newsModel->list(['status'=>['!=',2]],'id',['id','text']);
if(!empty($news_list)){
foreach ($news_list as $key => $values){
echo date('Y-m-d H:i:s') . '处理的数据id:'.$values['id'] . PHP_EOL;
$text = $this->handleText($values['text']);
$newsModel->edit(['text'=>$text],['id'=>$values['id']]);
}
}
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ... @@ -103,7 +107,7 @@ class HandleNewsText extends Command
*/
public function manager_uploads($files,$type = 'png'){
$this->uploads = config('upload.default_image');
$path = $this->uploads['path_b'].'/'.($this->user['project_id'] ?? 1618).'/image_news/'.date('Y-m');
$path = $this->uploads['path_b'].'/'.($this->project_id).'/image_news/'.date('Y-m');
$cosService = new CosService();
$fileName = md5(uniqid() . '_' . time() . '.' . ($this->user['project_id'] ?? 1618).rand(1,10000)) . '.' .$type;
return getImageUrl($cosService->uploadFile($files,$path,$fileName));
... ...