From 4bb27b624ea9bd18af94f0afece01e9fcbd02a64 Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Tue, 19 Oct 2021 11:00:55 +0800 Subject: [PATCH] * Adjust code for Api doc. --- db/update15.5.sql | 2 +- module/api/control.php | 3 +- module/api/css/common.css | 3 ++ module/api/css/index.css | 7 ++-- module/api/js/common.js | 4 +- module/api/js/create.js | 18 ++++----- module/api/lang/en.php | 31 ++++----------- module/api/lang/zh-cn.php | 39 ++++++------------- module/api/model.php | 4 +- module/api/view/content.html.php | 16 ++------ module/api/view/create.html.php | 16 ++++---- module/api/view/edit.html.php | 21 +++++----- module/group/lang/resource.php | 67 +++++++++++++++----------------- 13 files changed, 91 insertions(+), 140 deletions(-) diff --git a/db/update15.5.sql b/db/update15.5.sql index 5ef89ae5a5..a34d7cff26 100644 --- a/db/update15.5.sql +++ b/db/update15.5.sql @@ -12,7 +12,7 @@ CREATE TABLE `zt_api_lib_release` `version` varchar(255) NOT NULL DEFAULT '', `snap` mediumtext NOT NULL, `addedBy` varchar(30) NOT NULL DEFAULT 0, - `addedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `addedDate` datetime NOT NULL, PRIMARY KEY (`id`) ); diff --git a/module/api/control.php b/module/api/control.php index fa5f0c8566..a7ea5cbc44 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -1,5 +1,4 @@ doc->getLibById($id); + if(!empty($_POST)) { $lib = fixer::input('post')->join('groups', ',')->join('users', ',')->get(); diff --git a/module/api/css/common.css b/module/api/css/common.css index 4e8ea30a42..ed51ede397 100644 --- a/module/api/css/common.css +++ b/module/api/css/common.css @@ -97,3 +97,6 @@ ol, ul {margin-bottom: 0} .c-product, .c-execution, .c-lib {width: 80px !important;} .header-btn .btn > .text {text-overflow: unset !important;} + +.table-data {border: 1px solid #e2e2e3;} +.table-data thead {background: #f9f9f9;} diff --git a/module/api/css/index.css b/module/api/css/index.css index d41249682d..850d27513b 100644 --- a/module/api/css/index.css +++ b/module/api/css/index.css @@ -17,8 +17,8 @@ .main-col .doc-title .version .dropdown-menu a:hover {color: #ffffff;} .main-col .doc-title .actions a + a {margin-left: 8px;} .main-col .doc-title .actions i {font-size: 15px; color: #8c8c8c;} -#content h2.title {margin: 0;} -#content h3.title {font-weight: 500; font-size: 19px!important;} +#content h2.title {margin: 0; font-size: 17px; font-weight: normal;} +#content h3.title {font-weight: 500; font-size: 17px!important;} #content .desc {margin: 10px 0; color: #57585b;} #content .detail-content {padding-left: 10px;} #mainContent .scrollbar-hover {max-height: 2000px; overflow: scroll;} @@ -43,7 +43,6 @@ .outline-content li.text-ellipsis.active>a {font-weight: 700; color: #0c64eb;} #outline li.has-list.open:before {content: unset;} -.title {font-size: 20px !important;} .article-content.comment {width: 100% !important;} .cell .detail .detail-title {padding-left: 5px; list-style: none;} @@ -108,7 +107,7 @@ .detail .list-group-item .desc { width: auto; font-size: 14px; - line-height: 30px; + line-height: 38px; float: right; padding-right: 10px; } diff --git a/module/api/js/common.js b/module/api/js/common.js index 39ea04a053..3f5ae83f31 100644 --- a/module/api/js/common.js +++ b/module/api/js/common.js @@ -265,7 +265,7 @@ try { type: Array, default: [ {label: 'FormData', value: 'formData'}, - {label: 'Json', value: 'json'}, + {label: 'JSON', value: 'json'}, {label: 'Array', value: 'array'}, {label: 'Object', value: 'Object'}, ] @@ -413,4 +413,4 @@ try { ` }); -} catch(e) {} \ No newline at end of file +} catch(e) {} diff --git a/module/api/js/create.js b/module/api/js/create.js index 903d6f6a3f..bdbc7f17f7 100644 --- a/module/api/js/create.js +++ b/module/api/js/create.js @@ -9,8 +9,8 @@ var app = new Vue({ defaultHeader: { field: '', required: '', desc: '' }, }, created() { - this.header.push({...this.defaultHeader}) - this.queryP.push({...this.defaultHeader}) + this.header.push({...this.defaultHeader}); + this.queryP.push({...this.defaultHeader}); }, watch: { header: { @@ -21,13 +21,13 @@ var app = new Vue({ }, queryP: { handler() { - this.setParams() + this.setParams(); }, deep: true }, body: { handler() { - this.setParams() + this.setParams(); }, deep: true } @@ -37,7 +37,7 @@ var app = new Vue({ this.body = val; }, changeRes(val) { - this.response = JSON.stringify(val) + this.response = JSON.stringify(val); }, setParams() { const params = { @@ -49,14 +49,14 @@ var app = new Vue({ }, del(data, key) { if (data.length <= 1) { - return + return; } - data.splice(key, 1) + data.splice(key, 1); }, add(data, key, t) { if (t == "header" || t == 'query') { - data.splice(key+1, 0, this.defaultHeader) + data.splice(key+1, 0, this.defaultHeader); } } } -}) \ No newline at end of file +}) diff --git a/module/api/lang/en.php b/module/api/lang/en.php index 822c2e85ab..2b2cbac4f3 100644 --- a/module/api/lang/en.php +++ b/module/api/lang/en.php @@ -14,25 +14,9 @@ $lang->api->common = 'API'; $lang->api->getModel = 'Super Model API'; $lang->api->sql = 'SQL Query API'; -/* function of api doc */ -$lang->apiDoc = new stdClass(); -$lang->apiDoc->common = 'Api Doc'; -$lang->apiDoc->index = 'Api Doc Home'; -$lang->apiDoc->createLib = 'Create Api Library'; -$lang->apiDoc->editLib = 'Edit Api Library'; -$lang->apiDoc->deleteLib = 'Delete Api Library'; -$lang->apiDoc->publish = 'Publish'; -$lang->apiDoc->structPage = 'Data Structure'; -$lang->apiDoc->createStruct = 'Create Data Structure'; -$lang->apiDoc->editStruct = 'Edit Data Structure'; -$lang->apiDoc->deleteStruct = 'Delete Data Structure'; -$lang->apiDoc->createApi = 'Create Api'; -$lang->apiDoc->editApi = 'Edit Api'; -$lang->apiDoc->deleteApi = 'Delete Api'; - +$lang->api->index = 'Api Doc Home'; $lang->api->editLib = 'Edit Api Doc'; $lang->api->deleteLib = 'Delete Api Doc'; -$lang->api->createStruct = 'Create Data Structure'; $lang->api->publish = 'Publish'; $lang->api->createLib = 'Create Api Library'; $lang->api->createApi = 'Create Api'; @@ -52,7 +36,9 @@ $lang->api->post = 'Please refer to the page form for post debugging $lang->api->noUniqueName = 'Api library name already exists。'; $lang->api->noUniqueVersion = 'Version already exists。'; $lang->api->version = 'Version'; +$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->module = 'Directory'; @@ -81,7 +67,7 @@ $lang->struct->addSubField = 'Add Subfield'; $lang->struct->typeOptions = array( 'formData' => 'FormData', - 'json' => 'Json', + 'json' => 'JSON', 'array' => 'Array', 'object' => 'Object', ); @@ -181,12 +167,9 @@ $lang->api->paramsTypeCustomOptions = array( 'file' => 'file', 'ref' => 'ref', ); -$lang->api->structParamsOptons = array_merge($lang->api->paramsTypeOptions, array('file' => 'file', 'ref' => 'ref')); -$lang->api->allParamsTypeOptions = array_merge($lang->api->paramsTypeOptions, $lang->api->paramsTypeCustomOptions); -$lang->api->requiredOptions = [ - 0 => 'No', - 1 => 'Yes', -]; +$lang->api->structParamsOptons = array_merge($lang->api->paramsTypeOptions, array('file' => 'file', 'ref' => 'ref')); +$lang->api->allParamsTypeOptions = array_merge($lang->api->paramsTypeOptions, $lang->api->paramsTypeCustomOptions); +$lang->api->requiredOptions = array(0 => 'No', 1 => 'Yes'); $lang->doclib = new stdclass(); $lang->doclib->name = 'Interface Library Name'; diff --git a/module/api/lang/zh-cn.php b/module/api/lang/zh-cn.php index 78eff4768b..3018bb285d 100755 --- a/module/api/lang/zh-cn.php +++ b/module/api/lang/zh-cn.php @@ -9,35 +9,19 @@ * @version $Id: zh-cn.php 5129 2013-07-15 00:16:07Z zhujinyonging@gmail.com $ * @link http://www.zentao.net */ -$lang->api = new stdclass(); +$lang->api = new stdclass(); $lang->api->common = 'API接口'; $lang->api->getModel = '超级model调用接口'; $lang->api->sql = 'SQL查询接口'; -/* 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->index = '接口库主页'; $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->edit = '编辑接口'; +$lang->api->delete = '删除接口'; $lang->api->position = '位置'; $lang->api->startLine = "%s,%s行"; $lang->api->desc = '描述'; @@ -53,8 +37,10 @@ $lang->api->post = 'POST方式调试请参照页面表单'; $lang->api->noUniqueName = '接口库名已存在。'; $lang->api->noUniqueVersion = '版本已存在。'; $lang->api->version = '版本'; +$lang->api->createStruct = '创建数据结构'; $lang->api->editStruct = '修改数据结构'; -$lang->api->create = '创建文档'; +$lang->api->deleteStruct = '删除数据结构'; +$lang->api->create = '创建接口'; $lang->api->title = '接口库'; $lang->api->module = '目录'; $lang->api->apiDoc = '接口'; @@ -83,7 +69,7 @@ $lang->struct->addSubField = '添加子字段'; $lang->struct->typeOptions = array( 'formData' => 'FormData', - 'json' => 'Json', + 'json' => 'JSON', 'array' => 'Array', 'object' => 'Object', ); @@ -184,12 +170,9 @@ $lang->api->paramsTypeCustomOptions = array( 'file' => 'file', 'ref' => 'ref', ); -$lang->api->structParamsOptons = array_merge($lang->api->paramsTypeOptions, array('file' => 'file', 'ref' => 'ref')); -$lang->api->allParamsTypeOptions = array_merge($lang->api->paramsTypeOptions, $lang->api->paramsTypeCustomOptions); -$lang->api->requiredOptions = [ - 0 => '否', - 1 => '是', -]; +$lang->api->structParamsOptons = array_merge($lang->api->paramsTypeOptions, array('file' => 'file', 'ref' => 'ref')); +$lang->api->allParamsTypeOptions = array_merge($lang->api->paramsTypeOptions, $lang->api->paramsTypeCustomOptions); +$lang->api->requiredOptions = array(0 => '否', 1 => '是'); $lang->doclib = new stdclass(); $lang->doclib->name = '接口库名称'; diff --git a/module/api/model.php b/module/api/model.php index 112249ab0d..f1d44d1cda 100644 --- a/module/api/model.php +++ b/module/api/model.php @@ -94,12 +94,12 @@ class apiModel extends model ->batchCheck($this->config->api->create->requiredFields, 'notempty') ->exec(); - $id = $this->dao->lastInsertID(); + $params->id = $this->dao->lastInsertID(); $apiSpec = $this->getApiSpecByData($params); $this->dao->replace(TABLE_API_SPEC)->data($apiSpec)->exec(); - return dao::isError() ? false : $id; + return dao::isError() ? false : $params->id; } /** diff --git a/module/api/view/content.html.php b/module/api/view/content.html.php index 64267e4ce4..3a5e6e7feb 100644 --- a/module/api/view/content.html.php +++ b/module/api/view/content.html.php @@ -136,12 +136,7 @@ - params['params'] as $item) - { - echo parseTree($item); - } - ?> + params['params'] as $item) echo parseTree($item);?> @@ -151,7 +146,7 @@ response):?>

api->response;?>

- +
@@ -161,12 +156,7 @@ - response as $item) - { - echo parseTree($item); - } - ?> + response as $item) echo parseTree($item);?>
api->req->name;?>
diff --git a/module/api/view/create.html.php b/module/api/view/create.html.php index 1ce4216407..a26d9c2e82 100644 --- a/module/api/view/create.html.php +++ b/module/api/view/create.html.php @@ -121,8 +121,8 @@ js::set('struct_paramsType', $lang->struct->paramsType); struct->field;?> - struct->required;?> - struct->desc;?> + struct->required;?> + struct->desc;?> struct->action;?> @@ -131,14 +131,14 @@ js::set('struct_paramsType', $lang->struct->paramsType); - +
- + @@ -156,8 +156,8 @@ js::set('struct_paramsType', $lang->struct->paramsType); struct->field;?> - struct->required;?> - struct->desc;?> + struct->required;?> + struct->desc;?> struct->action;?> @@ -166,14 +166,14 @@ js::set('struct_paramsType', $lang->struct->paramsType); - +
- + diff --git a/module/api/view/edit.html.php b/module/api/view/edit.html.php index 4c3ca436f9..f338606508 100644 --- a/module/api/view/edit.html.php +++ b/module/api/view/edit.html.php @@ -122,8 +122,8 @@ js::set('api', $api); struct->field;?> - struct->required;?> - struct->desc;?> + struct->required;?> + struct->desc;?> struct->action;?> @@ -132,14 +132,14 @@ js::set('api', $api); - +
- + @@ -157,8 +157,8 @@ js::set('api', $api); struct->field;?> - struct->required;?> - struct->desc;?> + struct->required;?> + struct->desc;?> struct->action;?> @@ -167,14 +167,14 @@ js::set('api', $api); - +
- + @@ -222,8 +222,7 @@ js::set('api', $api); api->desc; ?> -
desc, "style='width:100%;height:200px'"); ?>
+
desc, "style='width:100%;height:200px'"); ?>
@@ -239,4 +238,4 @@ js::set('api', $api); noticeAcl); ?> - \ No newline at end of file + diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index ab31e6a9ab..b8cf5a98d7 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -1061,36 +1061,6 @@ $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'; @@ -1415,13 +1385,38 @@ $lang->webhook->methodOrder[35] = 'chooseDept'; /* Others. */ $lang->resource->api = new stdclass(); -$lang->resource->api->getModel = 'getModel'; -$lang->resource->api->debug = 'debug'; -$lang->resource->api->sql = 'sql'; +$lang->resource->api->index = 'index'; +$lang->resource->api->createLib = 'createLib'; +$lang->resource->api->editLib = 'editLib'; +$lang->resource->api->deleteLib = 'deleteLib'; +$lang->resource->api->publish = 'publish'; +$lang->resource->api->struct = 'struct'; +$lang->resource->api->createStruct = 'createStruct'; +$lang->resource->api->editStruct = 'editStruct'; +$lang->resource->api->deleteStruct = 'deleteStruct'; +$lang->resource->api->create = 'create'; +$lang->resource->api->edit = 'edit'; +$lang->resource->api->delete = 'delete'; -$lang->api->methodOrder[5] = 'getModel'; -$lang->api->methodOrder[10] = 'debug'; -$lang->api->methodOrder[15] = 'sql'; +$lang->resource->api->getModel = 'getModel'; +$lang->resource->api->debug = 'debug'; +$lang->resource->api->sql = 'sql'; + +$lang->api->methodOrder[0] = 'index'; +$lang->api->methodOrder[5] = 'createLib'; +$lang->api->methodOrder[10] = 'editLib'; +$lang->api->methodOrder[15] = 'deleteLib'; +$lang->api->methodOrder[20] = 'publish'; +$lang->api->methodOrder[25] = 'struct'; +$lang->api->methodOrder[30] = 'createStruct'; +$lang->api->methodOrder[35] = 'editStruct'; +$lang->api->methodOrder[40] = 'deleteStruct'; +$lang->api->methodOrder[45] = 'create'; +$lang->api->methodOrder[50] = 'edit'; +$lang->api->methodOrder[55] = 'delete'; +$lang->api->methodOrder[60] = 'getModel'; +$lang->api->methodOrder[65] = 'debug'; +$lang->api->methodOrder[70] = 'sql'; $lang->resource->file = new stdclass(); $lang->resource->file->download = 'download';