|
@@ -701,4 +701,43 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 前端-搜索新闻列表
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function selectWebsiteArticle(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+
|
|
|
+ $query = Article::where('status', 1);
|
|
|
+
|
|
|
+
|
|
|
+ if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(city_arr_id, '".intval($data['cityid'])."')");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (isset($data['department_id']) && $data['department_id'] !== null) {
|
|
|
+
|
|
|
+ $query->whereRaw("JSON_CONTAINS(department_arr_id, '".intval($data['department_id'])."')");
|
|
|
+ }
|
|
|
+
|
|
|
+ $count = $query->count();
|
|
|
+
|
|
|
+ $articles = $query->orderBy("updated_at", "desc")
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->get()->all();
|
|
|
+
|
|
|
+ if ($articles->isEmpty()) {
|
|
|
+ return Result::error("没有符合条件的资讯数据");
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'rows' => $articles->toArray(),
|
|
|
+ 'count' => $count
|
|
|
+ ];
|
|
|
+ return Result::success($data);
|
|
|
+ }
|
|
|
}
|