+ Finished importing issue to story.

This commit is contained in:
dingguodong
2021-07-08 15:55:11 +08:00
parent 6af64c8c12
commit 47102c509e
3 changed files with 54 additions and 3 deletions
+2 -1
View File
@@ -285,6 +285,7 @@ class gitlab extends control
$object = $this->gitlab->issueToZentaoObject($issue, $gitlabID);
$object->product = $productList[$issueID];
$object->execution = $executionID;
if($objectType == 'task')
{
$objectID = $this->loadModel('task')->createTaskFromGitlabIssue($object, $executionID);
@@ -302,7 +303,7 @@ class gitlab extends control
if($objectID)
{
$object->id = $objectID;
$object->id = $objectID;
$this->gitlab->saveImportedIssue($gitlabID, $projectID, $objectType, $objectID, $issue, $object);
}
else
+1 -1
View File
@@ -4,10 +4,10 @@ $config->story = new stdclass();
$config->story->batchCreate = 10;
$config->story->affectedFixedNum = 7;
$config->story->needReview = 1;
$config->story->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID,execution';
$config->story->batchClose = new stdclass();
$config->story->batchClose->columns = 10;
$config->story->create = new stdclass();
$config->story->edit = new stdclass();
$config->story->change = new stdclass();
+51 -1
View File
@@ -216,7 +216,7 @@ class storyModel extends model
/* Check repeat story. */
$result = $this->loadModel('common')->removeDuplicate('story', $story, "product={$story->product}");
if($result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']);
if(isset($result['stop']) and $result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']);
if($this->checkForceReview()) $story->status = 'draft';
if($story->status == 'draft') $story->stage = $this->post->plan > 0 ? 'planned' : 'wait';
@@ -348,6 +348,56 @@ class storyModel extends model
return false;
}
/**
* Create story from gitlab issue.
*
* @param object $story
* @param int $executionID
* @access public
* @return int
*/
public function createStoryFromGitlabIssue($story, $executionID)
{
foreach($story as $feild => $value) $_POST[$feild] = $value;
$now = helper::now();
$story = fixer::input('post')
->cleanInt('product,module,pri,plan')
->callFunc('title', 'trim')
->add('assignedDate', 0)
->add('version', 1)
->add('status', 'draft')
->setDefault('plan,verify', '')
->setDefault('openedBy', $this->app->user->account)
->setDefault('openedDate', $now)
->setIF($story->assignedTo != '', 'assignedDate', $now)
->setIF($executionID > 0, 'status', 'active')
->setIF($executionID > 0, 'stage', 'projected')
->join('mailto', ',')
->stripTags($this->config->story->editor->create['id'], $this->config->allowedTags)
->remove('files,labels,reviewer,needNotReview,newStory,uid,contactListMenu,URS')
->remove($this->config->story->removeFields)
->get();
$requiredFields = $this->config->story->create->requiredFields;
$this->dao->insert(TABLE_STORY)->data($story, 'spec,verify,gitlab,gitlabProject')->autoCheck()->batchCheck($requiredFields, 'notempty')->exec();
if(!dao::isError())
{
$storyID = $this->dao->lastInsertID();
$data = new stdclass();
$data->story = $storyID;
$data->version = 1;
$data->title = $story->title;
$data->spec = $story->spec;
$data->verify = $story->spec;
$this->dao->insert(TABLE_STORYSPEC)->data($data)->exec();
return $storyID;
}
return false;
}
/**
* Batch create stories.
*