* Refactor project model function checkCanChangeModel.
This commit is contained in:
+18
-10
@@ -2774,6 +2774,7 @@ class projectModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否可以修改model字段
|
||||
* Check if the project model can be changed.
|
||||
*
|
||||
* @param int $projectID
|
||||
@@ -2781,8 +2782,10 @@ class projectModel extends model
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkCanChangeModel($projectID, $model)
|
||||
public function checkCanChangeModel(int $projectID, string $model): bool
|
||||
{
|
||||
if(empty($model)) return false;
|
||||
|
||||
$checkList = $this->config->project->checkList->$model;
|
||||
if($this->config->edition == 'max') $checkList = $this->config->project->maxCheckList->$model;
|
||||
foreach($checkList as $module)
|
||||
@@ -2795,18 +2798,23 @@ class projectModel extends model
|
||||
{
|
||||
switch($model)
|
||||
{
|
||||
case 'waterfall':
|
||||
$type = 'stage';
|
||||
break;
|
||||
case 'kanban':
|
||||
$type = 'kanban';
|
||||
break;
|
||||
default:
|
||||
$type = 'sprint';
|
||||
break;
|
||||
case 'waterfall':
|
||||
$type = 'stage';
|
||||
break;
|
||||
case 'waterfallplus':
|
||||
$type = 'stage';
|
||||
break;
|
||||
case 'kanban':
|
||||
$type = 'kanban';
|
||||
break;
|
||||
default:
|
||||
$type = 'sprint';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 检查对应类型的数据是否已经存在。 */
|
||||
/* Check if the data of the type already exists. */
|
||||
$object = $this->getDataByProject($table, $projectID, $type);
|
||||
if(!empty($object)) return false;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,37 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . "/test/lib/init.php";
|
||||
|
||||
su('admin');
|
||||
|
||||
zdTable('project')->config('project')->gen(4);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 projectModel->checkCanChangeModel();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
查看ID为11的敏捷项目是否可切换项目管理模型 >> 0
|
||||
查看ID为41的瀑布项目是否可切换项目管理模型 >> 0
|
||||
- 执行project模块的checkCanChangeModel方法,参数是1, scrum @0
|
||||
|
||||
- 执行project模块的checkCanChangeModel方法,参数是1, agileplus @0
|
||||
|
||||
- 执行project模块的checkCanChangeModel方法,参数是1, kanban @0
|
||||
|
||||
- 执行project模块的checkCanChangeModel方法,参数是1, waterfall @1
|
||||
|
||||
- 执行project模块的checkCanChangeModel方法,参数是1, waterfallplus @1
|
||||
|
||||
- 执行project模块的checkCanChangeModel方法,参数是1, @0
|
||||
|
||||
*/
|
||||
|
||||
global $tester;
|
||||
$tester->loadModel('project');
|
||||
|
||||
r($tester->project->checkCanChangeModel(11, 'scrum')) && p() && e('0'); // 查看ID为11的敏捷项目是否可切换项目管理模型
|
||||
r($tester->project->checkCanChangeModel(41, 'waterfall')) && p() && e('0'); // 查看ID为41的瀑布项目是否可切换项目管理模型
|
||||
r($tester->project->checkCanChangeModel(1, 'scrum')) && p() && e('0');
|
||||
r($tester->project->checkCanChangeModel(1, 'agileplus')) && p() && e('0');
|
||||
r($tester->project->checkCanChangeModel(1, 'kanban')) && p() && e('0');
|
||||
r($tester->project->checkCanChangeModel(1, 'waterfall')) && p() && e('1');
|
||||
r($tester->project->checkCanChangeModel(1, 'waterfallplus')) && p() && e('1');
|
||||
r($tester->project->checkCanChangeModel(1, '')) && p() && e('0');
|
||||
@@ -0,0 +1,14 @@
|
||||
title: checkcanchangemodel-project
|
||||
author: chaideqing
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: PM
|
||||
range: 'admin'
|
||||
- field: id
|
||||
range: '1-8'
|
||||
- field: project
|
||||
range: '1'
|
||||
- field: model
|
||||
range: ', ,scrum,agileplus,kanban,waterfall,waterfallplus'
|
||||
- field: type
|
||||
range: 'project,sprint{2},kanban,stage{2}'
|
||||
Reference in New Issue
Block a user