add apimanager module
This commit is contained in:
83
catch/apimanager/controller/ApiCategory.php
Normal file
83
catch/apimanager/controller/ApiCategory.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?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>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\apimanager\controller;
|
||||
|
||||
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\apimanager\model\ApiCategory as ApiCategoryModel;
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\exceptions\FailedException;
|
||||
|
||||
class ApiCategory extends CatchController
|
||||
{
|
||||
protected $ApiCategoryModel;
|
||||
|
||||
public function __construct(ApiCategoryModel $ApiCategoryModel)
|
||||
{
|
||||
$this->ApiCategoryModel = $ApiCategoryModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @time 2021年05月19日 15:21
|
||||
* @param Request $request
|
||||
*/
|
||||
public function index(): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->ApiCategoryModel->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存信息
|
||||
* @time 2021年05月19日 15:21
|
||||
* @param Request $request
|
||||
*/
|
||||
public function save(Request $request) : \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->ApiCategoryModel->storeBy($request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取
|
||||
* @time 2021年05月19日 15:21
|
||||
* @param $id
|
||||
*/
|
||||
public function read($id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiCategoryModel->findBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @time 2021年05月19日 15:21
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function update(Request $request, $id) : \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->ApiCategoryModel->updateBy($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @time 2021年05月19日 15:21
|
||||
* @param $id
|
||||
*/
|
||||
public function delete($id) : \think\Response
|
||||
{
|
||||
if ($this->ApiCategoryModel->where('parent_id', $id)->find()) {
|
||||
throw new FailedException('存在子分类,无法删除');
|
||||
}
|
||||
return CatchResponse::success($this->ApiCategoryModel->deleteBy($id));
|
||||
}
|
||||
}
|
79
catch/apimanager/controller/ApiTester.php
Normal file
79
catch/apimanager/controller/ApiTester.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\apimanager\controller;
|
||||
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\apimanager\model\ApiTester as ApiTesterModel;
|
||||
use catchAdmin\apimanager\model\ApiCategory;
|
||||
|
||||
class ApiTester extends CatchController
|
||||
{
|
||||
protected $ApiTesterModel;
|
||||
|
||||
public function __construct(ApiTesterModel $ApiTesterModel)
|
||||
{
|
||||
$this->ApiTesterModel = $ApiTesterModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @time 2021年05月20日 11:41
|
||||
* @param Request $request
|
||||
*/
|
||||
public function index(Request $request) : \think\Response
|
||||
{
|
||||
return CatchResponse::paginate($this->ApiTesterModel->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存信息
|
||||
* @time 2021年05月20日 11:41
|
||||
* @param Request $request
|
||||
*/
|
||||
public function save(Request $request) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterModel->storeBy($request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取
|
||||
* @time 2021年05月20日 11:41
|
||||
* @param $id
|
||||
*/
|
||||
public function read($id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterModel->findBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @time 2021年05月20日 11:41
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function update(Request $request, $id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterModel->updateBy($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @time 2021年05月20日 11:41
|
||||
* @param $id
|
||||
*/
|
||||
public function delete($id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterModel->deleteBy($id));
|
||||
}
|
||||
}
|
78
catch/apimanager/controller/ApiTesterLog.php
Normal file
78
catch/apimanager/controller/ApiTesterLog.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\apimanager\controller;
|
||||
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\apimanager\model\ApiTesterLog as ApiTesterLogModel;
|
||||
|
||||
class ApiTesterLog extends CatchController
|
||||
{
|
||||
protected $ApiTesterLogModel;
|
||||
|
||||
public function __construct(ApiTesterLogModel $ApiTesterLogModel)
|
||||
{
|
||||
$this->ApiTesterLogModel = $ApiTesterLogModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @time 2021年06月10日 19:20
|
||||
* @param Request $request
|
||||
*/
|
||||
public function index(Request $request) : \think\Response
|
||||
{
|
||||
return CatchResponse::paginate($this->ApiTesterLogModel->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存信息
|
||||
* @time 2021年06月10日 19:20
|
||||
* @param Request $request
|
||||
*/
|
||||
public function save(Request $request) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterLogModel->storeBy($request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取
|
||||
* @time 2021年06月10日 19:20
|
||||
* @param $id
|
||||
*/
|
||||
public function read($id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterLogModel->findBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @time 2021年06月10日 19:20
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function update(Request $request, $id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterLogModel->updateBy($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @time 2021年06月10日 19:20
|
||||
* @param $id
|
||||
*/
|
||||
public function delete($id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterLogModel->deleteBy($id));
|
||||
}
|
||||
}
|
99
catch/apimanager/controller/ApiTesterUserenv.php
Normal file
99
catch/apimanager/controller/ApiTesterUserenv.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?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>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\apimanager\controller;
|
||||
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\apimanager\model\ApiTesterUserenv as ApiTesterUserenvModel;
|
||||
use think\facade\Log;
|
||||
|
||||
class ApiTesterUserenv extends CatchController
|
||||
{
|
||||
protected $ApiTesterUserenvModel;
|
||||
|
||||
public function __construct(ApiTesterUserenvModel $ApiTesterUserenvModel)
|
||||
{
|
||||
$this->ApiTesterUserenvModel = $ApiTesterUserenvModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @time 2021年05月26日 18:28
|
||||
* @param Request $request
|
||||
*/
|
||||
public function index(Request $request) : \think\Response
|
||||
{
|
||||
return CatchResponse::paginate($this->ApiTesterUserenvModel->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存信息
|
||||
* @time 2021年05月26日 18:28
|
||||
* @param Request $request
|
||||
*/
|
||||
public function save(Request $request) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterUserenvModel->storeBy($request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取
|
||||
* @time 2021年05月26日 18:28
|
||||
* @param $id
|
||||
*/
|
||||
public function read($id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterUserenvModel->findBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @time 2021年05月26日 18:28
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function update(Request $request, $id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterUserenvModel->updateBy($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @time 2021年05月26日 18:28
|
||||
* @param $id
|
||||
*/
|
||||
public function delete($id) : \think\Response
|
||||
{
|
||||
return CatchResponse::success($this->ApiTesterUserenvModel->deleteBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换API环境
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function selectAPIenv(Request $request,$id = "") : \think\Response
|
||||
{
|
||||
if ($id)
|
||||
{
|
||||
$creator_id = $request->user()->id;
|
||||
$this->ApiTesterUserenvModel->update(['selected' => 0], ['creator_id' => $creator_id]); //全不选
|
||||
$res = $this->ApiTesterUserenvModel->update(['selected' => 1], ['id' => $id]); //选中当前
|
||||
//设置为管理员当前选中的applet
|
||||
if($res){
|
||||
return CatchResponse::success($res,'切换API环境成功');
|
||||
}
|
||||
}
|
||||
return CatchResponse::fail('切换API环境错误');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user