From e9caee64f7175e076881cc8747d4a0c6d8c15431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Tue, 16 Nov 2021 14:41:36 +0800 Subject: [PATCH] * code for task #44306. --- api/v1/entries/executions.php | 19 +++++++++++++++---- api/v1/entries/product.php | 29 +++-------------------------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/api/v1/entries/executions.php b/api/v1/entries/executions.php index 594f5722cd..4a55ac51dc 100644 --- a/api/v1/entries/executions.php +++ b/api/v1/entries/executions.php @@ -21,6 +21,7 @@ class executionsEntry extends entry public function get($projectID = 0) { $appendFields = $this->param('fields', ''); + $withProject = $this->param('withProject', ''); $control = $this->loadController('execution', 'all'); $control->all($this->param('status', 'all'), $this->param('project', $projectID), $this->param('order', 'id_desc'), 0, 0, $this->param('limit', 20), $this->param('page', 1)); @@ -28,14 +29,24 @@ class executionsEntry extends entry if(isset($data->status) and $data->status == 'success') { - $pager = $data->data->pager; - $result = array(); + $pager = $data->data->pager; + $projects = $data->data->projects; + $result = array(); foreach($data->data->executionStats as $execution) { - $execution = $this->filterFields($execution, 'id,name,project,code,type,parent,begin,end,status,openedBy,openedDate,' . $appendFields); + foreach($execution->hours as $field => $value) $execution->$field = $value; + + $execution = $this->filterFields($execution, 'id,name,project,code,type,parent,begin,end,status,openedBy,openedDate,delay,progress,' . $appendFields); $result[] = $this->format($execution, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time,begin:date,end:date,realBegan:date,realEnd:date,deleted:bool'); } - return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'executions' => $result)); + + $data = array(); + $data['page'] = $pager->pageID; + $data['total'] = $pager->recTotal; + $data['limit'] = $pager->recPerPage; + $data['executions'] = $result; + if(!empty($withProject)) $data['projects'] = $projects; + return $this->send(200, $data); } if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); diff --git a/api/v1/entries/product.php b/api/v1/entries/product.php index 9df8b4962c..a2b2294318 100644 --- a/api/v1/entries/product.php +++ b/api/v1/entries/product.php @@ -34,7 +34,7 @@ class productEntry extends Entry $product = $this->format($data->data->product, 'createdDate:time'); - $users = $this->loadModel('user')->getPairs('noletter|nodeleted'); + $users = $data->data->users; $product->PO = $this->formatUser($product->PO, $users); $product->QD = $this->formatUser($product->QD, $users); $product->RD = $this->formatUser($product->RD, $users); @@ -60,31 +60,8 @@ class productEntry extends Entry case 'actions': $product->addComment = common::hasPriv('action', 'comment') ? true : false; - $actions = $this->loadModel('action')->getList('product', $productID); - $product->actions = array(); - foreach($actions as $action) - { - $action->actor = zget($users, $action->actor); - if($action->action == 'assigned') $action->extra = zget($users, $action->extra); - if(strpos($action->actor, ':') !== false) $action->actor = substr($action->actor, strpos($action->actor, ':') + 1); - - ob_start(); - $this->action->printAction($action); - $action->desc = ob_get_contents(); - ob_end_clean(); - - $action = $this->filterFields($action, 'id,objectType,objectID,actor,action,date,comment,extra,desc,history'); - if($action->history) - { - foreach($action->history as $i => $history) - { - $history = $this->filterFields($history, 'id,field,old,new,diff'); - $history->fieldName = zget($this->lang->product, $history->field); - $action->history[$i] = $history; - } - } - $product->actions[] = $action; - } + $actions = $data->data->actions; + $product->actions = $this->loadModel('action')->processActionForAPI($actions, $users, $this->lang->product); break; } }