1234567891011121314151617181920212223242526272829303132333435363738 |
- <?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);
- }
|