58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Http\Controllers\Post;
|
|
|
|
use App\Http\Controllers\Base\BaseController;
|
|
use App\Service\Api\AuthService;
|
|
|
|
class PostController extends BaseController
|
|
{
|
|
//$uid, $content = null, $media = null,$mid = null,$sBachSn = null
|
|
public array $validateMethodParams = [
|
|
'addPost' => [
|
|
'type' => 'required|numeric|max:2',
|
|
'content' => 'required|numeric|max:255',
|
|
'media' => 'json',
|
|
],
|
|
'pullPostList' => [
|
|
'lastId' => 'numeric|max:10',
|
|
'limit' => 'numeric|max:5',
|
|
],
|
|
];
|
|
public function addPost(): \Illuminate\Http\JsonResponse
|
|
{
|
|
$aParams = request()->only([
|
|
'type',
|
|
'content',
|
|
'media',
|
|
]);
|
|
if (!in_array($aParams['type'], [\App\Models\Api\Post\PostModel::TYPE_POST, \App\Models\Api\Post\PostModel::TYPE_REPOST])) return $this->error('type params error');
|
|
|
|
$oAuthService = new AuthService();
|
|
$aUser = $oAuthService->getCurrentUser();
|
|
$oFollowModel = new \App\Models\Api\Post\PostModel();
|
|
$aParams['uid'] = $aUser['id'];
|
|
|
|
$oFollowModel->addBatchPost([$aParams]);
|
|
|
|
return $this->success();
|
|
}
|
|
|
|
function pullPostList()
|
|
{
|
|
$aParams = request()->only([
|
|
'lastId',
|
|
'limit',
|
|
]);
|
|
$oAuthService = new AuthService();
|
|
$aUser = $oAuthService->getCurrentUser();
|
|
$oPostModel = new \App\Models\Api\Post\PostPushBoxModel();
|
|
$aPostList = $oPostModel->getPushBoxList($aUser['id'],$aParams['lastId']??0,$aParams['limit']??15);
|
|
return $this->success($aPostList);
|
|
|
|
}
|
|
|
|
|
|
}
|