handlers

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package handlers provides base CRUD handlers for component operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCRUDHandler

type BaseCRUDHandler struct {
	Config   CRUDConfig
	DB       *sql.DB
	Renderer *shared.TemplateRenderer
}

BaseCRUDHandler provides generic CRUD operations.

func NewBaseCRUDHandler

func NewBaseCRUDHandler(config CRUDConfig, db *sql.DB, renderer *shared.TemplateRenderer) *BaseCRUDHandler

NewBaseCRUDHandler creates a new base CRUD handler.

func (*BaseCRUDHandler) Create

func (h *BaseCRUDHandler) Create(c *gin.Context)

Create handles POST requests to create a new entity.

func (*BaseCRUDHandler) Delete

func (h *BaseCRUDHandler) Delete(c *gin.Context)

Delete handles DELETE requests (soft delete if configured).

func (*BaseCRUDHandler) Export

func (h *BaseCRUDHandler) Export(c *gin.Context)

Export handles CSV export.

func (*BaseCRUDHandler) Get

func (h *BaseCRUDHandler) Get(c *gin.Context)

Get handles GET requests for a single entity.

func (*BaseCRUDHandler) Import

func (h *BaseCRUDHandler) Import(c *gin.Context)

Import handles CSV import.

func (*BaseCRUDHandler) List

func (h *BaseCRUDHandler) List(c *gin.Context)

List handles GET requests for listing entities.

func (*BaseCRUDHandler) RegisterRoutes

func (h *BaseCRUDHandler) RegisterRoutes(router *gin.RouterGroup)

RegisterRoutes registers all CRUD routes.

func (*BaseCRUDHandler) Search

func (h *BaseCRUDHandler) Search(c *gin.Context)

Search handles search requests.

func (*BaseCRUDHandler) Update

func (h *BaseCRUDHandler) Update(c *gin.Context)

Update handles PUT requests to update an entity.

type CRUDConfig

type CRUDConfig struct {
	EntityName       string // e.g., "priority", "state", "type"
	EntityNamePlural string // e.g., "priorities", "states", "types"
	TableName        string // Database table name
	RoutePrefix      string // e.g., "/admin/priorities"
	TemplatePath     string // Path to the template

	// Field definitions
	Fields []FieldConfig

	// Features
	SoftDelete   bool // Use valid_id instead of DELETE
	Searchable   bool
	ImportExport bool
	HasColor     bool // For entities with color picker
}

CRUDConfig defines the configuration for a CRUD handler.

type FieldConfig

type FieldConfig struct {
	Name         string
	DBColumn     string
	Type         FieldType
	Required     bool
	Searchable   bool
	Sortable     bool
	DefaultValue interface{}
	Validation   string // Regex or validation rule
}

FieldConfig defines a field in the entity.

type FieldType

type FieldType string

FieldType represents the type of field.

const (
	FieldTypeString   FieldType = "string"
	FieldTypeInt      FieldType = "int"
	FieldTypeFloat    FieldType = "float"
	FieldTypeBool     FieldType = "bool"
	FieldTypeDate     FieldType = "date"
	FieldTypeDateTime FieldType = "datetime"
	FieldTypeColor    FieldType = "color"
	FieldTypeSelect   FieldType = "select"
	FieldTypeText     FieldType = "text"
)

Jump to

Keyboard shortcuts

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