diff --git a/Application/Admin/Controller/FieldsInfoManageController.class.php b/Application/Admin/Controller/FieldsInfoManageController.class.php deleted file mode 100644 index 8a0a6ee..0000000 --- a/Application/Admin/Controller/FieldsInfoManageController.class.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ - -namespace Admin\Controller; - - -class FieldsInfoManageController extends BaseController { - - public function index() { - $list = D('ApiFieldsInfo')->order('id asc')->select(); - $this->assign('list', $list); - $this->display(); - } - - public function edit() { - if( IS_GET ) { - $id = I('get.id'); - if( $id ){ - $detail = D('ApiFieldsInfo')->where(array('id' => $id))->find(); - $this->assign('detail', $detail); - $this->display('add'); - }else{ - $this->redirect('add'); - } - }elseif( IS_POST ) { - $data = I('post.'); - $res = D('ApiFieldsInfo')->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('ApiFieldsInfo')->add($data); - if( $res === false ) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('添加成功'); - } - } else { - $data['hash'] = uniqid(); - $this->assign('detail', $data); - $this->display(); - } - } - - public function del() { - if( IS_POST ) { - $id = I('post.id'); - if( $id ) { - D('ApiFieldsInfo')->where(array('id' => $id))->delete(); - $this->ajaxSuccess('操作成功'); - } else { - $this->ajaxError('缺少参数'); - } - } - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/FieldsManageController.class.php b/Application/Admin/Controller/FieldsManageController.class.php index 03a9ac1..a966a38 100644 --- a/Application/Admin/Controller/FieldsManageController.class.php +++ b/Application/Admin/Controller/FieldsManageController.class.php @@ -110,11 +110,26 @@ class FieldsManageController extends BaseController { $data = json_decode($jsonStr, true); D('ApiList')->where(array('hash' => $hash))->save(array('returnStr' => json_encode($data))); $this->handle($data['data'], $dataArr); - D('ApiFields')->where(array( + $old = D('ApiFields')->where(array( 'hash' => $hash, 'type' => I('post.type') - ))->delete(); - D('ApiFields')->addAll($dataArr); + ))->select(); + $oldArr = array_column($old, 'showName'); + $newArr = array_column($dataArr, 'showName'); + $addArr = array_diff($newArr, $oldArr); + $delArr = array_diff($oldArr, $newArr); + if ($delArr) { + D('ApiFields')->where(array('showName' => array('in', $delArr)))->delete(); + } + if ($addArr) { + $addData = array(); + foreach ($dataArr as $item) { + if (in_array($item['showName'], $addArr)) { + $addData[] = $item; + } + } + D('ApiFields')->addAll($addData); + } $this->ajaxSuccess('操作成功'); } else { $this->display(); diff --git a/Application/Admin/Model/ApiFieldsInfoModel.class.php b/Application/Admin/Model/ApiFieldsInfoModel.class.php deleted file mode 100644 index 7b812b1..0000000 --- a/Application/Admin/Model/ApiFieldsInfoModel.class.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ - -namespace Admin\Model; - - -class ApiFieldsInfoModel extends BaseModel { - -} \ No newline at end of file