mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 完成请求参数配置项
This commit is contained in:
parent
75c9be2ae6
commit
fe4d33d536
@ -7,10 +7,111 @@
|
|||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\model\ApiFields;
|
||||||
|
|
||||||
class ApiFieldsManager extends Base {
|
class ApiFieldsManager extends Base {
|
||||||
|
|
||||||
public function index(){
|
private $dataType = [
|
||||||
|
'string' => '字符串',
|
||||||
|
'int' => '整型',
|
||||||
|
'float' => '浮点型',
|
||||||
|
'boolean' => '布尔型',
|
||||||
|
'date' => '日期',
|
||||||
|
'array' => '数组',
|
||||||
|
'fixed' => '固定值',
|
||||||
|
'enum' => '枚举类型',
|
||||||
|
'object' => '对象',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function index(){
|
||||||
|
if( !session('apiId') ){
|
||||||
|
if( $this->request->get($this->primaryKey) ){
|
||||||
|
session('apiId', $this->request->get($this->primaryKey));
|
||||||
|
session('apiName', $this->request->get('name'));
|
||||||
|
}else{
|
||||||
|
$this->error('缺少必要参数', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data = ApiFields::all(['apiId' => session('apiId')]);
|
||||||
|
$table = [
|
||||||
|
'tempType' => 'table',
|
||||||
|
'header' => [
|
||||||
|
[
|
||||||
|
'field' => 'name',
|
||||||
|
'info' => '字段名称'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'type',
|
||||||
|
'info' => '字段类型'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'must',
|
||||||
|
'info' => '是否必须'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'default',
|
||||||
|
'info' => '默认值'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'topButton' => [
|
||||||
|
[
|
||||||
|
'href' => 'ApiFieldsManager/add',
|
||||||
|
'class'=> 'btn-success',
|
||||||
|
'info'=> '新增',
|
||||||
|
'icon' => 'fa fa-plus',
|
||||||
|
'confirm' => 0,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'href' => 'ApiFieldsManager/del',
|
||||||
|
'class'=> 'btn-danger ajax-delete',
|
||||||
|
'info'=> '删除',
|
||||||
|
'icon' => 'fa fa-trash',
|
||||||
|
'confirm' => 1,
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'rightButton' => [
|
||||||
|
[
|
||||||
|
'info' => '编辑',
|
||||||
|
'href' => 'ApiFieldsManager/edit',
|
||||||
|
'class'=> 'btn-primary',
|
||||||
|
'param'=> [$this->primaryKey],
|
||||||
|
'icon' => 'fa fa-pencil',
|
||||||
|
'confirm' => 0,
|
||||||
|
'show' => ''
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'info' => '删除',
|
||||||
|
'href' => 'ApiFieldsManager/del',
|
||||||
|
'class'=> 'btn-danger ajax-delete',
|
||||||
|
'param'=> [$this->primaryKey],
|
||||||
|
'icon' => 'fa fa-trash',
|
||||||
|
'confirm' => 1,
|
||||||
|
'show' => ''
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'typeRule' => [
|
||||||
|
'must' => [
|
||||||
|
'module' => 'icon',
|
||||||
|
'rule' => [
|
||||||
|
[
|
||||||
|
'info' => '',
|
||||||
|
'class' => 'fa fa-close'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'info' => '',
|
||||||
|
'class' => 'fa fa-check'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'type' => [
|
||||||
|
'module' => 'listValue',
|
||||||
|
'rule' => $this->dataType
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'data' => $data
|
||||||
|
];
|
||||||
|
$table = $this->_prepareTemplate($table);
|
||||||
|
$this->result($table, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function back(){
|
public function back(){
|
||||||
@ -18,7 +119,91 @@ class ApiFieldsManager extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function add(){
|
public function add(){
|
||||||
|
if( $this->request->isPost() ){
|
||||||
|
$apiModel = new ApiFields();
|
||||||
|
$result = $apiModel->allowField(true)->save($this->request->post());
|
||||||
|
if(false === $result){
|
||||||
|
$this->error($apiModel->getError());
|
||||||
|
}else{
|
||||||
|
$this->success('操作成功!', url('ApiFieldsManager/index'));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$form = [
|
||||||
|
'formTitle' => $this->menuInfo['name']."(".session('apiName').")",
|
||||||
|
'tempType' => 'add',
|
||||||
|
'formAttr' => [
|
||||||
|
'target' => url('ApiFieldsManager/add'),
|
||||||
|
'formId' => 'add-ApiFieldsManager-form',
|
||||||
|
'backUrl' => url('ApiFieldsManager/index'),
|
||||||
|
],
|
||||||
|
'formList' => [
|
||||||
|
[
|
||||||
|
'module' => 'hidden',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'apiId',
|
||||||
|
'value' => session('apiId'),
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'text',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '字段名称:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'name',
|
||||||
|
'value' => '',
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'select',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '字段类型:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'type',
|
||||||
|
'value' => '',
|
||||||
|
'options' => $this->dataType
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'radio',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '是否必须:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'must',
|
||||||
|
'value' => '',
|
||||||
|
'options' => [
|
||||||
|
'不必须',
|
||||||
|
'必须',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'text',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '默认值:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'default',
|
||||||
|
'value' => '',
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'textarea',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '字段描述:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'info',
|
||||||
|
'value' => '',
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$this->result($form, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function backAdd(){
|
public function backAdd(){
|
||||||
@ -26,7 +211,99 @@ class ApiFieldsManager extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function edit(){
|
public function edit(){
|
||||||
|
if( $this->request->isPut() ){
|
||||||
|
$data = $this->request->put();
|
||||||
|
$apiModel = new ApiFields();
|
||||||
|
$apiModel->update($data);
|
||||||
|
$this->success('操作成功!', url('ApiFieldsManager/index'));
|
||||||
|
}else{
|
||||||
|
$detail = ApiFields::get($this->request->get($this->primaryKey))->toArray();
|
||||||
|
$form = [
|
||||||
|
'formTitle' => $this->menuInfo['name']."(".session('apiName').")",
|
||||||
|
'tempType' => 'edit',
|
||||||
|
'formAttr' => [
|
||||||
|
'target' => url('ApiFieldsManager/edit'),
|
||||||
|
'formId' => 'edit-ApiFieldsManager-form',
|
||||||
|
'backUrl' => url('ApiFieldsManager/index'),
|
||||||
|
],
|
||||||
|
'formList' => [
|
||||||
|
[
|
||||||
|
'module' => 'hidden',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '',
|
||||||
|
'attr' => [
|
||||||
|
'name' => $this->primaryKey,
|
||||||
|
'value' => $detail[$this->primaryKey],
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'hidden',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'apiId',
|
||||||
|
'value' => session('apiId'),
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'text',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '字段名称:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'name',
|
||||||
|
'value' => $detail['name'],
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'select',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '字段类型:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'type',
|
||||||
|
'value' => $detail['type'],
|
||||||
|
'options' => $this->dataType
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'radio',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '是否必须:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'must',
|
||||||
|
'value' => $detail['must'],
|
||||||
|
'options' => [
|
||||||
|
'不必须',
|
||||||
|
'必须',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'text',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '默认值:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'default',
|
||||||
|
'value' => $detail['default'],
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'module' => 'textarea',
|
||||||
|
'description' => '',
|
||||||
|
'info' => '字段描述:',
|
||||||
|
'attr' => [
|
||||||
|
'name' => 'info',
|
||||||
|
'value' => $detail['info'],
|
||||||
|
'placeholder' => ''
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$this->result($form, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function backEdit(){
|
public function backEdit(){
|
||||||
@ -34,7 +311,14 @@ class ApiFieldsManager extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function del(){
|
public function del(){
|
||||||
|
if( $this->request->isDelete() ){
|
||||||
|
$key = $this->request->delete($this->primaryKey);
|
||||||
|
$delNum = ApiFields::destroy($key);
|
||||||
|
if( $delNum ){
|
||||||
|
$this->success('操作成功!', url('ApiFieldsManager/index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->error('操作失败!');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function backDel(){
|
public function backDel(){
|
||||||
|
@ -109,7 +109,7 @@ class ApiManager extends Base {
|
|||||||
'info' => '请求参数',
|
'info' => '请求参数',
|
||||||
'href' => 'ApiFieldsManager/index',
|
'href' => 'ApiFieldsManager/index',
|
||||||
'class'=> 'btn-warning',
|
'class'=> 'btn-warning',
|
||||||
'param'=> [$this->primaryKey],
|
'param'=> [$this->primaryKey, 'name'],
|
||||||
'icon' => 'fa fa-sign-in',
|
'icon' => 'fa fa-sign-in',
|
||||||
'confirm' => 0,
|
'confirm' => 0,
|
||||||
'show' => ''
|
'show' => ''
|
||||||
@ -118,7 +118,7 @@ class ApiManager extends Base {
|
|||||||
'info' => '返回参数',
|
'info' => '返回参数',
|
||||||
'href' => 'ApiFieldsManager/back',
|
'href' => 'ApiFieldsManager/back',
|
||||||
'class'=> 'btn-info',
|
'class'=> 'btn-info',
|
||||||
'param'=> [$this->primaryKey],
|
'param'=> [$this->primaryKey, 'name'],
|
||||||
'icon' => 'fa fa-sign-out',
|
'icon' => 'fa fa-sign-out',
|
||||||
'confirm' => 0,
|
'confirm' => 0,
|
||||||
'show' => ''
|
'show' => ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user