* check unique add branch condition when create build and release.

This commit is contained in:
wangyidong
2016-03-14 09:05:58 +08:00
parent c604bf2ba2
commit 800a0efd9e
2 changed files with 18 additions and 6 deletions
+8 -3
View File
@@ -181,13 +181,18 @@ class buildModel extends model
$build = fixer::input('post')
->setDefault('product', 0)
->setDefault('branch', 0)
->add('project', (int)$projectID)
->stripTags($this->config->build->editor->create['id'], $this->config->allowedTags)
->remove('resolvedBy,allchecker,files,labels')
->get();
$build = $this->loadModel('file')->processEditor($build, $this->config->build->editor->create['id']);
$this->dao->insert(TABLE_BUILD)->data($build)->autoCheck()->batchCheck($this->config->build->create->requiredFields, 'notempty')->check('name', 'unique', "product = {$build->product} AND deleted = '0'")->exec();
$this->dao->insert(TABLE_BUILD)->data($build)
->autoCheck()
->batchCheck($this->config->build->create->requiredFields, 'notempty')
->check('name', 'unique', "product = {$build->product} AND branch = {$build->branch} AND deleted = '0'")
->exec();
if(!dao::isError())
{
$buildID = $this->dao->lastInsertID();
@@ -206,7 +211,7 @@ class buildModel extends model
public function update($buildID)
{
$oldBuild = $this->getByID($buildID);
$build = fixer::input('post')->stripTags($this->config->build->editor->edit['id'], $this->config->allowedTags)
$build = fixer::input('post')->setDefault('branch', $oldBuild->branch)->stripTags($this->config->build->editor->edit['id'], $this->config->allowedTags)
->remove('allchecker,resolvedBy,files,labels')
->get();
@@ -215,7 +220,7 @@ class buildModel extends model
->autoCheck()
->batchCheck($this->config->build->edit->requiredFields, 'notempty')
->where('id')->eq((int)$buildID)
->check('name', 'unique', "id != $buildID AND product = {$build->product} AND deleted = '0'")
->check('name', 'unique', "id != $buildID AND product = {$build->product} AND branch = {$build->branch} AND deleted = '0'")
->exec();
if(isset($build->branch) and $oldBuild->branch != $build->branch) $this->dao->update(TABLE_RELEASE)->set('branch')->eq($build->branch)->where('build')->eq($buildID)->exec();
if(!dao::isError()) return common::createChanges($oldBuild, $build);
+10 -3
View File
@@ -113,7 +113,10 @@ class releaseModel extends model
->remove('build,files,labels')
->get();
$build = $this->loadModel('file')->processEditor($build, $this->config->release->editor->create['id']);
$this->dao->insert(TABLE_BUILD)->data($build)->autoCheck()->check('name', 'unique', "product = {$build->product} AND deleted = '0'")->exec();
$this->dao->insert(TABLE_BUILD)->data($build)
->autoCheck()
->check('name', 'unique', "product = {$build->product} AND branch = $branch AND deleted = '0'")
->exec();
$buildID = $this->dao->lastInsertID();
}
@@ -130,7 +133,11 @@ class releaseModel extends model
->get();
$release = $this->loadModel('file')->processEditor($release, $this->config->release->editor->create['id']);
$this->dao->insert(TABLE_RELEASE)->data($release)->autoCheck()->batchCheck($this->config->release->create->requiredFields, 'notempty')->check('name', 'unique', "product = {$release->product} AND deleted = '0'")->exec();
$this->dao->insert(TABLE_RELEASE)->data($release)
->autoCheck()
->batchCheck($this->config->release->create->requiredFields, 'notempty')
->check('name', 'unique', "product = {$release->product} AND branch = $branch AND deleted = '0'")
->exec();
if(!dao::isError())
{
@@ -162,7 +169,7 @@ class releaseModel extends model
$this->dao->update(TABLE_RELEASE)->data($release)
->autoCheck()
->batchCheck($this->config->release->edit->requiredFields, 'notempty')
->check('name', 'unique', "id != $releaseID AND product = {$release->product} AND deleted = '0'")
->check('name', 'unique', "id != $releaseID AND product = {$release->product} AND branch = $branch AND deleted = '0'")
->where('id')->eq((int)$releaseID)
->exec();
if(!dao::isError()) return common::createChanges($oldRelease, $release);