Passed
Push — main ( 26be31...19cade )
by Yume
01:25
created

app/models/utils.go   A

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 35
dl 0
loc 51
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A models.Permission.ToString 0 10 5
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
type CardResponse struct {
12
	CardID   uint `json:"card_id" example:"1"`
13
	Card     Card
14
	Response string `json:"response" example:"42"`
15
}
16
17
type CardResponseValidation struct {
18
	Validate bool   `json:"validate" example:"true"`
19
	Message  string `json:"message" example:"Correct answer"`
20
	Answer   string `json:"correct_answer" example:"42"`
21
}
22
23
type ResponseCard struct {
24
	Card    Card
25
	Answers []string
26
}
27
28
type ResponseAuth struct {
29
	Success bool
30
	User    User
31
	Message string
32
}
33
34
type Permission int64
35
36
const (
37
	PermUser Permission = iota
38
	PermMod
39
	PermAdmin
40
)
41
42
func (s Permission) ToString() string {
43
	switch s {
44
	case PermUser:
45
		return "PermUser"
46
	case PermMod:
47
		return "PermMod"
48
	case PermAdmin:
49
		return "PermAdmin"
50
	default:
51
		return "Unknown"
52
	}
53
}
54