From 403d1099f7d7b3f0a44aa983827bd0192c5d3006 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Fri, 29 Apr 2022 08:43:03 +0800 Subject: [PATCH 1/2] * Add api for feedback. --- api/v1/entries/feedback.php | 81 +++++++++++++++++++++++++++++++++++++ config/routes.php | 6 +++ 2 files changed, 87 insertions(+) create mode 100644 api/v1/entries/feedback.php diff --git a/api/v1/entries/feedback.php b/api/v1/entries/feedback.php new file mode 100644 index 0000000000..5cc13fa88d --- /dev/null +++ b/api/v1/entries/feedback.php @@ -0,0 +1,81 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class feedbackEntry extends Entry +{ + /** + * GET method. + * + * @param int $feedbackID + * @access public + * @return void + */ + public function get($feedbackID) + { + $control = $this->loadController('feedback', 'adminiView'); + $control->adminView($feedbackID); + + $data = $this->getData(); + + $feedback = $data->data->feedback; + + $feedback->productName = $data->data->product; + $feedback->moduleName = $data->data->modulePath[0]->name ? $data->data->modulePath[0]->name : '/'; + + if(!$data or !isset($data->status)) return $this->send400('error'); + if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); + + $feedback->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->feedback); + $this->send(200, $this->format($feedback, 'activatedDate:time,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,mailto:userList,resolvedBy:user,resolvedDate:time,closedBy:user,closedDate:time,lastEditedBy:user,lastEditedDate:time,deadline:date,deleted:bool')); + } + + /** + * PUT method. + * + * @param int $productID + * @access public + * @return void + */ + public function put($productID) + { + $oldProduct = $this->loadModel('product')->getByID($productID); + + /* Set $_POST variables. */ + $fields = 'program,line,name,PO,QD,RD,type,desc,whitelist,status,acl'; + $this->batchSetPost($fields, $oldProduct); + + $control = $this->loadController('product', 'edit'); + $control->edit($productID); + + $data = $this->getData(); + if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message); + + $product = $this->product->getByID($productID); + $this->send(200, $this->format($product, 'createdDate:time')); + } + + /** + * DELETE method. + * + * @param int $productID + * @access public + * @return void + */ + public function delete($productID) + { + $control = $this->loadController('product', 'delete'); + $control->delete($productID, 'yes'); + + $this->getData(); + $this->sendSuccess(200, 'success'); + } +} + diff --git a/config/routes.php b/config/routes.php index e1d77552bc..4ddaf2e661 100644 --- a/config/routes.php +++ b/config/routes.php @@ -16,6 +16,12 @@ $routes['/tabs/:module'] = 'tabs'; $routes['/files'] = 'files'; $routes['/files/:id'] = 'file'; +<<<<<<< Updated upstream +======= +$routes['/feedbacks'] = 'feedbacks'; +$routes['/feedbacks/:id'] = 'feedback'; + +>>>>>>> Stashed changes $routes['/options/:type'] = 'options'; $routes['/configurations'] = 'configs'; From 38a95abfab65f344ab9486e19a5c6711614ed357 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Fri, 29 Apr 2022 08:45:22 +0800 Subject: [PATCH 2/2] * Handle conflict. --- config/routes.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/routes.php b/config/routes.php index 4ddaf2e661..02ec051d03 100644 --- a/config/routes.php +++ b/config/routes.php @@ -16,12 +16,9 @@ $routes['/tabs/:module'] = 'tabs'; $routes['/files'] = 'files'; $routes['/files/:id'] = 'file'; -<<<<<<< Updated upstream -======= $routes['/feedbacks'] = 'feedbacks'; $routes['/feedbacks/:id'] = 'feedback'; ->>>>>>> Stashed changes $routes['/options/:type'] = 'options'; $routes['/configurations'] = 'configs';