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

获取一定周期内上映影片

family 1 год назад
Родитель
Сommit
6bf0720e2a
1 измененных файлов с 25 добавлено и 0 удалено
  1. 25 0
      app/common/repositories/movie/FilmRepository.php

+ 25 - 0
app/common/repositories/movie/FilmRepository.php

@@ -31,6 +31,31 @@ class FilmRepository extends BaseRepository
31 31
     }
32 32
 
33 33
     /**
34
+     * 根据开始、结束日期获取影片
35
+     *
36
+     * @param $page
37
+     * @param $limit
38
+     * @param $startDate
39
+     * @param $endDate
40
+     * @param $with
41
+     * @return array
42
+     * @throws \think\db\exception\DataNotFoundException
43
+     * @throws \think\db\exception\DbException
44
+     * @throws \think\db\exception\ModelNotFoundException
45
+     */
46
+    public function getFilmByStartEndDate($page, $limit, $startDate, $endDate, $with = [])
47
+    {
48
+        $field = 'film_sign,film_name,publish_date,language,type,duration,version,cover_img,grade,hots,director,actors';
49
+        $where = [['publish_date', '<=', $endDate], ['publish_date', '>', $startDate]];
50
+
51
+        return $this->dao->where($where)->when($with, function ($query) use ($with) {
52
+            $query->with($with);
53
+        })->when($page && $limit, function ($query) use ($page, $limit) {
54
+            $query->page($page, $limit);
55
+        })->field([$field])->order('hots desc')->select()->toArray();
56
+    }
57
+
58
+    /**
34 59
      * @param $page
35 60
      * @param $limit
36 61
      * @param $type