add apimanager module

This commit is contained in:
uctoo
2021-07-27 16:49:30 +08:00
parent 7ad6bacb2d
commit b784251605
25 changed files with 2248 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class ApiCategory extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('api_category', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => 'API分类' ,'id' => 'id' ,'primary_key' => ['id']]);
$table->addColumn('category_title', 'string', ['limit' => 64,'null' => false,'default' => '','signed' => true,'comment' => '分类标题',])
->addColumn('parent_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '父级ID',])
->addColumn('category_name', 'string', ['limit' => 128,'null' => false,'default' => '','signed' => true,'comment' => '分类唯一标识',])
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => true,'comment' => '状态:1=正常;2=停用',])
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '排序字段',])
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除字段',])
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
->addIndex(['category_name'], ['unique' => true,'name' => 'api_category_category_name'])
->create();
}
}

View File

@@ -0,0 +1,60 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class ApiTester extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('api_tester', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => 'api测试表' ,'id' => 'id' ,'primary_key' => ['id']]);
$table->addColumn('api_title', 'string', ['limit' => 128,'null' => false,'default' => '新建接口','signed' => true,'comment' => '标题',])
->addColumn('api_name', 'string', ['limit' => 128,'null' => false,'default' => '','signed' => true,'comment' => '英文唯一标识',])
->addColumn('category_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '分类',])
->addColumn('type', 'boolean', ['null' => false,'default' => 1,'signed' => true,'comment' => '数据源类型:1=remote,2=local',])
->addColumn('appid', 'string', ['limit' => 64,'null' => true,'signed' => true,'comment' => 'appid',])
->addColumn('project_id', 'string', ['limit' => 64,'null' => true,'signed' => true,'comment' => '项目ID',])
->addColumn('api_url', 'string', ['limit' => 512,'null' => false,'default' => 'https://127.0.0.1','signed' => true,'comment' => 'API URL',])
->addColumn('methods', 'string', ['limit' => 128,'null' => false,'default' => 'POST','signed' => true,'comment' => '方法:POST,GET,PUT,PATCH,DELETE,COPY,HEAD,OPTIONS',])
->addColumn('auth', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '鉴权',])
->addColumn('header', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => 'header',])
->addColumn('query', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => 'query',])
->addColumn('body', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => 'body',])
->addColumn('doc_url', 'string', ['limit' => 512,'null' => true,'signed' => true,'comment' => '文档URL',])
->addColumn('document', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '文档',])
->addColumn('sample_data', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '示例数据',])
->addColumn('sample_result', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '示例返回数据',])
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '排序',])
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => true,'comment' => '状态:1=已完成,2=待开发,3=开发中,4=已废弃',])
->addColumn('content_type', 'string', ['limit' => 128,'null' => false,'default' => 'application/x-www-form-urlencoded','signed' => true,'comment' => 'content-type:application/x-www-form-urlencoded,multipart/form-data,raw',])
->addColumn('env_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '环境ID',])
->addColumn('memo', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '备注',])
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除字段',])
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
->create();
}
}

View File

@@ -0,0 +1,44 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class ApiTesterUserenv extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('api_tester_userenv', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => 'API测试用户环境' ,'id' => 'id' ,'primary_key' => ['id']]);
$table->addColumn('env_name', 'string', ['limit' => 128,'null' => false,'default' => '','signed' => true,'comment' => '环境名称',])
->addColumn('appid', 'string', ['limit' => 64,'null' => false,'default' => '','signed' => true,'comment' => 'appid',])
->addColumn('project_id', 'string', ['limit' => 64,'null' => false,'default' => '','signed' => true,'comment' => '项目ID',])
->addColumn('env_json', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => false,'signed' => true,'comment' => '环境变量json',])
->addColumn('selected', 'boolean', ['null' => false,'default' => 0,'signed' => true,'comment' => '是否当前选中:0=否,1=是',])
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除字段',])
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
->create();
}
}

View File

@@ -0,0 +1,46 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class ApiTesterLog extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('api_tester_log', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => 'API测试记录' ,'id' => 'id' ,'primary_key' => ['id']]);
$table->addColumn('appid', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => 'appid',])
->addColumn('user_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => 'users表id',])
->addColumn('api_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => 'api_tester表id',])
->addColumn('params', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => 'api参数',])
->addColumn('result', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '返回值',])
->addColumn('request_data', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '请求数据',])
->addColumn('response_data', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '响应数据',])
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除字段',])
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
->create();
}
}

