Merge branch 'sprint/167_xiawenlong' into 'sprint/167'
Sprint/167 xiawenlong See merge request easycorp/zentaopms!109
This commit is contained in:
@@ -251,6 +251,7 @@ $config->objectTables['testtask'] = TABLE_TESTTASK;
|
||||
$config->objectTables['testsuite'] = TABLE_TESTSUITE;
|
||||
$config->objectTables['testreport'] = TABLE_TESTREPORT;
|
||||
$config->objectTables['user'] = TABLE_USER;
|
||||
$config->objectTables['api'] = TABLE_API;
|
||||
$config->objectTables['doc'] = TABLE_DOC;
|
||||
$config->objectTables['doclib'] = TABLE_DOCLIB;
|
||||
$config->objectTables['todo'] = TABLE_TODO;
|
||||
|
||||
@@ -13,6 +13,7 @@ $config->action->objectNameFields['testcase'] = 'title';
|
||||
$config->action->objectNameFields['case'] = 'title';
|
||||
$config->action->objectNameFields['testtask'] = 'name';
|
||||
$config->action->objectNameFields['user'] = 'account';
|
||||
$config->action->objectNameFields['api'] = 'title';
|
||||
$config->action->objectNameFields['doc'] = 'title';
|
||||
$config->action->objectNameFields['doclib'] = 'name';
|
||||
$config->action->objectNameFields['todo'] = 'name';
|
||||
|
||||
@@ -97,6 +97,7 @@ $lang->action->objectTypes['testsuite'] = 'Suite';
|
||||
$lang->action->objectTypes['testtask'] = 'Test Build';
|
||||
$lang->action->objectTypes['testreport'] = 'Report';
|
||||
$lang->action->objectTypes['doc'] = 'Document';
|
||||
$lang->action->objectTypes['api'] = 'Interface';
|
||||
$lang->action->objectTypes['doclib'] = 'Document Library';
|
||||
$lang->action->objectTypes['api'] = 'Interface Library';
|
||||
$lang->action->objectTypes['apistruct'] = 'API struct';
|
||||
|
||||
@@ -97,6 +97,7 @@ $lang->action->objectTypes['testsuite'] = '套件';
|
||||
$lang->action->objectTypes['testtask'] = '测试单';
|
||||
$lang->action->objectTypes['testreport'] = '报告';
|
||||
$lang->action->objectTypes['doc'] = '文档';
|
||||
$lang->action->objectTypes['api'] = '接口';
|
||||
$lang->action->objectTypes['doclib'] = '文档库';
|
||||
$lang->action->objectTypes['api'] = '接口库';
|
||||
$lang->action->objectTypes['apistruct'] = '数据结构';
|
||||
|
||||
@@ -57,6 +57,11 @@
|
||||
$methodName = 'view';
|
||||
$module = 'caselib';
|
||||
}
|
||||
if($action->objectType == 'api')
|
||||
{
|
||||
$params = "libID=0&moduelID=0&apiID={$action->objectID}";
|
||||
$methodName = 'index';
|
||||
}
|
||||
if(isset($config->action->customFlows[$action->objectType]))
|
||||
{
|
||||
$flow = $config->action->customFlows[$action->objectType];
|
||||
|
||||
+39
-15
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The control file of api of ZenTaoPMS.
|
||||
*
|
||||
@@ -32,16 +33,6 @@ class api extends control
|
||||
*/
|
||||
public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0, $release = 0)
|
||||
{
|
||||
/* Get all api doc libraries. */
|
||||
$libs = $this->doc->getApiLibs();
|
||||
|
||||
/* Generate bread crumbs dropMenu. */
|
||||
if($libs)
|
||||
{
|
||||
if($libID == 0) $libID = key($libs);
|
||||
$this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID, $release);
|
||||
}
|
||||
$this->setMenu($libID);
|
||||
|
||||
/* Get an api doc. */
|
||||
if($apiID > 0)
|
||||
@@ -67,9 +58,20 @@ class api extends control
|
||||
$this->view->apiList = $apiList;
|
||||
}
|
||||
|
||||
/* Get all api doc libraries. */
|
||||
$libs = $this->doc->getApiLibs();
|
||||
|
||||
/* Generate bread crumbs dropMenu. */
|
||||
if($libs)
|
||||
{
|
||||
if($libID == 0) $libID = key($libs);
|
||||
$this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID, $release);
|
||||
}
|
||||
$this->setMenu($libID);
|
||||
|
||||
$this->view->isRelease = $release > 0;
|
||||
$this->view->release = $release;
|
||||
$this->view->title = $this->lang->api->title;
|
||||
$this->view->title = $this->lang->api->pageTitle;
|
||||
$this->view->libID = $libID;
|
||||
$this->view->apiID = $apiID;
|
||||
$this->view->libs = $libs;
|
||||
@@ -210,6 +212,7 @@ class api extends control
|
||||
$userId = $this->app->user->account;
|
||||
$data = fixer::input('post')
|
||||
->add('lib', $libID)
|
||||
->skipSpecial('attribute')
|
||||
->add('addedBy', $userId)
|
||||
->add('addedDate', $now)
|
||||
->add('editedBy', $userId)
|
||||
@@ -231,6 +234,7 @@ class api extends control
|
||||
}
|
||||
$this->view->typeOptions = $options;
|
||||
$this->view->title = $this->lang->api->createStruct;
|
||||
$this->view->gobackLink = $this->createLink('api', 'struct', "libID=$libID");
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -253,6 +257,7 @@ class api extends control
|
||||
$now = helper::now();
|
||||
$userId = $this->app->user->account;
|
||||
$data = fixer::input('post')
|
||||
->skipSpecial('attribute')
|
||||
->add('lib', $struct->lib)
|
||||
->add('editedBy', $userId)
|
||||
->add('editedDate', $now)
|
||||
@@ -383,7 +388,7 @@ class api extends control
|
||||
{
|
||||
if($confirm == 'no')
|
||||
{
|
||||
die(js::confirm($this->lang->doc->confirmDeleteLib, $this->createLink('api', 'deleteLib', "libID=$libID&confirm=yes")));
|
||||
die(js::confirm($this->lang->api->confirmDeleteLib, $this->createLink('api', 'deleteLib', "libID=$libID&confirm=yes")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -415,6 +420,7 @@ class api extends control
|
||||
$userId = $this->app->user->account;
|
||||
$params = fixer::input('post')
|
||||
->remove('type')
|
||||
->skipSpecial('params,response')
|
||||
->add('addedBy', $userId)
|
||||
->add('addedDate', $now)
|
||||
->add('editedBy', $userId)
|
||||
@@ -449,6 +455,7 @@ class api extends control
|
||||
$options[] = array('label' => $item, 'value' => $key);
|
||||
}
|
||||
$this->view->typeOptions = $options;
|
||||
$this->view->gobackLink = $this->createLink('api', 'index', "libID={$api->lib}&moduleID={$api->module}");
|
||||
$this->view->user = $this->app->user->account;
|
||||
$this->view->allUsers = $this->loadModel('user')->getPairs('devfirst|noclosed');;
|
||||
$this->view->moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($api->lib, 'api', $startModuleID = 0);
|
||||
@@ -474,6 +481,7 @@ class api extends control
|
||||
$now = helper::now();
|
||||
$params = fixer::input('post')
|
||||
->remove('type')
|
||||
->skipSpecial('params,response')
|
||||
->add('addedBy', $this->app->user->account)
|
||||
->add('addedDate', $now)
|
||||
->add('editedBy', $this->app->user->account)
|
||||
@@ -501,6 +509,7 @@ class api extends control
|
||||
$example = json_encode($example, JSON_PRETTY_PRINT);
|
||||
|
||||
$this->getTypeOptions($libID);
|
||||
$this->view->gobackLink = $this->createLink('api', 'index', "libID=$libID&moduleID=$moduleID");
|
||||
$this->view->user = $this->app->user->account;
|
||||
$this->view->allUsers = $this->loadModel('user')->getPairs('devfirst|noclosed');
|
||||
$this->view->libID = $libID;
|
||||
@@ -595,6 +604,21 @@ class api extends control
|
||||
$this->sendSuccess(array('info' => $info));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get all child module.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetChild($libID, $type = 'module')
|
||||
{
|
||||
$this->loadModel('tree');
|
||||
$childModules = $this->tree->getOptionMenu($libID, 'api');
|
||||
$select = ($type == 'module') ? html::select('module', $childModules, '', "class='form-control chosen'") : html::select('parent', $childModules, '', "class='form-control chosen'");
|
||||
die($select);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set doc menu by method name.
|
||||
*
|
||||
@@ -665,7 +689,7 @@ class api extends control
|
||||
private function generateLibsDropMenu($libs, $libID, $version = 0)
|
||||
{
|
||||
if(empty($libs)) return '';
|
||||
if (!isset($libs[$libID])) return '';
|
||||
if(!isset($libs[$libID])) return '';
|
||||
|
||||
$libName = $libs[$libID]->name;
|
||||
$output = <<<EOT
|
||||
@@ -685,7 +709,7 @@ EOT;
|
||||
foreach($libs as $key => $lib)
|
||||
{
|
||||
$selected = $key == $libID ? 'selected' : '';
|
||||
$output .= html::a(inlink('index', "libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'");
|
||||
$output .= html::a(inlink('index', "libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'");
|
||||
}
|
||||
$output .= "</div></div></div></div></div>";
|
||||
|
||||
@@ -694,7 +718,7 @@ EOT;
|
||||
if(!empty($versions))
|
||||
{
|
||||
$versionName = $version > 0 ? $versions[$version]->version : $this->lang->api->defaultVersion;
|
||||
$output .= <<<EOT
|
||||
$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>
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
function loadDocModule(libID)
|
||||
{
|
||||
var link = createLink('api', 'ajaxGetChild', 'libID=' + libID + '&type=parent');
|
||||
$.post(link, function(data)
|
||||
{
|
||||
$('#module').empty().append($(data).children()).trigger('chosen:updated');
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Toggle acl.
|
||||
*
|
||||
@@ -378,6 +386,7 @@ try {
|
||||
data.push(field);
|
||||
},
|
||||
del(data, index) {
|
||||
if(data.length <= 1) return;
|
||||
data.splice(index, 1)
|
||||
},
|
||||
changeType() {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
$(function()
|
||||
{
|
||||
$('#top-submit').click(function()
|
||||
{
|
||||
$(this).addClass('disabled');
|
||||
$('form').submit();
|
||||
})
|
||||
})
|
||||
var app = new Vue({
|
||||
el: '#apiApp',
|
||||
data: {
|
||||
|
||||
@@ -43,7 +43,8 @@ $lang->api->createStruct = 'Create Data Structure';
|
||||
$lang->api->editStruct = 'Edit Data Structure';
|
||||
$lang->api->deleteStruct = 'Delete Data Structure';
|
||||
$lang->api->create = 'Ceate Doc';
|
||||
$lang->api->title = 'Api Library';
|
||||
$lang->api->title = 'Interface Name';
|
||||
$lang->api->pageTitle = 'Api Library';
|
||||
$lang->api->module = 'Directory';
|
||||
$lang->api->apiDoc = 'Interface';
|
||||
$lang->api->manageType = 'Manage Directory';
|
||||
@@ -104,6 +105,7 @@ $lang->api->desc = 'Description';
|
||||
$lang->api->control = 'Access Control';
|
||||
$lang->api->noLib = 'There is no interface library at present。';
|
||||
$lang->api->noApi = 'There is no interface for the time being。';
|
||||
$lang->api->noStruct = 'There is no structure for the time being。';
|
||||
$lang->api->lib = 'Interface Library';
|
||||
$lang->api->apiList = 'Interface List';
|
||||
$lang->api->formTitle = 'Interface Name';
|
||||
@@ -195,6 +197,12 @@ $lang->api->requiredOptions = array(0 => 'No', 1 => 'Yes');
|
||||
$lang->doclib = new stdclass();
|
||||
$lang->doclib->name = 'Interface Library Name';
|
||||
|
||||
$lang->apistruct = new stdClass();
|
||||
$lang->apistruct->name = 'Structure Name';
|
||||
|
||||
$lang->api_lib_release = new stdClass();
|
||||
$lang->api_lib_release->version = 'Version';
|
||||
|
||||
$lang->api->error = new stdclass();
|
||||
$lang->api->error->onlySelect = 'SQL interface only allow SELECT query.';
|
||||
$lang->api->error->disabled = 'For security reasons, this feature is disabled. You can go to the config directory and modify the configuration item %s to open this function.';
|
||||
|
||||
@@ -16,7 +16,7 @@ $lang->api->sql = 'SQL查询接口';
|
||||
|
||||
$lang->api->index = '接口库主页';
|
||||
$lang->api->editLib = '编辑接口库';
|
||||
$lang->api->editPublish = '编辑版本';
|
||||
$lang->api->editPublish = '版本管理';
|
||||
$lang->api->deleteLib = '删除接口库';
|
||||
$lang->api->publish = '发布接口';
|
||||
$lang->api->createLib = '创建接口库';
|
||||
@@ -43,7 +43,8 @@ $lang->api->createStruct = '创建数据结构';
|
||||
$lang->api->editStruct = '修改数据结构';
|
||||
$lang->api->deleteStruct = '删除数据结构';
|
||||
$lang->api->create = '创建接口';
|
||||
$lang->api->title = '接口库';
|
||||
$lang->api->title = '接口名称';
|
||||
$lang->api->pageTitle = '接口库';
|
||||
$lang->api->module = '目录';
|
||||
$lang->api->apiDoc = '接口';
|
||||
$lang->api->manageType = '维护目录';
|
||||
@@ -103,6 +104,7 @@ $lang->api->desc = '描述';
|
||||
$lang->api->control = '访问控制';
|
||||
$lang->api->noLib = '暂时没有接口库。';
|
||||
$lang->api->noApi = '暂时没有接口。';
|
||||
$lang->api->noStruct = '暂时没有数据结构。';
|
||||
$lang->api->lib = '所属接口库';
|
||||
$lang->api->apiList = '接口列表';
|
||||
$lang->api->formTitle = '接口名称';
|
||||
@@ -198,6 +200,9 @@ $lang->doclib->name = '接口库名称';
|
||||
$lang->apistruct = new stdClass();
|
||||
$lang->apistruct->name = '结构名';
|
||||
|
||||
$lang->api_lib_release = new stdClass();
|
||||
$lang->api_lib_release->version = '版本';
|
||||
|
||||
$lang->api->error = new stdclass();
|
||||
$lang->api->error->onlySelect = 'SQL查询接口只允许SELECT查询';
|
||||
$lang->api->error->disabled = '因为安全原因,该功能被禁用。可以到config目录,修改配置项 %s,打开此功能。';
|
||||
|
||||
+70
-65
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The model file of api module of ZenTaoCMS.
|
||||
*
|
||||
@@ -12,23 +13,23 @@
|
||||
class apiModel extends model
|
||||
{
|
||||
/* Status. */
|
||||
const STATUS_DOING = 'doing';
|
||||
const STATUS_DONE = 'done';
|
||||
const STATUS_DOING = 'doing';
|
||||
const STATUS_DONE = 'done';
|
||||
const STATUS_HIDDEN = 'hidden';
|
||||
|
||||
/* Scope. */
|
||||
const SCOPE_QUERY = 'query';
|
||||
const SCOPE_QUERY = 'query';
|
||||
const SCOPE_FORM_DATA = 'formData';
|
||||
const SCOPE_PATH = 'path';
|
||||
const SCOPE_BODY = 'body';
|
||||
const SCOPE_HEADER = 'header';
|
||||
const SCOPE_COOKIE = 'cookie';
|
||||
const SCOPE_PATH = 'path';
|
||||
const SCOPE_BODY = 'body';
|
||||
const SCOPE_HEADER = 'header';
|
||||
const SCOPE_COOKIE = 'cookie';
|
||||
|
||||
/* Params. */
|
||||
const PARAMS_TYPE_CUSTOM = 'custom';
|
||||
|
||||
/**
|
||||
* @param object $data
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
@@ -68,7 +69,7 @@ class apiModel extends model
|
||||
/**
|
||||
* Delete a lib publish.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
@@ -82,7 +83,7 @@ class apiModel extends model
|
||||
/**
|
||||
* Create an api doc.
|
||||
*
|
||||
* @param object $params
|
||||
* @param object $params
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
@@ -104,7 +105,7 @@ class apiModel extends model
|
||||
/**
|
||||
* Create a global struct
|
||||
*
|
||||
* @param object $data
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
@@ -136,8 +137,8 @@ class apiModel extends model
|
||||
/**
|
||||
* Update a struct.
|
||||
*
|
||||
* @param int $id
|
||||
* @param object $data
|
||||
* @param int $id
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -176,7 +177,7 @@ class apiModel extends model
|
||||
/**
|
||||
* Delete a struct.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
@@ -191,8 +192,8 @@ class apiModel extends model
|
||||
/**
|
||||
* Update an api doc.
|
||||
*
|
||||
* @param int $id
|
||||
* @param object $data
|
||||
* @param int $id
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
@@ -218,7 +219,7 @@ class apiModel extends model
|
||||
/**
|
||||
* Get struct list by api doc id.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -230,7 +231,7 @@ class apiModel extends model
|
||||
->fetchAll();
|
||||
|
||||
array_map(function ($item) {
|
||||
$item->attribute = json_decode(htmlspecialchars_decode($item->attribute), true);
|
||||
$item->attribute = json_decode($item->attribute, true);
|
||||
return $item;
|
||||
}, $res);
|
||||
return $res;
|
||||
@@ -239,7 +240,7 @@ class apiModel extends model
|
||||
/**
|
||||
* Get a struct info.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
@@ -250,7 +251,7 @@ class apiModel extends model
|
||||
->where('id')->eq($id)
|
||||
->fetch();
|
||||
|
||||
if($model) $model->attribute = json_decode(htmlspecialchars_decode($model->attribute), true);
|
||||
if($model) $model->attribute = json_decode($model->attribute, true);
|
||||
|
||||
return $model;
|
||||
}
|
||||
@@ -258,8 +259,8 @@ class apiModel extends model
|
||||
/**
|
||||
* Get release by version.
|
||||
*
|
||||
* @param int $libID
|
||||
* @param string $version
|
||||
* @param int $libID
|
||||
* @param string $version
|
||||
* @return object
|
||||
* @access public
|
||||
*/
|
||||
@@ -270,14 +271,14 @@ class apiModel extends model
|
||||
->where('version')->eq($version)
|
||||
->andWhere('lib')->eq($libID)
|
||||
->fetch();
|
||||
if($model) $model->snap = json_decode(htmlspecialchars_decode($model->snap), true);
|
||||
if($model) $model->snap = json_decode($model->snap, true);
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get release by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -287,14 +288,14 @@ class apiModel extends model
|
||||
->from(TABLE_API_LIB_RELEASE)
|
||||
->where('id')->eq($id)
|
||||
->fetch();
|
||||
if($model) $model->snap = json_decode(htmlspecialchars_decode($model->snap), true);
|
||||
if($model) $model->snap = json_decode($model->snap, true);
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Versions by api id
|
||||
*
|
||||
* @param int $libID
|
||||
* @param int $libID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -310,19 +311,20 @@ class apiModel extends model
|
||||
/**
|
||||
* Get api doc by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $version
|
||||
* @param int $release
|
||||
* @param int $id
|
||||
* @param int $version
|
||||
* @param int $release
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getLibById($id, $version = 0, $release = 0)
|
||||
{
|
||||
if ($release) {
|
||||
if($release)
|
||||
{
|
||||
$rel = $this->getReleaseById($release);
|
||||
foreach ($rel->snap['apis'] as $api)
|
||||
foreach($rel->snap['apis'] as $api)
|
||||
{
|
||||
if ($api['id'] == $id) $version = $api['version'];
|
||||
if($api['id'] == $id) $version = $api['version'];
|
||||
}
|
||||
}
|
||||
if($version)
|
||||
@@ -346,8 +348,8 @@ class apiModel extends model
|
||||
|
||||
if($model)
|
||||
{
|
||||
$model->params = json_decode(htmlspecialchars_decode($model->params), true);
|
||||
$model->response = json_decode(htmlspecialchars_decode($model->response), true);
|
||||
$model->params = json_decode($model->params, true);
|
||||
$model->response = json_decode($model->response, true);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
@@ -355,8 +357,8 @@ class apiModel extends model
|
||||
/**
|
||||
* Get api list by release.
|
||||
*
|
||||
* @param object $release
|
||||
* @param string $where
|
||||
* @param object $release
|
||||
* @param string $where
|
||||
* @return array
|
||||
*/
|
||||
public function getApiListByRelease($release, $where = '')
|
||||
@@ -368,7 +370,7 @@ class apiModel extends model
|
||||
}
|
||||
|
||||
if($strJoin) $where .= 'and (' . implode(' or ', $strJoin) . ')';
|
||||
$list = $this->dao->select('api.lib,spec.*,api.id')->from(TABLE_API)->alias('api')
|
||||
$list = $this->dao->select('api.lib,spec.*,api.id')->from(TABLE_API)->alias('api')
|
||||
->leftJoin(TABLE_API_SPEC)->alias('spec')->on('api.id = spec.doc')
|
||||
->where($where)
|
||||
->fetchAll();
|
||||
@@ -378,9 +380,9 @@ class apiModel extends model
|
||||
/**
|
||||
* Get api doc list by module id
|
||||
*
|
||||
* @param int $libID
|
||||
* @param int $moduleID
|
||||
* @param int $release
|
||||
* @param int $libID
|
||||
* @param int $moduleID
|
||||
* @param int $release
|
||||
* @return array $list
|
||||
* @author thanatos thanatos915@163.com
|
||||
*/
|
||||
@@ -403,7 +405,7 @@ class apiModel extends model
|
||||
$sub[] = $module['id'];
|
||||
}
|
||||
}
|
||||
if ($sub) $where .= 'and module in (' . implode(',', $sub) . ')';
|
||||
if($sub) $where .= 'and module in (' . implode(',', $sub) . ')';
|
||||
}
|
||||
$list = $this->getApiListByRelease($rel, $where);
|
||||
}
|
||||
@@ -426,7 +428,8 @@ class apiModel extends model
|
||||
->fetchAll();
|
||||
}
|
||||
array_map(function ($item) {
|
||||
$item->params = json_decode(htmlspecialchars_decode($item->params), true);
|
||||
$item->params = json_decode($item->params, true);
|
||||
$item->response = json_decode($item->response, true);
|
||||
return $item;
|
||||
}, $list);
|
||||
return $list;
|
||||
@@ -435,14 +438,14 @@ class apiModel extends model
|
||||
/**
|
||||
* Get status text by status.
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $status
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function getApiStatusText($status)
|
||||
{
|
||||
global $lang;
|
||||
switch ($status)
|
||||
switch($status)
|
||||
{
|
||||
case static::STATUS_DOING:
|
||||
{
|
||||
@@ -456,26 +459,27 @@ class apiModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $libID
|
||||
* @param string $pager
|
||||
* @param string $orderBy
|
||||
* @param int $libID
|
||||
* @param string $pager
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getStructByQuery($libID, $pager = '', $orderBy = '')
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_APISTRUCT)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('lib')->eq($libID)
|
||||
return $this->dao->select('s.*,user.realname as addedName')->from(TABLE_APISTRUCT)->alias('s')
|
||||
->leftJoin(TABLE_USER)->alias('user')->on('user.account = s.addedBy')
|
||||
->where('s.deleted')->eq(0)
|
||||
->andWhere('s.lib')->eq($libID)
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $libID
|
||||
* @param string $pager
|
||||
* @param string $orderBy
|
||||
* @param int $libID
|
||||
* @param string $pager
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -491,8 +495,8 @@ class apiModel extends model
|
||||
/**
|
||||
* Get struct tree by lib id
|
||||
*
|
||||
* @param int $libID
|
||||
* @param int $structID
|
||||
* @param int $libID
|
||||
* @param int $structID
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
@@ -525,8 +529,8 @@ class apiModel extends model
|
||||
/**
|
||||
* Get the details of the method by file path.
|
||||
*
|
||||
* @param string $filePath
|
||||
* @param string $ext
|
||||
* @param string $filePath
|
||||
* @param string $ext
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
@@ -562,9 +566,9 @@ class apiModel extends model
|
||||
/**
|
||||
* Request the api.
|
||||
*
|
||||
* @param string $moduleName
|
||||
* @param string $methodName
|
||||
* @param string $action
|
||||
* @param string $moduleName
|
||||
* @param string $methodName
|
||||
* @param string $action
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -606,8 +610,8 @@ class apiModel extends model
|
||||
/**
|
||||
* Query sql.
|
||||
*
|
||||
* @param string $sql
|
||||
* @param string $keyField
|
||||
* @param string $sql
|
||||
* @param string $keyField
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -641,12 +645,13 @@ class apiModel extends model
|
||||
}
|
||||
else
|
||||
{
|
||||
while ($row = $stmt->fetch()) $rows[$row->$keyField] = $row;
|
||||
while($row = $stmt->fetch()) $rows[$row->$keyField] = $row;
|
||||
}
|
||||
|
||||
$result['status'] = 'success';
|
||||
$result['data'] = $rows;
|
||||
} catch (PDOException $e)
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
$result['status'] = 'fail';
|
||||
$result['message'] = $e->getMessage();
|
||||
@@ -658,7 +663,7 @@ class apiModel extends model
|
||||
/**
|
||||
* Get spec of api.
|
||||
*
|
||||
* @param object $data
|
||||
* @param object $data
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -170,8 +170,7 @@
|
||||
<div class='cell'>
|
||||
<?php
|
||||
$canBeChanged = common::canBeChanged('api', $api);
|
||||
if($canBeChanged) $actionFormLink = $this->createLink('action', 'comment', "objectType=doc&objectID=$api->id");
|
||||
;?>
|
||||
if($canBeChanged) $actionFormLink = $this->createLink('action', 'comment', "objectType=api&objectID=$api->id");?>
|
||||
<?php include '../../common/view/action.html.php';?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -69,8 +69,7 @@ js::set('struct_paramsType', $lang->struct->paramsType);
|
||||
<tr>
|
||||
<th><?php echo $lang->api->module;?></th>
|
||||
<td>
|
||||
<span
|
||||
id='moduleBox'><?php echo html::select('module', $moduleOptionMenu, $moduleID, "class='form-control chosen'");?></span>
|
||||
<span id='moduleBox'><?php echo html::select('module', $moduleOptionMenu, $moduleID, "class='form-control chosen'");?></span>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
@@ -177,8 +176,8 @@ js::set('struct_paramsType', $lang->struct->paramsType);
|
||||
<input type="text" placeholder="<?php echo $lang->struct->desc;?>" autocomplete="off" class="form-control" v-model="item.desc">
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-link" type="button" @click="add(query, key, 'query')"><?php echo $lang->struct->add;?></button>
|
||||
<button class="btn btn-link" type="button" @click="del(query, key)"><?php echo $lang->delete;?></button>
|
||||
<button class="btn btn-link" type="button" @click="add(queryP, key, 'query')"><?php echo $lang->struct->add;?></button>
|
||||
<button class="btn btn-link" type="button" @click="del(queryP, key)"><?php echo $lang->delete;?></button>
|
||||
</td>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<?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>
|
||||
<li class="detail-title"><?php echo intval($libID) > 0 ? $lang->api->apiList : $lang->api->pageTitle;?></li>
|
||||
</div>
|
||||
<div class="detail">
|
||||
<div class="no-content"><img src="<?php echo $config->webRoot . 'theme/default/images/main/no_content.png'?>"/>
|
||||
|
||||
@@ -19,6 +19,13 @@
|
||||
<?php common::printLink('api', 'createStruct', "libID=$libID", "<i class='icon icon-plus'></i> " . $lang->api->createStruct, '', "class='btn btn-primary create-user-btn'");?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($structs)):?>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->api->noStruct;?></span>
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<form class='main-table table-user' data-ride='table' method='post' data-checkable='false' id='userListForm'>
|
||||
<table class='table has-sort-head' id='userList'>
|
||||
<thead>
|
||||
@@ -38,7 +45,7 @@
|
||||
<td><?php printf('%03d', $struct->id);?></td>
|
||||
<td><?php echo $struct->type;?></td>
|
||||
<td><?php echo $struct->name;?></td>
|
||||
<td><?php echo $struct->addedBy;?></td>
|
||||
<td><?php echo $struct->addedName;?></td>
|
||||
<td class="c-date"><?php echo $struct->addedDate;?></td>
|
||||
<td class='c-actions'>
|
||||
<?php
|
||||
@@ -51,6 +58,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -1390,7 +1390,7 @@ $lang->resource->api->createLib = 'createLib';
|
||||
$lang->resource->api->editLib = 'editLib';
|
||||
$lang->resource->api->deleteLib = 'deleteLib';
|
||||
$lang->resource->api->publish = 'publish';
|
||||
$lang->resource->api->editPublic = 'editPublish';
|
||||
$lang->resource->api->editPublish = 'editPublish';
|
||||
$lang->resource->api->struct = 'struct';
|
||||
$lang->resource->api->createStruct = 'createStruct';
|
||||
$lang->resource->api->editStruct = 'editStruct';
|
||||
@@ -1408,6 +1408,7 @@ $lang->api->methodOrder[5] = 'createLib';
|
||||
$lang->api->methodOrder[10] = 'editLib';
|
||||
$lang->api->methodOrder[15] = 'deleteLib';
|
||||
$lang->api->methodOrder[20] = 'publish';
|
||||
$lang->api->methodOrder[21] = 'editPublish';
|
||||
$lang->api->methodOrder[25] = 'struct';
|
||||
$lang->api->methodOrder[30] = 'createStruct';
|
||||
$lang->api->methodOrder[35] = 'editStruct';
|
||||
|
||||
Reference in New Issue
Block a user