Browse Source

添加字段发布地址

author
wanghongjun 10 months ago
parent
commit
bc5fef6a13
  1. 28
      app/enterprise/controller/Posts.php

28
app/enterprise/controller/Posts.php

@ -51,7 +51,7 @@ class Posts extends BaseController
where peu.posts_id = p.id and peu.user_id = p.user_id and peu.type = 2 where peu.posts_id = p.id and peu.user_id = p.user_id and peu.type = 2
))"; ))";
$field = 'p.id,p.content,p.location,p.type,p.user_id,p.create_time'; $field = 'p.id,p.content,p.location,p.address as location_address,p.type,p.user_id,p.create_time';
$order = 'p.create_time desc'; $order = 'p.create_time desc';
$model = new PostsModel(); $model = new PostsModel();
$list = $this->paginate($model->alias('p')->where($where)->whereOr($whereOr)->field($field)->order($order)); $list = $this->paginate($model->alias('p')->where($where)->whereOr($whereOr)->field($field)->order($order));
@ -72,15 +72,6 @@ class Posts extends BaseController
'nickname' => $friendNickname 'nickname' => $friendNickname
]; ];
$item['location_address'] = '';
if ($item['location']) {
$ipArr = \Ip::find($item['location']);
if (is_array($ipArr)) {
$ipArr = array_unique($ipArr);
}
$item['location_address'] = trim(implode(" ", $ipArr));
}
$item['files'] = PostsFile::getPostsFile($item['id']); $item['files'] = PostsFile::getPostsFile($item['id']);
$userIdArr = $friendIds; $userIdArr = $friendIds;
@ -105,7 +96,7 @@ class Posts extends BaseController
['delete_time', '=', 0] ['delete_time', '=', 0]
]; ];
$field = 'id,content,location,type,user_id,create_time'; $field = 'id,content,location,address,type,user_id,create_time';
$order = 'create_time desc'; $order = 'create_time desc';
$model = new PostsModel(); $model = new PostsModel();
@ -134,7 +125,7 @@ class Posts extends BaseController
'user_id' => $this->uid, 'user_id' => $this->uid,
'delete_time' => 0 'delete_time' => 0
]; ];
$field = 'id,content,location,type,user_id,create_time'; $field = 'id,content,location,address,type,user_id,create_time';
$data = (new PostsModel())->where($where)->field($field)->find(); $data = (new PostsModel())->where($where)->field($field)->find();
if (!$data) { if (!$data) {
return warning(lang('system.error')); return warning(lang('system.error'));
@ -185,6 +176,7 @@ class Posts extends BaseController
$content = $this->request->param('content', ''); $content = $this->request->param('content', '');
$privacy = $this->request->param('privacy', ''); $privacy = $this->request->param('privacy', '');
$location = $this->request->param('location', ''); $location = $this->request->param('location', '');
$address = $this->request->param('address', '');
$video_file = $this->request->param('video_file', ''); $video_file = $this->request->param('video_file', '');
$imgArr = $this->request->param('img_arr', []); $imgArr = $this->request->param('img_arr', []);
$posts_id = $this->request->param('posts_id', ''); $posts_id = $this->request->param('posts_id', '');
@ -226,7 +218,8 @@ class Posts extends BaseController
'type' => $type, 'type' => $type,
'content' => $content, 'content' => $content,
'privacy' => $privacy, 'privacy' => $privacy,
'location' => $location ?? '' 'location' => $location ?? '',
'address' => $address ?? ''
]; ];
if ($posts_id) { if ($posts_id) {
$info['update_time'] = time(); $info['update_time'] = time();
@ -300,16 +293,9 @@ class Posts extends BaseController
public function getLastPosts() public function getLastPosts()
{ {
$existsWhere = ['user_id' => $this->uid, 'privacy' => 0, 'delete_time' => 0]; $existsWhere = ['user_id' => $this->uid, 'privacy' => 0, 'delete_time' => 0];
$field = 'id as posts_id,content,type,location'; $field = 'id as posts_id,content,type,location,address as location_address';
$data = PostsModel::where($existsWhere)->field($field)->find()->toArray(); $data = PostsModel::where($existsWhere)->field($field)->find()->toArray();
if ($data) { if ($data) {
if ($data['location']) {
$ipArr = \Ip::find($data['location']);
if (is_array($ipArr)) {
$ipArr = array_unique($ipArr);
}
$data['location_address'] = trim(implode(" ", $ipArr));
}
$fileWhere = [ $fileWhere = [
'posts_id' => $data['posts_id'], 'posts_id' => $data['posts_id'],
'delete_time' => 0 'delete_time' => 0

Loading…
Cancel
Save