Explorar el Código

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

family hace 1 año
padre
commit
9480b66903

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

@@ -40,7 +40,7 @@ class FilmRepository extends BaseRepository
40 40
      * @throws \think\db\exception\DbException
41 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 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 50
         } else {
51 51
             $where = [['publish_date', '>', $time]];
52 52
         }
53
+        if ($film_name) $where[] = ['film_name', 'like', '%' . $film_name . '%'];
53 54
 
54 55
         $film_list = $this->dao->where($where)->when($with, function ($query) use ($with) {
55 56
             $query->with($with);

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

@@ -90,10 +90,11 @@ class Movie extends BaseController
90 90
     {
91 91
         [$page, $limit] = $this->getPage();
92 92
         $type = $this->request->param('type', 0);//热映:0:正在热映,1:即将上映
93
+        $film_name = $this->request->param('film_name', '');
93 94
 
94 95
         /** @var FilmRepository $filmRepository */
95 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
     /**