mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
added 获取字段列表
This commit is contained in:
parent
7888df9b85
commit
3f7e4a6138
@ -8,7 +8,9 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\model\ApiFields;
|
||||
use app\util\DataType;
|
||||
use app\util\ReturnCode;
|
||||
|
||||
class Fields extends Base {
|
||||
private $dataType = array(
|
||||
@ -27,30 +29,59 @@ class Fields extends Base {
|
||||
return $this->buildSuccess($this->dataType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求参数
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
public function request() {
|
||||
$hash = I('get.hash');
|
||||
$where['type'] = 0;
|
||||
$limit = $this->request->get('size', config('apiAdmin.ADMIN_LIST_DEFAULT'));
|
||||
$start = $limit * ($this->request->get('page', 1) - 1);
|
||||
$hash = $this->request->get('hash', '');
|
||||
|
||||
if (!empty($hash)) {
|
||||
$where['hash'] = $hash;
|
||||
$listInfo = (new ApiFields())->where(['hash' => $hash, 'type' => 0])->limit($start, $limit)->select();
|
||||
$count = (new ApiFields())->where(['hash' => $hash, 'type' => 0])->count();
|
||||
$listInfo = $this->buildArrFromObj($listInfo);
|
||||
|
||||
return $this->buildSuccess([
|
||||
'list' => $listInfo,
|
||||
'count' => $count,
|
||||
'dataType' => $this->dataType
|
||||
]);
|
||||
} else {
|
||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
|
||||
}
|
||||
$res = D('ApiFields')->where($where)->select();
|
||||
$this->assign('dataType', $this->dataType);
|
||||
$this->assign('list', $res);
|
||||
$this->assign('type', 0);
|
||||
$this->display('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取返回参数
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
public function response() {
|
||||
$hash = I('get.hash');
|
||||
$where['type'] = 1;
|
||||
$limit = $this->request->get('size', config('apiAdmin.ADMIN_LIST_DEFAULT'));
|
||||
$start = $limit * ($this->request->get('page', 1) - 1);
|
||||
$hash = $this->request->get('hash', '');
|
||||
|
||||
if (!empty($hash)) {
|
||||
$where['hash'] = $hash;
|
||||
$listInfo = (new ApiFields())->where(['hash' => $hash, 'type' => 1])->limit($start, $limit)->select();
|
||||
$count = (new ApiFields())->where(['hash' => $hash, 'type' => 1])->count();
|
||||
$listInfo = $this->buildArrFromObj($listInfo);
|
||||
|
||||
return $this->buildSuccess([
|
||||
'list' => $listInfo,
|
||||
'count' => $count,
|
||||
'dataType' => $this->dataType
|
||||
]);
|
||||
} else {
|
||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
|
||||
}
|
||||
$res = D('ApiFields')->where($where)->select();
|
||||
$this->assign('dataType', $this->dataType);
|
||||
$this->assign('list', $res);
|
||||
$this->assign('type', 1);
|
||||
$this->display('index');
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
@ -135,6 +135,34 @@ return [
|
||||
'admin/InterfaceList/del',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Fields/index' => [
|
||||
'admin/Fields/index',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Fields/request' => [
|
||||
'admin/Fields/request',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Fields/response' => [
|
||||
'admin/Fields/response',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Fields/add' => [
|
||||
'admin/Fields/add',
|
||||
['method' => 'post', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Fields/upload' => [
|
||||
'admin/Fields/upload',
|
||||
['method' => 'post', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Fields/edit' => [
|
||||
'admin/Fields/edit',
|
||||
['method' => 'post', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Fields/del' => [
|
||||
'admin/Fields/del',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'__miss__' => ['admin/Miss/index'],
|
||||
],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user