w2

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseResponse

type BaseResponse struct {
	Status  Status `json:"status"`
	Message string `json:"message,omitempty"`
}

func NewErrorResponse

func NewErrorResponse(message string) BaseResponse

func NewSuccessResponse

func NewSuccessResponse() BaseResponse

func (BaseResponse) Write added in v0.2.0

func (res BaseResponse) Write(w http.ResponseWriter, statusCode int)
type DropdownRequest struct {
	Max    int    `json:"max"`
	Search string `json:"search"`
}

func ParseDropdownRequest added in v0.2.0

func ParseDropdownRequest(request string) (DropdownRequest, error)
type DropdownResponse[T any] struct {
	Status  Status `json:"status"`
	Records []T    `json:"records"`
}

func NewDropdownResponse

func NewDropdownResponse[T any](records []T) DropdownResponse[T]
func (res DropdownResponse[T]) Write(w http.ResponseWriter)
type DropdownValue struct {
	ID   int    `json:"id"`
	Text string `json:"text"`
}

type Editable added in v0.2.0

type Editable[T any] struct {
	sql.Null[T]
	Provided bool
}

Editable wraps sql.Null[T] and tracks whether the value was explicitly provided (e.g., via JSON or SQL).

func NewEditable added in v0.2.0

func NewEditable[T any]() Editable[T]

NewEditable creates a new Editable[T] with Provided set to true but no value set.

func NewEditableWithValue added in v0.2.0

func NewEditableWithValue[T any](value T) Editable[T]

NewEditableWithValue creates a new Editable[T] with a given value, marked as valid and provided.

func (Editable[T]) IsZero added in v0.2.0

func (e Editable[T]) IsZero() bool

IsZero implements the json.Zeroed interface. Ensures proper marshalling of Editable values, skipping non-provided values with omitzero tag.

func (Editable[T]) MarshalJSON added in v0.2.0

func (e Editable[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. Ensures proper marshalling of Editable values, representing unset values as null.

func (*Editable[T]) Scan added in v0.2.0

func (e *Editable[T]) Scan(value any) error

Scan implements the sql.Scanner interface for Editable. Ensures that Provided flag is set.

func (*Editable[T]) UnmarshalJSON added in v0.2.0

func (e *Editable[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. Ensures proper unmarshalling of JSON data, setting the Valid flag based on the JSON data.

func (Editable[T]) Value added in v0.2.0

func (e Editable[T]) Value() (driver.Value, error)

Value implements the driver.Valuer interface for Editable.

type EditableDropdown added in v0.2.2

type EditableDropdown struct {
	ID   Editable[int]    `json:"id"`
	Text Editable[string] `json:"text"`
}

func (*EditableDropdown) UnmarshalJSON added in v0.2.2

func (e *EditableDropdown) UnmarshalJSON(data []byte) error

type FormGetRequest added in v0.2.0

type FormGetRequest struct {
	Action string `json:"action"`
	Name   string `json:"name"`
	RecID  int    `json:"recid"`
}

func ParseFormGetRequest added in v0.2.0

func ParseFormGetRequest(request string) (FormGetRequest, error)

type FormGetResponse added in v0.2.0

type FormGetResponse[T any] struct {
	Status Status `json:"status"`
	Record *T     `json:"record,omitempty"`
}

func NewFormGetResponse added in v0.2.0

func NewFormGetResponse[T any](record T) FormGetResponse[T]

func (FormGetResponse[T]) Write added in v0.2.0

func (res FormGetResponse[T]) Write(w http.ResponseWriter)

type FormSaveRequest added in v0.2.0

type FormSaveRequest[T any] struct {
	Action string `json:"action"`
	Name   string `json:"name"`
	RecID  int    `json:"recid"`
	Record T      `json:"record"`
}

func ParseFormSaveRequest added in v0.2.0

func ParseFormSaveRequest[T any](body io.Reader) (FormSaveRequest[T], error)

type FormSaveResponse added in v0.2.0

type FormSaveResponse struct {
	Status Status `json:"status"`
	RecID  int    `json:"recid,omitempty"`
}

func NewFormSaveResponse added in v0.2.0

func NewFormSaveResponse(recID int) FormSaveResponse

func (FormSaveResponse) Write added in v0.2.0

func (res FormSaveResponse) Write(w http.ResponseWriter)

type GridDataRequest

type GridDataRequest struct {
	Limit       int          `json:"limit"`
	Offset      int          `json:"offset"`
	SearchLogic string       `json:"searchLogic"`
	Search      []GridSearch `json:"search"`
	Sort        []GridSort   `json:"sort"`
}

func ParseGridDataRequest added in v0.2.0

func ParseGridDataRequest(request string) (GridDataRequest, error)

type GridDataResponse

type GridDataResponse[T any, V any] struct {
	Status  Status `json:"status"`
	Records []T    `json:"records,omitempty"`
	Summary []V    `json:"summary,omitempty"`
	Total   int    `json:"total,omitempty"`
}

func NewGridDataResponse

func NewGridDataResponse[T any](records []T, total int) GridDataResponse[T, any]

func NewGridDataResponseWithSummary

func NewGridDataResponseWithSummary[T any, V any](records []T, summary []V, total int) GridDataResponse[T, V]

func (GridDataResponse[T, V]) Write added in v0.2.0

func (res GridDataResponse[T, V]) Write(w http.ResponseWriter)

type GridRemoveRequest

type GridRemoveRequest struct {
	ID []int `json:"id"`
}

func ParseGridRemoveRequest added in v0.2.0

func ParseGridRemoveRequest(body io.Reader) (GridRemoveRequest, error)

type GridReorderRequest

type GridReorderRequest struct {
	RecID      int
	MoveBefore int
	Last       bool
}

func ParseGridReorderRequest added in v0.2.0

func ParseGridReorderRequest(body io.Reader) (GridReorderRequest, error)

func (GridReorderRequest) MarshalJSON added in v0.2.0

func (req GridReorderRequest) MarshalJSON() ([]byte, error)

func (*GridReorderRequest) UnmarshalJSON added in v0.2.0

func (req *GridReorderRequest) UnmarshalJSON(data []byte) error

type GridSaveRequest

type GridSaveRequest[T any] struct {
	Changes []T `json:"changes"`
}

func ParseGridSaveRequest added in v0.2.0

func ParseGridSaveRequest[T any](body io.Reader) (GridSaveRequest[T], error)

type GridSearch

type GridSearch struct {
	Field    string `json:"field"`
	Type     string `json:"type"`
	Operator string `json:"operator"`
	Value    any    `json:"value"`
}

type GridSort

type GridSort struct {
	Field     string `json:"field"`
	Direction string `json:"direction"`
}

type Status

type Status string
const (
	StatusSuccess Status = "success"
	StatusError   Status = "error"
)

Jump to

Keyboard shortcuts

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