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
a3b2e002
Commit
a3b2e002
authored
Oct 10, 2022
by
yemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提供不带事务返回封装的方法
parent
ab097e5d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
Response.go
getWay/Response.go
+26
-0
No files found.
getWay/Response.go
View file @
a3b2e002
...
...
@@ -49,6 +49,15 @@ func FailAndMsg(c *gin.Context, subCode, subMsg string) {
logEnd
(
c
,
resp
)
}
// FailAndMsgNoTx 不带事务
func
FailAndMsgNoTx
(
c
*
gin
.
Context
,
subCode
,
subMsg
string
)
{
resp
:=
ServerResponse
{
Code
:
BusinessError
,
Msg
:
"业务错误"
,
SubCode
:
subCode
,
SubMsg
:
subMsg
}
c
.
JSON
(
http
.
StatusOK
,
resp
)
c
.
Abort
()
logEnd
(
c
,
resp
)
}
// Success 有事务的用这个
func
Success
(
c
*
gin
.
Context
)
{
db
.
Commit
()
resp
:=
response
(
OK
)
...
...
@@ -57,6 +66,15 @@ func Success(c *gin.Context) {
logEnd
(
c
,
resp
)
}
// SuccessNoTx 不带事务提交
func
SuccessNoTx
(
c
*
gin
.
Context
)
{
resp
:=
response
(
OK
)
c
.
JSON
(
http
.
StatusOK
,
resp
)
c
.
Abort
()
logEnd
(
c
,
resp
)
}
// SuccessData 有事务的用这个
func
SuccessData
(
c
*
gin
.
Context
,
data
interface
{})
{
db
.
Commit
()
resp
:=
ServerDataResponse
{
response
(
OK
),
data
}
...
...
@@ -65,6 +83,14 @@ func SuccessData(c *gin.Context, data interface{}) {
logEnd
(
c
,
resp
)
}
// SuccessDataNoTx 不带事务提交
func
SuccessDataNoTx
(
c
*
gin
.
Context
,
data
interface
{})
{
resp
:=
ServerDataResponse
{
response
(
OK
),
data
}
c
.
JSON
(
http
.
StatusOK
,
resp
)
c
.
Abort
()
logEnd
(
c
,
resp
)
}
func
SuccessString
(
c
*
gin
.
Context
,
data
string
)
{
c
.
String
(
http
.
StatusOK
,
data
)
c
.
Abort
()
...
...
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