projectcases.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * The project cases entry point of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package entries
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class projectCasesEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $projectID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($projectID = 0)
  22. {
  23. if(!$projectID) $projectID = $this->param('project', 0);
  24. if(empty($projectID)) return $this->sendError(400, 'Need project id.');
  25. $this->resetOpenApp('project');
  26. $this->app->session->set('project', $projectID, $this->app->tab);
  27. $control = $this->loadController('project', 'testcase');
  28. $control->testcase($projectID, $this->param('product', 0), $this->param('branch', 'all'), $this->param('status', 'all'), 0, $this->param('caseType', ''), $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
  29. $data = $this->getData();
  30. if(isset($data->status) and $data->status == 'success')
  31. {
  32. $cases = $data->data->cases;
  33. $pager = $data->data->pager;
  34. $result = array();
  35. foreach($cases as $case)
  36. {
  37. $case->statusName = $this->lang->testcase->statusList[$case->status];
  38. $result[] = $this->format($case, 'openedDate:time,reviewedDate:date,lastEditedDate:time,lastRunDate:time');
  39. }
  40. return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'cases' => $result));
  41. }
  42. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  43. return $this->sendError(400, 'error');
  44. }
  45. }