diff --git a/thinkphp/convention.php b/thinkphp/convention.php
index c1753afca..6373e5064 100644
--- a/thinkphp/convention.php
+++ b/thinkphp/convention.php
@@ -4,7 +4,7 @@ return [
     // +----------------------------------------------------------------------
     // | 应用设置
     // +----------------------------------------------------------------------
-    'app'      => [
+    'app'        => [
         // 应用名称
         'app_name'               => '',
         // 应用地址
@@ -150,7 +150,7 @@ return [
     // | 模板设置
     // +----------------------------------------------------------------------
 
-    'template' => [
+    'template'   => [
         // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写
         'auto_rule'    => 1,
         // 模板引擎类型 支持 php think 支持扩展
@@ -177,7 +177,7 @@ return [
     // | 日志设置
     // +----------------------------------------------------------------------
 
-    'log'      => [
+    'log'        => [
         // 日志记录方式,内置 file socket 支持扩展
         'type'         => 'File',
         // 日志保存目录
@@ -194,7 +194,7 @@ return [
     // | Trace设置 开启 app_trace 后 有效
     // +----------------------------------------------------------------------
 
-    'trace'    => [
+    'trace'      => [
         // 内置Html Console 支持扩展
         'type' => 'Html',
         'file' => __DIR__ . '/tpl/page_trace.tpl',
@@ -204,7 +204,7 @@ return [
     // | 缓存设置
     // +----------------------------------------------------------------------
 
-    'cache'    => [
+    'cache'      => [
         // 驱动方式
         'type'   => 'File',
         // 缓存保存目录
@@ -219,7 +219,7 @@ return [
     // | 会话设置
     // +----------------------------------------------------------------------
 
-    'session'  => [
+    'session'    => [
         'id'             => '',
         // SESSION_ID的提交变量,解决flash上传跨域
         'var_session_id' => '',
@@ -237,7 +237,7 @@ return [
     // | Cookie设置
     // +----------------------------------------------------------------------
 
-    'cookie'   => [
+    'cookie'     => [
         // cookie 名称前缀
         'prefix'    => '',
         // cookie 保存时间
@@ -258,7 +258,7 @@ return [
     // | 数据库设置
     // +----------------------------------------------------------------------
 
-    'database' => [
+    'database'   => [
         // 数据库类型
         'type'            => 'mysql',
         // 数据库连接DSN配置
@@ -304,16 +304,21 @@ return [
     ],
 
     //分页配置
-    'paginate' => [
+    'paginate'   => [
         'type'      => 'bootstrap',
         'var_page'  => 'page',
         'list_rows' => 15,
     ],
 
     //控制台配置
-    'console'  => [
+    'console'    => [
         'name'    => 'Think Console',
         'version' => '0.1',
         'user'    => null,
     ],
+
+    // 中间件配置
+    'middleware' => [
+        'default_namespace' => 'app\\http\\middleware\\',
+    ],
 ];
diff --git a/thinkphp/library/think/App.php b/thinkphp/library/think/App.php
index 34b677af5..4c2e19d10 100644
--- a/thinkphp/library/think/App.php
+++ b/thinkphp/library/think/App.php
@@ -20,7 +20,7 @@ use think\route\Dispatch;
  */
 class App extends Container
 {
-    const VERSION = '5.1.15';
+    const VERSION = '5.1.16';
 
     /**
      * 当前模块路径
@@ -118,6 +118,12 @@ class App extends Container
      */
     protected $bindModule;
 
+    /**
+     * 初始化
+     * @var bool
+     */
+    protected $initialized = false;
+
     public function __construct($appPath = '')
     {
         $this->appPath = $appPath ? realpath($appPath) . DIRECTORY_SEPARATOR : $this->getAppPath();
@@ -153,39 +159,6 @@ class App extends Container
         return $this;
     }
 
-    /**
-     * 注册核心容器实例
-     * @access public
-     * @return void
-     */
-    public function registerCoreContainer()
-    {
-        // 注册核心类到容器
-        $this->bindTo([
-            'app'                   => App::class,
-            'build'                 => Build::class,
-            'cache'                 => Cache::class,
-            'config'                => Config::class,
-            'cookie'                => Cookie::class,
-            'debug'                 => Debug::class,
-            'env'                   => Env::class,
-            'hook'                  => Hook::class,
-            'lang'                  => Lang::class,
-            'log'                   => Log::class,
-            'middleware'            => Middleware::class,
-            'request'               => Request::class,
-            'response'              => Response::class,
-            'route'                 => Route::class,
-            'session'               => Session::class,
-            'url'                   => Url::class,
-            'validate'              => Validate::class,
-            'view'                  => View::class,
-            'rule_name'             => route\RuleName::class,
-            // 接口依赖注入
-            'think\LoggerInterface' => Log::class,
-        ]);
-    }
-
     /**
      * 初始化应用
      * @access public
@@ -193,13 +166,16 @@ class App extends Container
      */
     public function initialize()
     {
-        $this->beginTime = microtime(true);
-        $this->beginMem  = memory_get_usage();
+        if ($this->initialized) {
+            return;
+        }
+
+        $this->initialized = true;
+        $this->beginTime   = microtime(true);
+        $this->beginMem    = memory_get_usage();
 
         static::setInstance($this);
 
-        $this->registerCoreContainer();
-
         $this->instance('app', $this);
 
         // 加载惯例配置文件
@@ -370,6 +346,8 @@ class App extends Container
         }
 
         Db::init($config['database']);
+        $this->middleware->setConfig($config['middleware']);
+        $this->route->setConfig($config['app']);
         $this->request->init($config['app']);
         $this->cookie->init($config['cookie']);
         $this->view->init($config['template']);
@@ -505,7 +483,7 @@ class App extends Container
             $this->lang->detect();
         }
 
-        $this->request->langset($this->lang->range());
+        $this->request->setLangset($this->lang->range());
 
         // 加载系统语言包
         $this->lang->load([
diff --git a/thinkphp/library/think/Container.php b/thinkphp/library/think/Container.php
index 743a88d3f..79c84e13a 100644
--- a/thinkphp/library/think/Container.php
+++ b/thinkphp/library/think/Container.php
@@ -38,12 +38,27 @@ class Container implements \ArrayAccess
      * @var array
      */
     protected $bind = [
-        'app'      => 'think\App',
-        'config'   => 'think\Config',
-        'lang'     => 'think\Lang',
-        'log'      => 'think\Log',
-        'request'  => 'think\Request',
-        'response' => 'think\Response',
+        'app'                   => App::class,
+        'build'                 => Build::class,
+        'cache'                 => Cache::class,
+        'config'                => Config::class,
+        'cookie'                => Cookie::class,
+        'debug'                 => Debug::class,
+        'env'                   => Env::class,
+        'hook'                  => Hook::class,
+        'lang'                  => Lang::class,
+        'log'                   => Log::class,
+        'middleware'            => Middleware::class,
+        'request'               => Request::class,
+        'response'              => Response::class,
+        'route'                 => Route::class,
+        'session'               => Session::class,
+        'url'                   => Url::class,
+        'validate'              => Validate::class,
+        'view'                  => View::class,
+        'rule_name'             => route\RuleName::class,
+        // 接口依赖注入
+        'think\LoggerInterface' => Log::class,
     ];
 
     /**
diff --git a/thinkphp/library/think/Cookie.php b/thinkphp/library/think/Cookie.php
index 2fd8c31b6..08141617c 100644
--- a/thinkphp/library/think/Cookie.php
+++ b/thinkphp/library/think/Cookie.php
@@ -53,7 +53,7 @@ class Cookie
     {
         $this->config = array_merge($this->config, array_change_key_case($config));
 
-        if (!empty($this->config['httponly'])) {
+        if (!empty($this->config['httponly']) && PHP_SESSION_ACTIVE != session_status()) {
             ini_set('session.cookie_httponly', 1);
         }
     }
diff --git a/thinkphp/library/think/Model.php b/thinkphp/library/think/Model.php
index 124635508..c0dc9a3de 100644
--- a/thinkphp/library/think/Model.php
+++ b/thinkphp/library/think/Model.php
@@ -28,10 +28,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
     use model\concern\Conversion;
 
     /**
-     * 是否更新数据
+     * 是否存在数据
      * @var bool
      */
-    private $isUpdate = false;
+    private $exists = false;
 
     /**
      * 是否Replace
@@ -283,16 +283,14 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
 
         $query = $this->buildQuery();
 
-        if ($useBaseQuery) {
-            // 软删除
-            if (method_exists($this, 'withNoTrashed')) {
-                $this->withNoTrashed($query);
-            }
+        // 软删除
+        if (method_exists($this, 'withNoTrashed')) {
+            $this->withNoTrashed($query);
+        }
 
-            // 全局作用域
-            if (method_exists($this, 'base')) {
-                call_user_func_array([$this, 'base'], [ & $query]);
-            }
+        // 全局作用域
+        if ($useBaseQuery && method_exists($this, 'base')) {
+            call_user_func_array([$this, 'base'], [ & $query]);
         }
 
         // 返回当前模型的数据库查询对象
@@ -368,13 +366,23 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
         return $this;
     }
 
+    /**
+     * 新增数据是否使用Replace
+     * @access public
+     * @return bool
+     */
+    public function isExists()
+    {
+        return $this->exists;
+    }
+
     /**
      * 保存当前数据对象
      * @access public
      * @param  array  $data     数据
      * @param  array  $where    更新条件
      * @param  string $sequence 自增序列名
-     * @return integer|false
+     * @return bool
      */
     public function save($data = [], $where = [], $sequence = null)
     {
@@ -387,7 +395,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
             return false;
         }
 
-        $result = $this->isUpdate ? $this->updateData($where) : $this->insertData($sequence);
+        $result = $this->exists ? $this->updateData($where) : $this->insertData($sequence);
 
         if (false === $result) {
             return false;
@@ -399,7 +407,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
         // 重新记录原始数据
         $this->origin = $this->data;
 
-        return $result;
+        return true;
     }
 
     /**
@@ -412,14 +420,13 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
     protected function checkBeforeSave($data, $where)
     {
         if (!empty($data)) {
-
             // 数据对象赋值
             foreach ($data as $key => $value) {
                 $this->setAttr($key, $value, $data);
             }
 
             if (!empty($where)) {
-                $this->isUpdate    = true;
+                $this->exists      = true;
                 $this->updateWhere = $where;
             }
         }
@@ -463,14 +470,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
             // 废弃字段
             $field = array_diff($field, (array) $this->disuse);
         }
+
         return $field;
     }
 
     /**
-     * 保存写入数据
+     * 更新写入数据
      * @access protected
-     * @param  array   $where 保存条件
-     * @return int|false
+     * @param  mixed   $where 更新条件
+     * @return bool
      */
     protected function updateData($where)
     {
@@ -491,7 +499,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
                 $this->autoRelationUpdate();
             }
 
-            return 0;
+            return false;
         } elseif ($this->autoWriteTimestamp && $this->updateTime && !isset($data[$this->updateTime])) {
             // 自动写入更新时间
             $data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime);
@@ -542,7 +550,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
         $db->startTrans();
 
         try {
-            $result = $db->where($where)
+            $db->where($where)
                 ->strict(false)
                 ->field($allowFields)
                 ->update($data);
@@ -557,7 +565,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
             // 更新回调
             $this->trigger('after_update');
 
-            return $result;
+            return true;
         } catch (\Exception $e) {
             $db->rollback();
             throw $e;
@@ -567,8 +575,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
     /**
      * 新增写入数据
      * @access protected
-     * @param  string   $sequence 自增名
-     * @return int|false
+     * @param  string   $sequence 自增序列名
+     * @return bool
      */
     protected function insertData($sequence)
     {
@@ -612,12 +620,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
             $db->commit();
 
             // 标记为更新
-            $this->isUpdate = true;
+            $this->exists = true;
 
             // 新增回调
             $this->trigger('after_insert');
 
-            return $result;
+            return true;
         } catch (\Exception $e) {
             $db->rollback();
             throw $e;
@@ -630,7 +638,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
      * @param  string  $field    字段名
      * @param  integer $step     增长值
      * @param  integer $lazyTime 延时时间(s)
-     * @return integer|true
+     * @return bool
      * @throws Exception
      */
     public function setInc($field, $step = 1, $lazyTime = 0)
@@ -654,7 +662,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
         // 更新回调
         $this->trigger('after_update');
 
-        return $result;
+        return true;
     }
 
     /**
@@ -663,7 +671,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
      * @param  string  $field    字段名
      * @param  integer $step     减少值
      * @param  integer $lazyTime 延时时间(s)
-     * @return integer|true
+     * @return bool
      * @throws Exception
      */
     public function setDec($field, $step = 1, $lazyTime = 0)
@@ -687,7 +695,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
         // 更新回调
         $this->trigger('after_update');
 
-        return $result;
+        return true;
     }
 
     /**
@@ -734,7 +742,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
             }
 
             foreach ($dataSet as $key => $data) {
-                if ($this->isUpdate || (!empty($auto) && isset($data[$pk]))) {
+                if ($this->exists || (!empty($auto) && isset($data[$pk]))) {
                     $result[$key] = self::update($data, [], $this->field);
                 } else {
                     $result[$key] = self::create($data, $this->field);
@@ -760,13 +768,13 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
     public function isUpdate($update = true, $where = null)
     {
         if (is_bool($update)) {
-            $this->isUpdate = $update;
+            $this->exists = $update;
 
             if (!empty($where)) {
                 $this->updateWhere = $where;
             }
         } else {
-            $this->isUpdate    = true;
+            $this->exists      = true;
             $this->updateWhere = $update;
         }
 
@@ -776,11 +784,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
     /**
      * 删除当前的记录
      * @access public
-     * @return integer
+     * @return bool
      */
     public function delete()
     {
-        if (false === $this->trigger('before_delete')) {
+        if (!$this->exists || false === $this->trigger('before_delete')) {
             return false;
         }
 
@@ -803,11 +811,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
 
             $this->trigger('after_delete');
 
-            // 清空数据
-            $this->data   = [];
-            $this->origin = [];
+            $this->exists = false;
 
-            return $result;
+            return true;
         } catch (\Exception $e) {
             $db->rollback();
             throw $e;
@@ -960,12 +966,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
      * 删除记录
      * @access public
      * @param  mixed $data 主键列表 支持闭包查询条件
-     * @return integer 成功删除的记录数
+     * @return bool
      */
     public static function destroy($data)
     {
         if (empty($data) && 0 !== $data) {
-            return 0;
+            return false;
         }
 
         $model = new static();
@@ -981,16 +987,14 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
         }
 
         $resultSet = $query->select($data);
-        $count     = 0;
 
         if ($resultSet) {
             foreach ($resultSet as $data) {
-                $result = $data->delete();
-                $count += $result;
+                $data->delete();
             }
         }
 
-        return $count;
+        return true;
     }
 
     /**
diff --git a/thinkphp/library/think/Request.php b/thinkphp/library/think/Request.php
index 925e2148d..60d22d763 100644
--- a/thinkphp/library/think/Request.php
+++ b/thinkphp/library/think/Request.php
@@ -13,12 +13,6 @@ namespace think;
 
 class Request
 {
-    /**
-     * 对象实例
-     * @var object
-     */
-    protected $instance;
-
     /**
      * 配置参数
      * @var array
@@ -114,9 +108,9 @@ class Request
 
     /**
      * 当前调度信息
-     * @var array
+     * @var \think\route\Dispatch
      */
-    protected $dispatch = [];
+    protected $dispatch;
 
     /**
      * 当前模块名
@@ -276,6 +270,12 @@ class Request
      */
     protected $secureKey;
 
+    /**
+     * 是否合并Param
+     * @var bool
+     */
+    protected $mergeParam = false;
+
     /**
      * 架构函数
      * @access public
@@ -309,10 +309,10 @@ class Request
     public static function __make(App $app, Config $config)
     {
         $request = new static($config->pull('app'));
-        $request->session($app['session']->get());
-        $request->cookie($app['cookie']->get());
-        $request->server($_SERVER);
-        $request->env($app['env']->get());
+
+        $request->cookie = $app['cookie']->get();
+        $request->server = $_SERVER;
+        $request->env    = $app['env']->get();
 
         return $request;
     }
@@ -440,26 +440,14 @@ class Request
     }
 
     /**
-     * 设置或获取当前包含协议的域名
+     * 获取当前包含协议、端口的域名
      * @access public
-     * @param  string|bool $domain 域名
-     * @return string|$this
+     * @param  bool $port 是否需要去除端口号
+     * @return string
      */
-    public function domain($domain = null)
+    public function domain($port = false)
     {
-        if (is_null($domain)) {
-            if (!$this->domain) {
-                $this->domain = $this->scheme() . '://' . $this->host();
-            }
-            return $this->domain;
-        }
-
-        if (true === $domain) {
-            return $this->scheme() . '://' . $this->host(true);
-        }
-
-        $this->domain = $domain;
-        return $this;
+        return $this->scheme() . '://' . $this->host($port);
     }
 
     /**
@@ -505,35 +493,38 @@ class Request
     }
 
     /**
-     * 设置或获取当前泛域名的值
+     * 设置当前泛域名的值
      * @access public
      * @param  string $domain 域名
-     * @return string|$this
+     * @return $this
      */
-    public function panDomain($domain = null)
+    public function setPanDomain($domain)
     {
-        if (is_null($domain)) {
-            return $this->panDomain;
-        }
-
         $this->panDomain = $domain;
         return $this;
     }
 
     /**
-     * 设置或获取当前完整URL 包括QUERY_STRING
+     * 获取当前泛域名的值
      * @access public
-     * @param  string|true $url URL地址 true 带域名获取
-     * @return string|$this
+     * @return string
      */
-    public function url($url = null)
+    public function panDomain()
     {
-        if (!is_null($url) && true !== $url) {
-            $this->url = $url;
-            return $this;
-        } elseif (!$this->url) {
+        return $this->panDomain;
+    }
+
+    /**
+     * 获取当前完整URL 包括QUERY_STRING
+     * @access public
+     * @param  bool $complete 是否包含域名
+     * @return string
+     */
+    public function url($complete = false)
+    {
+        if (!$this->url) {
             if ($this->isCli()) {
-                $this->url = $this->server('argv')[1] ?: '';
+                $this->url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
             } elseif ($this->server('HTTP_X_REWRITE_URL')) {
                 $this->url = $this->server('HTTP_X_REWRITE_URL');
             } elseif ($this->server('REQUEST_URI')) {
@@ -545,40 +536,34 @@ class Request
             }
         }
 
-        return true === $url ? $this->domain() . $this->url : $this->url;
+        return $complete ? $this->domain() . $this->url : $this->url;
     }
 
     /**
-     * 设置或获取当前URL 不含QUERY_STRING
+     * 获取当前URL 不含QUERY_STRING
      * @access public
-     * @param  string $url URL地址
+     * @param  bool     $domain 是否包含域名
      * @return string|$this
      */
-    public function baseUrl($url = null)
+    public function baseUrl($domain = false)
     {
-        if (!is_null($url) && true !== $url) {
-            $this->baseUrl = $url;
-            return $this;
-        } elseif (!$this->baseUrl) {
+        if (!$this->baseUrl) {
             $str           = $this->url();
             $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str;
         }
 
-        return true === $url ? $this->domain() . $this->baseUrl : $this->baseUrl;
+        return $domain ? $this->domain() . $this->baseUrl : $this->baseUrl;
     }
 
     /**
      * 设置或获取当前执行的文件 SCRIPT_NAME
      * @access public
-     * @param  string $file 当前执行的文件
+     * @param  bool     $domain 是否包含域名
      * @return string|$this
      */
-    public function baseFile($file = null)
+    public function baseFile($domain = false)
     {
-        if (!is_null($file) && true !== $file) {
-            $this->baseFile = $file;
-            return $this;
-        } elseif (!$this->baseFile) {
+        if (!$this->baseFile) {
             $url = '';
             if (!$this->isCli()) {
                 $script_name = basename($this->server('SCRIPT_FILENAME'));
@@ -597,21 +582,31 @@ class Request
             $this->baseFile = $url;
         }
 
-        return true === $file ? $this->domain() . $this->baseFile : $this->baseFile;
+        return $domain ? $this->domain() . $this->baseFile : $this->baseFile;
     }
 
     /**
-     * 设置或获取URL访问根地址
+     * 设置URL访问根地址
      * @access public
      * @param  string $url URL地址
      * @return string|$this
      */
-    public function root($url = null)
+    public function setRoot($url = null)
     {
-        if (!is_null($url) && true !== $url) {
-            $this->root = $url;
-            return $this;
-        } elseif (!$this->root) {
+
+        $this->root = $url;
+        return $this;
+    }
+
+    /**
+     * 获取URL访问根地址
+     * @access public
+     * @param  bool     $domain 是否包含域名
+     * @return string|$this
+     */
+    public function root($domain = false)
+    {
+        if (!$this->root) {
             $file = $this->baseFile();
             if ($file && 0 !== strpos($this->url(), $file)) {
                 $file = str_replace('\\', '/', dirname($file));
@@ -619,7 +614,7 @@ class Request
             $this->root = rtrim($file, '/');
         }
 
-        return true === $url ? $this->domain() . $this->root : $this->root;
+        return $domain ? $this->domain() . $this->root : $this->root;
     }
 
     /**
@@ -653,7 +648,7 @@ class Request
                 unset($_GET[$this->config['var_pathinfo']]);
             } elseif ($this->isCli()) {
                 // CLI模式下 index.php module/controller/action/params/...
-                $pathinfo = isset($this->server('argv')[1]) ? $this->server('argv')[1] : '';
+                $pathinfo = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
             } elseif ('cli-server' == PHP_SAPI) {
                 $pathinfo = strpos($this->server('REQUEST_URI'), '?') ? strstr($this->server('REQUEST_URI'), '?', true) : $this->server('REQUEST_URI');
             } elseif ($this->server('PATH_INFO')) {
@@ -889,7 +884,7 @@ class Request
      */
     public function param($name = '', $default = null, $filter = '')
     {
-        if (empty($this->param)) {
+        if (!$this->mergeParam) {
             $method = $this->method(true);
 
             // 自动获取请求变量
@@ -907,7 +902,8 @@ class Request
             }
 
             // 当前请求参数和URL地址中的参数合并
-            $this->param = array_merge($this->get(false), $vars, $this->route(false));
+            $this->param      = array_merge($this->param, $this->get(false), $vars, $this->route(false));
+            $this->mergeParam = true;
         }
 
         if (true === $name) {
@@ -921,27 +917,34 @@ class Request
     }
 
     /**
-     * 设置获取路由参数
+     * 设置路由变量
      * @access public
-     * @param  mixed         $name 变量名
+     * @param  array         $route 路由变量
+     * @return $this
+     */
+    public function setRouteVars(array $route)
+    {
+        $this->route = array_merge($this->route, $route);
+        return $this;
+    }
+
+    /**
+     * 获取路由参数
+     * @access public
+     * @param  string|false  $name 变量名
      * @param  mixed         $default 默认值
      * @param  string|array  $filter 过滤方法
      * @return mixed
      */
     public function route($name = '', $default = null, $filter = '')
     {
-        if (is_array($name)) {
-            $this->param        = [];
-            return $this->route = array_merge($this->route, $name);
-        }
-
         return $this->input($this->route, $name, $default, $filter);
     }
 
     /**
-     * 设置获取GET参数
+     * 获取GET参数
      * @access public
-     * @param  mixed         $name 变量名
+     * @param  string|false  $name 变量名
      * @param  mixed         $default 默认值
      * @param  string|array  $filter 过滤方法
      * @return mixed
@@ -952,18 +955,13 @@ class Request
             $this->get = $_GET;
         }
 
-        if (is_array($name)) {
-            $this->param      = [];
-            return $this->get = array_merge($this->get, $name);
-        }
-
         return $this->input($this->get, $name, $default, $filter);
     }
 
     /**
-     * 设置获取POST参数
+     * 获取POST参数
      * @access public
-     * @param  mixed         $name 变量名
+     * @param  string|false  $name 变量名
      * @param  mixed         $default 默认值
      * @param  string|array  $filter 过滤方法
      * @return mixed
@@ -979,18 +977,13 @@ class Request
             }
         }
 
-        if (is_array($name)) {
-            $this->param       = [];
-            return $this->post = array_merge($this->post, $name);
-        }
-
         return $this->input($this->post, $name, $default, $filter);
     }
 
     /**
-     * 设置获取PUT参数
+     * 获取PUT参数
      * @access public
-     * @param  mixed             $name 变量名
+     * @param  string|false      $name 变量名
      * @param  mixed             $default 默认值
      * @param  string|array      $filter 过滤方法
      * @return mixed
@@ -1006,18 +999,13 @@ class Request
             }
         }
 
-        if (is_array($name)) {
-            $this->param      = [];
-            return $this->put = is_null($this->put) ? $name : array_merge($this->put, $name);
-        }
-
         return $this->input($this->put, $name, $default, $filter);
     }
 
     /**
-     * 设置获取DELETE参数
+     * 获取DELETE参数
      * @access public
-     * @param  mixed             $name 变量名
+     * @param  string|false      $name 变量名
      * @param  mixed             $default 默认值
      * @param  string|array      $filter 过滤方法
      * @return mixed
@@ -1028,9 +1016,9 @@ class Request
     }
 
     /**
-     * 设置获取PATCH参数
+     * 获取PATCH参数
      * @access public
-     * @param  mixed             $name 变量名
+     * @param  string|false      $name 变量名
      * @param  mixed             $default 默认值
      * @param  string|array      $filter 过滤方法
      * @return mixed
@@ -1043,8 +1031,8 @@ class Request
     /**
      * 获取request变量
      * @access public
-     * @param  mixed         $name 数据名称
-     * @param  string        $default 默认值
+     * @param  string|false  $name 变量名
+     * @param  mixed         $default 默认值
      * @param  string|array  $filter 过滤方法
      * @return mixed
      */
@@ -1054,44 +1042,40 @@ class Request
             $this->request = $_REQUEST;
         }
 
-        if (is_array($name)) {
-            $this->param          = [];
-            return $this->request = array_merge($this->request, $name);
-        }
-
         return $this->input($this->request, $name, $default, $filter);
     }
 
     /**
      * 获取session数据
      * @access public
-     * @param  mixed         $name 数据名称
+     * @param  string        $name 数据名称
      * @param  string        $default 默认值
-     * @param  string|array  $filter 过滤方法
      * @return mixed
      */
-    public function session($name = '', $default = null, $filter = '')
+    public function session($name = '', $default = null)
     {
-        if (is_array($name)) {
-            return $this->session = array_merge($this->session, $name);
+        if (empty($this->session)) {
+            $this->session = facade\Session::get();
         }
 
-        return $this->input($this->session, $name, $default, $filter);
+        if ('' === $name) {
+            return $this->session;
+        }
+
+        return isset($this->session[$name]) ? $this->session[$name] : $default;
     }
 
     /**
      * 获取cookie参数
      * @access public
-     * @param  mixed         $name 数据名称
+     * @param  string        $name 变量名
      * @param  string        $default 默认值
      * @param  string|array  $filter 过滤方法
      * @return mixed
      */
     public function cookie($name = '', $default = null, $filter = '')
     {
-        if (is_array($name)) {
-            return $this->cookie = array_merge($this->cookie, $name);
-        } elseif (!empty($name)) {
+        if (!empty($name)) {
             $data = isset($this->cookie[$name]) ? $this->cookie[$name] : $default;
         } else {
             $data = $this->cookie;
@@ -1113,24 +1097,25 @@ class Request
     /**
      * 获取server参数
      * @access public
-     * @param  mixed         $name 数据名称
+     * @param  string        $name 数据名称
      * @param  string        $default 默认值
-     * @param  string|array  $filter 过滤方法
      * @return mixed
      */
-    public function server($name = '', $default = null, $filter = '')
+    public function server($name = '', $default = null)
     {
-        if (is_array($name)) {
-            return $this->server = array_merge($this->server, $name);
+        if (empty($name)) {
+            return $this->server;
+        } else {
+            $name = strtoupper($name);
         }
 
-        return $this->input($this->server, false === $name ? false : strtoupper($name), $default, $filter);
+        return isset($this->server[$name]) ? $this->server[$name] : $default;
     }
 
     /**
      * 获取上传的文件信息
      * @access public
-     * @param  string|array $name 名称
+     * @param  string   $name 名称
      * @return null|array|\think\File
      */
     public function file($name = '')
@@ -1139,10 +1124,6 @@ class Request
             $this->file = isset($_FILES) ? $_FILES : [];
         }
 
-        if (is_array($name)) {
-            return $this->file = array_merge($this->file, $name);
-        }
-
         $files = $this->file;
         if (!empty($files)) {
             // 处理上传文件
@@ -1208,26 +1189,27 @@ class Request
     /**
      * 获取环境变量
      * @access public
-     * @param  mixed         $name 数据名称
+     * @param  string        $name 数据名称
      * @param  string        $default 默认值
-     * @param  string|array  $filter 过滤方法
      * @return mixed
      */
-    public function env($name = '', $default = null, $filter = '')
+    public function env($name = '', $default = null)
     {
-        if (is_array($name)) {
-            return $this->env = array_merge($this->env, $name);
+        if (empty($name)) {
+            return $this->env;
+        } else {
+            $name = strtoupper($name);
         }
 
-        return $this->input($this->env, false === $name ? false : strtoupper($name), $default, $filter);
+        return isset($this->env[$name]) ? $this->env[$name] : $default;
     }
 
     /**
-     * 设置或者获取当前的Header
+     * 获取当前的Header
      * @access public
-     * @param  string|array  $name header名称
-     * @param  string        $default 默认值
-     * @return string
+     * @param  string   $name header名称
+     * @param  string   $default 默认值
+     * @return string|array
      */
     public function header($name = '', $default = null)
     {
@@ -1236,7 +1218,7 @@ class Request
             if (function_exists('apache_request_headers') && $result = apache_request_headers()) {
                 $header = $result;
             } else {
-                $server = $this->server ?: $_SERVER;
+                $server = $this->server;
                 foreach ($server as $key => $val) {
                     if (0 === strpos($key, 'HTTP_')) {
                         $key          = str_replace('_', '-', strtolower(substr($key, 5)));
@@ -1253,10 +1235,6 @@ class Request
             $this->header = array_change_key_case($header);
         }
 
-        if (is_array($name)) {
-            return $this->header = array_merge($this->header, $name);
-        }
-
         if ('' === $name) {
             return $this->header;
         }
@@ -1287,8 +1265,6 @@ class Request
             // 解析name
             if (strpos($name, '/')) {
                 list($name, $type) = explode('/', $name);
-            } else {
-                $type = 's';
             }
 
             // 按.拆分成多维数组进行判断
@@ -1424,12 +1400,12 @@ class Request
                 break;
             // 字符串
             case 's':
-            default:
                 if (is_scalar($data)) {
                     $data = (string) $data;
                 } else {
                     throw new \InvalidArgumentException('variable type error:' . gettype($data));
                 }
+                break;
         }
     }
 
@@ -1443,6 +1419,10 @@ class Request
      */
     public function has($name, $type = 'param', $checkEmpty = false)
     {
+        if (!in_array($type, ['param', 'get', 'post', 'request', 'put', 'file', 'session', 'cookie', 'env', 'header', 'route'])) {
+            return false;
+        }
+
         if (empty($this->$type)) {
             $param = $this->$type();
         } else {
@@ -1549,8 +1529,8 @@ class Request
      */
     public function isAjax($ajax = false)
     {
-        $value  = $this->server('HTTP_X_REQUESTED_WITH', '', 'strtolower');
-        $result = ('xmlhttprequest' == $value) ? true : false;
+        $value  = $this->server('HTTP_X_REQUESTED_WITH');
+        $result = 'xmlhttprequest' == strtolower($value) ? true : false;
 
         if (true === $ajax) {
             return $result;
@@ -1695,7 +1675,7 @@ class Request
     /**
      * 当前请求 SERVER_PROTOCOL
      * @access public
-     * @return integer
+     * @return string
      */
     public function protocol()
     {
@@ -1739,7 +1719,7 @@ class Request
      * @param  array $route 路由名称
      * @return array
      */
-    public function routeInfo($route = [])
+    public function routeInfo(array $route = [])
     {
         if (!empty($route)) {
             $this->routeInfo = $route;
@@ -1751,8 +1731,8 @@ class Request
     /**
      * 设置或者获取当前请求的调度信息
      * @access public
-     * @param  array  $dispatch 调度信息
-     * @return array
+     * @param  \think\route\Dispatch  $dispatch 调度信息
+     * @return \think\route\Dispatch
      */
     public function dispatch($dispatch = null)
     {
@@ -1778,67 +1758,94 @@ class Request
     }
 
     /**
-     * 设置或者获取当前的模块名
+     * 设置当前的模块名
      * @access public
      * @param  string $module 模块名
-     * @return string|Request
+     * @return $this
      */
-    public function module($module = null)
+    public function setModule($module)
     {
-        if (!is_null($module)) {
-            $this->module = $module;
-            return $this;
-        }
+        $this->module = $module;
+        return $this;
+    }
 
+    /**
+     * 设置当前的控制器名
+     * @access public
+     * @param  string $controller 控制器名
+     * @return $this
+     */
+    public function setController($controller)
+    {
+        $this->controller = $controller;
+        return $this;
+    }
+
+    /**
+     * 设置当前的操作名
+     * @access public
+     * @param  string $action 操作名
+     * @return $this
+     */
+    public function setAction($action)
+    {
+        $this->action = $action;
+        return $this;
+    }
+
+    /**
+     * 获取当前的模块名
+     * @access public
+     * @return string
+     */
+    public function module()
+    {
         return $this->module ?: '';
     }
 
     /**
-     * 设置或者获取当前的控制器名
+     * 获取当前的控制器名
      * @access public
-     * @param  string $controller 控制器名
-     * @return string|Request
+     * @param  bool $convert 转换为小写
+     * @return string
      */
-    public function controller($controller = null)
+    public function controller($convert = false)
     {
-        if (!is_null($controller)) {
-            $this->controller = $controller;
-            return $this;
-        }
-
-        return $this->controller ?: '';
+        $name = $this->controller ?: '';
+        return $convert ? strtolower($name) : $name;
     }
 
     /**
-     * 设置或者获取当前的操作名
+     * 获取当前的操作名
      * @access public
-     * @param  string $action 操作名
-     * @return string|Request
+     * @param  bool $convert 转换为驼峰
+     * @return string
      */
-    public function action($action = null)
+    public function action($convert = false)
     {
-        if (!is_null($action) && !is_bool($action)) {
-            $this->action = $action;
-            return $this;
-        }
-
         $name = $this->action ?: '';
-        return true === $action ? $name : strtolower($name);
+        return $convert ? $name : strtolower($name);
     }
 
     /**
-     * 设置或者获取当前的语言
+     * 设置当前的语言
      * @access public
      * @param  string $lang 语言名
-     * @return string|Request
+     * @return $this
      */
-    public function langset($lang = null)
+    public function setLangset($lang)
     {
-        if (!is_null($lang)) {
-            $this->langset = $lang;
-            return $this;
-        }
+        $this->langset = $lang;
+        return $this;
+    }
 
+    /**
+     * 获取当前的语言
+     * @access public
+     * @return string
+     */
+    public function langset()
+    {
         return $this->langset ?: '';
     }
 
@@ -1873,7 +1880,7 @@ class Request
      * @param  mixed  $type 令牌生成方法
      * @return string
      */
-    public function token($name = '__token__', $type = 'md5')
+    public function token($name = '__token__', $type = null)
     {
         $type  = is_callable($type) ? $type : 'md5';
         $token = call_user_func($type, $this->server('REQUEST_TIME_FLOAT'));
@@ -1987,4 +1994,14 @@ class Request
         return $this->param($name);
     }
 
+    /**
+     * 检测请求数据的值
+     * @access public
+     * @param  string $name 名称
+     * @return boolean
+     */
+    public function __isset($name)
+    {
+        return isset($this->param[$name]);
+    }
 }
diff --git a/thinkphp/library/think/Route.php b/thinkphp/library/think/Route.php
index af5d2191c..29e0d33e6 100644
--- a/thinkphp/library/think/Route.php
+++ b/thinkphp/library/think/Route.php
@@ -28,11 +28,11 @@ class Route
     protected $rest = [
         'index'  => ['get', '', 'index'],
         'create' => ['get', '/create', 'create'],
-        'edit'   => ['get', '/:id/edit', 'edit'],
-        'read'   => ['get', '/:id', 'read'],
+        'edit'   => ['get', '/<id>/edit', 'edit'],
+        'read'   => ['get', '/<id>', 'read'],
         'save'   => ['post', '', 'save'],
-        'update' => ['put', '/:id', 'update'],
-        'delete' => ['delete', '/:id', 'delete'],
+        'update' => ['put', '/<id>', 'update'],
+        'delete' => ['delete', '/<id>', 'delete'],
     ];
 
     /**
@@ -144,6 +144,17 @@ class Route
         return isset($this->config[$name]) ? $this->config[$name] : null;
     }
 
+    /**
+     * 配置
+     * @access public
+     * @param  array $config
+     * @return void
+     */
+    public function setConfig(array $config = [])
+    {
+        $this->config = array_merge($this->config, array_change_key_case($config));
+    }
+
     public static function __make(App $app, Config $config)
     {
         $config = $config->pull('app');
@@ -371,11 +382,12 @@ class Route
      * 读取路由标识
      * @access public
      * @param  string    $name 路由标识
+     * @param  string    $domain 域名
      * @return mixed
      */
-    public function getName($name = null)
+    public function getName($name = null, $domain = null)
     {
-        return $this->app['rule_name']->get($name);
+        return $this->app['rule_name']->get($name, $domain);
     }
 
     /**
@@ -861,7 +873,7 @@ class Route
 
             if (isset($panDomain)) {
                 // 保存当前泛域名
-                $this->request->panDomain($panDomain);
+                $this->request->setPanDomain($panDomain);
             }
         }
 
diff --git a/thinkphp/library/think/Session.php b/thinkphp/library/think/Session.php
index 2d05599c4..89e339b24 100644
--- a/thinkphp/library/think/Session.php
+++ b/thinkphp/library/think/Session.php
@@ -93,6 +93,14 @@ class Session
     public function setConfig(array $config = [])
     {
         $this->config = array_merge($this->config, array_change_key_case($config));
+
+        if (isset($config['prefix'])) {
+            $this->prefix = $config['prefix'];
+        }
+
+        if (isset($config['use_lock'])) {
+            $this->lock = $config['use_lock'];
+        }
     }
 
     /**
@@ -197,7 +205,9 @@ class Session
     {
         if (is_null($this->init)) {
             $this->init();
-        } elseif (false === $this->init) {
+        }
+
+        if (false === $this->init) {
             if (PHP_SESSION_ACTIVE != session_status()) {
                 session_start();
             }
diff --git a/thinkphp/library/think/Url.php b/thinkphp/library/think/Url.php
index 7cbdfffa5..aa27b3e60 100644
--- a/thinkphp/library/think/Url.php
+++ b/thinkphp/library/think/Url.php
@@ -112,7 +112,10 @@ class Url
         }
 
         if ($url) {
-            $rule = $this->app['route']->getName(isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''));
+            $checkName   = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '');
+            $checkDomain = $domain && is_string($domain) ? $domain : null;
+
+            $rule = $this->app['route']->getName($checkName, $checkDomain);
 
             if (is_null($rule) && isset($info['query'])) {
                 $rule = $this->app['route']->getName($url);
@@ -384,6 +387,6 @@ class Url
     public function root($root)
     {
         $this->root = $root;
-        $this->app['request']->root($root);
+        $this->app['request']->setRoot($root);
     }
 }
diff --git a/thinkphp/library/think/console/command/Make.php b/thinkphp/library/think/console/command/Make.php
index 3bdfc6b9d..7474f2668 100644
--- a/thinkphp/library/think/console/command/Make.php
+++ b/thinkphp/library/think/console/command/Make.php
@@ -46,7 +46,7 @@ abstract class Make extends Command
         }
 
         if (!is_dir(dirname($pathname))) {
-            mkdir(strtolower(dirname($pathname)), 0755, true);
+            mkdir(dirname($pathname), 0755, true);
         }
 
         file_put_contents($pathname, $this->buildClass($classname));
diff --git a/thinkphp/library/think/facade/Request.php b/thinkphp/library/think/facade/Request.php
index 50e642fb7..d0eedb246 100644
--- a/thinkphp/library/think/facade/Request.php
+++ b/thinkphp/library/think/facade/Request.php
@@ -18,11 +18,11 @@ use think\Facade;
  * @mixin \think\Request
  * @method void hook(mixed $method, mixed $callback = null) static Hook 方法注入
  * @method \think\Request create(string $uri, string $method = 'GET', array $params = [], array $cookie = [], array $files = [], array $server = [], string $content = null) static 创建一个URL请求
- * @method mixed domain(string $domain = null) static 设置或获取当前包含协议的域名
- * @method mixed url(mixed $url = null) static 设置或获取当前完整URL
- * @method mixed baseUrl(string $url = null) static 设置或获取当前URL
- * @method mixed baseFile(string $file = null) static 设置或获取当前执行的文件
- * @method mixed root(string $url = null) static 设置或获取URL访问根地址
+ * @method mixed domain(bool $port = false) static 获取当前包含协议、端口的域名
+ * @method mixed url(bool $domain = false) static 获取当前完整URL
+ * @method mixed baseUrl(bool $domain = false) static 获取当前URL
+ * @method mixed baseFile(bool $domain = false) static 获取当前执行的文件
+ * @method mixed root(bool $domain = false) static 获取URL访问根地址
  * @method string rootUrl() static 获取URL访问根目录
  * @method string pathinfo() static 获取当前请求URL的pathinfo信息(含URL后缀)
  * @method string path() static 获取当前请求URL的pathinfo信息(不含URL后缀)
@@ -40,20 +40,20 @@ use think\Facade;
  * @method bool isOptions() static 是否为OPTIONS请求
  * @method bool isCli() static 是否为cli
  * @method bool isCgi() static 是否为cgi
- * @method mixed param(mixed $name = '', mixed $default = null, mixed $filter = '') static 获取当前请求的参数
- * @method mixed route(mixed $name = '', mixed $default = null, mixed $filter = '') static 设置获取路由参数
- * @method mixed get(mixed $name = '', mixed $default = null, mixed $filter = '') static 设置获取GET参数
- * @method mixed post(mixed $name = '', mixed $default = null, mixed $filter = '') static 设置获取POST参数
- * @method mixed put(mixed $name = '', mixed $default = null, mixed $filter = '') static 设置获取PUT参数
- * @method mixed delete(mixed $name = '', mixed $default = null, mixed $filter = '') static 设置获取DELETE参数
- * @method mixed patch(mixed $name = '', mixed $default = null, mixed $filter = '') static 设置获取PATCH参数
- * @method mixed request(mixed $name = '', mixed $default = null, mixed $filter = '') static 获取request变量
- * @method mixed session(mixed $name = '', mixed $default = null, mixed $filter = '') static 获取session数据
- * @method mixed cookie(mixed $name = '', mixed $default = null, mixed $filter = '') static 获取cookie参数
- * @method mixed server(mixed $name = '', mixed $default = null, mixed $filter = '') static 获取server参数
- * @method mixed env(mixed $name = '', mixed $default = null, mixed $filter = '') static 获取环境变量
- * @method mixed file(mixed $name = '') static 获取上传的文件信息
- * @method mixed header(mixed $name = '', mixed $default = null) static 设置或者获取当前的Header
+ * @method mixed param(string $name = '', mixed $default = null, mixed $filter = '') static 获取当前请求的参数
+ * @method mixed route(string $name = '', mixed $default = null, mixed $filter = '') static 设置获取路由参数
+ * @method mixed get(string $name = '', mixed $default = null, mixed $filter = '') static 设置获取GET参数
+ * @method mixed post(string $name = '', mixed $default = null, mixed $filter = '') static 设置获取POST参数
+ * @method mixed put(string $name = '', mixed $default = null, mixed $filter = '') static 设置获取PUT参数
+ * @method mixed delete(string $name = '', mixed $default = null, mixed $filter = '') static 设置获取DELETE参数
+ * @method mixed patch(string $name = '', mixed $default = null, mixed $filter = '') static 设置获取PATCH参数
+ * @method mixed request(string $name = '', mixed $default = null, mixed $filter = '') static 获取request变量
+ * @method mixed session(string $name = '', mixed $default = null, mixed $filter = '') static 获取session数据
+ * @method mixed cookie(string $name = '', mixed $default = null, mixed $filter = '') static 获取cookie参数
+ * @method mixed server(string $name = '', mixed $default = null, mixed $filter = '') static 获取server参数
+ * @method mixed env(string $name = '', mixed $default = null, mixed $filter = '') static 获取环境变量
+ * @method mixed file(string $name = '') static 获取上传的文件信息
+ * @method mixed header(string $name = '', mixed $default = null) static 设置或者获取当前的Header
  * @method mixed input(array $data,mixed $name = '', mixed $default = null, mixed $filter = '') static 获取变量 支持过滤和默认值
  * @method mixed filter(mixed $filter = null) static 设置或获取当前的过滤规则
  * @method mixed has(string $name, string $type = 'param', bool $checkEmpty = false) static 是否存在某个请求参数
@@ -71,12 +71,12 @@ use think\Facade;
  * @method string protocol() static 当前请求 SERVER_PROTOCOL
  * @method string remotePort() static 当前请求 REMOTE_PORT
  * @method string contentType() static 当前请求 HTTP_CONTENT_TYPE
- * @method array routeInfo(array $route = []) static 获取当前请求的路由信息
- * @method array dispatch(array $dispatch = null) static 设置或者获取当前请求的调度信息
- * @method mixed module(string $module = null) static 设置或者获取当前的模块名
- * @method mixed controller(string $controller = null) static 设置或者获取当前的控制器名
- * @method mixed action(string $action = null) static 设置或者获取当前的操作名
- * @method mixed langset(string $lang = null) static 设置或者获取当前的语言
+ * @method array routeInfo() static 获取当前请求的路由信息
+ * @method array dispatch() static 获取当前请求的调度信息
+ * @method string module() static 获取当前的模块名
+ * @method string controller(bool $convert = false) static 获取当前的控制器名
+ * @method string action(bool $convert = false) static 获取当前的操作名
+ * @method string langset() static 获取当前的语言
  * @method string getContent() static 设置或者获取当前请求的content
  * @method string getInput() static 获取当前请求的php://input
  * @method string token(string $name = '__token__', mixed $type = 'md5') static 生成请求令牌
diff --git a/thinkphp/library/think/model/Relation.php b/thinkphp/library/think/model/Relation.php
index 315fb28da..b969bca2a 100644
--- a/thinkphp/library/think/model/Relation.php
+++ b/thinkphp/library/think/model/Relation.php
@@ -127,6 +127,19 @@ abstract class Relation
         }
     }
 
+    /**
+     * 删除记录
+     * @access public
+     * @param  mixed $data 表达式 true 表示强制删除
+     * @return int
+     * @throws Exception
+     * @throws PDOException
+     */
+    public function delete($data = null)
+    {
+        return $this->query->delete($data);
+    }
+
     /**
      * 执行基础查询(仅执行一次)
      * @access protected
diff --git a/thinkphp/library/think/model/concern/Conversion.php b/thinkphp/library/think/model/concern/Conversion.php
index 697e495bf..7494f76a0 100644
--- a/thinkphp/library/think/model/concern/Conversion.php
+++ b/thinkphp/library/think/model/concern/Conversion.php
@@ -53,7 +53,7 @@ trait Conversion
      * @param  bool  $override 是否覆盖
      * @return $this
      */
-    public function append($append = [], $override = false)
+    public function append(array $append = [], $override = false)
     {
         $this->append = $override ? $append : array_merge($this->append, $append);
 
@@ -102,7 +102,7 @@ trait Conversion
      * @param  bool  $override 是否覆盖
      * @return $this
      */
-    public function hidden($hidden = [], $override = false)
+    public function hidden(array $hidden = [], $override = false)
     {
         $this->hidden = $override ? $hidden : array_merge($this->hidden, $hidden);
 
@@ -116,7 +116,7 @@ trait Conversion
      * @param  bool  $override 是否覆盖
      * @return $this
      */
-    public function visible($visible = [], $override = false)
+    public function visible(array $visible = [], $override = false)
     {
         $this->visible = $override ? $visible : array_merge($this->visible, $visible);
 
@@ -168,12 +168,12 @@ trait Conversion
                 if (is_array($name)) {
                     // 追加关联对象属性
                     $relation   = $this->getAttr($key);
-                    $item[$key] = $relation->append($name)->toArray();
+                    $item[$key] = $relation->visible($name)->append($name)->toArray();
                 } elseif (strpos($name, '.')) {
                     list($key, $attr) = explode('.', $name);
                     // 追加关联对象属性
                     $relation   = $this->getAttr($key);
-                    $item[$key] = $relation->append([$attr])->toArray();
+                    $item[$key] = $relation->visible([$attr])->append([$attr])->toArray();
                 } else {
                     $value = $this->getAttr($name, $item);
                     if (false !== $value) {
diff --git a/thinkphp/library/think/model/concern/SoftDelete.php b/thinkphp/library/think/model/concern/SoftDelete.php
index 2aaa5319d..3ffb3d6ba 100644
--- a/thinkphp/library/think/model/concern/SoftDelete.php
+++ b/thinkphp/library/think/model/concern/SoftDelete.php
@@ -72,11 +72,11 @@ trait SoftDelete
      * 删除当前的记录
      * @access public
      * @param  bool  $force 是否强制删除
-     * @return integer
+     * @return bool
      */
     public function delete($force = false)
     {
-        if (false === $this->trigger('before_delete', $this)) {
+        if (!$this->exists || false === $this->trigger('before_delete', $this)) {
             return false;
         }
 
@@ -104,11 +104,9 @@ trait SoftDelete
 
         $this->trigger('after_delete', $this);
 
-        // 清空数据
-        $this->data   = [];
-        $this->origin = [];
+        $this->exists = false;
 
-        return $result;
+        return true;
     }
 
     /**
@@ -116,7 +114,7 @@ trait SoftDelete
      * @access public
      * @param  mixed $data 主键列表 支持闭包查询条件
      * @param  bool  $force 是否强制删除
-     * @return integer 成功删除的记录数
+     * @return bool
      */
     public static function destroy($data, $force = false)
     {
@@ -130,20 +128,18 @@ trait SoftDelete
             call_user_func_array($data, [ & $query]);
             $data = null;
         } elseif (is_null($data)) {
-            return 0;
+            return false;
         }
 
         $resultSet = $query->select($data);
-        $count     = 0;
 
         if ($resultSet) {
             foreach ($resultSet as $data) {
-                $result = $data->delete($force);
-                $count += $result;
+                $data->delete($force);
             }
         }
 
-        return $count;
+        return true;
     }
 
     /**
@@ -176,7 +172,6 @@ trait SoftDelete
             $this->trigger('after_restore');
 
             return $result;
-
         }
 
         return 0;
diff --git a/thinkphp/library/think/model/relation/BelongsToMany.php b/thinkphp/library/think/model/relation/BelongsToMany.php
index a798fd6d9..a6ff4ef47 100644
--- a/thinkphp/library/think/model/relation/BelongsToMany.php
+++ b/thinkphp/library/think/model/relation/BelongsToMany.php
@@ -566,13 +566,15 @@ class BelongsToMany extends Relation
             $pivot[] = is_array($id) ? [$this->foreignKey, 'in', $id] : [$this->foreignKey, '=', $id];
         }
 
-        $this->pivot->where($pivot)->delete();
+        $result = $this->pivot->where($pivot)->delete();
 
         // 删除关联表数据
         if (isset($id) && $relationDel) {
             $model = $this->model;
             $model::destroy($id);
         }
+
+        return $result;
     }
 
     /**
diff --git a/thinkphp/library/think/model/relation/HasMany.php b/thinkphp/library/think/model/relation/HasMany.php
index aecc25452..46082d0ae 100644
--- a/thinkphp/library/think/model/relation/HasMany.php
+++ b/thinkphp/library/think/model/relation/HasMany.php
@@ -189,13 +189,13 @@ class HasMany extends Relation
     /**
      * 一对多 关联模型预查询
      * @access public
-     * @param  array  $where       关联预查询条件
-     * @param  string $relation    关联名
-     * @param  string $subRelation 子关联
-     * @param  bool   $closure
+     * @param  array    $where       关联预查询条件
+     * @param  string   $relation    关联名
+     * @param  string   $subRelation 子关联
+     * @param  \Closure $closure
      * @return array
      */
-    protected function eagerlyOneToMany($where, $relation, $subRelation = '', $closure = false)
+    protected function eagerlyOneToMany($where, $relation, $subRelation = '', $closure = null)
     {
         $foreignKey = $this->foreignKey;
 
@@ -221,10 +221,11 @@ class HasMany extends Relation
     /**
      * 保存(新增)当前关联数据对象
      * @access public
-     * @param  mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键
+     * @param  mixed    $data       数据 可以使用数组 关联模型对象 和 关联对象的主键
+     * @param  boolean  $replace    是否自动识别更新和写入
      * @return Model|false
      */
-    public function save($data)
+    public function save($data, $replace = true)
     {
         if ($data instanceof Model) {
             $data = $data->getData();
@@ -235,21 +236,22 @@ class HasMany extends Relation
 
         $model = new $this->model;
 
-        return $model->save($data) ? $model : false;
+        return $model->replace($replace)->save($data) ? $model : false;
     }
 
     /**
      * 批量保存当前关联数据对象
      * @access public
-     * @param  array $dataSet 数据集
+     * @param  array $dataSet   数据集
+     * @param  boolean $replace 是否自动识别更新和写入
      * @return array|false
      */
-    public function saveAll(array $dataSet)
+    public function saveAll(array $dataSet, $replace = true)
     {
         $result = [];
 
         foreach ($dataSet as $key => $data) {
-            $result[] = $this->save($data);
+            $result[] = $this->save($data, $replace);
         }
 
         return empty($result) ? false : $result;
diff --git a/thinkphp/library/think/model/relation/MorphMany.php b/thinkphp/library/think/model/relation/MorphMany.php
index a50ed8dc8..3e913ccd0 100644
--- a/thinkphp/library/think/model/relation/MorphMany.php
+++ b/thinkphp/library/think/model/relation/MorphMany.php
@@ -236,10 +236,10 @@ class MorphMany extends Relation
      * @param  array         $where       关联预查询条件
      * @param  string        $relation    关联名
      * @param  string        $subRelation 子关联
-     * @param  bool|\Closure $closure     闭包
+     * @param  \Closure      $closure     闭包
      * @return array
      */
-    protected function eagerlyMorphToMany($where, $relation, $subRelation = '', $closure = false)
+    protected function eagerlyMorphToMany($where, $relation, $subRelation = '', $closure = null)
     {
         // 预载入关联查询 支持嵌套预载入
         $this->query->removeOption('where');
diff --git a/thinkphp/library/think/model/relation/MorphOne.php b/thinkphp/library/think/model/relation/MorphOne.php
index 094440089..ede680c63 100644
--- a/thinkphp/library/think/model/relation/MorphOne.php
+++ b/thinkphp/library/think/model/relation/MorphOne.php
@@ -180,10 +180,10 @@ class MorphOne extends Relation
      * @param  array         $where       关联预查询条件
      * @param  string        $relation    关联名
      * @param  string        $subRelation 子关联
-     * @param  bool|\Closure $closure     闭包
+     * @param  \Closure      $closure     闭包
      * @return array
      */
-    protected function eagerlyMorphToOne($where, $relation, $subRelation = '', $closure = false)
+    protected function eagerlyMorphToOne($where, $relation, $subRelation = '', $closure = null)
     {
         // 预载入关联查询 支持嵌套预载入
         if ($closure) {
diff --git a/thinkphp/library/think/model/relation/MorphTo.php b/thinkphp/library/think/model/relation/MorphTo.php
index 208c6ecf8..17315c88c 100644
--- a/thinkphp/library/think/model/relation/MorphTo.php
+++ b/thinkphp/library/think/model/relation/MorphTo.php
@@ -112,7 +112,7 @@ class MorphTo extends Relation
 
     /**
      * 解析模型的完整命名空间
-     * @access public
+     * @access protected
      * @param  string $model 模型名(或者完整类名)
      * @return string
      */
diff --git a/thinkphp/library/think/model/relation/OneToOne.php b/thinkphp/library/think/model/relation/OneToOne.php
index 195d0bdda..ac5d4e4c4 100644
--- a/thinkphp/library/think/model/relation/OneToOne.php
+++ b/thinkphp/library/think/model/relation/OneToOne.php
@@ -313,10 +313,10 @@ abstract class OneToOne extends Relation
      * @param  string        $key         关联键名
      * @param  string        $relation    关联名
      * @param  string        $subRelation 子关联
-     * @param  bool|\Closure $closure
+     * @param  \Closure      $closure
      * @return array
      */
-    protected function eagerlyWhere($where, $key, $relation, $subRelation = '', $closure = false)
+    protected function eagerlyWhere($where, $key, $relation, $subRelation = '', $closure = null)
     {
         // 预载入关联查询 支持嵌套预载入
         if ($closure) {
diff --git a/thinkphp/library/think/route/Dispatch.php b/thinkphp/library/think/route/Dispatch.php
index 059839786..27a56d461 100644
--- a/thinkphp/library/think/route/Dispatch.php
+++ b/thinkphp/library/think/route/Dispatch.php
@@ -81,7 +81,7 @@ abstract class Dispatch
             // 设置请求的路由信息
 
             // 设置当前请求的参数
-            $this->request->route($this->rule->getVars());
+            $this->request->setRouteVars($this->rule->getVars());
             $this->request->routeInfo([
                 'rule'   => $this->rule->getRule(),
                 'route'  => $this->rule->getRoute(),
@@ -135,7 +135,7 @@ abstract class Dispatch
         }
 
         if (!empty($option['append'])) {
-            $this->request->route($option['append']);
+            $this->request->setRouteVars($option['append']);
         }
     }
 
diff --git a/thinkphp/library/think/route/Domain.php b/thinkphp/library/think/route/Domain.php
index 4c3f0a352..260ca500a 100644
--- a/thinkphp/library/think/route/Domain.php
+++ b/thinkphp/library/think/route/Domain.php
@@ -61,7 +61,7 @@ class Domain extends RuleGroup
         $result = $this->checkUrlBind($request, $url);
 
         if (!empty($this->option['append'])) {
-            $request->route($this->option['append']);
+            $request->setRouteVars($this->option['append']);
             unset($this->option['append']);
         }
 
diff --git a/thinkphp/library/think/route/Rule.php b/thinkphp/library/think/route/Rule.php
index affd328f2..bdb7f1f26 100644
--- a/thinkphp/library/think/route/Rule.php
+++ b/thinkphp/library/think/route/Rule.php
@@ -340,6 +340,24 @@ abstract class Rule
         return $this->option('domain', $domain);
     }
 
+    /**
+     * 设置参数过滤检查
+     * @access public
+     * @param  string|array     $name
+     * @param  mixed            $value
+     * @return $this
+     */
+    public function filter($name, $value = null)
+    {
+        if (is_array($name)) {
+            $this->option['filter'] = $name;
+        } else {
+            $this->option['filter'][$name] = $value;
+        }
+
+        return $this;
+    }
+
     /**
      * 绑定模型
      * @access public
@@ -791,9 +809,9 @@ abstract class Rule
 
         $result = new ControllerDispatch($request, $this, implode('/', $route), $var);
 
-        $request->action(array_pop($route));
-        $request->controller($route ? array_pop($route) : $this->getConfig('default_controller'));
-        $request->module($route ? array_pop($route) : $this->getConfig('default_module'));
+        $request->setAction(array_pop($route));
+        $request->setController($route ? array_pop($route) : $this->getConfig('default_controller'));
+        $request->setModule($route ? array_pop($route) : $this->getConfig('default_module'));
 
         return $result;
     }
@@ -821,7 +839,7 @@ abstract class Rule
         }
 
         // 设置当前请求的路由变量
-        $request->route($var);
+        $request->setRouteVars($var);
 
         // 路由到模块/控制器/操作
         return new ModuleDispatch($request, $this, [$module, $controller, $action], ['convert' => false]);
@@ -870,6 +888,14 @@ abstract class Rule
             return false;
         }
 
+        // 请求参数检查
+        if (isset($option['filter'])) {
+            foreach ($option['filter'] as $name => $value) {
+                if ($request->param($name, '', null) != $value) {
+                    return false;
+                }
+            }
+        }
         return true;
     }
 
diff --git a/thinkphp/library/think/route/RuleName.php b/thinkphp/library/think/route/RuleName.php
index 408a7c93e..11fc19429 100644
--- a/thinkphp/library/think/route/RuleName.php
+++ b/thinkphp/library/think/route/RuleName.php
@@ -47,9 +47,10 @@ class RuleName
      * 根据路由标识获取路由信息(用于URL生成)
      * @access public
      * @param  string   $name      路由标识
+     * @param  string   $domain   域名
      * @return array|null
      */
-    public function get($name = null)
+    public function get($name = null, $domain = null)
     {
         if (is_null($name)) {
             return $this->item;
@@ -57,7 +58,22 @@ class RuleName
 
         $name = strtolower($name);
 
-        return isset($this->item[$name]) ? $this->item[$name] : null;
+        if (isset($this->item[$name])) {
+            if (is_null($domain)) {
+                $result = $this->item[$name];
+            } else {
+                $result = [];
+                foreach ($this->item[$name] as $item) {
+                    if ($item[2] == $domain) {
+                        $result[] = $item;
+                    }
+                }
+            }
+        } else {
+            $result = null;
+        }
+
+        return $result;
     }
 
 }
diff --git a/thinkphp/library/think/route/dispatch/Module.php b/thinkphp/library/think/route/dispatch/Module.php
index 091f2f6e9..9f1db055b 100644
--- a/thinkphp/library/think/route/dispatch/Module.php
+++ b/thinkphp/library/think/route/dispatch/Module.php
@@ -55,7 +55,7 @@ class Module extends Dispatch
             // 模块初始化
             if ($module && $available) {
                 // 初始化模块
-                $this->request->module($module);
+                $this->request->setModule($module);
                 $this->app->init($module);
             } else {
                 throw new HttpException(404, 'module not exists:' . $module);
@@ -72,7 +72,9 @@ class Module extends Dispatch
         $this->actionName = strip_tags($result[2] ?: $this->rule->getConfig('default_action'));
 
         // 设置当前请求的控制器、操作
-        $this->request->controller(Loader::parseName($this->controller, 1))->action($this->actionName);
+        $this->request
+            ->setController(Loader::parseName($this->controller, 1))
+            ->setAction($this->actionName);
 
         return $this;
     }
@@ -104,7 +106,7 @@ class Module extends Dispatch
             $methodName = $reflect->getName();
             $suffix     = $this->rule->getConfig('action_suffix');
             $actionName = $suffix ? substr($methodName, 0, -strlen($suffix)) : $methodName;
-            $this->request->action($actionName);
+            $this->request->setAction($actionName);
 
             // 自动获取请求变量
             $vars = $this->rule->getConfig('url_param_type')
diff --git a/thinkphp/library/think/route/dispatch/Url.php b/thinkphp/library/think/route/dispatch/Url.php
index 1329cb4c0..90a865b49 100644
--- a/thinkphp/library/think/route/dispatch/Url.php
+++ b/thinkphp/library/think/route/dispatch/Url.php
@@ -52,6 +52,7 @@ class Url extends Dispatch
 
         // 解析模块
         $module = $this->rule->getConfig('app_multi_module') ? array_shift($path) : null;
+
         if ($this->param['auto_search']) {
             $controller = $this->autoFindController($module, $path);
         } else {
@@ -74,13 +75,14 @@ class Url extends Dispatch
         }
 
         $panDomain = $this->request->panDomain();
+
         if ($panDomain && $key = array_search('*', $var)) {
             // 泛域名赋值
             $var[$key] = $panDomain;
         }
 
         // 设置当前请求的参数
-        $this->request->route($var);
+        $this->request->setRouteVars($var);
 
         // 封装路由
         $route = [$module, $controller, $action];
@@ -112,7 +114,9 @@ class Url extends Dispatch
             $name2 = strtolower(Loader::parseName($controller, 1) . '/' . $action);
         }
 
-        if ($this->rule->getRouter()->getName($name) || $this->rule->getRouter()->getName($name2)) {
+        $host = $this->request->host(true);
+
+        if ($this->rule->getRouter()->getName($name, $host) || $this->rule->getRouter()->getName($name2, $host)) {
             return true;
         }
 
diff --git a/vendor/autoload.php b/vendor/autoload.php
index 67f4a311f..1f1e0e8c0 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -4,4 +4,4 @@
 
 require_once __DIR__ . '/composer/autoload_real.php';
 
-return ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527::getLoader();
+return ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5::getLoader();
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
index 83dd59e65..df2c1a766 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
 
 // autoload_real.php @generated by Composer
 
-class ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527
+class ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5
 {
     private static $loader;
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527
             return self::$loader;
         }
 
-        spl_autoload_register(array('ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527', 'loadClassLoader'), true, true);
+        spl_autoload_register(array('ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5', 'loadClassLoader'), true, true);
         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
-        spl_autoload_unregister(array('ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527', 'loadClassLoader'));
+        spl_autoload_unregister(array('ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5', 'loadClassLoader'));
 
         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
         if ($useStaticLoader) {
             require_once __DIR__ . '/autoload_static.php';
 
-            call_user_func(\Composer\Autoload\ComposerStaticInit6a1d9670263853112be0eb50705ac527::getInitializer($loader));
+            call_user_func(\Composer\Autoload\ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::getInitializer($loader));
         } else {
             $map = require __DIR__ . '/autoload_namespaces.php';
             foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527
         $loader->register(true);
 
         if ($useStaticLoader) {
-            $includeFiles = Composer\Autoload\ComposerStaticInit6a1d9670263853112be0eb50705ac527::$files;
+            $includeFiles = Composer\Autoload\ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::$files;
         } else {
             $includeFiles = require __DIR__ . '/autoload_files.php';
         }
         foreach ($includeFiles as $fileIdentifier => $file) {
-            composerRequire6a1d9670263853112be0eb50705ac527($fileIdentifier, $file);
+            composerRequire85ad62973eba00accc9df3b4f34e6aa5($fileIdentifier, $file);
         }
 
         return $loader;
     }
 }
 
-function composerRequire6a1d9670263853112be0eb50705ac527($fileIdentifier, $file)
+function composerRequire85ad62973eba00accc9df3b4f34e6aa5($fileIdentifier, $file)
 {
     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
         require $file;
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 29f7c305a..f7354d2e0 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
 
 namespace Composer\Autoload;
 
-class ComposerStaticInit6a1d9670263853112be0eb50705ac527
+class ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5
 {
     public static $files = array (
         '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php',
@@ -303,9 +303,9 @@ class ComposerStaticInit6a1d9670263853112be0eb50705ac527
     public static function getInitializer(ClassLoader $loader)
     {
         return \Closure::bind(function () use ($loader) {
-            $loader->prefixLengthsPsr4 = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$prefixLengthsPsr4;
-            $loader->prefixDirsPsr4 = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$prefixDirsPsr4;
-            $loader->classMap = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$classMap;
+            $loader->prefixLengthsPsr4 = ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::$prefixLengthsPsr4;
+            $loader->prefixDirsPsr4 = ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::$prefixDirsPsr4;
+            $loader->classMap = ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::$classMap;
 
         }, null, ClassLoader::class);
     }
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index f7a90c3b6..bf4ff7d30 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -191,17 +191,17 @@
     },
     {
         "name": "topthink/framework",
-        "version": "v5.1.15",
-        "version_normalized": "5.1.15.0",
+        "version": "v5.1.16",
+        "version_normalized": "5.1.16.0",
         "source": {
             "type": "git",
             "url": "https://github.com/top-think/framework.git",
-            "reference": "04d8180148fe11610a9601ed6a7d7320998d21f1"
+            "reference": "94c66cfb5b8a570a7624e06c2f98fb087c222ad5"
         },
         "dist": {
             "type": "zip",
-            "url": "https://files.phpcomposer.com/files/top-think/framework/04d8180148fe11610a9601ed6a7d7320998d21f1.zip",
-            "reference": "04d8180148fe11610a9601ed6a7d7320998d21f1",
+            "url": "https://files.phpcomposer.com/files/top-think/framework/94c66cfb5b8a570a7624e06c2f98fb087c222ad5.zip",
+            "reference": "94c66cfb5b8a570a7624e06c2f98fb087c222ad5",
             "shasum": ""
         },
         "require": {
@@ -217,7 +217,7 @@
             "sebastian/phpcpd": "2.*",
             "squizlabs/php_codesniffer": "2.*"
         },
-        "time": "2018-06-01T03:56:50+00:00",
+        "time": "2018-06-07T07:34:34+00:00",
         "type": "think-framework",
         "installation-source": "dist",
         "notification-url": "https://packagist.org/downloads/",