KeywordVideoController.php
4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
/**
* @remark :
* @name :KeywordVideoController.php
* @author :lyh
* @method :post
* @time :2024/2/26 9:23
*/
namespace App\Http\Controllers\Aside\Com;
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 App\Models\Project\Project;
class KeywordVideoController extends BaseController
{
/**
* @remark :任务列表
* @name :lists
* @author :lyh
* @method :post
* @time :2024/2/26 11:36
*/
public function lists(){
$keywordModel = new KeywordVideoTask();
$query = $keywordModel->leftJoin('gl_project', 'gl_keyword_video_task.project_id', '=', 'gl_project.id');
$query = $this->searchParam($query);
$query = $this->orderByList($query);
$lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
$this->response('success',Code::SUCCESS,$lists);
}
/**
* 需要查询的字段
* @return array
*/
public function selectParam(){
$select = [
'gl_keyword_video_task.id AS id',
'gl_keyword_video_task.project_id AS project_id',
'gl_keyword_video_task.number AS number',
'gl_keyword_video_task.status AS status',
'gl_keyword_video_task.keywords AS keywords',
'gl_keyword_video_task.sort AS sort',
'gl_keyword_video_task.created_at AS created_at',
'gl_keyword_video_task.updated_at AS updated_at',
'gl_project.title AS title',
'gl_project.company AS company',
];
return $select;
}
/**
* @remark :搜索参数处理
* @name :searchParam
* @author :lyh
* @method :post
* @time :2023/8/18 10:58
*/
public function searchParam(&$query){
if(isset($this->map['title'])){
$query->where('gl_project.title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['status'])){
$query->where('gl_keyword_video_task.status',$this->map['status']);
}
return $query;
}
/**
* @remark :排序
* @name :orderByList
* @author :lyh
* @method :post
* @time :2023/12/29 17:14
*/
public function orderByList(&$query){
$query = $query->orderBy('gl_keyword_video_task.sort', 'desc')->orderBy('gl_keyword_video_task.id', 'desc');
return $query;
}
/**
* @remark :创建关键字任务池子
* @name :saveKeyword
* @author :lyh
* @method :post
* @time :2024/2/26 9:24
*/
public function createKeywordTask(){
$this->request->validate([
'project_id'=>'required',
'number'=>'required'
], [
'project_id.required' => '项目唯一标识不为空',
'number.required' => 'number不为空',
]);
//查看当前项目是否已添加
$keywordModel = new KeywordVideoTask();
$keywordInfo = $keywordModel->read(['project_id'=>$this->param['project_id']]);
if($keywordInfo !== false){
$this->response('当前项目已添加');
}
//查看当前项目是否有正式域名
$domainModel = new DomainInfo();
$info = $domainModel->read(['project_id'=>$this->param['project_id']]);
if($info === false){
$this->response('请先设置域名',Code::SYSTEM_ERROR);
}
$rs = $keywordModel->add($this->param);
if($rs === false){
$this->response('添加失败',Code::SYSTEM_ERROR);
}
$this->response('success');
}
/**
* @remark :修改项目
* @name :editSort
* @author :lyh
* @method :post
* @time :2024/2/26 11:35
*/
public function edit(){
$this->request->validate([
'id'=>'required'
], [
'id.required' => '主键标识不为空',
]);
$keywordModel = new KeywordVideoTask();
if($this->param['status'] == 0){
$this->param['num'] = $this->param['number'];
}
$rs = $keywordModel->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->response('编辑失败',Code::SYSTEM_ERROR);
}
$this->response('success');
}
/**
* @remark :记录
* @name :getVideoTaskLog
* @author :lyh
* @method :post
* @time :2024/3/1 16:40
*/
public function getVideoTaskLog(){
$this->request->validate([
'project_id'=>'required',
], [
'project_id.required' => '项目唯一标识不为空',
]);
$taskLogModel = new KeywordVideoTaskLog();
$list = $taskLogModel->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$list);
}
}