作者 Your Name
... ... @@ -117,13 +117,16 @@ class VideoTask extends Command
}
$keywordInfo = $this->getKeywordImage($val->id,$task_project->project_id,$domainInfo['domain']);
if(!empty($keywordInfo['product_list'])){
if(!empty($task_project->logo_img)){
$logo_bg['logo'] = $task_project->logo_img;
}
$array = [
'project_id' => $task_project->project_id,
'keyword_id' => $val->id,
'keyword' => $val->title,
'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'],
'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'],
'keywords' => $keywordInfo['keyword_list'], 'logo_bg' => $logo_bg]),
'keywords' => $keywordInfo['keyword_list'], 'logo_bg' => $logo_bg , 'template_data' => $task_project->template_data]),
'status' => KeywordVideoTaskLog::STATUS_INIT,
'updated_at' => date('Y-m-d H:i:s'),
'created_at' => date('Y-m-d H:i:s'),
... ... @@ -162,7 +165,8 @@ class VideoTask extends Command
'description' => $valData['description'],
'images' => $valData['images'],
'logo'=> $valData['logo_bg']['logo'] ?? '',
'bg'=> $valData['logo_bg']['bg'] ?? ''
'bg'=> $valData['logo_bg']['bg'] ?? '',
'template_id'=> ((array)$valData['template_data'])['template_id'],
],
'task_id' => $task_id,
'callback_url' => env('APP_URL') . '/api/video_task_callback',
... ...
... ... @@ -7,13 +7,14 @@
* @time :2024/2/26 9:23
*/
namespace App\Http\Controllers\Aside\Com;
namespace App\Http\Controllers\Aside\KeywordVideo;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Com\KeywordVideoTask;
use App\Models\Com\KeywordVideoTaskLog;
use App\Models\Domain\DomainInfo;
use Illuminate\Support\Facades\Cache;
class KeywordVideoController extends BaseController
{
... ... @@ -114,6 +115,8 @@ class KeywordVideoController extends BaseController
'status'=>$this->param['status'] ?? 0,
'sort'=>$this->param['sort'] ?? 0,
'keywords'=>$this->param['keywords'] ?? '',
'logo_img'=>$this->param['logo_img'] ?? '',
'template_data'=>isset($this->param['template_data']) ? json_encode($this->param['template_data'],true) : null
];
$rs = $keywordModel->add($data);
if($rs === false){
... ... @@ -136,6 +139,9 @@ class KeywordVideoController extends BaseController
'id.required' => '主键标识不为空',
]);
$keywordModel = new KeywordVideoTask();
if(isset($this->param['template_data']) && !empty($this->param['template_data'])){
$this->param['template_data'] = json_encode($this->param['template_data'],true);
}
$rs = $keywordModel->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->response('编辑失败',Code::SYSTEM_ERROR);
... ... @@ -193,4 +199,26 @@ class KeywordVideoController extends BaseController
$count = $taskLogModel->formatQuery(['created_at'=>['between',[$start_of_month,$end_of_month]]])->count();
$this->response('success',Code::SUCCESS,['count'=>$count]);
}
/**
* @remark :获取模版库模版
* @name :get_template
* @author :lyh
* @method :post
* @time :2024/11/1 11:48
*/
public function get_template(){
$data = Cache::get('template_data');
if(empty($data)){
$url = 'http://216.250.255.116:7866/get_template';
$header = [
'accept: application/json'
];
$data = http_get($url,$header);
if(!empty($data)){
Cache::put('template_data',$data,12 * 3600);
}
}
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Models\Com;
use App\Helper\Arr;
use App\Models\Base;
class KeywordVideoTask extends Base
... ... @@ -17,4 +18,10 @@ class KeywordVideoTask extends Base
const STATUS_CLOSE = 1;//停止
protected $table = 'gl_keyword_video_task';
public function getTemplateDataAttribute($value)
{
$value = Arr::s2a($value);
return $value;
}
}
... ...
... ... @@ -348,12 +348,13 @@ Route::middleware(['aloginauth'])->group(function () {
* 生成视频的项目
*/
Route::prefix('keyword_video')->group(function () {
Route::any('/', [Aside\Com\KeywordVideoController::class, 'lists'])->name('keyword_video_lists');
Route::any('/createKeywordTask', [Aside\Com\KeywordVideoController::class, 'createKeywordTask'])->name('keyword_video_createKeywordTask');
Route::any('/edit', [Aside\Com\KeywordVideoController::class, 'edit'])->name('keyword_video_edit');
Route::any('/getVideoTaskLog', [Aside\Com\KeywordVideoController::class, 'getVideoTaskLog'])->name('keyword_video_getVideoTaskLog');
Route::any('/taskNum', [Aside\Com\KeywordVideoController::class, 'taskNum'])->name('keyword_video_taskNum');
Route::any('/getVideoCount', [Aside\Com\KeywordVideoController::class, 'getVideoCount'])->name('keyword_video_getVideoCount');
Route::any('/', [Aside\KeywordVideo\KeywordVideoController::class, 'lists'])->name('keyword_video_lists');
Route::any('/createKeywordTask', [Aside\KeywordVideo\KeywordVideoController::class, 'createKeywordTask'])->name('keyword_video_createKeywordTask');
Route::any('/edit', [Aside\KeywordVideo\KeywordVideoController::class, 'edit'])->name('keyword_video_edit');
Route::any('/getVideoTaskLog', [Aside\KeywordVideo\KeywordVideoController::class, 'getVideoTaskLog'])->name('keyword_video_getVideoTaskLog');
Route::any('/taskNum', [Aside\KeywordVideo\KeywordVideoController::class, 'taskNum'])->name('keyword_video_taskNum');
Route::any('/getVideoCount', [Aside\KeywordVideo\KeywordVideoController::class, 'getVideoCount'])->name('keyword_video_getVideoCount');
Route::any('/get_template', [Aside\KeywordVideo\KeywordVideoController::class, 'get_template'])->name('keyword_get_template');
});
// 公共主题模版
... ...