diff --git a/Application/Admin/Controller/ApiKeyController.class.php b/Application/Admin/Controller/ApiKeyController.class.php
new file mode 100644
index 0000000..9ea4312
--- /dev/null
+++ b/Application/Admin/Controller/ApiKeyController.class.php
@@ -0,0 +1,103 @@
+
+ */
+
+namespace Admin\Controller;
+
+
+class ApiKeyController extends BaseController {
+
+ public function index() {
+ $this->display();
+ }
+
+ public function ajaxGetIndex() {
+ $postData = I('post.');
+ $start = $postData['start'] ? $postData['start'] : 0;
+ $limit = $postData['length'] ? $postData['length'] : 20;
+ $draw = $postData['draw'];
+ $total = D('ApiStoreAuth')->count();
+ $info = D('ApiStoreAuth')->limit($start, $limit)->select();
+ $data = array(
+ 'draw' => $draw,
+ 'recordsTotal' => $total,
+ 'recordsFiltered' => $total,
+ 'data' => $info
+ );
+ $this->ajaxReturn($data, 'json');
+ }
+
+ public function edit(){
+ if( IS_GET ){
+ $id = I('get.id');
+ if( $id ){
+ $detail = D('ApiStoreAuth')->where(array('id' => $id))->find();
+ $this->assign('detail', $detail);
+ $this->display('add');
+ }else{
+ $this->redirect('add');
+ }
+ }elseif( IS_POST ){
+ $data = I('post.');
+ $res = D('ApiStoreAuth')->where(array('id' => $data['id']))->save($data);
+ if( $res === false ){
+ $this->ajaxError('操作失败');
+ }else{
+ $this->ajaxSuccess('操作成功');
+ }
+ }
+ }
+
+ public function add(){
+ if( IS_POST ){
+ $data = I('post.');
+ $res = D('ApiStoreAuth')->add($data);
+ if( $res === false ){
+ $this->ajaxError('操作失败');
+ }else{
+ $this->ajaxSuccess('添加成功');
+ }
+ }else{
+ $this->display();
+ }
+ }
+
+ public function open(){
+ if( IS_POST ){
+ $id = I('post.id');
+ if( $id ){
+ D('ApiStoreAuth')->open(array('id' => $id));
+ $this->ajaxSuccess('操作成功');
+ }else{
+ $this->ajaxError('缺少参数');
+ }
+ }
+ }
+
+ public function close(){
+ if( IS_POST ){
+ $id = I('post.id');
+ if( $id ){
+ D('ApiStoreAuth')->close(array('id' => $id));
+ $this->ajaxSuccess('操作成功');
+ }else{
+ $this->ajaxError('缺少参数');
+ }
+ }
+ }
+
+ public function del(){
+ if( IS_POST ){
+ $id = I('post.id');
+ if( $id ){
+ D('ApiStoreAuth')->where(array('id' => $id))->delete();
+ $this->ajaxSuccess('操作成功');
+ }else{
+ $this->ajaxError('缺少参数');
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Application/Admin/Controller/ApiStoreController.class.php b/Application/Admin/Controller/ApiStoreController.class.php
new file mode 100644
index 0000000..5054e05
--- /dev/null
+++ b/Application/Admin/Controller/ApiStoreController.class.php
@@ -0,0 +1,129 @@
+
+ */
+
+namespace Admin\Controller;
+
+
+class ApiStoreController extends BaseController {
+ public function index() {
+ $keyArr = D('ApiStoreAuth')->select();
+ $list = array_column($keyArr, 'name', 'id');
+ $list[0] = '暂不绑定';
+ $this->assign('list', $list);
+ $this->display();
+ }
+
+ public function ajaxGetIndex() {
+ $postData = I('post.');
+ $start = $postData['start'] ? $postData['start'] : 0;
+ $limit = $postData['length'] ? $postData['length'] : 20;
+ $draw = $postData['draw'];
+ $total = D('ApiStore')->count();
+ $info = D('ApiStore')->limit($start, $limit)->select();
+ $data = array(
+ 'draw' => $draw,
+ 'recordsTotal' => $total,
+ 'recordsFiltered' => $total,
+ 'data' => $info
+ );
+ $this->ajaxReturn($data, 'json');
+ }
+
+ public function edit() {
+ if (IS_GET) {
+ $id = I('get.id');
+ if ($id) {
+ $detail = D('ApiStore')->where(array('id' => $id))->find();
+ $this->assign('detail', $detail);
+ $keyArr = D('ApiStoreAuth')->select();
+ $list = array_column($keyArr, 'name', 'id');
+ $list[0] = '暂不绑定';
+ $this->assign('list', $list);
+ $this->display('add');
+ } else {
+ $this->redirect('add');
+ }
+ } elseif (IS_POST) {
+ $data = I('post.');
+ $res = D('ApiStore')->where(array('id' => $data['id']))->save($data);
+ if ($res === false) {
+ $this->ajaxError('操作失败');
+ } else {
+ $this->ajaxSuccess('操作成功');
+ }
+ }
+ }
+
+ public function refresh() {
+ $apiPath = dirname(THINK_PATH) . '/Application/Home/ApiStore/';
+ $dir = opendir($apiPath);
+ if ($dir) {
+ $preData = array();
+ while (($file = readdir($dir)) !== false) {
+ $filePath = $apiPath . $file;
+ if (!is_dir($filePath)) {
+ $prefix = 'Home\\ApiStore\\';
+ $moduleName = str_replace('.class.php', '', $file);
+ $reflection = new \ReflectionClass($prefix . $moduleName);
+ if ($reflection->hasProperty('apiName')) {
+ $data['name'] = $reflection->getStaticPropertyValue('apiName');
+ } else {
+ $data['name'] = '未定义';
+ }
+ $data['path'] = $prefix . $moduleName;
+ $preDataPath[] = $prefix . $moduleName;
+ $preData[] = $data;
+ }
+ }
+ if (!$preData) {
+ D('ApiStore')->execute('Truncate Table api_store');
+ } else {
+ $old = D('ApiStore')->select();
+ $oldPath = array_column($old, 'path');
+ $addArr = array_diff($preDataPath, $oldPath);
+ $delArr = array_diff($oldPath, $preDataPath);
+ if ($delArr) {
+ D('ApiStore')->where(array('path' => array('in', $delArr)))->delete();
+ }
+ if ($addArr) {
+ $addData = array();
+ foreach ($preData as $item) {
+ if (in_array($item['path'], $addArr)) {
+ $addData[] = $item;
+ }
+ }
+ D('ApiStore')->addAll($addData);
+ }
+ }
+ }
+ $this->ajaxSuccess('操作成功');
+ }
+
+ public function open() {
+ if (IS_POST) {
+ $id = I('post.id');
+ if ($id) {
+ D('ApiStore')->open(array('id' => $id));
+ $this->ajaxSuccess('操作成功');
+ } else {
+ $this->ajaxError('缺少参数');
+ }
+ }
+ }
+
+ public function close() {
+ if (IS_POST) {
+ $id = I('post.id');
+ if ($id) {
+ D('ApiStore')->close(array('id' => $id));
+ $this->ajaxSuccess('操作成功');
+ } else {
+ $this->ajaxError('缺少参数');
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Application/Admin/Model/ApiStoreAuthModel.class.php b/Application/Admin/Model/ApiStoreAuthModel.class.php
new file mode 100644
index 0000000..4450f9a
--- /dev/null
+++ b/Application/Admin/Model/ApiStoreAuthModel.class.php
@@ -0,0 +1,20 @@
+
+ */
+
+namespace Admin\Model;
+
+
+class ApiStoreAuthModel extends BaseModel {
+
+ public function open( $where ){
+ return $this->where( $where )->save( array('status' => 1) );
+ }
+
+ public function close( $where ){
+ return $this->where( $where )->save( array('status' => 0) );
+ }
+
+}
\ No newline at end of file
diff --git a/Application/Admin/Model/ApiStoreModel.class.php b/Application/Admin/Model/ApiStoreModel.class.php
new file mode 100644
index 0000000..9da476d
--- /dev/null
+++ b/Application/Admin/Model/ApiStoreModel.class.php
@@ -0,0 +1,13 @@
+
+ */
+
+namespace Admin\Model;
+
+
+class ApiStoreModel extends BaseModel {
+
+}
\ No newline at end of file
diff --git a/Application/Admin/Model/BaseModel.class.php b/Application/Admin/Model/BaseModel.class.php
index f62cdf0..9e89210 100644
--- a/Application/Admin/Model/BaseModel.class.php
+++ b/Application/Admin/Model/BaseModel.class.php
@@ -12,4 +12,12 @@ use Think\Model;
class BaseModel extends Model {
Protected $autoCheckFields = false;
+
+ public function open( $where ){
+ return $this->where( $where )->save( array('status' => 1) );
+ }
+
+ public function close( $where ){
+ return $this->where( $where )->save( array('status' => 0) );
+ }
}
\ No newline at end of file
diff --git a/Application/Admin/View/ApiKey/add.html b/Application/Admin/View/ApiKey/add.html
new file mode 100644
index 0000000..2af8432
--- /dev/null
+++ b/Application/Admin/View/ApiKey/add.html
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Application/Admin/View/ApiKey/index.html b/Application/Admin/View/ApiKey/index.html
new file mode 100644
index 0000000..b676dbc
--- /dev/null
+++ b/Application/Admin/View/ApiKey/index.html
@@ -0,0 +1,160 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Application/Admin/View/ApiStore/add.html b/Application/Admin/View/ApiStore/add.html
new file mode 100644
index 0000000..e1309f1
--- /dev/null
+++ b/Application/Admin/View/ApiStore/add.html
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Application/Admin/View/ApiStore/index.html b/Application/Admin/View/ApiStore/index.html
new file mode 100644
index 0000000..56225cf
--- /dev/null
+++ b/Application/Admin/View/ApiStore/index.html
@@ -0,0 +1,152 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file