Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
system
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
_site-res
system
Commits
2d93b2ea
Commit
2d93b2ea
authored
Jun 20, 2018
by
tufengqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish
parent
881c888e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
ResponseApi.php
classes/fpf/response/ResponseApi.php
+7
-10
No files found.
classes/fpf/response/ResponseApi.php
View file @
2d93b2ea
...
@@ -23,10 +23,9 @@ class ResponseApi
...
@@ -23,10 +23,9 @@ class ResponseApi
* 失败返回接口
* 失败返回接口
* @param string $msg
* @param string $msg
* @param int $code
* @param int $code
* @param string $flag
* @return string
* @return string
*/
*/
public
static
function
jsonError
(
$msg
=
''
,
$code
=
-
1
,
$flag
=
''
)
public
static
function
jsonError
(
$msg
=
''
,
$code
=
-
1
)
{
{
if
(
empty
(
$msg
))
{
if
(
empty
(
$msg
))
{
$msg
=
'unknown error'
;
$msg
=
'unknown error'
;
...
@@ -36,17 +35,16 @@ class ResponseApi
...
@@ -36,17 +35,16 @@ class ResponseApi
'msg'
=>
$msg
,
'msg'
=>
$msg
,
];
];
$json
=
json_encode
(
$view
);
$json
=
json_encode
(
$view
);
return
self
::
dumpJsonData
(
$json
,
$flag
);
return
self
::
dumpJsonData
(
$json
);
}
}
/**
/**
* 成功返回接口
* 成功返回接口
* @param string $msg
* @param string $msg
* @param int $code
* @param int $code
* @param string $flag
* @return string
* @return string
*/
*/
public
static
function
jsonSuccess
(
$msg
=
''
,
$code
=
0
,
$flag
=
''
)
public
static
function
jsonSuccess
(
$msg
=
''
,
$code
=
0
)
{
{
$view
=
[
$view
=
[
BaseConstant
::
CODE
=>
$code
,
BaseConstant
::
CODE
=>
$code
,
...
@@ -54,20 +52,19 @@ class ResponseApi
...
@@ -54,20 +52,19 @@ class ResponseApi
BaseConstant
::
VAL
=>
$msg
BaseConstant
::
VAL
=>
$msg
];
];
$json
=
json_encode
(
$view
);
$json
=
json_encode
(
$view
);
return
self
::
dumpJsonData
(
$json
,
$flag
);
return
self
::
dumpJsonData
(
$json
);
}
}
/**
/**
* 直接处理接口数据
* 直接处理接口数据
* @param $ret
* @param $ret
* @param string $flag
*/
*/
public
static
function
dealRet
(
$ret
,
$flag
=
''
)
public
static
function
dealRet
(
$ret
)
{
{
if
(
true
===
$ret
[
'error'
])
{
if
(
true
===
$ret
[
'error'
])
{
self
::
jsonError
(
$ret
[
'msg'
]
?
$ret
[
'msg'
]
:
'unknown error'
);
self
::
jsonError
(
$ret
[
'msg'
]
?
:
'unknown error'
);
}
else
{
}
else
{
self
::
jsonSuccess
(
$ret
[
'msg'
]
?
$ret
[
'msg'
]
:
BaseConstant
::
OK
,
$flag
);
self
::
jsonSuccess
(
$ret
[
'msg'
]
?
:
BaseConstant
::
OK
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment