model

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PaginationResultTransform added in v0.2.8

func PaginationResultTransform[Src any, Dst any](
	dst *PaginationResult[Dst], src *PaginationResult[Src],
	f func(dst *Dst, src *Src))

Types

type AppResponse

type AppResponse struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func NewDataResponse

func NewDataResponse(data interface{}) AppResponse

func NewErrorCodeResponse

func NewErrorCodeResponse(err *errcode.Error) AppResponse

func NewErrorResponse

func NewErrorResponse(code int, err error) AppResponse

func NewOkResponse

func NewOkResponse() AppResponse

func TryErrorCodeResponse

func TryErrorCodeResponse(err error) AppResponse

type DatabaseConfig

type DatabaseConfig struct {
	Host     string `scfg:"host"`
	Port     int    `scfg:"port"`
	Username string `scfg:"username"`
	Password string `scfg:"password"`
	Database string `scfg:"database,default=scene"`
	Options  string `scfg:"options"` // in format of "key1=value1&key2=value2"
}

DatabaseConfig is a struct that contains the configuration for a database. Universal database configuration. "scfg" is the tag name used in infrastructure/config.

func DatabaseConfigFromDSN

func DatabaseConfigFromDSN(dsn string) DatabaseConfig

DatabaseConfigFromDSN parses a DSN string and returns a DatabaseConfig.

func (DatabaseConfig) MongoDSN

func (d DatabaseConfig) MongoDSN() string

func (DatabaseConfig) MysqlDSN

func (d DatabaseConfig) MysqlDSN() string

func (DatabaseConfig) RedisDSN

func (d DatabaseConfig) RedisDSN() string

func (DatabaseConfig) SqliteDSN added in v0.2.6

func (d DatabaseConfig) SqliteDSN() string

type FileConfig

type FileConfig struct {
	Path string
}

func NewFileConfig

func NewFileConfig(path string) FileConfig

type FormEntry added in v0.3.2

type FormEntry struct {
	Name  string
	Label string
	Hint  string
}

type JsonResponse added in v0.2.6

type JsonResponse map[string]interface{}

type PageParam

type PageParam struct {
	Page int `json:"page" bson:"page"` // Page is the page number, starts from 1
	Size int `json:"size" bson:"size"` // Size is the page size
}

type PageResult

type PageResult[T any] struct {
	Results   []T `json:"results" bson:"results"`
	PageNum   int `json:"page_num" bson:"page_num"`
	PageTotal int `json:"page_total" bson:"page_total"`
}

type PaginationParam

type PaginationParam struct {
	Offset int `json:"offset" bson:"offset"` // Page is the page number, starts from 0
	Limit  int `json:"limit" bson:"limit"`   // Size is the page size
}

PaginationParam is a *interface* struct provide interface for all common pagination parameter

type PaginationResult

type PaginationResult[T any] struct {
	Total   int64 `json:"total" bson:"total"`
	Offset  int64 `json:"offset" bson:"offset"`
	Results []T   `json:"results" bson:"results"`
	Count   int64 `json:"count" bson:"count"`
}

PaginationResult is a *interface* struct provide interface for all common pagination response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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