1
|
|
|
package models |
2
|
|
|
|
3
|
|
|
// ResponseHTTP structure |
4
|
|
|
type ResponseHTTP struct { |
5
|
|
|
Success bool `json:"success"` |
6
|
|
|
Data interface{} `json:"data"` |
7
|
|
|
Message string `json:"message"` |
8
|
|
|
Count int `json:"count"` |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
func (res *ResponseHTTP) Generator(success bool, message string, data interface{}, count int) { |
12
|
|
|
*res = ResponseHTTP{ |
13
|
|
|
Success: success, |
14
|
|
|
Data: data, |
15
|
|
|
Message: message, |
16
|
|
|
Count: count, |
17
|
|
|
} |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
func (res *ResponseHTTP) GenerateError(message string) { |
21
|
|
|
*res = ResponseHTTP{ |
22
|
|
|
Success: false, |
23
|
|
|
Data: nil, |
24
|
|
|
Message: message, |
25
|
|
|
Count: 0, |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
func (res *ResponseHTTP) GenerateSuccess(message string, data interface{}, count int) { |
30
|
|
|
*res = ResponseHTTP{ |
31
|
|
|
Success: true, |
32
|
|
|
Data: data, |
33
|
|
|
Message: message, |
34
|
|
|
Count: count, |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
type CardResponse struct { |
39
|
|
|
CardID uint `json:"card_id" example:"1"` |
40
|
|
|
Card Card |
41
|
|
|
Response string `json:"response" example:"42"` |
42
|
|
|
Training bool `json:"training" example:"false"` |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
type CardResponseValidation struct { |
46
|
|
|
Validate bool `json:"validate" example:"true"` |
47
|
|
|
Message string `json:"message" example:"Correct answer"` |
48
|
|
|
Answer string `json:"correct_answer" example:"42"` |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
type ResponseCard struct { |
52
|
|
|
Card Card |
53
|
|
|
Answers []string |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
func (responseCard *ResponseCard) Generate(card Card, answers []string) { |
57
|
|
|
responseCard.Answers = answers |
58
|
|
|
responseCard.Card = card |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
type ResponseAuth struct { |
62
|
|
|
Success bool |
63
|
|
|
User User |
64
|
|
|
Message string |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
type ResponseDeck struct { |
68
|
|
|
DeckID uint `json:"deck_id" example:"1"` |
69
|
|
|
Deck Deck |
70
|
|
|
Permission AccessPermission `json:"permission" example:"1"` |
71
|
|
|
CardCount int64 `json:"card_count" example:"42"` |
72
|
|
|
OwnerId uint `json:"owner_id" example:"6"` |
73
|
|
|
Owner User |
74
|
|
|
} |
75
|
|
|
|