diff --git a/app/enterprise/controller/Posts.php b/app/enterprise/controller/Posts.php index b71173c..b3cf224 100644 --- a/app/enterprise/controller/Posts.php +++ b/app/enterprise/controller/Posts.php @@ -48,7 +48,7 @@ class Posts extends BaseController // 不可见 $where .= " or ( p.privacy = 4 and not exists ( select 1 from {$prefix}posts_privacy_users peu - where peu.posts_id = p.id and peu.user_id = p.user_id + where peu.posts_id = p.id and peu.type = 2 and peu.user_id = {$this->uid} ))"; } @@ -211,6 +211,9 @@ class Posts extends BaseController $type = '1'; } if (!empty($imgArr)) { + if (is_array($imgArr) && count($imgArr) > 9) { + return error(lang('posts.img_max_length')); + } $type .= '2'; } elseif (!empty($video_file)) { $type .= '3'; @@ -337,20 +340,7 @@ class Posts extends BaseController $field = 'id as posts_id,content,type,location,address as location_address,privacy'; $data = PostsModel::where($existsWhere)->field($field)->find(); if ($data) { - $fileWhere = [ - 'posts_id' => $data['posts_id'], - 'delete_time' => 0 - ]; - $files = (new PostsFile()) - ->where($fileWhere) - ->field('file_id,type') - ->order('sort asc') - ->select() - ->toArray(); - foreach ($files as $fileKey => $fileValue) { - $files[$fileKey]['src'] = File::where(['file_id' => $fileValue['file_id']])->value('src'); - } - $data['files'] = $files; + $data['files'] = PostsFile::getPostsFile($data['posts_id']); $privacy_user =[]; if (in_array($data['privacy'], $this->privacyUserArr)) { $PrivacyUsers = PostsPrivacyUsers::where(['posts_id' => $data['id']])->column('user_id'); diff --git a/app/lang/en_us.php b/app/lang/en_us.php index b23314f..8f763ad 100644 --- a/app/lang/en_us.php +++ b/app/lang/en_us.php @@ -158,6 +158,7 @@ return [ 'exists' => 'Save failed', 'user_empty' => 'Restricting users to not be empty', 'success_like' => 'Liked successfully', - 'cancel_like' => 'Cancel likes' + 'cancel_like' => 'Cancel likes', + 'img_max_length' => 'Up to 9 images can be uploaded' ] ]; \ No newline at end of file diff --git a/app/lang/zh_cn.php b/app/lang/zh_cn.php index dc7f30b..7abc9ef 100644 --- a/app/lang/zh_cn.php +++ b/app/lang/zh_cn.php @@ -157,6 +157,7 @@ return [ 'exists' => '保存失败', 'user_empty' => '限制用户不能为空', 'success_like' => '点赞成功', - 'cancel_like' => '取消点赞' + 'cancel_like' => '取消点赞', + 'img_max_length' => '图片最多上传9张' ] ]; \ No newline at end of file