Total Lines | 69 |
Duplicated Lines | 0 % |
Changes | 0 |
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 | } |
||
43 | |||
44 | type CardResponseValidation struct { |
||
45 | Validate bool `json:"validate" example:"true"` |
||
46 | Message string `json:"message" example:"Correct answer"` |
||
47 | Answer string `json:"correct_answer" example:"42"` |
||
48 | } |
||
49 | |||
50 | type ResponseCard struct { |
||
51 | Card Card |
||
52 | Answers []string |
||
53 | } |
||
54 | |||
55 | type ResponseAuth struct { |
||
56 | Success bool |
||
57 | User User |
||
58 | Message string |
||
59 | } |
||
60 | |||
61 | type ResponseDeck struct { |
||
62 | DeckID uint `json:"deck_id" example:"1"` |
||
63 | Deck Deck |
||
64 | Permission AccessPermission `json:"permission" example:"1"` |
||
65 | CardCount int64 `json:"card_count" example:"42"` |
||
66 | AverageRating float32 `json:"average_rating" example:"3.4"` |
||
67 | PersonnalRating uint `json:"personnal_rating" example:"3.4"` |
||
68 | OwnerId uint `json:"owner_id" example:"6"` |
||
69 | Owner User |
||
70 | } |
||
71 |