-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_vo.go
78 lines (64 loc) · 1.22 KB
/
common_vo.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package vo
import (
"github.com/star-table/common/core/errors"
"github.com/star-table/polaris-backend/common/core/errs"
)
type Err struct {
Code int `json:"code"`
Message string `json:"message"`
}
func (e Err) Successful() bool {
if e.Code == errs.OK.Code() {
return true
}
return false
}
func (e Err) Failure() bool {
return !e.Successful()
}
func (e Err) Error() errors.SystemErrorInfo {
if e.Successful() {
return nil
}
return errs.BuildSystemErrorInfoWithMessageAndCode(errs.SystemError, e.Code, e.Message)
}
type VoidErr struct {
Err
}
func NewErr(err errs.SystemErrorInfo) Err {
if err == nil {
err = errs.OK
}
return Err{
Code: err.Code(),
Message: err.Message(),
}
}
type CommonReqVo struct {
UserId int64 `json:"userId"`
OrgId int64 `json:"orgId"`
SourceChannel string `json:"sourceChannel"`
}
type CommonRespVo struct {
Err
Void *Void `json:"data"`
}
type BasicReqVo struct {
Page uint
Size uint
}
type BoolRespVo struct {
Err
IsTrue bool `json:"data"`
}
type BoolRespVoData struct {
IsTrue bool `json:"isTrue"`
}
type BasicInfoReqVo struct {
UserId int64 `json:"userId"`
OrgId int64 `json:"orgId"`
}
type DataRespVo struct {
Err
Data interface{} `json:"data"`
}