View File

@@ -0,0 +1,98 @@
<?php
// +----------------------------------------------------------------------
// | UCToo [ Universal Convergence Technology ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2021 https://www.uctoo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: UCToo <contact@uctoo.com>
// +----------------------------------------------------------------------
use think\migration\Seeder;
class ApiCategorySeed extends Seeder
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*/
public function run()
{
$data = array (
0 =>
array (
'id' => 1,
'category_title' => '微信第三方平台',
'parent_id' => 0,
'category_name' => 'wechatopen',
'status' => 1,
'sort' => 1,
'created_at' => 1621414770,
'updated_at' => 1621414770,
'deleted_at' => 0,
'creator_id' => 1,
),
1 =>
array (
'id' => 2,
'category_title' => '微信交易组件标准版',
'parent_id' => 1,
'category_name' => 'MiniShop_Base',
'status' => 1,
'sort' => 1,
'created_at' => 1621415897,
'updated_at' => 1621415897,
'deleted_at' => 0,
'creator_id' => 1,
),
2 =>
array (
'id' => 3,
'category_title' => '腾讯AI开放平台',
'parent_id' => 0,
'category_name' => 'tencentAI',
'status' => 1,
'sort' => 1,
'created_at' => 1621493345,
'updated_at' => 1621493345,
'deleted_at' => 0,
'creator_id' => 1,
),
3 =>
array (
'id' => 4,
'category_title' => '批量代云开发',
'parent_id' => 1,
'category_name' => 'componenttcb',
'status' => 1,
'sort' => 1,
'created_at' => 1621494287,
'updated_at' => 1621494287,
'deleted_at' => 0,
'creator_id' => 1,
),
4 =>
array (
'id' => 5,
'category_title' => '本地接口',
'parent_id' => 0,
'category_name' => 'local',
'status' => 1,
'sort' => 2,
'created_at' => 1621494287,
'updated_at' => 1621494287,
'deleted_at' => 0,
'creator_id' => 1,
),
);
foreach ($data as $item) {
\catchAdmin\apimanager\model\ApiCategory::create($item);
}
}
}

View File

