|
|
|
@ -16,6 +16,15 @@ use think\facade\Db; |
|
|
|
class Posts extends BaseController |
|
|
|
{ |
|
|
|
|
|
|
|
protected $url=''; |
|
|
|
|
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
parent::__construct(app()); |
|
|
|
$this->url=getDiskUrl().'/'; |
|
|
|
} |
|
|
|
|
|
|
|
// 朋友圈列表 |
|
|
|
public function index() |
|
|
|
{ |
|
|
|
$where = []; |
|
|
|
@ -83,6 +92,7 @@ class Posts extends BaseController |
|
|
|
return success('', $data,$list->total(),$list->currentPage()); |
|
|
|
} |
|
|
|
|
|
|
|
// 我的朋友圈列表 |
|
|
|
public function myPosts() |
|
|
|
{ |
|
|
|
$where = [ |
|
|
|
@ -138,6 +148,7 @@ class Posts extends BaseController |
|
|
|
return success('', $data); |
|
|
|
} |
|
|
|
|
|
|
|
// 删除帖子 |
|
|
|
public function del() |
|
|
|
{ |
|
|
|
try { |
|
|
|
@ -164,12 +175,13 @@ class Posts extends BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 添加帖子 |
|
|
|
public function add() |
|
|
|
{ |
|
|
|
$content = $this->request->param('content', ''); |
|
|
|
$privacy = $this->request->param('privacy', ''); |
|
|
|
$location = $this->request->param('location', ''); |
|
|
|
$video_file_id = $this->request->param('file_id', ''); |
|
|
|
$video_file = $this->request->param('video_file', ''); |
|
|
|
$imgArr = $this->request->param('img_arr', []); |
|
|
|
$posts_id = $this->request->param('posts_id', ''); |
|
|
|
$user_ids = $this->request->param('user_ids', []); |
|
|
|
@ -226,22 +238,32 @@ class Posts extends BaseController |
|
|
|
} |
|
|
|
|
|
|
|
$fileSaveArr = []; |
|
|
|
foreach ($imgArr as $key => $img_file_id) { |
|
|
|
$fileSaveArr[] = [ |
|
|
|
'posts_id' => $posts_id, |
|
|
|
'type' => 1, |
|
|
|
'file_id' => $img_file_id, |
|
|
|
'sort' => $key + 1 |
|
|
|
]; |
|
|
|
foreach ($imgArr as $key => $img_url) { |
|
|
|
$imgUrl = str_replace($this->url, '', $img_url); |
|
|
|
$whereFile = ['src' => $imgUrl, 'user_id' => $this->uid, 'delete_time' => 0]; |
|
|
|
$img_file_id = File::where($whereFile)->value('file_id'); |
|
|
|
if ($img_file_id) { |
|
|
|
$fileSaveArr[] = [ |
|
|
|
'posts_id' => $posts_id, |
|
|
|
'type' => 1, |
|
|
|
'file_id' => $img_file_id, |
|
|
|
'sort' => $key + 1 |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!empty($video_file_id)) { |
|
|
|
$fileSaveArr[] = [ |
|
|
|
'posts_id' => $posts_id, |
|
|
|
'type' => 2, |
|
|
|
'file_id' => $video_file_id, |
|
|
|
'sort' => 1 |
|
|
|
]; |
|
|
|
if (!empty($video_file)) { |
|
|
|
$videoUrl = str_replace($this->url, '', $video_file); |
|
|
|
$whereFile = ['src' => $videoUrl, 'user_id' => $this->uid, 'delete_time' => 0]; |
|
|
|
$video_file_id = File::where($whereFile)->value('file_id'); |
|
|
|
if ($video_file_id) { |
|
|
|
$fileSaveArr[] = [ |
|
|
|
'posts_id' => $posts_id, |
|
|
|
'type' => 2, |
|
|
|
'file_id' => $video_file_id, |
|
|
|
'sort' => 1 |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($fileSaveArr) { |
|
|
|
@ -270,6 +292,7 @@ class Posts extends BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 获取上传草稿帖子数据 |
|
|
|
public function getLastPosts() |
|
|
|
{ |
|
|
|
$existsWhere = ['user_id' => $this->uid, 'privacy' => 0, 'delete_time' => 0]; |
|
|
|
@ -297,6 +320,7 @@ class Posts extends BaseController |
|
|
|
return success('', $data); |
|
|
|
} |
|
|
|
|
|
|
|
// 点赞帖子 |
|
|
|
public function like() |
|
|
|
{ |
|
|
|
$posts_id = $this->request->param('posts_id'); |
|
|
|
@ -322,6 +346,7 @@ class Posts extends BaseController |
|
|
|
return success(lang('posts.success_like')); |
|
|
|
} |
|
|
|
|
|
|
|
// 评论帖子 |
|
|
|
public function comment() |
|
|
|
{ |
|
|
|
$posts_id = $this->request->param('posts_id'); |
|
|
|
@ -352,6 +377,7 @@ class Posts extends BaseController |
|
|
|
return success(lang('system.success')); |
|
|
|
} |
|
|
|
|
|
|
|
// 删除评论 |
|
|
|
public function delComment() |
|
|
|
{ |
|
|
|
$posts_id = $this->request->param('posts_id'); |
|
|
|
|