Passed
Pull Request — main (#128)
by Yume
01:48 queued 35s
created

domain/utils.go   A

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 17
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A domain.Permission.String 0 2 1
A domain.Permission.IsValid 0 2 2
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