|
@@ -88,13 +88,16 @@ class PostController extends Controller
|
|
|
{
|
|
|
Log::debug('内容搜索' . json_encode($request));
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if (empty($userInfo)) {
|
|
|
- Log::debug('获取用户信息失败index'.json_encode($request));
|
|
|
- return jsonError('获取用户信息失败');
|
|
|
+ if ($userInfo) {
|
|
|
+ $uid = $userInfo['uid'];
|
|
|
+ $inviteCode = $userInfo['invite_code'];
|
|
|
+ }else{
|
|
|
+ $uid = 0;
|
|
|
+ $inviteCode = '';
|
|
|
}
|
|
|
$list = $this->postRepositories->lists($request->all());
|
|
|
$fractal = new Manager();
|
|
|
- $resource = new Collection($list, new ListTransformer($userInfo['uid'], $userInfo['invite_code']));
|
|
|
+ $resource = new Collection($list, new ListTransformer($uid, $inviteCode));
|
|
|
$resource->setPaginator(new IlluminatePaginatorAdapter($list));
|
|
|
$data = $fractal->createData($resource)->toArray();
|
|
|
|
|
@@ -107,13 +110,16 @@ class PostController extends Controller
|
|
|
public function video(Request $request)
|
|
|
{
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if (empty($userInfo)) {
|
|
|
- Log::debug('获取用户信息失败video'.json_encode($request));
|
|
|
- return jsonError('获取用户信息失败');
|
|
|
+ if ($userInfo) {
|
|
|
+ $uid = $userInfo['uid'];
|
|
|
+ $inviteCode = $userInfo['invite_code'];
|
|
|
+ }else{
|
|
|
+ $uid = 0;
|
|
|
+ $inviteCode = '';
|
|
|
}
|
|
|
$list = $this->postRepositories->video($request->all());
|
|
|
$fractal = new Manager();
|
|
|
- $resource = new Collection($list, new VideoTransformer($userInfo['uid'], $userInfo['invite_code']));
|
|
|
+ $resource = new Collection($list, new VideoTransformer($uid, $inviteCode));
|
|
|
$resource->setPaginator(new IlluminatePaginatorAdapter($list));
|
|
|
$data = $fractal->createData($resource)->toArray();
|
|
|
|
|
@@ -159,15 +165,18 @@ class PostController extends Controller
|
|
|
public function suggestPost(Request $request)
|
|
|
{
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if (empty($userInfo)) {
|
|
|
- Log::debug('获取用户信息失败suggestPost'.json_encode($request));
|
|
|
- return jsonError('获取用户信息失败');
|
|
|
+ if ($userInfo) {
|
|
|
+ $uid = $userInfo['uid'];
|
|
|
+ $inviteCode = $userInfo['invite_code'];
|
|
|
+ }else{
|
|
|
+ $uid = 0;
|
|
|
+ $inviteCode = '';
|
|
|
}
|
|
|
|
|
|
$param = $request->all();
|
|
|
$list = $this->postRepositories->suggestPost($param);
|
|
|
$fractal = new Manager();
|
|
|
- $resource = new Collection($list, new SuggestTransformer($userInfo['uid'], $userInfo['invite_code']));
|
|
|
+ $resource = new Collection($list, new SuggestTransformer($uid, $inviteCode));
|
|
|
$resource->setPaginator(new IlluminatePaginatorAdapter($list));
|
|
|
$data = $fractal->createData($resource)->toArray();
|
|
|
|
|
@@ -184,7 +193,6 @@ class PostController extends Controller
|
|
|
} else {
|
|
|
$floor = json_decode($floor, true);
|
|
|
}
|
|
|
-
|
|
|
if ($floor) {
|
|
|
$newData = [];
|
|
|
foreach ($data['data'] as $key => $val) {
|
|
@@ -210,7 +218,8 @@ class PostController extends Controller
|
|
|
} elseif ($floor[$key + 1]['show_type'] == 'user') {
|
|
|
$userData = [];
|
|
|
foreach ($floor[$key + 1]['data'] as $item) {
|
|
|
- $userData[] = array_merge($item, ['follow_status' => $this->getFollowStatus($userInfo['uid'], $item['uid'])]);
|
|
|
+ $followStatus = $uid ? $this->getFollowStatus($userInfo['uid'], $item['uid']) : 0;
|
|
|
+ $userData[] = array_merge($item, ['follow_status' => $followStatus]);
|
|
|
}
|
|
|
if ($userData) {
|
|
|
$newData[] = [
|
|
@@ -251,16 +260,19 @@ class PostController extends Controller
|
|
|
return jsonError($validator->errors()->first());
|
|
|
}
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if (empty($userInfo)) {
|
|
|
- Log::debug('获取用户信息失败detail'.json_encode($request));
|
|
|
- return jsonError('获取用户信息失败');
|
|
|
+ if ($userInfo) {
|
|
|
+ $uid = $userInfo['uid'];
|
|
|
+ $inviteCode = $userInfo['invite_code'];
|
|
|
+ }else{
|
|
|
+ $uid = 0;
|
|
|
+ $inviteCode = '';
|
|
|
}
|
|
|
$detail = $this->postRepositories->detail($request['id']);
|
|
|
if (!$detail) {
|
|
|
return jsonError('内容飞走了');
|
|
|
}
|
|
|
$fractal = new Manager();
|
|
|
- $res = new Item($detail, new DetailTransformer($userInfo['uid'], $userInfo['invite_code']));
|
|
|
+ $res = new Item($detail, new DetailTransformer($uid, $inviteCode));
|
|
|
$data = $fractal->createData($res)->toArray();
|
|
|
|
|
|
return jsonSuccess($data);
|
|
@@ -339,16 +351,17 @@ class PostController extends Controller
|
|
|
return jsonError($validator->errors()->first());
|
|
|
}
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if (empty($userInfo)) {
|
|
|
- Log::debug('获取用户信息失败topicDetail'.json_encode($request));
|
|
|
- return jsonError('获取用户信息失败');
|
|
|
+ if ($userInfo) {
|
|
|
+ $uid = $userInfo['uid'];
|
|
|
+ }else{
|
|
|
+ $uid = 0;
|
|
|
}
|
|
|
$detail = $this->postRepositories->topicDetail($request['id']);
|
|
|
if (!$detail) {
|
|
|
return jsonError('获取话题信息失败');
|
|
|
}
|
|
|
$fractal = new Manager();
|
|
|
- $res = new Item($detail, new TopicDetailTransformer($userInfo['uid']));
|
|
|
+ $res = new Item($detail, new TopicDetailTransformer($uid));
|
|
|
$data = $fractal->createData($res)->toArray();
|
|
|
|
|
|
return jsonSuccess($data);
|
|
@@ -360,13 +373,16 @@ class PostController extends Controller
|
|
|
public function topicPost(Request $request)
|
|
|
{
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if (empty($userInfo)) {
|
|
|
- Log::debug('获取用户信息失败topicPost'.json_encode($request));
|
|
|
- return jsonError('获取用户信息失败');
|
|
|
+ if ($userInfo) {
|
|
|
+ $uid = $userInfo['uid'];
|
|
|
+ $inviteCode = $userInfo['invite_code'];
|
|
|
+ }else{
|
|
|
+ $uid = 0;
|
|
|
+ $inviteCode = '';
|
|
|
}
|
|
|
$list = $this->postRepositories->topicPost($request->all());
|
|
|
$fractal = new Manager();
|
|
|
- $resource = new Collection($list, new TopicPostTransformer($userInfo['uid'], $userInfo['invite_code']));
|
|
|
+ $resource = new Collection($list, new TopicPostTransformer($uid, $inviteCode));
|
|
|
$resource->setPaginator(new IlluminatePaginatorAdapter($list));
|
|
|
$data = $fractal->createData($resource)->toArray();
|
|
|
|