Commit: Bulk unfinished work
This commit is contained in:
9
fx/interfaces/integration.go
Normal file
9
fx/interfaces/integration.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package interfaces
|
||||
|
||||
import "context"
|
||||
|
||||
type BasicIntegration interface {
|
||||
OnStart(context.Context) error
|
||||
OnStop(context.Context) error
|
||||
Invoke()
|
||||
}
|
||||
1
fx/interfaces/stores/mandantstore.go
Normal file
1
fx/interfaces/stores/mandantstore.go
Normal file
@@ -0,0 +1 @@
|
||||
package stores
|
||||
17
fx/interfaces/stores/messagestore.go
Normal file
17
fx/interfaces/stores/messagestore.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package stores
|
||||
|
||||
import "context"
|
||||
|
||||
type Message struct {
|
||||
Id int
|
||||
From string
|
||||
Subject string
|
||||
Body string
|
||||
}
|
||||
|
||||
type MessageStore interface {
|
||||
AddMessage(ctx context.Context, m *Message) error
|
||||
GetMessage(ctx context.Context, id int) (*Message, error)
|
||||
ListMessages(ctx context.Context) ([]*Message, error)
|
||||
RemoveMessage(ctx context.Context, id int) error
|
||||
}
|
||||
1
fx/interfaces/stores/projectstore.go
Normal file
1
fx/interfaces/stores/projectstore.go
Normal file
@@ -0,0 +1 @@
|
||||
package stores
|
||||
44
fx/interfaces/stores/sessionstore.go
Normal file
44
fx/interfaces/stores/sessionstore.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package stores
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
Token string
|
||||
UserID uint
|
||||
MandantId uint
|
||||
}
|
||||
|
||||
func (s *Session) Deserialize(t string, m map[string]string) (*Session, error) {
|
||||
userid, err := strconv.Atoi(m["userid"])
|
||||
if err != nil {
|
||||
return nil, errors.New("Userid from cache not an int")
|
||||
}
|
||||
|
||||
mandantid, err := strconv.Atoi(m["mandantid"])
|
||||
if err != nil {
|
||||
return nil, errors.New("Mandantid from cache not an int")
|
||||
}
|
||||
|
||||
s.Token = t
|
||||
s.UserID = uint(userid)
|
||||
s.MandantId = uint(mandantid)
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (s *Session) Serialize() map[string]string {
|
||||
m := make(map[string]string)
|
||||
m["userid"] = strconv.Itoa(int(s.UserID))
|
||||
m["mandantid"] = strconv.Itoa(int(s.MandantId))
|
||||
return m
|
||||
}
|
||||
|
||||
type SessionStore interface {
|
||||
AddSession(s *Session)
|
||||
GetSessionFromToken(token string) (*Session, error)
|
||||
RemoveSession(token string)
|
||||
SetMandantInSession(token string, mandantId uint) error
|
||||
}
|
||||
1
fx/interfaces/stores/todostore.go
Normal file
1
fx/interfaces/stores/todostore.go
Normal file
@@ -0,0 +1 @@
|
||||
package stores
|
||||
Reference in New Issue
Block a user