Controller\Admin\Node::update PHP Method

update() public method

添加 node
public update ( )
    public function update()
    {
        $result = array('error' => -1, 'message' => '保存失败');
        if ($_POST['node_id'] == null) {
            $node = new NodeModel();
            if ($_POST['node_name'] != null) {
                $node->name = $_POST['node_name'];
            }
            if ($_POST['node_type'] != null) {
                $node->type = $_POST['node_type'];
            }
            if ($_POST['node_server'] != null) {
                $node->server = $_POST['node_server'];
            }
            if ($_POST['node_method'] != null) {
                $node->method = $_POST['node_method'];
            }
            if ($_POST['node_info'] != null) {
                $node->info = $_POST['node_info'];
            }
            if ($_POST['node_status'] != null) {
                $node->status = $_POST['node_status'];
            }
            if ($_POST['node_custom_method'] != null) {
                $node->custom_method = $_POST['node_custom_method'];
            }
            if ($_POST['node_order'] != null) {
                $node->order = intval($_POST['node_order']);
            }
            $node->save();
            $result = array('error' => 0, 'message' => '添加成功', 'node' => $node);
        } else {
            if ($_POST['node_id'] != '') {
                $node = NodeModel::getNodeById(trim($_POST['node_id']));
                if ($_POST['node_name'] != null) {
                    $node->name = $_POST['node_name'];
                }
                if ($_POST['node_type'] != null) {
                    $node->type = $_POST['node_type'];
                }
                if ($_POST['node_server'] != null) {
                    $node->server = $_POST['node_server'];
                }
                if ($_POST['node_method'] != null) {
                    $node->method = $_POST['node_method'];
                }
                if ($_POST['node_info'] != null) {
                    $node->info = $_POST['node_info'];
                }
                if ($_POST['node_status'] != null) {
                    $node->status = $_POST['node_status'];
                }
                if ($_POST['node_custom_method'] != null) {
                    $node->custom_method = $_POST['node_custom_method'];
                }
                if ($_POST['node_order'] != null) {
                    $node->order = intval($_POST['node_order']);
                }
                $node->save();
                $result = array('error' => 0, 'message' => '修改成功', 'node' => $node);
            }
        }
        return $result;
    }