|
...
|
...
|
@@ -7,6 +7,7 @@ |
|
|
|
*/
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Models\Geo\GeoConfirm;
|
|
|
|
use App\Models\Geo\GeoWritings;
|
|
|
|
use App\Models\Project\Project;
|
|
...
|
...
|
@@ -35,13 +36,15 @@ class GeoController extends BaseController |
|
|
|
} catch (\Exception $e) {
|
|
|
|
return $this->error('非法请求');
|
|
|
|
}
|
|
|
|
$project = Project::select('title', 'version')->where(['project_id' => $this->param['project_id']])->first();
|
|
|
|
$list = GeoWritings::select(['title', 'status', 'uniqid', 'confirm_at'])->where(['project_id' => $project_id, 'is_del' => GeoWritings::IS_DEL_FALSE])->get();
|
|
|
|
$projectModel = new Project();
|
|
|
|
$projectInfo = $projectModel->read(['project_id' => $project_id],['title','version']);
|
|
|
|
$geoWritingsModel = new GeoWritings();
|
|
|
|
$lists = $geoWritingsModel->list(['project_id' => $project_id, 'status' => 2 ,'is_del' => GeoWritings::IS_DEL_FALSE],'id',['title', 'status', 'uniqid', 'confirm_at']);
|
|
|
|
$result = [
|
|
|
|
'project' => $project,
|
|
|
|
'list' => $list
|
|
|
|
'project' => $projectInfo,
|
|
|
|
'list' => $lists
|
|
|
|
];
|
|
|
|
return $this->success($result);
|
|
|
|
$this->response('success',Code::SUCCESS,$result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -49,11 +52,12 @@ class GeoController extends BaseController |
|
|
|
* @param Request $request
|
|
|
|
* @return false|string
|
|
|
|
*/
|
|
|
|
public function getWritingsDetail(Request $request)
|
|
|
|
public function getWritingsDetail()
|
|
|
|
{
|
|
|
|
$token = trim($request->input('token'));
|
|
|
|
$detail = GeoWritings::select(['title', 'content', 'status'])->where(['uniqid' => $token])->first();
|
|
|
|
return $this->success($detail);
|
|
|
|
$geoWritingsModel = new GeoWritings();
|
|
|
|
$token = trim($this->param['token']);
|
|
|
|
$detail = $geoWritingsModel->read(['uniqid' => $token],['title', 'content', 'status']);
|
|
|
|
$this->response('success',Code::SUCCESS,$detail);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
...
|
...
|
@@ -62,9 +66,9 @@ class GeoController extends BaseController |
|
|
|
* @param Request $request
|
|
|
|
* @return false|string
|
|
|
|
*/
|
|
|
|
public function confirmWritings(Request $request)
|
|
|
|
public function confirmWritings()
|
|
|
|
{
|
|
|
|
$request->validate([
|
|
|
|
$this->request->validate([
|
|
|
|
'token' => 'required',
|
|
|
|
'title' => 'required|max:120',
|
|
|
|
'content' => 'required|max:5000'
|
|
...
|
...
|
@@ -75,19 +79,21 @@ class GeoController extends BaseController |
|
|
|
'content.required' => '内容不能为空',
|
|
|
|
'content.max' => '内容过长保存失败',
|
|
|
|
]);
|
|
|
|
$token = trim($request->input('token'));
|
|
|
|
$data = GeoWritings::where(['uniqid' => $token])->first();
|
|
|
|
if (empty($data)){
|
|
|
|
$token = trim($this->param['token']);
|
|
|
|
$geoWritingsModel = new GeoWritings();
|
|
|
|
$info = $geoWritingsModel->read(['uniqid' => $token]);
|
|
|
|
if ($info === false){
|
|
|
|
return $this->error('非法请求');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($data->status != GeoWritings::STATUS_RUNNING){
|
|
|
|
if ($info['status'] == GeoWritings::STATUS_FINISH){
|
|
|
|
return $this->error('当前文章已确认,不可再次确认');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME 验证完成,保存数据,计算内容长度,处理内容中的资源, IP 确认时间 状态
|
|
|
|
return $data;
|
|
|
|
$this->param['confirm_ip'] = $this->request->ip();
|
|
|
|
$this->param['confirm_at'] = date('Y-m-d H:i:s');
|
|
|
|
$this->param['content_length'] = strlen($this->param['content']);
|
|
|
|
$this->param['status'] = GeoWritings::STATUS_FINISH;
|
|
|
|
$geoWritingsModel->edit($this->param,['uniqid' => $token]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -95,9 +101,9 @@ class GeoController extends BaseController |
|
|
|
* @param Request $request
|
|
|
|
* @return false|string
|
|
|
|
*/
|
|
|
|
public function getConfirm(Request $request)
|
|
|
|
public function getConfirm()
|
|
|
|
{
|
|
|
|
$token = trim($request->input('token'));
|
|
|
|
$token = trim($this->param['token']);
|
|
|
|
$data = GeoConfirm::where(['uniqid' => $token])->first();
|
|
|
|
if (empty($data)){
|
|
|
|
return $this->error('当前授权已失效');
|
|
...
|
...
|
@@ -107,7 +113,7 @@ class GeoController extends BaseController |
|
|
|
$type = $data->type;
|
|
|
|
$status = $data->status;
|
|
|
|
$result = compact('content', 'confirm', 'type', 'status');
|
|
|
|
return $this->success($result);
|
|
|
|
$this->response('success',Code::SUCCESS,$result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -115,6 +121,20 @@ class GeoController extends BaseController |
|
|
|
* 验证当前确认数据状态, 不可重复确认
|
|
|
|
* @param Request $request
|
|
|
|
*/
|
|
|
|
public function saveConfirm(Request $request)
|
|
|
|
{}
|
|
|
|
public function saveConfirm()
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'uniqid' => 'required',
|
|
|
|
'confirm' => 'required',
|
|
|
|
'confirm_num' => 'required',
|
|
|
|
], [
|
|
|
|
'uniqid.required' => '非法请求',
|
|
|
|
'confirm.required' => '客户确认内容不能为空',
|
|
|
|
'confirm_num.max' => '客户确认数量不能为空',
|
|
|
|
]);
|
|
|
|
$geoConfirmModel = new GeoConfirm();
|
|
|
|
$this->param['status'] = $geoConfirmModel::STATUS_FINISH;
|
|
|
|
$result = $geoConfirmModel->edit($this->param,['uniqid'=>$this->param['uniqid']]);
|
|
|
|
$this->response('success',Code::SUCCESS,$result);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|