utils

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JustNow    = "刚刚"
	MinutesAgo = "%d分钟前"
	HoursAgo   = "%d小时前"
	DaysAgo    = "%d天前"
)

Variables

This section is empty.

Functions

func GetLimitOffset added in v0.1.3

func GetLimitOffset(page, size int) (limit int, offset int)

func GetMetaWithError

func GetMetaWithError(err error) *v1.Metadata

func GetMetaWithErrorString

func GetMetaWithErrorString(err string) *v1.Metadata

func GetPageInfo added in v0.1.6

func GetPageInfo(total int64, page, size int32) int32

func GetSnowflakeId

func GetSnowflakeId() int64

func GetSuccessMeta

func GetSuccessMeta() *v1.Metadata

func InitDefaultSnowflakeNode

func InitDefaultSnowflakeNode(node int64)

func InitStdLogger

func InitStdLogger(config *conf.App) log.Logger

func ParseToDateString added in v0.1.3

func ParseToDateString(t time.Time) string

ParseToDateString 将time.Time转换为日期字符串

Types

type DBClient

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

func (*DBClient) DB

func (c *DBClient) DB(ctx context.Context) *gorm.DB

func (*DBClient) ExecTx

func (c *DBClient) ExecTx(ctx context.Context, fn func(ctx context.Context) error) error

ExecTx gorm Transaction

func (*DBClient) GetDB

func (c *DBClient) GetDB() *gorm.DB

func (*DBClient) WhereWithPaginateAndSort

func (c *DBClient) WhereWithPaginateAndSort(
	ctx context.Context,
	fn WhereConditionFn,
	value interface{},
	sort string,
	request *dto.PaginationRequest,
) *gorm.DB

type Transaction

type Transaction interface {
	ExecTx(context.Context, func(ctx context.Context) error) error
}

type WhereConditionFn

type WhereConditionFn func(db *gorm.DB) *gorm.DB

Jump to

Keyboard shortcuts

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