migrate nkode-core
This commit is contained in:
101
entities/models.go
Normal file
101
entities/models.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/google/uuid"
|
||||
"net/mail"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type KeySelection []int
|
||||
|
||||
type CustomerId uuid.UUID
|
||||
|
||||
func CustomerIdToString(customerId CustomerId) string {
|
||||
customerUuid := uuid.UUID(customerId)
|
||||
return customerUuid.String()
|
||||
}
|
||||
|
||||
type SessionId uuid.UUID
|
||||
type UserId uuid.UUID
|
||||
|
||||
func UserIdFromString(userId string) UserId {
|
||||
id, err := uuid.Parse(userId)
|
||||
if err != nil {
|
||||
fmt.Errorf("unable to parse user id %+v", err)
|
||||
}
|
||||
return UserId(id)
|
||||
}
|
||||
|
||||
func (s *SessionId) String() string {
|
||||
id := uuid.UUID(*s)
|
||||
return id.String()
|
||||
}
|
||||
|
||||
type UserEmail string
|
||||
|
||||
func ParseEmail(email string) (UserEmail, error) {
|
||||
_, err := mail.ParseAddress(email)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return UserEmail(strings.ToLower(email)), err
|
||||
|
||||
}
|
||||
|
||||
type IdxInterface []int
|
||||
type SvgIdInterface []int
|
||||
|
||||
func SessionIdFromString(sessionId string) (SessionId, error) {
|
||||
id, err := uuid.Parse(sessionId)
|
||||
if err != nil {
|
||||
return SessionId{}, err
|
||||
}
|
||||
|
||||
return SessionId(id), nil
|
||||
}
|
||||
|
||||
type EncipheredNKode struct {
|
||||
Code string
|
||||
Mask string
|
||||
}
|
||||
|
||||
type RGBColor struct {
|
||||
Red int `json:"red"`
|
||||
Green int `json:"green"`
|
||||
Blue int `json:"blue"`
|
||||
}
|
||||
|
||||
var SetColors = []RGBColor{
|
||||
{0, 0, 0}, // Black
|
||||
{255, 0, 0}, // Red
|
||||
{0, 128, 0}, // Dark Green
|
||||
{0, 0, 255}, // Blue
|
||||
{244, 200, 60}, // Yellow
|
||||
{255, 0, 255}, // Magenta
|
||||
{0, 200, 200}, // Cyan
|
||||
{127, 0, 127}, // Purple
|
||||
{232, 92, 13}, // Orange
|
||||
{0, 127, 127}, // Teal
|
||||
{127, 127, 0}, // Olive
|
||||
{127, 0, 0}, // Dark Red
|
||||
{128, 128, 128}, // Gray
|
||||
{228, 102, 102}, // Dark Purple
|
||||
{185, 17, 240}, // Salmon
|
||||
{16, 200, 100}, // Green
|
||||
}
|
||||
|
||||
type SignupResetInterface struct {
|
||||
SessionId string `json:"session_id"`
|
||||
UserIdxInterface IdxInterface `json:"user_interface"`
|
||||
SvgInterface []string `json:"svg_interface"`
|
||||
Colors []RGBColor `json:"colors"`
|
||||
}
|
||||
|
||||
type LoginInterface struct {
|
||||
UserIdxInterface IdxInterface `json:"user_interface"`
|
||||
SvgInterface []string `json:"svg_interface"`
|
||||
AttrsPerKey int `json:"attrs_per_key"`
|
||||
NumbOfKeys int `json:"numb_of_keys"`
|
||||
Colors []RGBColor `json:"colors"`
|
||||
}
|
||||
Reference in New Issue
Block a user