w2

package
v0.2.14 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 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) error
type Dropdown struct {
	ID   Field[int]    `json:"id"`
	Text Field[string] `json:"text"`
}
func (d *Dropdown) UnmarshalJSON(data []byte) error

type Field added in v0.2.9

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

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

func NewField added in v0.2.9

func NewField[T any](value T) Field[T]

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

func (Field[T]) IsZero added in v0.2.9

func (f Field[T]) IsZero() bool

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

func (Field[T]) MarshalJSON added in v0.2.9

func (f Field[T]) MarshalJSON() ([]byte, error)

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

func (*Field[T]) Scan added in v0.2.9

func (f *Field[T]) Scan(value any) error

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

func (*Field[T]) UnmarshalJSON added in v0.2.9

func (f *Field[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 (Field[T]) Value added in v0.2.9

func (f Field[T]) Value() (driver.Value, error)

Value implements the driver.Valuer interface for Field.

type GetDropdownRequest added in v0.2.11

type GetDropdownRequest struct {
	Max    int    `json:"max"`
	Search string `json:"search"`
}

func ParseGetDropdownRequest added in v0.2.11

func ParseGetDropdownRequest(request string) (GetDropdownRequest, error)

type GetDropdownResponse added in v0.2.11

type GetDropdownResponse[T any] struct {
	Status  Status `json:"status"`
	Records []T    `json:"records"`
}

func NewGetDropdownResponse added in v0.2.11

func NewGetDropdownResponse[T any](records []T) GetDropdownResponse[T]

func (GetDropdownResponse[T]) Write added in v0.2.11

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

type GetFormRequest added in v0.2.11

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

func ParseGetFormRequest added in v0.2.11

func ParseGetFormRequest(request string) (GetFormRequest, error)

type GetFormResponse added in v0.2.11

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

func NewGetFormResponse added in v0.2.11

func NewGetFormResponse[T any](record T) GetFormResponse[T]

func (GetFormResponse[T]) Write added in v0.2.11

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

type GetGridRequest added in v0.2.11

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

func ParseGetGridRequest added in v0.2.11

func ParseGetGridRequest(request string) (GetGridRequest, error)

type GetGridResponse added in v0.2.11

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

func NewGetGridResponse added in v0.2.11

func NewGetGridResponse[T any](records []T, total int) GetGridResponse[T]

func NewGetGridResponseWithSummary added in v0.2.11

func NewGetGridResponseWithSummary[T any](records []T, summary []T, total int) GetGridResponse[T]

func (GetGridResponse[T]) Write added in v0.2.11

func (res GetGridResponse[T]) Write(w http.ResponseWriter) 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 RemoveGridRequest added in v0.2.11

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

func ParseRemoveGridRequest added in v0.2.11

func ParseRemoveGridRequest(body io.Reader) (RemoveGridRequest, error)

type ReorderGridRequest added in v0.2.11

type ReorderGridRequest struct {
	RecID      int
	MoveBefore int
	Bottom     bool
}

func ParseReorderGridRequest added in v0.2.11

func ParseReorderGridRequest(body io.Reader) (ReorderGridRequest, error)

func (ReorderGridRequest) MarshalJSON added in v0.2.11

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

func (*ReorderGridRequest) UnmarshalJSON added in v0.2.11

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

type ReorderManyGridRequest added in v0.2.11

type ReorderManyGridRequest struct {
	RecID      []int
	MoveBefore int
	Bottom     bool
}

func ParseReorderManyGridRequest added in v0.2.11

func ParseReorderManyGridRequest(body io.Reader) (ReorderManyGridRequest, error)

func (ReorderManyGridRequest) MarshalJSON added in v0.2.11

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

func (*ReorderManyGridRequest) UnmarshalJSON added in v0.2.11

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

type SaveFormRequest added in v0.2.11

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

func ParseSaveFormRequest added in v0.2.11

func ParseSaveFormRequest[T any](body io.Reader) (SaveFormRequest[T], error)

type SaveFormResponse added in v0.2.11

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

func NewSaveFormResponse added in v0.2.11

func NewSaveFormResponse(recID int) SaveFormResponse

func (SaveFormResponse) Write added in v0.2.11

type SaveGridRequest added in v0.2.11

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

func ParseSaveGridRequest added in v0.2.11

func ParseSaveGridRequest[T any](body io.Reader) (SaveGridRequest[T], error)

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