utils

package
v0.1.11 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 GetPageResponse added in v0.1.9

func GetPageResponse(count int64, page, size int32) *v1.PaginationResponse

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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