helper

package
v0.0.0-...-13bee45 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateLayout = "2006-01-02"
)
View Source
const (
	PSQL_TOTAL_ROW_KEY = "total_row"
)
View Source
const (
	TimestampLayout = "2006-01-02 15:04:05" // 2006-01-02 15:04:05, 2006-01-02T15:04:05
)

Variables

This section is empty.

Functions

func ConvertToUUIDAndBinary

func ConvertToUUIDAndBinary(v interface{}) (*uuid.UUID, *bson.Binary)

func FindInSliceUUID

func FindInSliceUUID(slice []*uuid.UUID, uid *uuid.UUID) (exists bool, index int)

func GetBsonSlice

func GetBsonSlice(uuids []*uuid.UUID) []*bson.Binary

func GetENV

func GetENV(key string, defaultValue string) string

func GetUUIDFromBson

func GetUUIDFromBson(binary *bson.Binary) uuid.UUID

func IsCompany

func IsCompany(citizen string) bool

func SetUUIDBson

func SetUUIDBson(id uuid.UUID) *bson.Binary

func ToUUIDBson

func ToUUIDBson(v interface{}) *bson.Binary

func UUIDToSliceString

func UUIDToSliceString(slice []*uuid.UUID) []string

func ValidCitizenId

func ValidCitizenId(citizen string) bool

func ValidateKeyExists

func ValidateKeyExists(keys []string, params map[string]interface{}) map[string]error

func ValidateNotSpace

func ValidateNotSpace(val interface{}) error

func ValidateOnlyThaiLetterNumeric

func ValidateOnlyThaiLetterNumeric(val interface{}) error

func ValidateTimeISO8601

func ValidateTimeISO8601(val interface{}) error

func ValidateTypeBool

func ValidateTypeBool(v interface{}) error

func ValidateTypeBoolString

func ValidateTypeBoolString(v interface{}) error

func ValidateTypeFloat

func ValidateTypeFloat(val interface{}) error

func ValidateTypeInt

func ValidateTypeInt(val interface{}) error

func ValidateTypeMap

func ValidateTypeMap(val interface{}) error

func ValidateTypeMapWithNull

func ValidateTypeMapWithNull(val interface{}) error

func ValidateTypeSlice

func ValidateTypeSlice(val interface{}) error

func ValidateTypeString

func ValidateTypeString(val interface{}) error

func ValidateTypeUUID

func ValidateTypeUUID(val interface{}) error

func ValidateUUIDOrIDZero

func ValidateUUIDOrIDZero(val interface{}) error

Types

type Date

type Date time.Time

func NewDateFromString

func NewDateFromString(dateString string) Date

func NewDateFromStringWithTime

func NewDateFromStringWithTime(dateString string) Date

func NewDateFromTime

func NewDateFromTime(t time.Time) Date

func (Date) Format

func (j Date) Format(s string) string

func (*Date) GetBSON

func (j *Date) GetBSON() (interface{}, error)

func (Date) MarshalJSON

func (j Date) MarshalJSON() ([]byte, error)

func (Date) String

func (j Date) String() string

func (*Date) UnmarshalJSON

func (j *Date) UnmarshalJSON(b []byte) error

func (Date) Weekday

func (j Date) Weekday() time.Weekday

type GUIDWrapper

type GUIDWrapper struct {
	guid.GUID
}

func NewGUIDWrapper

func NewGUIDWrapper() GUIDWrapper

func NewGUIDWrapperFromString

func NewGUIDWrapperFromString(s string) GUIDWrapper

func (GUIDWrapper) MarshalJSON

func (g GUIDWrapper) MarshalJSON() ([]byte, error)

สำหรับ JSON marshaling

func (*GUIDWrapper) Scan

func (g *GUIDWrapper) Scan(value interface{}) error

Implement Scanner interface for GUIDWrapper

func (*GUIDWrapper) UnmarshalJSON

func (g *GUIDWrapper) UnmarshalJSON(data []byte) error

สำหรับ JSON unmarshaling

func (GUIDWrapper) Value

