Browse Source

api状态码修改

曹鹤洋 1 year ago
parent
commit
3d9ba912ef
1 changed files with 6 additions and 6 deletions
  1. 6 6
      application/common/controller/Api.php

+ 6 - 6
application/common/controller/Api.php

@@ -163,11 +163,11 @@ class Api
      * 操作成功返回的数据
      * @param string $msg    提示信息
      * @param mixed  $data   要返回的数据
-     * @param int    $code   错误码,默认为1
+     * @param int    $code   错误码,默认为0
      * @param string $type   输出类型
      * @param array  $header 发送的 Header 信息
      */
-    protected function success($msg = '', $data = null, $code = 1, $type = null, array $header = [])
+    protected function success($msg = '', $data = null, $code = 0, $type = null, array $header = [])
     {
         $this->result($msg, $data, $code, $type, $header);
     }
@@ -176,11 +176,11 @@ class Api
      * 操作失败返回的数据
      * @param string $msg    提示信息
      * @param mixed  $data   要返回的数据
-     * @param int    $code   错误码,默认为0
+     * @param int    $code   错误码,默认为1
      * @param string $type   输出类型
      * @param array  $header 发送的 Header 信息
      */
-    protected function error($msg = '', $data = null, $code = 0, $type = null, array $header = [])
+    protected function error($msg = '', $data = null, $code = 1, $type = null, array $header = [])
     {
         $this->result($msg, $data, $code, $type, $header);
     }
@@ -190,13 +190,13 @@ class Api
      * @access protected
      * @param mixed  $msg    提示信息
      * @param mixed  $data   要返回的数据
-     * @param int    $code   错误码,默认为0
+     * @param int    $code   错误码,默认为1
      * @param string $type   输出类型,支持json/xml/jsonp
      * @param array  $header 发送的 Header 信息
      * @return void
      * @throws HttpResponseException
      */
-    protected function result($msg, $data = null, $code = 0, $type = null, array $header = [])
+    protected function result($msg, $data = null, $code = 1, $type = null, array $header = [])
     {
         $result = [
             'code' => $code,