- Remove repeat or unused methods.

This commit is contained in:
caoyanyi
2023-12-16 17:27:35 +08:00
parent fbb5e00202
commit fa8e55a28c
13 changed files with 4 additions and 323 deletions
-11
View File
@@ -20,17 +20,6 @@ class giteaModel extends model
public $developerAccess = 30;
public $maintainerAccess = 40;
/**
* Get gitea pairs.
*
* @access public
* @return array
*/
public function getPairs()
{
return $this->loadModel('pipeline')->getPairs('gitea');
}
/**
* Get gitea api base url by gitea id.
*
-48
View File
@@ -10,17 +10,6 @@ class giteaTest
$this->gitea = $this->tester->loadModel('gitea');
}
/**
* Get gitea pairs
*
* @return string
*/
public function getPairs()
{
$pairs = $this->gitea->getPairs();
return key($pairs);
}
/**
* Get gitea tasks.
*
@@ -34,41 +23,4 @@ class giteaTest
if(empty($tasks)) return 0;
return $tasks;
}
/**
* Create a gitea.
*
* @access public
* @return object|string
*/
public function create()
{
$giteaID = $this->gitea->create();
if(dao::isError())
{
$errors = dao::getError();
return key($errors);
}
return $this->gitea->fetchByID($giteaID);
}
/**
* Update a gitea.
*
* @param int $id
* @access public
* @return object|string
*/
public function update($id)
{
$this->gitea->update($id);
if(dao::isError())
{
$errors = dao::getError();
return key($errors);
}
return $this->gitea->fetchByID($id);
}
}
-34
View File
@@ -1,34 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/gitea.class.php';
su('admin');
/**
title=测试giteaModel->create();
cid=1
pid=1
Gitea名称为空 >> name
服务器地址为空 >> url
正确Gitea数据 >> Gitea,http://10.0.7.242:9020,1196c85ba525a268570df9da627e3a7b2d
*/
$gitea = new giteaTest();
$_POST = array();
$_POST['name'] = '';
$_POST['url'] = 'http://10.0.7.242:9020';
$_POST['token'] = 'c6769e6761a7d719129b2421dcb3112d936e2b1f';
r($gitea->create()) && p() && e('name'); // Gitea名称为空
$_POST['name'] = 'Gitea';
$_POST['url'] = '';
r($gitea->create()) && p() && e('url'); // 服务器地址为空
$_POST['url'] = 'http://10.0.7.242:9020';
r($gitea->create()) && p('name,url,token') && e('Gitea,http://10.0.7.242:9020,c6769e6761a7d719129b2421dcb3112d936e2b1f'); // 正确Gitea数据
-20
View File
@@ -1,20 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/gitea.class.php';
su('admin');
/**
title=测试giteaModel->gitPairs();
cid=1
pid=1
获取Gitea >> 4
*/
$gitea = new giteaTest();
r($gitea->getPairs()) && p() && e('4'); // 获取Gitea
-36
View File
@@ -1,36 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/gitea.class.php';
su('admin');
/**
title=测试giteaModel->update();
cid=1
pid=1
Gitea名称为空 >> name
服务器地址为空 >> url
正确Gitea数据 >> Changed Gitea
*/
$gitea = new giteaTest();
$giteaID = 3;
$_POST = array();
$_POST['name'] = '';
$_POST['url'] = 'http://10.0.7.242:9020';
$_POST['token'] = 'c6769e6761a7d719129b2421dcb3112d936e2b1f';
r($gitea->update($giteaID)) && p() && e('name'); // Gitea名称为空
$_POST['name'] = 'Changed Gitea';
$_POST['url'] = '';
r($gitea->update($giteaID)) && p() && e('url'); // 服务器地址为空
$_POST['url'] = 'http://10.0.7.242:9020';
r($gitea->update($giteaID)) && p('name') && e('Changed Gitea'); // 正确Gitea数据
+1 -1
View File
@@ -115,7 +115,7 @@ class gogs extends control
{
$gogs = form::data($this->config->gogs->form->edit)->get();
$this->checkToken($gogs);
$this->gogs->update($gogsID, $gogs);
$this->loadModel('pipeline')->update($gogsID, $gogs);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$gogs = $this->gogs->fetchByID($gogsID);
-34
View File
@@ -12,17 +12,6 @@
class gogsModel extends model
{
/**
* Get gogs pairs.
*
* @access public
* @return array
*/
public function getPairs()
{
return $this->loadModel('pipeline')->getPairs('gogs');
}
/**
* Get gogs api base url by gogs id.
*
@@ -38,29 +27,6 @@ class gogsModel extends model
return rtrim($gogs->url, '/') . '/api/v1%s' . "?token={$gogs->token}";
}
/**
* Create a gogs.
*
* @access public
* @return bool
*/
public function create()
{
return $this->loadModel('pipeline')->create('gogs');
}
/**
* Update a gogs.
*
* @param int $id
* @access public
* @return bool
*/
public function update($id)
{
return $this->loadModel('pipeline')->update($id);
}
/**
* Bind users.
*
-48
View File
@@ -9,52 +9,4 @@ class gogsTest
$this->tester = $tester;
$this->gogs = $this->tester->loadModel('gogs');
}
/**
* Get gogs pairs
*
* @return string
*/
public function getPairs()
{
$pairs = $this->gogs->getPairs();
return key($pairs);
}
/**
* Create a gogs.
*
* @access public
* @return object|string
*/
public function create()
{
$gogsID = $this->gogs->create();
if(dao::isError())
{
$errors = dao::getError();
return key($errors);
}
return $this->gogs->fetchByID($gogsID);
}
/**
* Update a gogs.
*
* @param int $id
* @access public
* @return object|string
*/
public function update($id)
{
$this->gogs->update($id);
if(dao::isError())
{
$errors = dao::getError();
return key($errors);
}
return $this->gogs->fetchByID($id);
}
}
-34
View File
@@ -1,34 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/gogs.class.php';
su('admin');
/**
title=测试gogsModel->create();
cid=1
pid=1
Gogs名称为空 >> name
服务器地址为空 >> url
正确Gogs数据 >> Gogs,http://10.0.7.242:9021,9ff43f9d1a369465bcf0781a3785f46bcef782d1
*/
$gogs = new gogsTest();
$_POST = array();
$_POST['name'] = '';
$_POST['url'] = 'http://10.0.7.242:9021';
$_POST['token'] = '9ff43f9d1a369465bcf0781a3785f46bcef782d1';
r($gogs->create()) && p() && e('name'); // Gogs名称为空
$_POST['name'] = 'Gogs';
$_POST['url'] = '';
r($gogs->create()) && p() && e('url'); // 服务器地址为空
$_POST['url'] = 'http://10.0.7.242:9021';
r($gogs->create()) && p('name,url,token') && e('Gogs,http://10.0.7.242:9021,9ff43f9d1a369465bcf0781a3785f46bcef782d1'); // 正确Gogs数据
-20
View File
@@ -1,20 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/gogs.class.php';
su('admin');
/**
title=测试gogsModel->gitPairs();
cid=1
pid=1
获取Gogs >> 5
*/
$gogs = new gogsTest();
r($gogs->getPairs()) && p() && e('5'); // 获取Gogs
-36
View File
@@ -1,36 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/gogs.class.php';
su('admin');
/**
title=测试gogsModel->update();
cid=1
pid=1
Gogs名称为空 >> name
服务器地址为空 >> url
正确Gogs数据 >> Changed Gogs
*/
$gogs = new gogsTest();
$gogsID = 3;
$_POST = array();
$_POST['name'] = '';
$_POST['url'] = 'http://10.0.7.242:9021';
$_POST['token'] = '9ff43f9d1a369465bcf0781a3785f46bcef782d1';
r($gogs->update($gogsID)) && p() && e('name'); // Gogs名称为空
$_POST['name'] = 'Changed Gogs';
$_POST['url'] = '';
r($gogs->update($gogsID)) && p() && e('url'); // 服务器地址为空
$_POST['url'] = 'http://10.0.7.242:9021';
r($gogs->update($gogsID)) && p('name') && e('Changed Gogs'); // 正确Gogs数据
+2
View File
@@ -66,6 +66,7 @@ class pipelineModel extends model
*/
public function getList(string $type = 'jenkins', string $orderBy = 'id_desc', object|null $pager = null): array
{
$type = strtolower($type);
return $this->dao->select('*')->from(TABLE_PIPELINE)
->where('deleted')->eq('0')
->beginIF($type)->AndWhere('type')->in($type)->fi()
@@ -84,6 +85,7 @@ class pipelineModel extends model
*/
public function getPairs(string $type = ''): array
{
$type = strtolower($type);
return $this->dao->select('id,name')->from(TABLE_PIPELINE)
->where('deleted')->eq('0')
->beginIF($type)->AndWhere('type')->eq($type)->fi()
+1 -1
View File
@@ -1309,7 +1309,7 @@ class repo extends control
*/
public function ajaxGetHosts(string $scm)
{
$hosts = $this->loadModel(strtolower($scm))->getPairs();
$hosts = $this->loadModel('pipeline')->getPairs($scm);
$options = array();
foreach($hosts as $hostID => $host)