Completed
Push — main ( 3a80b2...74ebe2 )
by Yume
15s queued 13s
created

domain.Permission.IsValid   A

Complexity

Conditions 2

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
package domain
2
3
import "github.com/gofiber/fiber/v2"
4
5
// Permission is the permission level of a user.
6
type Permission int64
7
8
const (
9
	PermissionNone  Permission = iota // PermissionNone is the default permission level.
10
	PermissionUser                    // PermissionUser is the permission level of a user.
11
	PermissionVip                     // PermissionVip is the permission level of a vip.
12
	PermissionAdmin                   // PermissionAdmin is the permission level of an admin.
13
)
14
15
func (p Permission) String() string {
16
	return [...]string{"none", "user", "vip", "admin"}[p]
17
}
18
19
func (p Permission) IsValid() bool {
20
	return p >= PermissionNone && p <= PermissionAdmin
21
}
22
23
// Route is a route for the API
24
// It contains the handler, method and permission level.
25
type Route struct {
26
	Handler    func(c *fiber.Ctx) error // Handler is the handler function for the route.
27
	Method     string                   // Method is the method of the route.
28
	Permission Permission               // Permission is the permission level of the route.
29
}
30
31
type Model interface {
32
	TableName() string
33
}
34