作者 lyh

gx

@@ -26,16 +26,54 @@ class KeywordVideoController extends BaseController @@ -26,16 +26,54 @@ class KeywordVideoController extends BaseController
26 */ 26 */
27 public function lists(){ 27 public function lists(){
28 $keywordModel = new KeywordVideoTask(); 28 $keywordModel = new KeywordVideoTask();
29 - $lists = $keywordModel->lists($this->map,$this->page,$this->row);  
30 - if(!empty($lists) && !empty($lists['list'])){  
31 - $projectModel = new Project();  
32 - foreach ($lists['list'] as $k => $v){  
33 - $v['project_name'] = $projectModel->read(['id'=>$v['project_id']],['id','title'])['title'];  
34 - $lists['list'][$k] = $v;  
35 - }  
36 - } 29 + $query = $keywordModel->leftJoin('gl_project', 'gl_keyword_video_task.project_id', '=', 'gl_project.id');
  30 + $query = $this->searchParam($query);
  31 + $query = $this->orderByList($query);
  32 + $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
37 $this->response('success',Code::SUCCESS,$lists); 33 $this->response('success',Code::SUCCESS,$lists);
38 } 34 }
  35 + /**
  36 + * 需要查询的字段
  37 + * @return array
  38 + */
  39 + public function selectParam(){
  40 + $select = [
  41 + 'gl_keyword_video_task.project_id AS project_id',
  42 + 'gl_keyword_video_task.number AS number',
  43 + 'gl_keyword_video_task.status AS status',
  44 + 'gl_keyword_video_task.sort AS sort',
  45 + 'gl_keyword_video_task.created_at AS created_at',
  46 + 'gl_keyword_video_task.updated_at AS updated_at',
  47 + 'gl_project.title AS title',
  48 + 'gl_project.company AS company',
  49 + ];
  50 + return $select;
  51 + }
  52 + /**
  53 + * @remark :搜索参数处理
  54 + * @name :searchParam
  55 + * @author :lyh
  56 + * @method :post
  57 + * @time :2023/8/18 10:58
  58 + */
  59 + public function searchParam(&$query){
  60 + if(isset($this->map['project_name']) && is_array($this->map['project_name'])){
  61 + $query->where('gl_project.title','like','%'.$this->map['project_name'].'%');
  62 + }
  63 + return $query;
  64 + }
  65 +
  66 + /**
  67 + * @remark :排序
  68 + * @name :orderByList
  69 + * @author :lyh
  70 + * @method :post
  71 + * @time :2023/12/29 17:14
  72 + */
  73 + public function orderByList(&$query){
  74 + $query = $query->orderBy('gl_keyword_video_task.sort', 'desc')->orderBy('gl_keyword_video_task.id', 'desc');
  75 + return $query;
  76 + }
39 77
40 /** 78 /**
41 * @remark :创建关键字任务池子 79 * @remark :创建关键字任务池子