-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresponse.go
More file actions
45 lines (37 loc) · 1.05 KB
/
Copy pathresponse.go
File metadata and controls
45 lines (37 loc) · 1.05 KB
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
package easycodefgo
import (
"encoding/json"
)
type Response map[string]interface{}
func (self *Response) GetData() interface{} {
return (*self)[KeyData]
}
func (self *Response) GetResult() map[string]interface{} {
return (*self)[KeyResult].(map[string]interface{})
}
func (self *Response) GetMessageInfo() (string, string, string) {
r := self.GetResult()
return r[KeyCode].(string), r[KeyMessage].(string), r[KeyExtraMessage].(string)
}
func (self *Response) WriteValueAsString() string {
b, _ := json.Marshal(self)
return string(b)
}
// message 정보로 Response 생성 메소드
func newResponseByMessage(message *messageConstant) *Response {
result := map[string]interface{}{
KeyCode: message.Code,
KeyMessage: message.Message,
KeyExtraMessage: message.ExtraMessage,
}
return &Response{
KeyResult: result,
KeyData: make(map[string]interface{}),
}
}
// Response 생성 메소드
// 코드에프 결과를 생성하기 위한 메소드
func newResponseByMap(m map[string]interface{}) *Response {
res := Response(m)
return &res
}