tao.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. class testtaskTao extends testtaskModel
  3. {
  4. /**
  5. * 查询测试单列表。
  6. * Fetch testtask list.
  7. *
  8. * @param int $productID
  9. * @param string $branch
  10. * @param int $projectID
  11. * @param string $unit
  12. * @param string $scope
  13. * @param string $status
  14. * @param string $begin
  15. * @param string $end
  16. * @param string $orderBy
  17. * @param object $pager
  18. * @access protected
  19. * @return array
  20. */
  21. public function fetchTesttaskList($productID, $branch = '', $projectID = 0, $unit = 'no', $scope = '', $status = '', $begin = '', $end = '', $orderBy = '', $pager = null)
  22. {
  23. return $this->dao->select("t1.*, t5.multiple, IF(t2.shadow = 1, t5.name, t2.name) AS productName, t3.name AS executionName, t4.name AS buildName, t4.branch AS branch, t5.name AS projectName")
  24. ->from(TABLE_TESTTASK)->alias('t1')
  25. ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
  26. ->leftJoin(TABLE_EXECUTION)->alias('t3')->on('t1.execution = t3.id')
  27. ->leftJoin(TABLE_BUILD)->alias('t4')->on('t1.build = t4.id')
  28. ->leftJoin(TABLE_PROJECT)->alias('t5')->on('t1.project = t5.id')
  29. ->where('t1.deleted')->eq(0)
  30. ->andWhere('t2.deleted')->eq(0)
  31. ->beginIF($unit == 'unit')->andWhere('t1.auto')->eq('unit')->fi()
  32. ->beginIF($unit != 'unit')->andWhere('t1.auto')->ne('unit')->fi()
  33. ->beginIF(!$this->app->user->admin)->andWhere('t1.execution')->in("0,{$this->app->user->view->sprints}")->fi()
  34. ->beginIF($scope == 'local')->andWhere('t1.product')->eq($productID)->fi()
  35. ->beginIF($scope == 'all')->andWhere('t1.product')->in($this->app->user->view->products)->fi()
  36. ->beginIF(strtolower($status) == 'myinvolved')
  37. ->andWhere('(t1.owner')->eq($this->app->user->account)
  38. ->orWhere("FIND_IN_SET('{$this->app->user->account}', t1.members)")
  39. ->markRight(1)
  40. ->fi()
  41. ->beginIF($projectID)->andWhere('t1.project')->eq($projectID)->fi()
  42. ->beginIF(strtolower($status) == 'totalstatus')->andWhere('t1.status')->in('blocked,doing,wait,done')->fi()
  43. ->beginIF(strtolower($status) == 'review') // 工作流开启审批的时候才会使用,才会新增字段。
  44. ->andWhere("FIND_IN_SET('{$this->app->user->account}', t1.reviewers)")
  45. ->andWhere('t1.reviewStatus')->eq('doing')
  46. ->fi()
  47. ->beginIF(!in_array(strtolower($status), array('totalstatus', 'review', 'myinvolved'), true) && $status)->andWhere('t1.status')->eq($status)->fi()
  48. ->beginIF($unit != 'unit')
  49. ->beginIF($begin)->andWhere('t1.begin')->ge($begin)->fi()
  50. ->beginIF($end)->andWhere('t1.end')->le($end)->fi()
  51. ->fi()
  52. ->beginIF($unit == 'unit')
  53. ->beginIF($begin)->andWhere('t1.end')->ge($begin)->fi()
  54. ->beginIF($end)->andWhere('t1.end')->le($end)->fi()
  55. ->fi()
  56. ->beginIF($branch !== 'all' && $branch)->andWhere("CONCAT(',', t4.branch, ',')")->like("%,$branch,%")->fi()
  57. ->beginIF($branch == BRANCH_MAIN)
  58. ->orWhere('(t1.build')->eq('trunk')
  59. ->andWhere('t1.product')->eq($productID)
  60. ->markRight(1)
  61. ->fi()
  62. ->orderBy($orderBy)
  63. ->page($pager)
  64. ->fetchAll('id', false);
  65. }
  66. }