mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
added 接口组相关配置
This commit is contained in:
parent
559d832b65
commit
a5251bbabd
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @since 2018-02-11
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
class ApiGroup extends Base {
|
||||
|
||||
}
|
@ -9,5 +9,4 @@ namespace app\admin\controller;
|
||||
|
||||
|
||||
class AppGroup extends Base {
|
||||
|
||||
}
|
||||
|
119
application/admin/controller/InterfaceGroup.php
Normal file
119
application/admin/controller/InterfaceGroup.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* 接口组维护
|
||||
* @since 2018-02-11
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\model\ApiGroup;
|
||||
use app\util\ReturnCode;
|
||||
|
||||
class InterfaceGroup extends Base {
|
||||
/**
|
||||
* 获取接口组列表
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function index() {
|
||||
$limit = $this->request->get('size', config('apiAdmin.ADMIN_LIST_DEFAULT'));
|
||||
$start = $limit * ($this->request->get('page', 1) - 1);
|
||||
$keywords = $this->request->get('keywords', '');
|
||||
$type = $this->request->get('type', '');
|
||||
$status = $this->request->get('status', '');
|
||||
|
||||
$where = [];
|
||||
if ($status === '1' || $status === '0') {
|
||||
$where['status'] = $status;
|
||||
}
|
||||
if ($type) {
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$where['hash'] = $keywords;
|
||||
break;
|
||||
case 2:
|
||||
$where['name'] = ['like', "%{$keywords}%"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$listInfo = (new ApiGroup())->where($where)->limit($start, $limit)->select();
|
||||
$count = (new ApiGroup())->where($where)->count();
|
||||
$listInfo = $this->buildArrFromObj($listInfo);
|
||||
|
||||
return $this->buildSuccess([
|
||||
'list' => $listInfo,
|
||||
'count' => $count
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口组状态编辑
|
||||
* @return array
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
public function changeStatus() {
|
||||
$id = $this->request->get('id');
|
||||
$status = $this->request->get('status');
|
||||
$res = ApiGroup::update([
|
||||
'status' => $status
|
||||
], [
|
||||
'id' => $id
|
||||
]);
|
||||
if ($res === false) {
|
||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||
} else {
|
||||
return $this->buildSuccess([]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加接口组
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
* @return array
|
||||
*/
|
||||
public function add() {
|
||||
$postData = $this->request->post();
|
||||
$res = ApiGroup::create($postData);
|
||||
if ($res === false) {
|
||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||
} else {
|
||||
return $this->buildSuccess([]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口组编辑
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
* @return array
|
||||
*/
|
||||
public function edit() {
|
||||
$postData = $this->request->post();
|
||||
$res = ApiGroup::update($postData);
|
||||
if ($res === false) {
|
||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||
} else {
|
||||
return $this->buildSuccess([]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口组删除
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
* @return array
|
||||
*/
|
||||
public function del() {
|
||||
$hash = $this->request->get('hash');
|
||||
if (!$hash) {
|
||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
|
||||
}
|
||||
ApiGroup::destroy(['hash' => $hash]);
|
||||
|
||||
return $this->buildSuccess([]);
|
||||
}
|
||||
}
|
@ -163,6 +163,26 @@ return [
|
||||
'admin/Fields/del',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'InterfaceGroup/index' => [
|
||||
'admin/InterfaceGroup/index',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'InterfaceGroup/add' => [
|
||||
'admin/InterfaceGroup/add',
|
||||
['method' => 'post', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'InterfaceGroup/edit' => [
|
||||
'admin/InterfaceGroup/edit',
|
||||
['method' => 'post', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'InterfaceGroup/del' => [
|
||||
'admin/InterfaceGroup/del',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'InterfaceGroup/changeStatus' => [
|
||||
'admin/InterfaceGroup/changeStatus',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'__miss__' => ['admin/Miss/index'],
|
||||
],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user