123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- // 应用公共文件
- /**
- * 通用化api输出模块
- * @param $code
- * @param $msg
- * @param array $data
- * @param int $httpStatus
- * @return \think\response\Json
- */
- function show($code,$msg,$data=[],$httpStatus=200)
- {
- $result=[
- 'code'=>$code,
- 'message'=>$msg,
- 'data'=>$data,
- ];
- return json($result,$httpStatus);
- }
- function showSuccess($data = [],$httpStatus=200)
- {
- $result=[
- 'code' => config('status.success')[0],
- 'message' => config('status.success')[1],
- 'data' => $data,
- ];
- return json($result, $httpStatus);
- }
- function showError($status, $httpStatus = 400)
- {
- $result=[
- 'code' => $status[0],
- 'message' => $status[1],
- 'data' => [],
- ];
- return json($result, $httpStatus);
- }
|