finish api release.
This commit is contained in:
+9
-9
@@ -58,7 +58,7 @@ CREATE TABLE `zt_apispec`
|
||||
`method` varchar(10) NOT NULL DEFAULT '',
|
||||
`requestType` varchar(100) NOT NULL DEFAULT '',
|
||||
`responseType` varchar(100) NOT NULL DEFAULT '',
|
||||
`status` tinyint UNSIGNED NOT NULL DEFAULT 0,
|
||||
`status` varchar(20) NOT NULL DEFAULT '',
|
||||
`owner` varchar(255) NOT NULl DEFAULT 0,
|
||||
`desc` text NULL,
|
||||
`version` smallint UNSIGNED NOT NULL DEFAULT 0,
|
||||
@@ -90,13 +90,13 @@ create table `zt_apistruct`
|
||||
-- DROP TABLE IF EXISTS `zt_apistruct_spec`;
|
||||
create table `zt_apistruct_spec`
|
||||
(
|
||||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`type` varchar(50) NOT NULL DEFAULT '',
|
||||
`desc` varchar(255) NOT NULL DEFAULT '',
|
||||
`attribute` text NULL,
|
||||
`version` smallint unsigned NOT NULL DEFAULT 0,
|
||||
`addedBy` varchar(30) NOT NULL DEFAULT 0,
|
||||
`addedDate` datetime NOT NULL,
|
||||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`type` varchar(50) NOT NULL DEFAULT '',
|
||||
`desc` varchar(255) NOT NULL DEFAULT '',
|
||||
`attribute` text NULL,
|
||||
`version` smallint unsigned NOT NULL DEFAULT 0,
|
||||
`addedBy` varchar(30) NOT NULL DEFAULT 0,
|
||||
`addedDate` datetime NOT NULL,
|
||||
primary key (`id`)
|
||||
)
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
<?php
|
||||
$config->api = new stdClass();
|
||||
$config->api->createlib = new stdclass();
|
||||
$config->api = new stdClass();
|
||||
$config->api->createlib = new stdclass();
|
||||
$config->api->createlib->requiredFields = 'name';
|
||||
|
||||
$config->api->editlib = new stdclass();
|
||||
$config->api->editlib = new stdclass();
|
||||
$config->api->editlib->requiredFields = 'name';
|
||||
|
||||
$config->api->struct = new stdClass();
|
||||
$config->api->struct = new stdClass();
|
||||
$config->api->struct->requiredFields = 'name,params';
|
||||
|
||||
$config->api->create = new stdclass();
|
||||
$config->api->create = new stdclass();
|
||||
$config->api->create->requiredFields = 'lib,title,path';
|
||||
|
||||
$config->api->edit = new stdclass();
|
||||
$config->api->edit = new stdclass();
|
||||
$config->api->edit->requiredFields = 'lib,title,path';
|
||||
|
||||
$config->api->publish = new stdclass();
|
||||
$config->api->publish = new stdclass();
|
||||
$config->api->publish->requiredFields = 'version';
|
||||
|
||||
$config->api->editor = new stdclass();
|
||||
$config->api->editor = new stdclass();
|
||||
$config->api->editor->createlib = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->api->editor->editlib = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->api->editor->create = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->api->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->api->editor->publish = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
|
||||
+98
-22
@@ -26,10 +26,12 @@ class api extends control
|
||||
* @param int $libID
|
||||
* @param int $moduleID
|
||||
* @param int $apiID
|
||||
* @param int $version
|
||||
* @param int $release
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0)
|
||||
public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0, $release = 0)
|
||||
{
|
||||
/* Get all api doc libraries. */
|
||||
$libs = $this->doc->getApiLibs();
|
||||
@@ -38,7 +40,7 @@ class api extends control
|
||||
if($libs)
|
||||
{
|
||||
if($libID == 0) $libID = key($libs);
|
||||
$this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID);
|
||||
$this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID, $release);
|
||||
}
|
||||
$this->setMenu($libID);
|
||||
|
||||
@@ -61,11 +63,13 @@ class api extends control
|
||||
else
|
||||
{
|
||||
/* Get module api list. */
|
||||
$apiList = $this->api->getListByModuleId($libID, $moduleID);
|
||||
$apiList = $this->api->getListByModuleId($libID, $moduleID, $release);
|
||||
|
||||
$this->view->apiList = $apiList;
|
||||
}
|
||||
|
||||
$this->view->isRelease = $release > 0;
|
||||
$this->view->release = $release;
|
||||
$this->view->title = $this->lang->api->title;
|
||||
$this->view->libID = $libID;
|
||||
$this->view->apiID = $apiID;
|
||||
@@ -87,8 +91,9 @@ class api extends control
|
||||
{
|
||||
$lib = $this->doc->getLibById($libID);
|
||||
|
||||
if(!empty($_POST)) {
|
||||
$data = fixer::input('post')
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$data = fixer::input('post')
|
||||
->add('lib', $libID)
|
||||
->add('addedBy', $this->app->user->account)
|
||||
->add('addedDate', helper::now())
|
||||
@@ -120,7 +125,10 @@ class api extends control
|
||||
*/
|
||||
public function struct($libID = 0, $orderBy = 'id', $recTotal = 0, $recPerPage = 15, $pageID = 1)
|
||||
{
|
||||
$libs = $this->doc->getApiLibs();
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID);
|
||||
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
/* Append id for secend sort. */
|
||||
@@ -299,10 +307,7 @@ class api extends control
|
||||
$doc = $this->doc->getLibById($id);
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$lib = fixer::input('post')
|
||||
->join('groups', ',')
|
||||
->join('users', ',')
|
||||
->get();
|
||||
$lib = fixer::input('post')->join('groups', ',')->join('users', ',')->get();
|
||||
|
||||
if($lib->acl == 'private') $lib->users = $this->app->user->account;
|
||||
$this->doc->updateApiLib($id, $doc, $lib);
|
||||
@@ -324,6 +329,31 @@ class api extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $libID
|
||||
* @param string $confirm
|
||||
* @param string $from
|
||||
*/
|
||||
public function deleteLib($libID, $confirm = 'no')
|
||||
{
|
||||
if($confirm == 'no')
|
||||
{
|
||||
die(js::confirm($this->lang->doc->confirmDeleteLib, $this->createLink('api', 'deleteLib', "libID=$libID&confirm=yes")));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->doc->delete(TABLE_DOCLIB, $libID);
|
||||
if(isonlybody())
|
||||
{
|
||||
unset($_GET['onlybody']);
|
||||
die(js::locate($this->createLink('api', 'index'), 'parent.parent'));
|
||||
}
|
||||
|
||||
die(js::locate($this->createLink('api', 'index'), 'parent'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit library.
|
||||
*
|
||||
@@ -429,15 +459,7 @@ class api extends control
|
||||
$example = array('example' => 'type,description');
|
||||
$example = json_encode($example, JSON_PRETTY_PRINT);
|
||||
|
||||
$options = [];
|
||||
foreach($this->lang->api->paramsTypeOptions as $key => $item)
|
||||
{
|
||||
$options[] = [
|
||||
'label' => $item,
|
||||
'value' => $key,
|
||||
];
|
||||
}
|
||||
$this->view->typeOptions = $options;
|
||||
$this->getTypeOptions($libID);
|
||||
$this->view->user = $this->app->user->account;
|
||||
$this->view->allUsers = $this->loadModel('user')->getPairs('devfirst|noclosed');
|
||||
$this->view->libID = $libID;
|
||||
@@ -549,7 +571,10 @@ class api extends control
|
||||
// global struct link
|
||||
$menu = '';
|
||||
|
||||
$menu .= html::a(helper::createLink('api', 'publish', "libID=$libID"), $this->lang->api->publish, '', 'class="btn btn-link iframe"');
|
||||
if(common::hasPriv('api', 'publish'))
|
||||
{
|
||||
$menu .= html::a(helper::createLink('api', 'publish', "libID=$libID"), $this->lang->api->publish, '', 'class="btn btn-link iframe"');
|
||||
}
|
||||
// page of index menu
|
||||
if(intval($libID) > 0)
|
||||
{
|
||||
@@ -591,10 +616,11 @@ class api extends control
|
||||
*
|
||||
* @param array $libs
|
||||
* @param int $libID
|
||||
* @param int $version
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
private function generateLibsDropMenu($libs, $libID)
|
||||
private function generateLibsDropMenu($libs, $libID, $version = 0)
|
||||
{
|
||||
if(empty($libs)) return '';
|
||||
|
||||
@@ -620,6 +646,35 @@ EOT;
|
||||
}
|
||||
$output .= "</div></div></div></div></div>";
|
||||
|
||||
/* Get lib version */
|
||||
$versions = $this->api->getReleaseListByApi($libID);
|
||||
if(!empty($versions))
|
||||
{
|
||||
$versionName = $version > 0 ? $versions[$version]->desc : $this->lang->api->defaultVersion;
|
||||
$output .= <<<EOT
|
||||
<div class='btn-group angle-btn'>
|
||||
<div class='btn-group'>
|
||||
<button id='currentBranch' data-toggle='dropdown' type='button' class='btn btn-limit'>{$versionName} <span class='caret'></span>
|
||||
</button>
|
||||
<div id='dropMenu' class='dropdown-menu search-list' data-ride='searchList'>
|
||||
<div class="input-control search-box has-icon-left has-icon-right search-example">
|
||||
<input type="search" class="form-control search-input" />
|
||||
<label class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label>
|
||||
<a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a>
|
||||
</div>
|
||||
<div class='table-col'>
|
||||
<div class='list-group'>
|
||||
EOT;
|
||||
$selected = $version > 0 ? '' : 'selected';
|
||||
$output .= html::a(inlink('index', "libID=$libID&moduleID=0&apiID=0&version=0&release=0"), $this->lang->api->defaultVersion, '', "class='$selected'");
|
||||
foreach($versions as $key => $item)
|
||||
{
|
||||
$selected = $key == $version ? 'selected' : '';
|
||||
$output .= html::a(inlink('index', "libID=$libID&moduleID=0&apiID=0&version=0&release=$key"), $item->desc, '', "class='$selected' data-app='{$this->app->tab}'");
|
||||
}
|
||||
$output .= "</div></div></div></div></div>";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -642,8 +697,7 @@ EOT;
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public
|
||||
function getSessionID()
|
||||
public function getSessionID()
|
||||
{
|
||||
$this->session->set('rand', mt_rand(0, 10000));
|
||||
$this->view->sessionName = session_name();
|
||||
@@ -745,4 +799,26 @@ EOT;
|
||||
die($this->output);
|
||||
}
|
||||
|
||||
private function getTypeOptions($libID)
|
||||
{
|
||||
$options = [];
|
||||
foreach($this->lang->api->paramsTypeOptions as $key => $item)
|
||||
{
|
||||
$options[] = [
|
||||
'label' => $item,
|
||||
'value' => $key,
|
||||
];
|
||||
}
|
||||
/* get all struct by libID. */
|
||||
$structs = $this->api->getStructListByLibID($libID);
|
||||
foreach($structs as $struct)
|
||||
{
|
||||
$options[] = [
|
||||
'label' => $struct->name,
|
||||
'value' => $struct->id,
|
||||
];
|
||||
}
|
||||
$this->view->typeOptions = $options;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ try {
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td class="w-200px">
|
||||
<td class="w-300px">
|
||||
<input type="text" :placeholder="langDesc" autocomplete="off" class="form-control" v-model="value.desc">
|
||||
</td>
|
||||
<td>
|
||||
@@ -400,7 +400,7 @@ try {
|
||||
<th class="w-300px">${struct_field}</th>
|
||||
<th class="w-100px">${struct_paramsType}</th>
|
||||
<th class="w-80px">${struct_required}</th>
|
||||
<th class="w-200px">${struct_desc}</th>
|
||||
<th class="w-300px">${struct_desc}</th>
|
||||
<th>${struct_action}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -6,7 +6,7 @@ new Vue({
|
||||
attr: '',
|
||||
struct: {
|
||||
...struct,
|
||||
attribute: JSON.parse(struct.attribute)
|
||||
attribute: struct.attribute
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -14,7 +14,28 @@ $lang->api->common = 'API接口';
|
||||
$lang->api->getModel = '超级model调用接口';
|
||||
$lang->api->sql = 'SQL查询接口';
|
||||
|
||||
$lang->api->publish = '发布';
|
||||
/* function of api doc */
|
||||
$lang->apiDoc = new stdClass();
|
||||
$lang->apiDoc->common = '接口库';
|
||||
$lang->apiDoc->index = '接口库主页';
|
||||
$lang->apiDoc->createLib = '创建接口库';
|
||||
$lang->apiDoc->editLib = '编辑接口库';
|
||||
$lang->apiDoc->deleteLib = '删除接口库';
|
||||
$lang->apiDoc->publish = '发布接口';
|
||||
$lang->apiDoc->structPage = '数据结构';
|
||||
$lang->apiDoc->createStruct = '创建数据结构';
|
||||
$lang->apiDoc->editStruct = '创建数据结构';
|
||||
$lang->apiDoc->deleteStruct = '删除数据结构';
|
||||
$lang->apiDoc->createApi = '创建接口';
|
||||
$lang->apiDoc->editApi = '编辑接口';
|
||||
$lang->apiDoc->deleteApi = '删除接口';
|
||||
|
||||
$lang->api->editLib = '编辑接口库';
|
||||
$lang->api->deleteLib = '删除接口库';
|
||||
$lang->api->createStruct = '创建数据结构';
|
||||
$lang->api->publish = '发布接口';
|
||||
$lang->api->createLib = '创建接口库';
|
||||
$lang->api->createApi = '创建接口';
|
||||
$lang->api->edit = '编辑';
|
||||
$lang->api->delete = '删除';
|
||||
$lang->api->position = '位置';
|
||||
@@ -32,17 +53,12 @@ $lang->api->post = 'POST方式调试请参照页面表单';
|
||||
$lang->api->noUniqueName = '接口库名已存在。';
|
||||
$lang->api->noUniqueVersion = '版本已存在。';
|
||||
$lang->api->version = '版本';
|
||||
$lang->api->createLib = '创建接口库';
|
||||
$lang->api->createStruct = '创建数据结构';
|
||||
$lang->api->editStruct = '修改数据结构';
|
||||
$lang->api->editLib = '编辑接口库';
|
||||
$lang->api->deleteLib = '删除接口库';
|
||||
$lang->api->create = '创建文档';
|
||||
$lang->api->createApi = '创建接口';
|
||||
$lang->api->title = '接口库';
|
||||
$lang->api->module = '模块';
|
||||
$lang->api->module = '目录';
|
||||
$lang->api->apiDoc = '接口';
|
||||
$lang->api->manageType = '维护模块';
|
||||
$lang->api->manageType = '维护目录';
|
||||
$lang->api->doing = '开发中';
|
||||
$lang->api->done = '开发完成';
|
||||
$lang->api->basicInfo = '基本信息';
|
||||
@@ -50,6 +66,7 @@ $lang->api->apiDesc = '接口说明';
|
||||
$lang->api->confirmDelete = "您确定删除该接口吗?";
|
||||
$lang->api->confirmDeleteLib = "您确定删除该接口库吗?";
|
||||
$lang->api->filterStruct = "使用数据结构填充";
|
||||
$lang->api->defaultVersion = "当前版本";
|
||||
|
||||
/* fields of struct */
|
||||
$lang->struct = new stdClass();
|
||||
@@ -84,7 +101,7 @@ $lang->api->control = '访问控制';
|
||||
$lang->api->noLib = '暂时没有接口库。';
|
||||
$lang->api->noApi = '暂时没有接口。';
|
||||
$lang->api->lib = '所属接口库';
|
||||
$lang->api->module = '所属模块';
|
||||
$lang->api->apiList = '接口列表';
|
||||
$lang->api->formTitle = '接口名称';
|
||||
$lang->api->path = '请求路径';
|
||||
$lang->api->protocol = '请求协议';
|
||||
|
||||
+100
-12
@@ -95,7 +95,12 @@ class apiModel extends model
|
||||
->batchCheck($this->config->api->create->requiredFields, 'notempty')
|
||||
->exec();
|
||||
|
||||
return dao::isError() ? false : $this->dao->lastInsertID();
|
||||
$id = $this->dao->lastInsertID();
|
||||
|
||||
$apiSpec = $this->getApiSpecByData($params);
|
||||
$this->dao->replace(TABLE_API_SPEC)->data($apiSpec)->exec();
|
||||
|
||||
return dao::isError() ? false : $id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,6 +118,8 @@ class apiModel extends model
|
||||
->batchCheck($this->config->api->struct->requiredFields, 'notempty')
|
||||
->exec();
|
||||
|
||||
$id = $this->dao->lastInsertID();
|
||||
|
||||
/* Create a struct version. */
|
||||
$version = array(
|
||||
'name' => $data->name,
|
||||
@@ -125,7 +132,7 @@ class apiModel extends model
|
||||
);
|
||||
$this->dao->insert(TABLE_APISTRUCT_SPEC)->data($version)->exec();
|
||||
|
||||
return dao::isError() ? 0 : $this->dao->lastInsertID();
|
||||
return dao::isError() ? 0 : $id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,6 +274,38 @@ class apiModel extends model
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get release by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getReleaseById($id)
|
||||
{
|
||||
$model = $this->dao->select('*')
|
||||
->from(TABLE_API_LIB_RELEASE)
|
||||
->where('id')->eq($id)
|
||||
->fetch();
|
||||
if($model) $model->snap = json_decode(htmlspecialchars_decode($model->snap), true);
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Versions by api id
|
||||
*
|
||||
* @param int $libID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getReleaseListByApi($libID)
|
||||
{
|
||||
$versions = $this->dao->select('*')->from(TABLE_API_LIB_RELEASE)
|
||||
->where('lib')->eq($libID)
|
||||
->fetchAll('id');
|
||||
return $versions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get api doc by id.
|
||||
@@ -305,30 +344,79 @@ class apiModel extends model
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get api list by release.
|
||||
*
|
||||
* @param object $release
|
||||
* @param string $where
|
||||
* @return array
|
||||
*/
|
||||
public function getApiListByRelease($release, $where = '')
|
||||
{
|
||||
$strJoin = array();
|
||||
foreach($release->snap['apis'] as $api)
|
||||
{
|
||||
$strJoin[] = "(doc = {$api['id']} and version = {$api['version']} )";
|
||||
}
|
||||
|
||||
$where .= 'and (' . implode(' or ', $strJoin) . ')';
|
||||
$list = $this->dao->select('*')->from(TABLE_API_SPEC)
|
||||
->where($where)
|
||||
->fetchAll();
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get api doc list by module id
|
||||
*
|
||||
* @param int $libID
|
||||
* @param int $moduleID
|
||||
* @param int $release
|
||||
* @return array $list
|
||||
* @author thanatos thanatos915@163.com
|
||||
*/
|
||||
public function getListByModuleId($libID = 0, $moduleID = 0)
|
||||
public function getListByModuleId($libID = 0, $moduleID = 0, $release = 0)
|
||||
{
|
||||
if($moduleID > 0)
|
||||
/* Get release info. */
|
||||
if($release > 0)
|
||||
{
|
||||
$sub = $this->dao->select('id')->from(TABLE_MODULE)->where('FIND_IN_SET(' . $moduleID . ', path)')->processSQL();
|
||||
$where = 'module in (' . $sub . ')';
|
||||
$rel = $this->getReleaseById($release);
|
||||
|
||||
$where = '1=1 ';
|
||||
if($moduleID > 0)
|
||||
{
|
||||
$sub = array();
|
||||
foreach($rel->snap['modules'] as $module)
|
||||
{
|
||||
$tmp = explode(',', $module['path']);
|
||||
if(in_array($moduleID, $tmp))
|
||||
{
|
||||
$sub[] = $module['id'];
|
||||
}
|
||||
}
|
||||
$where .= 'and module in (' . implode(',', $sub) . ')';
|
||||
}
|
||||
|
||||
$list = $this->getApiListByRelease($rel, $where);
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = 'lib = ' . $libID;
|
||||
|
||||
if($moduleID > 0)
|
||||
{
|
||||
$sub = $this->dao->select('id')->from(TABLE_MODULE)->where('FIND_IN_SET(' . $moduleID . ', path)')->processSQL();
|
||||
$where = 'module in (' . $sub . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = 'lib = ' . $libID;
|
||||
}
|
||||
$list = $this->dao->select('*')
|
||||
->from(TABLE_API)
|
||||
->where($where)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchAll();
|
||||
}
|
||||
$list = $this->dao->select('*')
|
||||
->from(TABLE_API)
|
||||
->where($where)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchAll();
|
||||
array_map(function ($item) {
|
||||
$item->params = json_decode(htmlspecialchars_decode($item->params), true);
|
||||
return $item;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<?php for($version = $api->version; $version > 0; $version--):?>
|
||||
<li>
|
||||
<a href='javascript:void(0)'
|
||||
data-url='<?php echo $this->createLink('api', 'index', "libID=0&moduleID=0&apiID=$apiID&version=$version");?>'>#<?php echo $version;?></a>
|
||||
data-url='<?php echo $this->createLink('api', 'index', "libID={$api->lib}&moduleID=0&apiID=$apiID&version=$version&release=$release");?>'>#<?php echo $version;?></a>
|
||||
</li>
|
||||
<?php endfor;?>
|
||||
</ul>
|
||||
@@ -29,13 +29,16 @@
|
||||
<div class="actions">
|
||||
<?php
|
||||
echo html::a("javascript:fullScreen()", '<i class="icon-fullscreen"></i>', '', "title='{$lang->fullscreen}' class='btn btn-link fullscreen-btn'");
|
||||
if(common::hasPriv('api', 'edit')) echo html::a(inlink('edit', "apiID=$api->id"), '<i class="icon-edit"></i>', '', "title='{$lang->api->edit}' class='btn btn-link' data-app='{$this->app->tab}'");
|
||||
if(common::hasPriv('doc', 'delete'))
|
||||
if(!$isRelease)
|
||||
{
|
||||
$deleteURL = $this->createLink('api', 'delete', "apiID=$api->id&confirm=yes");
|
||||
echo html::a("javascript:ajaxDeleteApi(\"$deleteURL\", confirmDelete)", '<i class="icon-trash"></i>', '', "title='{$lang->api->delete}' class='btn btn-link'");
|
||||
if(common::hasPriv('api', 'edit')) echo html::a(inlink('edit', "apiID=$api->id"), '<i class="icon-edit"></i>', '', "title='{$lang->api->edit}' class='btn btn-link' data-app='{$this->app->tab}'");
|
||||
if(common::hasPriv('api', 'delete'))
|
||||
{
|
||||
$deleteURL = $this->createLink('api', 'delete', "apiID=$api->id&confirm=yes");
|
||||
echo html::a("javascript:ajaxDeleteApi(\"$deleteURL\", confirmDelete)", '<i class="icon-trash"></i>', '', "title='{$lang->api->delete}' class='btn btn-link'");
|
||||
}
|
||||
}
|
||||
;?>
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -97,13 +100,13 @@
|
||||
<?php
|
||||
function parseTree($data, $level = 0)
|
||||
{
|
||||
$str = '<tr>';
|
||||
$str = '<tr>';
|
||||
$field = '';
|
||||
for($i=0; $i < $level; $i++)
|
||||
for($i = 0; $i < $level; $i++)
|
||||
{
|
||||
$field .= ' ';
|
||||
$field .= ' ∟ ';
|
||||
}
|
||||
$field .= $data['field'];
|
||||
$field .= $data['field'];
|
||||
$str .= '<td>' . $field . '</td>';
|
||||
$str .= '<td>' . $data['paramsType'] . '</td>';
|
||||
$require = $data['required'] ? '是' : '否';
|
||||
|
||||
@@ -122,7 +122,7 @@ js::set('struct_paramsType', $lang->struct->paramsType);
|
||||
<tr>
|
||||
<th class="w-300px"><?php echo $lang->struct->field;?></th>
|
||||
<th class="w-80px"><?php echo $lang->struct->required;?></th>
|
||||
<th class="w-200px"><?php echo $lang->struct->desc;?></th>
|
||||
<th class="w-300px"><?php echo $lang->struct->desc;?></th>
|
||||
<th><?php echo $lang->struct->action;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -138,7 +138,7 @@ js::set('struct_paramsType', $lang->struct->paramsType);
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td class="w-200px">
|
||||
<td class="w-300px">
|
||||
<input type="text" placeholder="<?php echo $lang->struct->desc;?>" autocomplete="off" class="form-control" v-model="item.desc">
|
||||
</td>
|
||||
<td>
|
||||
@@ -157,7 +157,7 @@ js::set('struct_paramsType', $lang->struct->paramsType);
|
||||
<tr>
|
||||
<th class="w-300px"><?php echo $lang->struct->field;?></th>
|
||||
<th class="w-80px"><?php echo $lang->struct->required;?></th>
|
||||
<th class="w-200px"><?php echo $lang->struct->desc;?></th>
|
||||
<th class="w-300px"><?php echo $lang->struct->desc;?></th>
|
||||
<th><?php echo $lang->struct->action;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -173,7 +173,7 @@ js::set('struct_paramsType', $lang->struct->paramsType);
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td class="w-200px">
|
||||
<td class="w-300px">
|
||||
<input type="text" placeholder="<?php echo $lang->struct->desc;?>" autocomplete="off" class="form-control" v-model="item.desc">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -18,16 +18,25 @@
|
||||
<div class="side-col" style="width:<?php echo $sideWidth; ?>px" data-min-width="<?php echo $sideWidth; ?>">
|
||||
<div class="cell" style="min-height: 286px">
|
||||
<div id='title'>
|
||||
<li class='menu-title'><?php echo $this->lang->api->apiDoc; ?></li>
|
||||
<li class='menu-title'><?php echo $this->lang->api->module; ?></li>
|
||||
<?php
|
||||
echo "<div class='menu-actions'>";
|
||||
echo html::a('javascript:;', "<i class='icon icon-ellipsis-v'></i>", '', "data-toggle='dropdown' class='btn btn-link'");
|
||||
echo "<ul class='dropdown-menu pull-right'>";
|
||||
echo '<li>' . html::a($this->createLink('tree', 'browse', "rootID=$libID&view=api", '', true), '<i class="icon-cog-outline"></i> ' . $this->lang->api->manageType, '', "class='iframe'") . '</li>';
|
||||
echo "<li class='divider'></li>";
|
||||
echo '<li>' . html::a($this->createLink('api', 'editLib', "rootID=$libID"), '<i class="icon-edit"></i> ' . $lang->api->editLib, '', "class='iframe'") . '</li>';
|
||||
echo '<li>' . html::a($this->createLink('api', 'deleteLib', "rootID=$libID"), '<i class="icon-trash"></i> ' . $lang->api->deleteLib, 'hiddenwin') . '</li>';
|
||||
echo '</ul></div>';
|
||||
if(!$isRelease)
|
||||
{
|
||||
echo "<div class='menu-actions'>";
|
||||
echo html::a('javascript:;', "<i class='icon icon-ellipsis-v'></i>", '', "data-toggle='dropdown' class='btn btn-link'");
|
||||
echo "<ul class='dropdown-menu pull-right'>";
|
||||
echo '<li>' . html::a($this->createLink('tree', 'browse', "rootID=$libID&view=api", '', true), '<i class="icon-cog-outline"></i> ' . $this->lang->api->manageType, '', "class='iframe'") . '</li>';
|
||||
echo "<li class='divider'></li>";
|
||||
if(common::hasPriv('api', 'createLib'))
|
||||
{
|
||||
echo '<li>' . html::a($this->createLink('api', 'editLib', "rootID=$libID"), '<i class="icon-edit"></i> ' . $lang->api->editLib, '', "class='iframe'") . '</li>';
|
||||
}
|
||||
if(common::hasPriv('api', 'deleteLib'))
|
||||
{
|
||||
echo '<li>' . html::a($this->createLink('api', 'deleteLib', "rootID=$libID"), '<i class="icon-trash"></i> ' . $lang->api->deleteLib, 'hiddenwin') . '</li>';
|
||||
}
|
||||
echo '</ul></div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php if(!$moduleTree): ?>
|
||||
@@ -40,52 +49,54 @@
|
||||
<?php endif;?>
|
||||
|
||||
<?php if($apiID):?>
|
||||
<?php include './content.html.php';?>
|
||||
<?php include './content.html.php'; ?>
|
||||
<?php else: ?>
|
||||
<?php if(empty($libs) || empty($apiList)): ?>
|
||||
<div class="cell">
|
||||
<div class="detail">
|
||||
<li class="detail-title"><?php echo intval($libID) > 0 ? $lang->api->module : $lang->api->title; ?></li>
|
||||
<?php if(empty($libs) || empty($apiList)): ?>
|
||||
<div class="cell">
|
||||
<div class="detail">
|
||||
<li class="detail-title"><?php echo intval($libID) > 0 ? $lang->api->apiList : $lang->api->title; ?></li>
|
||||
</div>
|
||||
<div class="detail">
|
||||
<div class="no-content"><img src="<?php echo $config->webRoot . 'theme/default/images/main/no_content.png' ?>"/>
|
||||
</div>
|
||||
<div class="detail">
|
||||
<div class="no-content"><img src="<?php echo $config->webRoot . 'theme/default/images/main/no_content.png' ?>"/></div>
|
||||
<div class="notice text-muted"><?php echo (empty($libs)) ? $lang->api->noLib : $lang->api->noApi; ?></div>
|
||||
<div class="no-content-button">
|
||||
<?php
|
||||
$html = '';
|
||||
if($libID && common::hasPriv('api', 'create'))
|
||||
{
|
||||
$html = html::a(helper::createLink('api', 'create', "libID={$libID}"), '<i class="icon icon-plus"></i> ' . $lang->api->createApi, '', 'class="btn btn-info btn-wide"');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html = html::a(helper::createLink('api', 'createLib'), '<i class="icon icon-plus"></i> ' . $lang->api->createLib, '', 'class="btn btn-info btn-wide iframe"');
|
||||
}
|
||||
echo $html;
|
||||
?>
|
||||
</div>
|
||||
<div class="notice text-muted"><?php echo (empty($libs)) ? $lang->api->noLib : $lang->api->noApi; ?></div>
|
||||
<div class="no-content-button">
|
||||
<?php
|
||||
$html = '';
|
||||
if($libID && common::hasPriv('api', 'create'))
|
||||
{
|
||||
$html = html::a(helper::createLink('api', 'create', "libID={$libID}"), '<i class="icon icon-plus"></i> ' . $lang->api->createApi, '', 'class="btn btn-info btn-wide"');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html = html::a(helper::createLink('api', 'createLib'), '<i class="icon icon-plus"></i> ' . $lang->api->createLib, '', 'class="btn btn-info btn-wide iframe"');
|
||||
}
|
||||
echo $html;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="cell">
|
||||
<div class="detail">
|
||||
<ul class="list-group">
|
||||
<?php foreach($apiList as $api): ?>
|
||||
<li class="list-group-item">
|
||||
<div class="heading <?php echo $api->method;?>">
|
||||
<a href="<?php echo helper::createLink('api', 'index', 'libID=0&moduleID=0&apiID='. $api->id) ?>">
|
||||
<span class="label label-primary"><?php echo $api->method; ?></span>
|
||||
<span class="label label-warning" style="width: 60px"><?php echo apiModel::getApiStatusText($api->status); ?></span>
|
||||
<span class="path"><?php echo $api->path; ?></span>
|
||||
<span class="desc"><?php echo $api->title; ?></span>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="cell">
|
||||
<div class="detail">
|
||||
<ul class="list-group">
|
||||
<?php foreach($apiList as $api): ?>
|
||||
<li class="list-group-item">
|
||||
<div class="heading <?php echo $api->method;?>">
|
||||
<a href="<?php echo helper::createLink('api', 'index', "libID={$api->lib}&moduleID=0&apiID={$api->id}&version=0&release=$release") ?>">
|
||||
<span class="label label-primary"><?php echo $api->method; ?></span>
|
||||
<span class="label label-warning"
|
||||
style="width: 60px"><?php echo apiModel::getApiStatusText($api->status); ?></span>
|
||||
<span class="path"><?php echo $api->path; ?></span>
|
||||
<span class="desc"><?php echo $api->title; ?></span>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php'; ?>
|
||||
|
||||
+46
-24
@@ -86,7 +86,7 @@ class docModel extends model
|
||||
$executions = $this->loadModel('execution')->getPairs();
|
||||
|
||||
$libPairs = array();
|
||||
while($lib = $stmt->fetch())
|
||||
while ($lib = $stmt->fetch())
|
||||
{
|
||||
if($lib->product != 0 and !isset($products[$lib->product])) continue;
|
||||
if($lib->execution != 0 and !isset($executions[$lib->execution])) continue;
|
||||
@@ -108,7 +108,7 @@ class docModel extends model
|
||||
if(!empty($appendLibs))
|
||||
{
|
||||
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('id')->in($appendLibs)->orderBy('`order`, id desc')->query();
|
||||
while($lib = $stmt->fetch())
|
||||
while ($lib = $stmt->fetch())
|
||||
{
|
||||
if(!isset($libPairs[$lib->id]) and $this->checkPrivLib($lib, $extra)) $libPairs[$lib->id] = $lib->name;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class docModel extends model
|
||||
|
||||
$account = ",{$this->app->user->account},";
|
||||
$userGroups = $this->app->user->groups;
|
||||
while($lib = $stmt->fetch())
|
||||
while ($lib = $stmt->fetch())
|
||||
{
|
||||
if(strpos(",$lib->users,", $account) !== false)
|
||||
{
|
||||
@@ -219,9 +219,10 @@ class docModel extends model
|
||||
->exec();
|
||||
|
||||
$changes = array();
|
||||
if(!dao::isError()) {
|
||||
if(!dao::isError())
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$changes = common::createChanges($oldDoc, $data);
|
||||
$changes = common::createChanges($oldDoc, $data);
|
||||
$actionID = $this->action->create('docLib', $id, 'Edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
@@ -460,7 +461,7 @@ class docModel extends model
|
||||
->query();
|
||||
|
||||
$docIdList = array();
|
||||
while($doc = $stmt->fetch())
|
||||
while ($doc = $stmt->fetch())
|
||||
{
|
||||
if($this->checkPrivDoc($doc)) $docIdList[$doc->id] = $doc->id;
|
||||
}
|
||||
@@ -1037,7 +1038,7 @@ class docModel extends model
|
||||
$executionLibs = array();
|
||||
|
||||
$otherLibs = array();
|
||||
while($lib = $stmt->fetch())
|
||||
while ($lib = $stmt->fetch())
|
||||
{
|
||||
if($lib->type == 'product')
|
||||
{
|
||||
@@ -2170,16 +2171,26 @@ EOT;
|
||||
*
|
||||
* @author thanatos thanatos915@163.com
|
||||
*/
|
||||
public function getApiModuleTree($rootID, &$docID = 0)
|
||||
public function getApiModuleTree($rootID, &$docID = 0, $release = 0)
|
||||
{
|
||||
$startModulePath = '';
|
||||
$currentMethod = $this->app->getMethodName();
|
||||
$users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->loadModel('api');
|
||||
|
||||
if($release)
|
||||
{
|
||||
$rel = $this->api->getReleaseById($release);
|
||||
$docs = $this->api->getApiListByRelease($rel);
|
||||
}
|
||||
else
|
||||
{
|
||||
$docs = $this->dao->select('*')->from(TABLE_API)
|
||||
->where('lib')->eq($rootID)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
$docs = $this->dao->select('*')->from(TABLE_API)
|
||||
->where('lib')->eq($rootID)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchAll();
|
||||
$moduleDocs = array();
|
||||
foreach($docs as $doc)
|
||||
{
|
||||
@@ -2189,18 +2200,29 @@ EOT;
|
||||
}
|
||||
|
||||
$treeMenu = array();
|
||||
$query = $this->dao->select('*')->from(TABLE_MODULE)
|
||||
->where('root')->eq((int)$rootID)
|
||||
->andWhere('type')->eq('api')
|
||||
->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi()
|
||||
->andWhere('deleted')->eq(0)
|
||||
->orderBy('grade desc, `order`')
|
||||
->get();
|
||||
$stmt = $this->dbh->query($query);
|
||||
while($module = $stmt->fetch())
|
||||
if($release)
|
||||
{
|
||||
$this->buildTree($treeMenu, 'api', 0, $rootID, $module, $moduleDocs, $docID);
|
||||
foreach($release->snap['modules'] as $module)
|
||||
{
|
||||
$this->buildTree($treeMenu, 'api', 0, $rootID, $module, $moduleDocs, $docID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $this->dao->select('*')->from(TABLE_MODULE)
|
||||
->where('root')->eq((int)$rootID)
|
||||
->andWhere('type')->eq('api')
|
||||
->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi()
|
||||
->andWhere('deleted')->eq(0)
|
||||
->orderBy('grade desc, `order`')
|
||||
->get();
|
||||
$stmt = $this->dbh->query($query);
|
||||
while ($module = $stmt->fetch())
|
||||
{
|
||||
$this->buildTree($treeMenu, 'api', 0, $rootID, $module, $moduleDocs, $docID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($moduleDocs[0]))
|
||||
{
|
||||
@@ -2266,7 +2288,7 @@ EOT;
|
||||
->orderBy('grade desc, `order`')
|
||||
->get();
|
||||
$stmt = $this->dbh->query($query);
|
||||
while($module = $stmt->fetch())
|
||||
while ($module = $stmt->fetch())
|
||||
{
|
||||
$this->buildTree($treeMenu, $type, $objectID, $rootID, $module, $moduleDocs, $docID);
|
||||
}
|
||||
@@ -2411,7 +2433,7 @@ EOT;
|
||||
|
||||
/* Unit conversion. */
|
||||
$i = 0;
|
||||
while($sizeCount > 1024 and $i <= 4)
|
||||
while ($sizeCount > 1024 and $i <= 4)
|
||||
{
|
||||
$sizeCount = $sizeCount / 1024;
|
||||
$i++;
|
||||
|
||||
@@ -1061,6 +1061,36 @@ $lang->doc->methodOrder[60] = 'collect';
|
||||
$lang->doc->methodOrder[65] = 'tableContents';
|
||||
$lang->doc->methodOrder[70] = 'showFiles';
|
||||
|
||||
/* Api Lib */
|
||||
$lang->resource->apiDoc = new stdClass();
|
||||
$lang->resource->apiDoc->index = 'index';
|
||||
$lang->resource->apiDoc->createLib = 'createLib';
|
||||
$lang->resource->apiDoc->editLib = 'editLib';
|
||||
$lang->resource->apiDoc->deleteLib = 'deleteLib';
|
||||
$lang->resource->apiDoc->publish = 'publish';
|
||||
$lang->resource->apiDoc->struct = 'structPage';
|
||||
$lang->resource->apiDoc->createStruct = 'createStruct';
|
||||
$lang->resource->apiDoc->editStruct = 'editStruct';
|
||||
$lang->resource->apiDoc->deleteStruct = 'deleteStruct';
|
||||
$lang->resource->apiDoc->create = 'createApi';
|
||||
$lang->resource->apiDoc->edit = 'editApi';
|
||||
$lang->resource->apiDoc->delete = 'deleteApi';
|
||||
|
||||
$lang->apiDoc->methodOrder[0] = 'index';
|
||||
$lang->apiDoc->methodOrder[5] = 'createLib';
|
||||
$lang->apiDoc->methodOrder[10] = 'editLib';
|
||||
$lang->apiDoc->methodOrder[15] = 'deleteLib';
|
||||
$lang->apiDoc->methodOrder[20] = 'publish';
|
||||
$lang->apiDoc->methodOrder[25] = 'structPage';
|
||||
$lang->apiDoc->methodOrder[30] = 'createStruct';
|
||||
$lang->apiDoc->methodOrder[35] = 'editStruct';
|
||||
$lang->apiDoc->methodOrder[40] = 'deleteStruct';
|
||||
$lang->apiDoc->methodOrder[45] = 'createApi';
|
||||
$lang->apiDoc->methodOrder[50] = 'editApi';
|
||||
$lang->apiDoc->methodOrder[55] = 'deleteApi';
|
||||
|
||||
|
||||
|
||||
/* Mail. */
|
||||
$lang->resource->mail = new stdclass();
|
||||
$lang->resource->mail->index = 'index';
|
||||
|
||||
@@ -57,8 +57,8 @@ $lang->task->common = '任务';
|
||||
$lang->task->id = '编号';
|
||||
$lang->task->project = '所属项目';
|
||||
$lang->task->execution = '所属' . $lang->execution->common;
|
||||
$lang->task->module = '所属模块';
|
||||
$lang->task->moduleAB = '模块';
|
||||
$lang->task->module = '目录';
|
||||
$lang->task->moduleAB = '目录';
|
||||
$lang->task->story = "相关{$lang->SRCommon}";
|
||||
$lang->task->storyAB = $lang->SRCommon;
|
||||
$lang->task->storySpec = "{$lang->SRCommon}描述";
|
||||
|
||||
Reference in New Issue
Block a user