ding

package
v0.0.0-...-65f1757 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name         = "name"
	Allgemein    = "allgemein"
	Anzahl       = "anzahl"
	Code         = "code"
	Beschreibung = "beschreibung"
	Aktualisiert = "aktualisiert"
)

Variables

View Source
var CreateScript string
View Source
var ErrDataAccess = errors.New("data access error")

ErrDataAccess beschreibt einen Fehler während des Zugriffs auf die Daten des Repositories.

Es handelt sich dabei um einen nicht näher bezeichneten technischen Fehler. Üblicherweise verursachen context.Canceled oder sql.ErrConnDone, sql.ErrNoRows oder sql.ErrTxDone diesen Fehler.

View Source
var ErrInsertEvent = errors.New("event cannot be logged")

ErrInsertEvent beschreibt einen Fehler, der beim Protokollieren eines Eregnisses auftritt.

View Source
var ErrInvalidParameter = errors.New("invalid paramater")
View Source
var ErrNoRecord = errors.New("no record found")
View Source
var FixtureScript string

Functions

func NewDestroyFormData

func NewDestroyFormData(code string, anzahl int, history []Event) webx.TemplateData[ScannerFormData]

func NewScannerFormData

func NewScannerFormData(code string, anzahl int, history []Event) webx.TemplateData[ScannerFormData]

func SliceEqual

func SliceEqual[T Comperable[T]](left []T, right []T) bool

Types

type Aktualisierungsanfrage

type Aktualisierungsanfrage struct {
	Id           int64
	Name         string
	Beschreibung string
	Allgemein    string
}

type Clock

type Clock interface {
	Now() time.Time
}

Clock ist eine Schnittstelle, die das aktuelle Datum und die aktuelle Uhrzeit bereitstellt.

type Comperable

type Comperable[T any] interface {
	Equal(other T) bool
}

type Ding

type Ding struct {
	DingRef
	Beschreibung string
	Allgemein    string
	Aktualisiert time.Time
}

type DingRef

type DingRef struct {
	Id       int64
	Name     string
	Code     string
	Anzahl   int
	PhotoUrl string
}

DingRef repräsentiert ein Ding in der Übersicht.

func (DingRef) Equal

func (d DingRef) Equal(other DingRef) bool

type Event

type Event struct {
	Operation int
	Anzahl    int
	Created   time.Time
	DingRef
}

func (Event) Equal

func (e Event) Equal(other Event) bool

func (Event) String

func (e Event) String() string

type IndexFormData

type IndexFormData struct {
	Q      string
	S      string
	Result []DingRef
}

type InsertResult

type InsertResult struct {
	Created bool
	Id      int64
}

type Module

type Module struct {
	Repository *Repository
	Templates  fs.FS
	Photos     webx.Module
}

func (Module) Create

func (m Module) Create(w http.ResponseWriter, r *http.Request)

Lagert Dinge ein.

Ziel der Form von NewForm.

Wenn ein Fehler auftritt, wird die Form von [NewForm] mit den übertragenen Werte erneut angezeigt. Zusätzlich werden die Validierungsfehler ausgegeben.

Wenn die Erzeugung eine neuen Dings erfolgreich war, wird nach /new weitergeleitet, wenn das Ding bekannt ist, so dass der Workflow fortgesetzt werden kann und weitere Dinge hinzugefügt werden können. Wenn es sich um ein neues Ding handelt, wird nach /:id/edit weitergeleitet, um weitere Daten über das Ding anzufordern.

func (Module) Destroy

func (m Module) Destroy(w http.ResponseWriter, r *http.Request)

func (Module) DestroyForm

func (m Module) DestroyForm(w http.ResponseWriter, r *http.Request)

Zeigt eine Form an, um Dinge zu entnehmen.

func (Module) Edit

func (m Module) Edit(w http.ResponseWriter, r *http.Request)

Edit zeigt eine Form zum Bearbeiten eines spezifischen Dings

func (Module) Index

func (m Module) Index(w http.ResponseWriter, r *http.Request)

Zeigt eine Liste aller Dinge

func (*Module) Mount

func (m *Module) Mount(mux *http.ServeMux, prefix string, middleware ...webx.Middleware)

func (Module) NewForm

func (m Module) NewForm(w http.ResponseWriter, r *http.Request)

Liefert eine HTML Form zum Einlagern eines neuen Dings.

func (Module) Show

func (m Module) Show(w http.ResponseWriter, r *http.Request)

Zeigt ein spezifisches Ding an

func (Module) Update

func (m Module) Update(w http.ResponseWriter, r *http.Request)

Bearbeitet ein Ding

type Repository

type Repository struct {
	Clock Clock
	Tm    sqlx.TransactionManager
}

func (Repository) Aktualisieren

func (r Repository) Aktualisieren(ctx context.Context, anfrage Aktualisierungsanfrage) error

func (Repository) GetAllEvents

func (r Repository) GetAllEvents(ctx context.Context, limit int) ([]Event, error)

func (Repository) GetById

func (r Repository) GetById(ctx context.Context, id int64) (Ding, error)

func (Repository) GetEvents

func (r Repository) GetEvents(ctx context.Context, query string, args ...any) ([]Event, error)

func (Repository) Insert

func (r Repository) Insert(ctx context.Context, code string, anzahl int) (InsertResult, error)

func (Repository) LogEvent

func (r Repository) LogEvent(ctx context.Context, operation int, count int, dingId int64) error

func (Repository) MengeAktualisieren

func (r Repository) MengeAktualisieren(ctx context.Context, code string, menge int) (*Ding, error)

Todo: Wird nur von Destroy verwendet. Also Spezialisieren!!

func (Repository) ProductHistory

func (r Repository) ProductHistory(ctx context.Context, dingId int64, limit int) ([]Event, error)

ProductHistory liefert eine Liste der Ereignisse zu einem Ding

TODO: Es muss differenziert werden zwischen der Historie eines Dings und der Historie in der Übersicht. Die Historie zu einem Ding benötigt keine Referenz zum Ding selbst, das dieses ja bekannt ist. Hingegen benötigt die Übersicht aber eben jene Referenz, damit eine Navigation möglich ist.

func (Repository) Search

func (r Repository) Search(ctx context.Context, limit int, query string, sort string) ([]DingRef, error)

TODO: Iterator statt Slice zurückgeben.

type ScannerFormData

type ScannerFormData struct {
	Title            string
	ActionUrl        string
	SubmitButtonText string

	Code    string
	Anzahl  int
	History []Event
}

type ShowResponseData

type ShowResponseData struct {
	Ding
	History []Event
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