oth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert added in v0.1.0

func Convert(dst, src any) (err error)

func Copy added in v0.1.0

func Copy(dst, src any) error

func CopyStruct added in v0.1.0

func CopyStruct(dst, src interface{})

func CopyWithOption added in v0.1.0

func CopyWithOption(dst, src any, opt Option) error

func FileExist added in v0.1.0

func FileExist(path string) bool

func NanoID

func NanoID(len ...int) (string, error)

func ProjectPath

func ProjectPath() string

func ReverseString

func ReverseString(s string) string

func UUID

func UUID() string

func UnicodeToString

func UnicodeToString(u string) string

Types

type BaseError added in v0.1.0

type BaseError struct {
	Code    int
	Message string
}

func (*BaseError) Error added in v0.1.0

func (u *BaseError) Error() string

type Model added in v0.1.0

type Model struct {
	ID        uint           `json:"id" gorm:"column:id;primaryKey;comment:主键"`
	Tenant    string         `json:"-" gorm:"index;column:tenant;comment:租户"`
	CreatedAt time.Time      `json:"createdAt" gorm:"autoCreateTime;default:current_timestamp;comment:创建日期"`
	UpdatedAt time.Time      `json:"updatedAt" gorm:"autoUpdateTime;default:current_timestamp;comment:更新日期"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:逻辑删除"`
}

func (*Model) BeforeCreate added in v0.1.0

func (m *Model) BeforeCreate(tx *gorm.DB) (err error)

type Option added in v0.1.0

type Option copier.Option

type Optional added in v0.1.0

type Optional[S any] struct {
	O *Optional[S]
	// contains filtered or unexported fields
}

func Of added in v0.1.0

func Of[S any](s ...S) *Optional[S]

func OfNilable added in v0.1.0

func OfNilable[S any](s ...S) *Optional[S]

func OfNilables added in v0.1.0

func OfNilables[S any](s []S) *Optional[S]

func Ofs added in v0.1.0

func Ofs[S any](s []S) *Optional[S]

func (*Optional[S]) ForEach added in v0.1.0

func (o *Optional[S]) ForEach(f func(S))

func (*Optional[S]) IfPresent added in v0.1.0

func (o *Optional[S]) IfPresent(f func(S))

func (*Optional[S]) IsPresent added in v0.1.0

func (o *Optional[S]) IsPresent() bool

func (*Optional[S]) Of added in v0.1.0

func (o *Optional[S]) Of(s []S) *Optional[S]

func (*Optional[S]) OfNilable added in v0.1.0

func (o *Optional[S]) OfNilable(s []S) *Optional[S]

type Page added in v0.1.0

type Page[T any] struct {
	Current int  `json:"current"`
	Size    int  `json:"size"`
	Total   int  `json:"total"`
	Count   int  `json:"count"`
	First   bool `json:"first"`
	Last    bool `json:"last"`
	List    []T  `json:"list"`
}

func IPage added in v0.1.0

func IPage[T any](current, size, total int, list []T) *Page[T]

func ToPage added in v0.1.0

func ToPage[T any](current, size int, data []T) *Page[T]

type PageParam added in v0.1.0

type PageParam struct {
	Current int `json:"current"`
	Size    int `json:"size"`
}

type Result added in v0.1.0

type Result struct {
	Message string `json:"message,omitempty"`
	Code    int    `json:"code"`
	Data    any    `json:"data,omitempty"`
}

func Fail added in v0.1.0

func Fail() *Result

func FailMsg added in v0.1.0

func FailMsg(msg string) *Result

func FailMsgCode added in v0.1.0

func FailMsgCode(msg string, code int) *Result

func FailMsgCodeData added in v0.1.0

func FailMsgCodeData(msg string, code int, data any) *Result

func FailMsgData added in v0.1.0

func FailMsgData(msg string, data any) *Result

func Ok added in v0.1.0

func Ok() *Result

func OkCode added in v0.1.0

func OkCode(code int) *Result

func OkData added in v0.1.0

func OkData(data any) *Result

func OkDataCode added in v0.1.0

func OkDataCode(data any, code int) *Result

func OkDataMsg added in v0.1.0

func OkDataMsg(data any, msg string) *Result

func OkDataMsgCode added in v0.1.0

func OkDataMsgCode(data any, msg string, code int) *Result

func OkMsg added in v0.1.0

func OkMsg(msg string) *Result

type Slice added in v0.1.0

type Slice[S any] []S

Jump to

Keyboard shortcuts

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