Browse Source

3-6通用化API数据格式

Home 5 years ago
parent
commit
9f96166d24
1 changed files with 18 additions and 0 deletions
  1. 18 0
      app/common.php

+ 18 - 0
app/common.php

@@ -1,2 +1,20 @@
 <?php
 <?php
 // 应用公共文件
 // 应用公共文件
+
+/**
+ * 通用化API数据格式输出
+ * @param $status
+ * @param string $message
+ * @param array $data
+ * @param int $httpStatus
+ * @return \think\response\Json
+ */
+function show($status, $message = 'error', $data = [], $httpStatus = 200)
+{
+    $result = [
+        "status" => $status,
+        "message" => $message,
+        "result" => $data,
+    ];
+    return json($result, $httpStatus);
+}