Просмотр исходного кода

影片接口加入影片名称搜索字段

family 1 год назад
Родитель
Сommit
9480b66903
2 измененных файлов с 4 добавлено и 2 удалено
  1. 2 1
      app/common/repositories/movie/FilmRepository.php
  2. 2 1
      app/controller/api/movie/Movie.php

+ 2 - 1
app/common/repositories/movie/FilmRepository.php

@@ -40,7 +40,7 @@ class FilmRepository extends BaseRepository
40
      * @throws \think\db\exception\DbException
40
      * @throws \think\db\exception\DbException
41
      * @throws \think\db\exception\ModelNotFoundException
41
      * @throws \think\db\exception\ModelNotFoundException
42
      */
42
      */
43
-    public function getFilm($page, $limit, $type = 0, $with = [])
43
+    public function getFilm($page, $limit, $type = 0, $film_name = '', $with = [])
44
     {
44
     {
45
         $field = 'film_sign,film_name,publish_date,language,type,duration,version,cover_img,grade,hots,director,actors';
45
         $field = 'film_sign,film_name,publish_date,language,type,duration,version,cover_img,grade,hots,director,actors';
46
 
46
 
@@ -50,6 +50,7 @@ class FilmRepository extends BaseRepository
50
         } else {
50
         } else {
51
             $where = [['publish_date', '>', $time]];
51
             $where = [['publish_date', '>', $time]];
52
         }
52
         }
53
+        if ($film_name) $where[] = ['film_name', 'like', '%' . $film_name . '%'];
53
 
54
 
54
         $film_list = $this->dao->where($where)->when($with, function ($query) use ($with) {
55
         $film_list = $this->dao->where($where)->when($with, function ($query) use ($with) {
55
             $query->with($with);
56
             $query->with($with);

+ 2 - 1
app/controller/api/movie/Movie.php

@@ -90,10 +90,11 @@ class Movie extends BaseController
90
     {
90
     {
91
         [$page, $limit] = $this->getPage();
91
         [$page, $limit] = $this->getPage();
92
         $type = $this->request->param('type', 0);//热映:0:正在热映,1:即将上映
92
         $type = $this->request->param('type', 0);//热映:0:正在热映,1:即将上映
93
+        $film_name = $this->request->param('film_name', '');
93
 
94
 
94
         /** @var FilmRepository $filmRepository */
95
         /** @var FilmRepository $filmRepository */
95
         $filmRepository = app()->make(FilmRepository::class);
96
         $filmRepository = app()->make(FilmRepository::class);
96
-        return app('json')->success($filmRepository->getFilm($page, $limit, $type));
97
+        return app('json')->success($filmRepository->getFilm($page, $limit, $type, $film_name));
97
     }
98
     }
98
 
99
 
99
     /**
100
     /**