Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengqiuyun
rym-util
Commits
025e4980
Commit
025e4980
authored
Aug 17, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初始化
parent
40adad1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
31 deletions
+11
-31
Response.go
getWay/Response.go
+8
-4
State.go
getWay/State.go
+3
-27
No files found.
getWay/Response.go
View file @
025e4980
...
...
@@ -17,8 +17,8 @@ import (
type
ServerResponse
struct
{
Code
State
`json:"code"`
//0为成功,其他都是失败
Msg
string
`json:"msg,omitempty"`
//非1000情况下的错误描述
SubCode
string
`json:"subCode"`
SubMsg
string
`json:"subMsg"`
SubCode
string
`json:"subCode
,omitempty
"`
SubMsg
string
`json:"subMsg
,omitempty
"`
}
type
ServerDataResponse
struct
{
...
...
@@ -30,8 +30,12 @@ func response(state State) ServerResponse {
return
ServerResponse
{
Code
:
state
,
Msg
:
state
.
String
()}
}
func
FailGetWay
(
c
*
gin
.
Context
,
state
State
)
{
resp
:=
response
(
state
)
func
responseSub
(
state
State
,
subCode
,
subMsg
string
)
ServerResponse
{
return
ServerResponse
{
Code
:
state
,
Msg
:
state
.
String
(),
SubCode
:
subCode
,
SubMsg
:
subMsg
}
}
func
FailGetWay
(
c
*
gin
.
Context
,
state
State
,
subCode
,
subMsg
string
)
{
resp
:=
responseSub
(
state
,
subCode
,
subMsg
)
c
.
JSON
(
http
.
StatusBadGateway
,
resp
)
c
.
Abort
()
logEnd
(
c
,
resp
)
...
...
getWay/State.go
View file @
025e4980
...
...
@@ -6,15 +6,7 @@ type State int16
const
(
BusinessError
State
=
1001
OK
State
=
1000
Illegal1
State
=
1
-
iota
Illegal2
Illegal3
Illegal4
Illegal5
Illegal6
Illegal7
Illegal8
Illegal9
Illegal
State
=
9000
)
func
(
t
State
)
String
()
string
{
...
...
@@ -23,24 +15,8 @@ func (t State) String() string {
return
"business error"
case
OK
:
return
"OK"
case
Illegal1
:
return
"illegal request(1)"
case
Illegal2
:
return
"illegal request(2)"
case
Illegal3
:
return
"illegal request(3)"
case
Illegal4
:
return
"illegal request(4)"
case
Illegal5
:
return
"illegal request(5)"
case
Illegal6
:
return
"illegal request(6)"
case
Illegal7
:
return
"illegal request(7)"
case
Illegal8
:
return
"illegal request(8)"
case
Illegal9
:
return
"illegal request(9)"
case
Illegal
:
return
"非法请求"
default
:
return
"unknown"
}
...
...
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