* Add API 404 handler for product and project.

This commit is contained in:
dingguodong
2021-08-11 17:59:44 +08:00
parent 98bb1ab539
commit ec56a0fed2
4 changed files with 15 additions and 4 deletions
+1
View File
@@ -14,6 +14,7 @@ class productEntry extends Entry
$control->view($productID);
$data = $this->getData();
if(!$data or (isset($data->status) and $data->message == '404 Not found')) return $this->send404();
if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->product, 'createdDate:time'));
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
+1
View File
@@ -14,6 +14,7 @@ class projectEntry extends entry
$control->view($projectID);
$data = $this->getData();
if(!$data or (isset($data->status) and $data->message == '404 Not found')) return $this->send404();
if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->project, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time'));
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
+6 -1
View File
@@ -687,7 +687,12 @@ class product extends control
{
$productID = (int)$productID;
$product = $this->product->getStatByID($productID);
if(!$product) die(js::error($this->lang->notFound) . js::locate('back'));
if(!$product)
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
die(js::error($this->lang->notFound) . js::locate('back'));
}
$product->desc = $this->loadModel('file')->setImgSize($product->desc);
$this->product->setMenu($productID);
+7 -3
View File
@@ -560,9 +560,13 @@ class project extends control
*/
public function view($projectID = 0)
{
$projectID = $this->project->saveState((int)$projectID, $this->project->getPairsByProgram());
$project = $this->project->getById($projectID);
if(empty($project) || strpos('scrum,waterfall', $project->model) === false) die(js::error($this->lang->notFound) . js::locate('back'));
if(!defined('RUN_MODE') || RUN_MODE != 'api') $projectID = $this->project->saveState((int)$projectID, $this->project->getPairsByProgram());
$project = $this->project->getById($projectID);
if(empty($project) || strpos('scrum,waterfall', $project->model) === false)
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
die(js::error($this->lang->notFound) . js::locate('back'));
}
$this->project->setMenu($projectID);