* [task#132861,doing,0.5h] split project release create method.

This commit is contained in:
caoyanyi
2024-11-26 09:25:43 +08:00
committed by 田淑杰
parent d652943ffc
commit 11d2f8d86c
2 changed files with 58 additions and 29 deletions
+1 -28
View File
@@ -107,34 +107,7 @@ class projectrelease extends control
if(!empty($_POST))
{
$this->lang->projectrelease->system = $this->lang->release->system;
if(!$this->post->newSystem && !$this->post->system) $this->config->release->form->create['system']['required'] = true;
if($this->post->newSystem && !$this->post->systemName)
{
$this->config->release->form->create['systemName'] = array('type' => 'string', 'required' => true);
$this->lang->projectrelease->systemName = $this->lang->release->system;
}
$release = form::data($this->config->release->form->create)
->add('product', $this->post->product ? $this->post->product : 0)
->add('branch', $this->post->branch ? $this->post->branch : 0)
->setIF($projectID, 'project', $projectID)
->setIF($this->post->build === false, 'build', 0)
->get();
/* Check build if build is required. */
if(strpos($this->config->release->create->requiredFields, 'build') !== false && empty($release->build)) dao::$errors['build'] = sprintf($this->lang->error->notempty, $this->lang->release->build);
if($this->post->newSystem && $this->post->systemName && $this->post->product)
{
$system = new stdclass();
$system->name = $this->post->systemName;
$system->product = $this->post->product;
$system->createdBy = $this->app->user->account;
$system->createdDate = helper::now();
$release->system = $this->loadModel('system')->create($system);
}
$release = $this->projectreleaseZen->buildReleaseForCreate($projectID);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if(!empty($_FILES['releaseFiles'])) $_FILES['files'] = $_FILES['releaseFiles'];
+57 -1
View File
@@ -27,9 +27,65 @@ class projectreleaseZen extends projectrelease
$this->view->products = $this->products;
$this->view->product = $product;
$this->view->apps = $this->loadModel('system')->getPairs($productID, '', 'active');
$this->view->branches = (isset($product->type) and $product->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($productID, 'active', $projectID);
$this->view->branch = $branch;
$this->view->project = $this->project->getByID($projectID);
$this->view->appList = $this->loadModel('system')->getList($productID);
}
/**
* 构造项目发布数据。
* Construct project release data.
*
* @param int $projectID
* @access protected
* @return void
*/
protected function buildReleaseForCreate(int $projectID): object|false
{
$this->lang->projectrelease->system = $this->lang->release->system;
if(!$this->post->newSystem && !$this->post->system) $this->config->release->form->create['system']['required'] = true;
if($this->post->newSystem && !$this->post->systemName)
{
$this->config->release->form->create['systemName'] = array('type' => 'string', 'required' => true);
$this->lang->projectrelease->systemName = $this->lang->release->system;
}
$release = form::data($this->config->release->form->create)
->add('product', $this->post->product ? $this->post->product : 0)
->add('branch', $this->post->branch ? $this->post->branch : 0)
->setIF($projectID, 'project', $projectID)
->setIF($this->post->build === false, 'build', 0)
->get();
/* Check build if build is required. */
if(strpos($this->config->release->create->requiredFields, 'build') !== false && empty($release->build)) dao::$errors['build'] = sprintf($this->lang->error->notempty, $this->lang->release->build);
if(!$this->post->newSystem && $this->post->system)
{
$system = $this->loadModel('system')->fetchByID((int)$this->post->system);
if(!$system) dao::$errors['system'][] = sprintf($this->lang->error->notempty, $this->lang->release->system);
if($system->integrated == '1')
{
$releases = (array)$this->post->releases;
$release->build = '';
$release->releases = trim(implode(',', $releases), ',');
if(!$release->releases) dao::$errors['releases[' . key($releases) . ']'][] = sprintf($this->lang->error->notempty, $this->lang->release->includedSystem);
}
}
if(dao::isError()) return false;
if($this->post->newSystem && $this->post->systemName && $this->post->product)
{
$system = new stdclass();
$system->name = $this->post->systemName;
$system->product = $this->post->product;
$system->createdBy = $this->app->user->account;
$system->createdDate = helper::now();
$release->system = $this->loadModel('system')->create($system);
}
return $release;
}
}