|
@@ -22,7 +22,6 @@ use App\Transformers\Topic\TopicDetailTransformer;
|
|
|
use App\Transformers\Topic\TopicListTransformer;
|
|
|
use App\Transformers\Topic\TopicPostTransformer;
|
|
|
use Illuminate\Http\Request;
|
|
|
-use Illuminate\Support\Carbon;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
@@ -36,6 +35,7 @@ class PostController extends Controller
|
|
|
{
|
|
|
use UserTrait;
|
|
|
use CmsTrait;
|
|
|
+
|
|
|
public function __construct(PostRepositories $postRepositories)
|
|
|
{
|
|
|
$this->postRepositories = $postRepositories;
|
|
@@ -47,7 +47,7 @@ class PostController extends Controller
|
|
|
public function create(Request $request)
|
|
|
{
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
- 'type' => ['required',Rule::in('image', 'video', 'html')],
|
|
|
+ 'type' => ['required', Rule::in('image', 'video', 'html')],
|
|
|
'img' => 'required|url',
|
|
|
'video' => 'required_if:type,video|string|url',
|
|
|
'topic_ids' => 'required|string|max:64',
|
|
@@ -60,7 +60,7 @@ class PostController extends Controller
|
|
|
return jsonError($validator->errors()->first());
|
|
|
}
|
|
|
|
|
|
- return $this->postRepositories->create($request->all());
|
|
|
+ return $this->postRepositories->create($request->all());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -76,7 +76,7 @@ class PostController extends Controller
|
|
|
return jsonError($validator->errors()->first());
|
|
|
}
|
|
|
|
|
|
- return $this->postRepositories->comment($request->all());
|
|
|
+ return $this->postRepositories->comment($request->all());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -85,7 +85,7 @@ class PostController extends Controller
|
|
|
public function index(Request $request)
|
|
|
{
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if(empty($userInfo)){
|
|
|
+ if (empty($userInfo)) {
|
|
|
Log::info('获取用户信息失败');
|
|
|
return jsonError('获取用户信息失败');
|
|
|
}
|
|
@@ -104,7 +104,7 @@ class PostController extends Controller
|
|
|
public function video(Request $request)
|
|
|
{
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if(empty($userInfo)){
|
|
|
+ if (empty($userInfo)) {
|
|
|
Log::info('获取用户信息失败');
|
|
|
return jsonError('获取用户信息失败');
|
|
|
}
|
|
@@ -123,14 +123,14 @@ class PostController extends Controller
|
|
|
public function myPost(Request $request)
|
|
|
{
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
- 'type' => ['required',Rule::in('create', 'collect', 'share')],
|
|
|
+ 'type' => ['required', Rule::in('create', 'collect', 'share')],
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return jsonError($validator->errors()->first());
|
|
|
}
|
|
|
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if(empty($userInfo)){
|
|
|
+ if (empty($userInfo)) {
|
|
|
Log::info('获取用户信息失败');
|
|
|
return jsonError('获取用户信息失败');
|
|
|
}
|
|
@@ -149,7 +149,7 @@ class PostController extends Controller
|
|
|
public function suggestPost(Request $request)
|
|
|
{
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if(empty($userInfo)){
|
|
|
+ if (empty($userInfo)) {
|
|
|
Log::info('获取用户信息失败');
|
|
|
return jsonError('获取用户信息失败');
|
|
|
}
|
|
@@ -161,54 +161,54 @@ class PostController extends Controller
|
|
|
$resource->setPaginator(new IlluminatePaginatorAdapter($list));
|
|
|
$data = $fractal->createData($resource)->toArray();
|
|
|
|
|
|
- if(!(isset($param['current_page']) && $param['current_page'] > 1)){
|
|
|
+ if (!(isset($param['current_page']) && $param['current_page'] > 1)) {
|
|
|
$key = 'suggest_post_floor';
|
|
|
$floor = Redis::get($key);
|
|
|
- if(!$floor){
|
|
|
+ if (!$floor) {
|
|
|
$floor = $this->getFloorInfo();
|
|
|
- if($floor){
|
|
|
+ if ($floor) {
|
|
|
Redis::set($key, json_encode($floor));
|
|
|
Redis::expire($key, 600);
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$floor = json_decode($floor, true);
|
|
|
}
|
|
|
|
|
|
- if($floor){
|
|
|
+ if ($floor) {
|
|
|
$newData = [];
|
|
|
- foreach($data['data'] as $key => $val){
|
|
|
- if(isset($floor[$key+1])){
|
|
|
- if($floor[$key+1]['show_type'] == 'banner'){
|
|
|
+ foreach ($data['data'] as $key => $val) {
|
|
|
+ if (isset($floor[$key + 1])) {
|
|
|
+ if ($floor[$key + 1]['show_type'] == 'banner') {
|
|
|
$newData[] = [
|
|
|
'show_type' => 'banner',
|
|
|
- 'data' => $floor[$key+1]['data'],
|
|
|
+ 'data' => $floor[$key + 1]['data'],
|
|
|
];
|
|
|
- }elseif($floor[$key+1]['show_type'] == 'user'){
|
|
|
- $uidArray = array_column($floor[$key+1]['data'], 'uid');
|
|
|
+ } elseif ($floor[$key + 1]['show_type'] == 'user') {
|
|
|
+ $uidArray = array_column($floor[$key + 1]['data'], 'uid');
|
|
|
$followMembersStatus = $this->getFollowMembersStatus(implode(',', $uidArray));
|
|
|
- if($followMembersStatus){
|
|
|
+ if ($followMembersStatus) {
|
|
|
$userData = [];
|
|
|
- foreach($floor[$key+1]['data'] as $item){
|
|
|
- if(!isset($followMembersStatus[$item['uid']])) continue;
|
|
|
+ foreach ($floor[$key + 1]['data'] as $item) {
|
|
|
+ if (!isset($followMembersStatus[$item['uid']])) continue;
|
|
|
$userData[] = array_merge($item, ['follow_status' => $followMembersStatus[$item['uid']]['follow_status']]);
|
|
|
}
|
|
|
- if($userData){
|
|
|
+ if ($userData) {
|
|
|
$newData[] = [
|
|
|
'show_type' => 'user',
|
|
|
'data' => $userData,
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
- }elseif($floor[$key+1]['show_type'] == 'video'){
|
|
|
+ } elseif ($floor[$key + 1]['show_type'] == 'video') {
|
|
|
$newData[] = [
|
|
|
'show_type' => 'video',
|
|
|
- 'data' => $floor[$key+1]['data'],
|
|
|
+ 'data' => $floor[$key + 1]['data'],
|
|
|
];
|
|
|
- }elseif($floor[$key+1]['show_type'] == 'topic'){
|
|
|
+ } elseif ($floor[$key + 1]['show_type'] == 'topic') {
|
|
|
$newData[] = [
|
|
|
'show_type' => 'topic',
|
|
|
- 'data' => $floor[$key+1]['data'],
|
|
|
+ 'data' => $floor[$key + 1]['data'],
|
|
|
];
|
|
|
}
|
|
|
}
|
|
@@ -232,12 +232,12 @@ class PostController extends Controller
|
|
|
return jsonError($validator->errors()->first());
|
|
|
}
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if(empty($userInfo)){
|
|
|
+ if (empty($userInfo)) {
|
|
|
Log::info('获取用户信息失败');
|
|
|
return jsonError('获取用户信息失败');
|
|
|
}
|
|
|
$detail = $this->postRepositories->detail($request['id']);
|
|
|
- if(!$detail){
|
|
|
+ if (!$detail) {
|
|
|
return jsonError('获取内容信息失败');
|
|
|
}
|
|
|
$fractal = new Manager();
|
|
@@ -315,12 +315,12 @@ class PostController extends Controller
|
|
|
return jsonError($validator->errors()->first());
|
|
|
}
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if(empty($userInfo)){
|
|
|
+ if (empty($userInfo)) {
|
|
|
Log::info('获取用户信息失败');
|
|
|
return jsonError('获取用户信息失败');
|
|
|
}
|
|
|
$detail = $this->postRepositories->topicDetail($request['id']);
|
|
|
- if(!$detail){
|
|
|
+ if (!$detail) {
|
|
|
return jsonError('获取话题信息失败');
|
|
|
}
|
|
|
$fractal = new Manager();
|
|
@@ -336,7 +336,7 @@ class PostController extends Controller
|
|
|
public function topicPost(Request $request)
|
|
|
{
|
|
|
$userInfo = $this->getUserInfo();
|
|
|
- if(empty($userInfo)){
|
|
|
+ if (empty($userInfo)) {
|
|
|
Log::info('获取用户信息失败');
|
|
|
return jsonError('获取用户信息失败');
|
|
|
}
|
|
@@ -380,8 +380,11 @@ class PostController extends Controller
|
|
|
$data = $this->postRepositories->getPostVideo($request['ids']);
|
|
|
return jsonSuccess($data);
|
|
|
}
|
|
|
+
|
|
|
//用户内容数统计
|
|
|
- public function memberPostStatistics(Request $request){
|
|
|
- return $this->postRepositories->memberPostStatistics();
|
|
|
+ public function memberPostStatistics(Request $request)
|
|
|
+ {
|
|
|
+ return $this->postRepositories->memberPostStatistics();
|
|
|
}
|
|
|
+
|
|
|
}
|