form

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout is the default timeout for form operations
	DefaultTimeout = 30 * time.Second
)

Variables

View Source
var ErrFormSchemaNotFound = errors.New("form schema not found")

ErrFormSchemaNotFound is returned when a form schema cannot be found

Functions

func NewService

func NewService(repo Repository, publisher event.Publisher, logger logging.Logger) *service

NewService creates a new form service instance

Types

type Repository added in v0.1.5

type Repository interface {
	// Create creates a new form
	Create(ctx context.Context, form *model.Form) error
	// GetByID gets a form by ID
	GetByID(ctx context.Context, id string) (*model.Form, error)
	// GetByUserID gets all forms for a user
	GetByUserID(ctx context.Context, userID string) ([]*model.Form, error)
	// Update updates a form
	Update(ctx context.Context, form *model.Form) error
	// Delete deletes a form
	Delete(ctx context.Context, id string) error
	// GetFormSubmissions gets all submissions for a form
	GetFormSubmissions(ctx context.Context, formID string) ([]*model.FormSubmission, error)
	// List returns a paginated list of forms
	List(ctx context.Context, offset, limit int) ([]*model.Form, error)
	// Count returns the total number of forms
	Count(ctx context.Context) (int, error)
	// Search searches forms by title or description
	Search(ctx context.Context, query string, offset, limit int) ([]*model.Form, error)
	// GetActiveForms returns all active forms
	GetActiveForms(ctx context.Context) ([]*model.Form, error)
	// GetFormsByStatus returns forms by their active status
	GetFormsByStatus(ctx context.Context, active bool) ([]*model.Form, error)
}

Repository defines the interface for form data access

type Service

type Service interface {
	CreateForm(ctx context.Context, userID string, form *model.Form) error
	GetForm(ctx context.Context, id string) (*model.Form, error)
	GetUserForms(ctx context.Context, userID string) ([]*model.Form, error)
	UpdateForm(ctx context.Context, userID string, form *model.Form) error
	DeleteForm(ctx context.Context, userID, id string) error
	GetFormSubmissions(ctx context.Context, formID string) ([]*model.FormSubmission, error)
}

type SubmissionStore added in v0.2.0

type SubmissionStore interface {
	// Create creates a new form submission
	Create(ctx context.Context, submission *model.FormSubmission) error

	// GetByID retrieves a form submission by its ID
	GetByID(ctx context.Context, id string) (*model.FormSubmission, error)

	// GetByFormID retrieves all submissions for a specific form
	GetByFormID(ctx context.Context, formID string) ([]*model.FormSubmission, error)

	// Update updates an existing form submission
	Update(ctx context.Context, submission *model.FormSubmission) error

	// Delete deletes a form submission by its ID
	Delete(ctx context.Context, id string) error
}

SubmissionStore defines the interface for form submission persistence

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL