common

package
v0.0.0-...-fffbf87 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBTypeRestaurant = 1
	DBTypeUser       = 2
)

Variables

View Source
var RecordNotFound = errors.New("record not found")

Functions

func AppRecover

func AppRecover()

func NewSuccessReponse

func NewSuccessReponse(data, paging, filter interface{}) *successResponse

func SimpleSuccessResponse

func SimpleSuccessResponse(data interface{}) *successResponse

Types

type AppError

type AppError struct {
	StatusCode int    `json:"status_code"`
	RootErr    error  `json:"-"`
	Message    string `json:"message"`
	Log        string `json:"log"`
	Key        string `json:"error_key"`
}

func ErrCannotCreateEntity

func ErrCannotCreateEntity(entity string, err error) *AppError

func ErrCannotDeleteEntity

func ErrCannotDeleteEntity(entity string, err error) *AppError

func ErrCannotGetEntity

func ErrCannotGetEntity(entity string, err error) *AppError

func ErrCannotListEntity

func ErrCannotListEntity(entity string, err error) *AppError

func ErrCannotUpdateEntity

func ErrCannotUpdateEntity(entity string, err error) *AppError

func ErrDB

func ErrDB(err error) *AppError

func ErrEntityExisted

func ErrEntityExisted(entity string, err error) *AppError

func ErrEntityNotFound

func ErrEntityNotFound(entity string, err error) *AppError

func ErrInternal

func ErrInternal(err error) *AppError

func ErrInvalidRequest

func ErrInvalidRequest(err error) *AppError

func ErrNoPermission

func ErrNoPermission(err error) *AppError

func NewAuthorized

func NewAuthorized(root error, msg, log, key string) *AppError

func NewCustomError

func NewCustomError(root error, msg string, key string) *AppError

func NewErrorResponse

func NewErrorResponse(root error, msg, log, key string) *AppError

func NewFullErrorResponse

func NewFullErrorResponse(statusCode int, root error, msg, log, key string) *AppError

func (*AppError) Error

func (e *AppError) Error() string

func (*AppError) RootError

func (e *AppError) RootError() error

type Paging

type Paging struct {
	Page  int   `json:"page" form:"page"`
	Limit int   `json:"limit" form:"limit"`
	Total int64 `json:"total" form:"total"`
	// Support cursor with UID
	FakeCursor string `json:"cursor" form:"cursor"`
	NextCursor string `json:"next_cursor"`
}

func (*Paging) Fulfill

func (p *Paging) Fulfill()

type SQLModel

type SQLModel struct {
	Id        int        `json:"-" gorm:"column:id"`
	FakedId   *UID       `json:"id" gorm:"-"`
	Status    int        `json:"status" gorm:"column:status;default:1"`
	CreatedAt *time.Time `json:"created_at" gorm:"column:created_at"`
	UpdatedAt *time.Time `json:"updated_at" gorm:"column:updated_at"`
}

func (*SQLModel) GenUID

func (m *SQLModel) GenUID(dbType int)

type UID

type UID struct {
	// contains filtered or unexported fields
}

func DecomposeUID

func DecomposeUID(s string) (UID, error)

func FromBase58

func FromBase58(s string) (UID, error)

func NewUID

func NewUID(logicalID uint32, objectType int, shardID uint32) UID

func (UID) GeeShardID

func (uid UID) GeeShardID() uint32

func (UID) GetLocalID

func (uid UID) GetLocalID() uint32

func (UID) GetObjectType

func (uid UID) GetObjectType() uint

func (UID) MarshalJSON

func (uid UID) MarshalJSON() ([]byte, error)

func (*UID) Scan

func (uid *UID) Scan(value interface{}) error

func (UID) String

func (uid UID) String() string

func (*UID) UnmarshalJSON

func (uid *UID) UnmarshalJSON(data []byte) error

func (*UID) Value

func (uid *UID) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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