Passed
Push — main ( 3bacef...ab25eb )
by Yume
01:02
created

models.DeckLogType.ToString   A

Complexity

Conditions 5

Size

Total Lines 10
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 10
nop 0
dl 0
loc 10
rs 9.3333
c 0
b 0
f 0
1
package models
2
3
import (
4
	"gorm.io/gorm"
5
)
6
7
// Mem structure
8
type DeckLogs struct {
9
	gorm.Model
10
	DeckID  uint `json:"deck_id" example:"1"`
11
	Deck    Deck
12
	LogType DeckLogType `json:"deck_log_type" example:"1"`
13
	Message string      `json:"deck_message" example:"Added a new card"`
14
}
15
16
type DeckLogType int64
17
18
const (
19
	DeckUndefined DeckLogType = iota
20
	DeckCreated
21
	DeckDeleted
22
	DeckEdited
23
)
24
25
func (s DeckLogType) ToString() string {
26
	switch s {
27
	case DeckCreated:
28
		return "Deck Created"
29
	case DeckDeleted:
30
		return "Deck Deleted"
31
	case DeckEdited:
32
		return "Deck Edited"
33
	default:
34
		return "Unknown"
35
	}
36
}
37