func (g GUIDWrapper) Value() (driver.Value, error)

Implement Valuer interface for GUIDWrapper

type NullUUID

type NullUUID struct {
	UUID  ZeroUUID
	Valid bool
}

func (*NullUUID) Scan

func (zu *NullUUID) Scan(src interface{}) error

func (NullUUID) Value

func (zu NullUUID) Value() (driver.Value, error)

type Paginator

type Paginator struct {
	Page            int `json:"page"`
	PerPage         int `json:"per_page"`
	TotalPages      int `json:"total_page"`
	TotalEntrySizes int `json:"total_rows"`
}

func NewPaginator

func NewPaginator() Paginator

func NewPaginatorWithParams

func NewPaginatorWithParams(page int, perPage int) Paginator

func (*Paginator) SetPaginatorByAllRows

func (p *Paginator) SetPaginatorByAllRows(allRows int)

func (*Paginator) SetTotalFromRows

func (p *Paginator) SetTotalFromRows(rows *sqlx.Rows) error

func (Paginator) String

func (p Paginator) String() string

type Timestamp

type Timestamp time.Time

func NewTimestampFromString

func NewTimestampFromString(dateString string) Timestamp

func NewTimestampFromTime

func NewTimestampFromTime(t time.Time) Timestamp

func (Timestamp) Format

func (j Timestamp) Format(s string) string

func (*Timestamp) GetBSON

func (j *Timestamp) GetBSON() (interface{}, error)

func (*Timestamp) Interface

func (j *Timestamp) Interface() interface{}

func (Timestamp) MarshalJSON

func (j Timestamp) MarshalJSON() ([]byte, error)

func (*Timestamp) Scan

func (t *Timestamp) Scan(value interface{}) error

func (Timestamp) String

func (j Timestamp) String() string

func (Timestamp) ToTime

func (j Timestamp) ToTime() time.Time

func (Timestamp) ToUnix

func (t Timestamp) ToUnix() int64

func (*Timestamp) UnmarshalJSON

func (j *Timestamp) UnmarshalJSON(b []byte) error

func (Timestamp) Value

func (j Timestamp) Value() (driver.Value, error)

func (Timestamp) ValueOrZero

func (j Timestamp) ValueOrZero() string

func (Timestamp) YearDay

func (j Timestamp) YearDay() int

type ZeroUUID

type ZeroUUID uuid.UUID

func NewV4

func NewV4() ZeroUUID

func NewZeroUUIDFromUUID

func NewZeroUUIDFromUUID(uid *uuid.UUID) (ZeroUUID, error)

func NewZeroUUIDFromstring

func NewZeroUUIDFromstring(uidStr string) (ZeroUUID, error)

func (ZeroUUID) Interface

func (zu ZeroUUID) Interface() interface{}

func (ZeroUUID) IsZero

func (zu ZeroUUID) IsZero() bool

func (ZeroUUID) MarshalBinary

func (zu ZeroUUID) MarshalBinary() ([]byte, error)

func (ZeroUUID) MarshalJSON

func (zu ZeroUUID) MarshalJSON() ([]byte, error)

func (ZeroUUID) NullUUID

func (zu ZeroUUID) NullUUID() NullUUID

func (*ZeroUUID) Scan

func (zu *ZeroUUID) Scan(src interface{}) error

func (ZeroUUID) String

func (zu ZeroUUID) String() string

func (ZeroUUID) ToBsonBinary

func (zu ZeroUUID) ToBsonBinary() *bson.Binary

func (ZeroUUID) ToUUID

func (zu ZeroUUID) ToUUID() *uuid.UUID

func (*ZeroUUID) UnmarshalBinary

func (zu *ZeroUUID) UnmarshalBinary(data []byte) error

func (ZeroUUID) UnmarshalJSON

func (zu ZeroUUID) UnmarshalJSON(b []byte) error

func (*ZeroUUID) UnmarshalText

func (zu *ZeroUUID) UnmarshalText(text []byte) error

func (ZeroUUID) Value

func (zu ZeroUUID) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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