package domain import ( "context" "time" "mengstack/internal/kernel/model" ) // Example is a sample entity demonstrating the plugin data model. type Example struct { model.BaseModel Name string `json:"name" gorm:"type:varchar(255);not null"` Description string `json:"description" gorm:"type:text"` Status int `json:"status" gorm:"type:smallint;default:1"` ExpiresAt time.Time `json:"expires_at"` } func (Example) TableName() string { return "examples" } // ExampleDTO is the response projection. type ExampleDTO struct { ID uint `json:"id"` TenantID string `json:"tenant_id"` Name string `json:"name"` Description string `json:"description"` Status int `json:"status"` ExpiresAt time.Time `json:"expires_at"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // ToDTO converts an Example entity to its DTO. func ToDTO(e *Example) ExampleDTO { return ExampleDTO{ ID: e.ID, TenantID: e.TenantID, Name: e.Name, Description: e.Description, Status: e.Status, ExpiresAt: e.ExpiresAt, CreatedAt: e.CreatedAt, UpdatedAt: e.UpdatedAt, } } // CreateExampleRequest is the input for creating an example. type CreateExampleRequest struct { Name string `json:"name" binding:"required,max=255"` Description string `json:"description"` ExpiresAt time.Time `json:"expires_at"` } // Repository defines the data access contract for examples. type Repository interface { Create(ctx context.Context, e *Example) error FindByID(ctx context.Context, tenantID string, id uint) (*Example, error) FindAll(ctx context.Context, tenantID string) ([]Example, error) Update(ctx context.Context, tenantID string, e *Example) error Delete(ctx context.Context, tenantID string, id uint) error }