-
Notifications
You must be signed in to change notification settings - Fork 0
/
response.go
54 lines (47 loc) · 1.32 KB
/
response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package ogs
// Rsp return code and message
func Rsp(code interface{}, message Message) interface{} {
return CodeMsg{Code: code, Message: message}
}
// RspData return code, message and data
func RspData(code interface{}, message Message, data interface{}) interface{} {
r := CodeMsgData{}
r.Code = code
r.Message = message
r.Data = data
return r
}
// RspDataPag return code, message and data with pagination
func RspDataPag(code interface{}, message Message, data interface{}, pag Pagination) interface{} {
r := CodeMsgDataWithPag{}
r.Code = code
r.Message = message
r.Data = data
r.Pagination = pag
return r
}
// RspOK return +CodeOK+ code and message
func RspOK(msgContent string) interface{} {
return Rsp(CodeOK, blankOrSuccessMsg(msgContent))
}
// RspError return error code and message
func RspError(code interface{}, msgContent string) interface{} {
return Rsp(code, ErrorMsg(msgContent))
}
// RspDataOK return +CodeOK+ code, message and data
func RspDataOK(msgContent string, data interface{}) interface{} {
return RspData(
CodeOK,
blankOrSuccessMsg(msgContent),
data,
)
}
// RspDataPagOK return +CodeOK+ code, message and data with pagination
func RspDataPagOK(msgContent string, data interface{}, pag Pagination) interface{} {
return RspDataPag(
CodeOK,
blankOrSuccessMsg(msgContent),
data,
pag,
)
}