|
@@ -849,7 +849,32 @@ class CameraApiController extends BaseController
|
|
|
|
|
|
//文章列表
|
|
|
public function articleList(Request $request){
|
|
|
- $result = DB::connection('etl_zaoquan')->select("select * from news_column_list");
|
|
|
+ $result = DB::connection('etl_zaoquan')->select("select * from news_column_list order by create_time desc");
|
|
|
+
|
|
|
+ $pattern = '/<img(.*?)src=["\'](.*?)["\'](.*?)>/i';
|
|
|
+
|
|
|
+ if(count($result) > 0){
|
|
|
+ for($i=0;$i<count($result);$i++){
|
|
|
+ //替换title_image
|
|
|
+ $old_title_image = $result[$i]->title_image;
|
|
|
+ $old_title_image_array = explode('/',$old_title_image);
|
|
|
+ $old_img_path = $old_title_image_array[count($old_title_image_array)-1];
|
|
|
+ $new_img_path_list = DB::connection('etl_zaoquan')->select("select * from news_img_list where img_name ='".$old_img_path."'");
|
|
|
+ if(count($new_img_path_list) > 0){
|
|
|
+ $result[$i]->title_image = $new_img_path_list[0]->new_name;
|
|
|
+ }
|
|
|
+
|
|
|
+ //替换text
|
|
|
+ preg_match_all($pattern, $result[$i]->text, $matches);
|
|
|
+ foreach ($matches[2] as $index => $oldSrc) {
|
|
|
+ $news_img_list = DB::connection('etl_zaoquan')->select("select * from news_img_list where img_name ='".basename($oldSrc)."'");
|
|
|
+ if(count($news_img_list) > 0){
|
|
|
+ $newSrc = $news_img_list[0]->new_name;
|
|
|
+ $result[$i]->text = str_replace($oldSrc, $newSrc, $result[$i]->text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return self::successResponse($result);
|
|
|
}
|