@@ -0,0 +1,785 @@
<?php
// +----------------------------------------------------------------------
// | UCToo [ Universal Convergence Technology ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2021 https://www.uctoo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: UCToo <contact@uctoo.com>
// +----------------------------------------------------------------------
use think\migration\Seeder;
class ApiTesterSeed extends Seeder
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*/
public function run()
{
$data = array (
0 =>
array (
'id' => 1,
'api_title' => '获取类目详情',
'api_name' => 'product/category/get',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/category/get',
'methods' => 'POST',
'auth' => NULL,
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/cat/get_cat_list.html',
'document' => '参考文档url',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 2,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => NULL,
'created_at' => 1621484754,
'updated_at' => 1622461634,
'deleted_at' => 0,
'creator_id' => 1,
),
1 =>
array (
'id' => 2,
'api_title' => '获取品牌列表',
'api_name' => 'product/brand/get',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/brand/get',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/cat/get_brand.html',
'document' => '详见文档url地址',
'sample_data' => '无',
'sample_result' => '返回',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => NULL,
'created_at' => 1621485017,
'updated_at' => 1622378856,
'deleted_at' => 0,
'creator_id' => 1,
),
2 =>
array (
'id' => 3,
'api_title' => '登录日志',
'api_name' => '/log/login',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/log/login',
'methods' => 'GET',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '',
'body' => '',
'doc_url' => 'http://apidoc.catchadmin.com/web/#/5?page_id=23',
'document' => '无',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1621598744,
'updated_at' => 1622965477,
'deleted_at' => 0,
'creator_id' => 1,
),
3 =>
array (
'id' => 4,
'api_title' => '操作日志',
'api_name' => 'log/operate',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/log/operate',
'methods' => 'GET',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '',
'body' => '',
'doc_url' => 'http://apidoc.catchadmin.com/web/#/5?page_id=53',
'document' => '无',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1621598935,
'updated_at' => 1622965460,
'deleted_at' => 0,
'creator_id' => 1,
),
4 =>
array (
'id' => 5,
'api_title' => '获取运费模板',
'api_name' => 'product/delivery/get_freight_template',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/delivery/get_freight_template',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '',
'doc_url' => 'https://developers.weixin.qq.com/doc/ministore/minishopopencomponent/API/cat/get_freight_template.html',
'document' => '详见文档URL',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1621599469,
'updated_at' => 1622378826,
'deleted_at' => 0,
'creator_id' => 1,
),
5 =>
array (
'id' => 6,
'api_title' => '获取店铺的商品分类',
'api_name' => 'product/store/get_shopcat',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/store/get_shopcat',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/store/get_shopcat.html',
'document' => '参考文档url',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1621762669,
'updated_at' => 1622378816,
'deleted_at' => 0,
'creator_id' => 1,
),
6 =>
array (
'id' => 7,
'api_title' => '添加商品',
'api_name' => 'product/spu/add',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/spu/add',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '{
"out_product_id": "1234566",
"title": "任天堂 Nintendo Switch 国行续航增强版 NS家用体感游戏机掌机 便携掌上游戏机 红蓝主机",
"sub_title": "JD自营更放心】【国行Switch更安心的保修服务更快的国行服务器】一台主机三种模式游戏掌机随时随地一起趣玩。",
"head_img":
[
"http://img10.360buyimg.com/n1/s450x450_jfs/t1/85865/39/13611/488083/5e590a40E4bdf69c0/55c9bf645ea2b727.jpg"
],
"desc_info":
{
"imgs":
[
"http://img10.360buyimg.com/n1/s450x450_jfs/t1/85865/39/13611/488083/5e590a40E4bdf69c0/55c9bf645ea2b727.jpg"
]
},
"brand_id": 2100000000,
"cats":
[
{
"cat_id": 6033,
"level": 1
},
{
"cat_id": 6057,
"level": 2
},
{
"cat_id": 6091,
"level": 3
}
],
"attrs":
[
{
"attr_key": "商品毛重",
"attr_value": "380g"
},
{
"attr_key": "商品产地",
"attr_value": "中国大陆"
}
],
"model": "国行续航增强版",
"express_info":
{
"template_id": 5189
},
"skus":
[
{
"out_product_id": "1234566",
"out_sku_id": "1024",
"thumb_img": "http://img10.360buyimg.com/n1/s450x450_jfs/t1/100778/17/13648/424215/5e590a40E2d68e774/e171d222a0c9b763.jpg",
"sale_price": 1300,
"market_price": 1500,
"stock_num": 100,
"sku_code": "A24525252",
"barcode": "13251454",
"sku_attrs":
[
{
"attr_key": "选择颜色",
"attr_value": "红蓝主机"
},
{
"attr_key": "选择套装",
"attr_value": "主机+保护套"
}
]
}
]
}',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/spu/add_spu.html',
'document' => '参考文档url',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1621764682,
'updated_at' => 1622378805,
'deleted_at' => 0,
'creator_id' => 1,
),
7 =>
array (
'id' => 8,
'api_title' => '获取商品',
'api_name' => 'product/spu/get',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/spu/get',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '{\'product_id\':\'31334398\'}',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/spu/get_spu.html',
'document' => '参考文档URL',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1621774347,
'updated_at' => 1622378781,
'deleted_at' => 0,
'creator_id' => 1,
),
8 =>
array (
'id' => 9,
'api_title' => '获取商品列表',
'api_name' => 'product/spu/get_list',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/spu/get_list',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '{"status":5}',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/spu/get_spu_list.html',
'document' => '参考文档URL',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1621777668,
'updated_at' => 1622378754,
'deleted_at' => 0,
'creator_id' => 1,
),
9 =>
array (
'id' => 10,
'api_title' => '搜索商品',
'api_name' => 'product/spu/search',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/spu/search',
'methods' => 'POST',
'auth' => NULL,
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '{\'status\':5,\'keyword\':\'UI\',\'page\':1}',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/spu/search_spu.html',
'document' => '参考文档url',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 1,
'memo' => NULL,
'created_at' => 1622000389,
'updated_at' => 1622378719,
'deleted_at' => 0,
'creator_id' => 1,
),
10 =>
array (
'id' => 11,
'api_title' => '上架商品',
'api_name' => 'product/spu/listing',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/spu/listing',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '{\'product_id\':\'33541981\'}',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/spu/up_spu_listing.html',
'document' => '参考文档URL',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622019456,
'updated_at' => 1622378710,
'deleted_at' => 0,
'creator_id' => 1,
),
11 =>
array (
'id' => 12,
'api_title' => '下架商品',
'api_name' => 'product/spu/delisting',
'category_id' => 2,
'type' => 1,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/api/wechatopen/product/spu/delisting',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{"appid":"{{appid}}"}',
'body' => '{\'product_id\':33541981}',
'doc_url' => 'https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/spu/up_spu_delisting.html',
'document' => '参考文档URL',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622019791,
'updated_at' => 1622378701,
'deleted_at' => 0,
'creator_id' => 1,
),
12 =>
array (
'id' => 13,
'api_title' => 'API测试用户环境新增',
'api_name' => 'ApiTesterUserenv/save',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/apiTesterUserenv',
'methods' => 'POST',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '',
'body' => '{\'env_name\':\'api.server.local\',\'appid\':\'wx407e\',\'project_id\':1,\'selected\':0}',
'doc_url' => '无',
'document' => '新增一条API测试用户环境数据',
'sample_data' => '{\'env_name\':\'appapi.uctoo.local\',\'appid\':\'wx407e\',\'project_id\':1,\'env_json\':\'{"{{host}}":"api.server.local","{{appid}}":"wx407e","{{authorization}}":"BearereyJ0eXA"}\',\'selected\':0}',
'sample_result' => '无',
'sort' => 1,
'status' => 4,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 1,
'memo' => '',
'created_at' => 1622030621,
'updated_at' => 1622965370,
'deleted_at' => 0,
'creator_id' => 1,
),
13 =>
array (
'id' => 14,
'api_title' => 'API测试用户环境列表',
'api_name' => 'apiTesterUserenv/index',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/apiTesterUserenv',
'methods' => 'GET',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{\'creator\':\'admin\'}',
'body' => '',
'doc_url' => '无',
'document' => 'API测试用户环境列表。可以按用户名检索环境列表在query部分增加creator筛选字段。',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622031131,
'updated_at' => 1622965325,
'deleted_at' => 0,
'creator_id' => 1,
),
14 =>
array (
'id' => 15,
'api_title' => 'API测试用户环境更新',
'api_name' => 'apiTesterUserenv/update',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/apiTesterUserenv/3',
'methods' => 'PUT',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '',
'body' => '{\'selected\':1}',
'doc_url' => '无',
'document' => 'API地址http://127.0.0.1/apiTesterUserenv/{id}
id为数据主键。body部分为要更新的字段。',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622033581,
'updated_at' => 1622965309,
'deleted_at' => 0,
'creator_id' => 1,
),
15 =>
array (
'id' => 16,
'api_title' => '微应用列表',
'api_name' => 'applet/index',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/applet',
'methods' => 'GET',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '{\'creator\':\'demo\'}',
'body' => '',
'doc_url' => '无',
'document' => '可在query字段用creator用户名、name应用名称、appid字段进行筛选。',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622083381,
'updated_at' => 1622965295,
'deleted_at' => 0,
'creator_id' => 1,
),
16 =>
array (
'id' => 17,
'api_title' => '设置选中微应用',
'api_name' => 'applet/setapplet/<id>',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/applet/setapplet/1',
'methods' => 'GET',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '',
'body' => '',
'doc_url' => '无',
'document' => '<id>参数为数据主键',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622085296,
'updated_at' => 1622965277,
'deleted_at' => 0,
'creator_id' => 1,
),
17 =>
array (
'id' => 18,
'api_title' => '获取当前选中应用',
'api_name' => 'admin/applet/<creator_id>',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/admin/applet/1',
'methods' => 'GET',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '',
'body' => '',
'doc_url' => '无',
'document' => '<creator_id>参数是后台用户主键ID',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622097323,
'updated_at' => 1622965263,
'deleted_at' => 0,
'creator_id' => 1,
),
18 =>
array (
'id' => 19,
'api_title' => '切换API环境',
'api_name' => 'apiTesterUserenv/selectAPIenv/<id>',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/apiTesterUserenv/selectAPIenv/1',
'methods' => 'GET',
'auth' => '',
'header' => '{"authorization":"{{authorization}}"}',
'query' => '',
'body' => '',
'doc_url' => '无',
'document' => '<id>为API环境数据主键',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622176574,
'updated_at' => 1622965231,
'deleted_at' => 0,
'creator_id' => 1,
),
19 =>
array (
'id' => 20,
'api_title' => '帐号登录',
'api_name' => 'login',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/login',
'methods' => 'POST',
'auth' => '',
'header' => '',
'query' => '',
'body' => '{"email":"catch@admin.com","password":"catchadmin"}',
'doc_url' => 'http://apidoc.catchadmin.com/web/#/5?page_id=24',
'document' => '无',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/json; charset=utf-8',
'env_id' => 0,
'memo' => '',
'created_at' => 1622429937,
'updated_at' => 1622460840,
'deleted_at' => 0,
'creator_id' => 1,
),
20 =>
array (
'id' => 21,
'api_title' => '微信扫码登录后获取后台帐号',
'api_name' => 'wechatlogin/wechatoauth',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/wechatlogin/wechatoauth',
'methods' => 'GET',
'auth' => '',
'header' => '',
'query' => '{"code":"0712VE1"}',
'body' => '',
'doc_url' => 'https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html',
'document' => '微信扫码登录后,在跳转到的页面需要先调用此接口获取微信用户关联的后台管理员帐号列表。根据此接口返回的帐号列表信息,展示帐号名,用户可以点选登录对应帐号。如此接口返回空值,则展示用户注册后台帐号页面。
Query参数
必填参数
code微信扫码登录后微信服务器通知跳转到redirect_url时添加的code参数用于获取微信用户access_token
非必填参数
state扫码登录时添加的随机验证字符串。前端自定义。前端自验证。
返回值accountList 包含扫码登录后获得的 openidaccess_token以及关联的后台帐号列表
',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/x-www-form-urlencoded',
'env_id' => 0,
'memo' => '',
'created_at' => 1622539671,
'updated_at' => 1622709792,
'deleted_at' => 0,
'creator_id' => 1,
),
21 =>
array (
'id' => 22,
'api_title' => '扫码登录后注册用户帐号',
'api_name' => 'wechatlogin/wechatregist',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/wechatlogin/wechatregist',
'methods' => 'POST',
'auth' => '',
'header' => '',
'query' => '',
'body' => '{"username":"13688888888","password":"123456","email":"demo@uctoo.com","openid":"openid","access_token":"access_token"}',
'doc_url' => '无',
'document' => 'openid和access_token是微信扫码登录后获取到的值用于调用帐号注册接口权限验证。
username建议采用用户手机号码并进行短信验证。
password建议校验密码复杂度。
email建议进行邮箱验证。可作为密码找回方式之一。',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/json; charset=utf-8',
'env_id' => 0,
'memo' => '',
'created_at' => 1622710277,
'updated_at' => 1622876680,
'deleted_at' => 0,
'creator_id' => 1,
),
22 =>
array (
'id' => 23,
'api_title' => '微信扫码登录后选择帐号登录',
'api_name' => 'wechatlogin/wechatlogin',
'category_id' => 5,
'type' => 2,
'appid' => '',
'project_id' => '',
'api_url' => '{{host}}/wechatlogin/wechatlogin',
'methods' => 'POST',
'auth' => '',
'header' => '',
'query' => '',
'body' => '{"email":"demo@uctoo.com","openid":"openid","access_token":"access_token","password":"any"}',
'doc_url' => '无',
'document' => '微信扫码后,选择帐号登录。
openid和access_token是在扫码授权后获得。
password参数必须传可以是任意值不做验证。',
'sample_data' => '无',
'sample_result' => '无',
'sort' => 1,
'status' => 1,
'content_type' => 'application/json; charset=utf-8',
'env_id' => 0,
'memo' => '',
'created_at' => 1622713987,
'updated_at' => 1622876660,
'deleted_at' => 0,
'creator_id' => 1,
),
);
foreach ($data as $item) {
\catchAdmin\apimanager\model\ApiTester::create($item);
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
// +----------------------------------------------------------------------
// | UCToo [ Universal Convergence Technology ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2021 https://www.uctoo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: UCToo <contact@uctoo.com>
// +----------------------------------------------------------------------
use think\migration\Seeder;
class ApiTesterUserenvSeed extends Seeder
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*/
public function run()
{
$data = array (
0 =>
array (
'id' => 1,
'env_name' => 'localhost',
'appid' => 'wx407e4',
'project_id' => '1',
'env_json' => '{"{{host}}":"http://127.0.0.1:8000","{{status}}":"5","{{appid}}":"wx407","{{authorization}}":"Bearer{{手动替换为login接口的token}}"}',
'selected' => 1,
'created_at' => 1622029539,
'updated_at' => 1622386890,
'deleted_at' => 0,
'creator_id' => 1,
),
1 =>
array (
'id' => 2,
'env_name' => 'api.server.local',
'appid' => 'wx407',
'project_id' => '1',
'env_json' => '{"{{host}}":"http://api.server.local"}',
'selected' => 0,
'created_at' => 1622030904,
'updated_at' => 1622386890,
'deleted_at' => 0,
'creator_id' => 1,
),
);
foreach ($data as $item) {
\catchAdmin\apimanager\model\ApiTesterUserenv::create($item);
}
}
}

View File

@@ -0,0 +1,144 @@
<?php
// +----------------------------------------------------------------------
// | UCToo [ Universal Convergence Technology ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2021 https://www.uctoo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: UCToo <contact@uctoo.com>
// +----------------------------------------------------------------------
use think\facade\Log;
use think\migration\Seeder;
class ApimanagerMenusSeed extends Seeder
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*/
public function run()
{
Log::write("ApimanagerMenusSeed",'debug');
\catcher\Utils::importTreeData($this->getPermissions(), 'permissions', 'parent_id');
}
protected function getPermissions()
{
return array (
0 =>
array (
'id' => 136,
'permission_name' => 'API管理',
'parent_id' => 0,
'level' => '',
'route' => '/apimanager',
'icon' => 'el-icon-sort',
'module' => 'apimanager',
'creator_id' => 1,
'permission_mark' => 'apimanager',
'component' => 'layout',
'redirect' => '',
'keepalive' => 1,
'type' => 1,
'hidden' => 1,
'sort' => 10,
'created_at' => 1622926698,
'updated_at' => 1622959419,
'deleted_at' => 0,
'children' =>
array (
0 =>
array (
'id' => 137,
'permission_name' => 'API分类',
'parent_id' => 136,
'level' => '',
'route' => '/apicategory',
'icon' => 'el-icon-s-grid',
'module' => 'apimanager',
'creator_id' => 1,
'permission_mark' => 'apicategory',
'component' => 'apicategory',
'redirect' => '',
'keepalive' => 1,
'type' => 1,
'hidden' => 1,
'sort' => 10,
'created_at' => 1622928640,
'updated_at' => 1622959419,
'deleted_at' => 0,
),
1 =>
array (
'id' => 138,
'permission_name' => 'API环境变量',
'parent_id' => 136,
'level' => '',
'route' => '/apienv',
'icon' => 'el-icon-setting',
'module' => 'apimanager',
'creator_id' => 1,
'permission_mark' => 'apienv',
'component' => 'apienv',
'redirect' => '',
'keepalive' => 1,
'type' => 1,
'hidden' => 1,
'sort' => 9,
'created_at' => 1622930243,
'updated_at' => 1622959419,
'deleted_at' => 0,
),
2 =>
array (
'id' => 140,
'permission_name' => 'API测试列表',
'parent_id' => 136,
'level' => '',
'route' => '/apitester',
'icon' => 'el-icon-stopwatch',
'module' => 'apimanager',
'creator_id' => 1,
'permission_mark' => 'apitester',
'component' => 'apitester',
'redirect' => '',
'keepalive' => 1,
'type' => 1,
'hidden' => 1,
'sort' => 8,
'created_at' => 1622951640,
'updated_at' => 1622959419,
'deleted_at' => 0,
),
3 =>
array (
'id' => 141,
'permission_name' => 'API运行',
'parent_id' => 136,
'level' => '',
'route' => '/apimanager/apirun',
'icon' => 'el-icon-position',
'module' => 'apimanager',
'creator_id' => 1,
'permission_mark' => 'apirun',
'component' => 'apirun',
'redirect' => '',
'keepalive' => 1,
'type' => 1,
'hidden' => 2,
'sort' => 1,
'created_at' => 1622951894,
'updated_at' => 1622959419,
'deleted_at' => 0,
),
),
),
);
}
}