utils

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDSN

func InitAuditField added in v0.0.5

func InitAuditField[T any](entity T, name string) T

func InitAuditFieldWhitJwt added in v0.0.5

func InitAuditFieldWhitJwt[T any](entity T, jwt common.JWTSession) T

func InitUpdateAuditField added in v0.0.5

func InitUpdateAuditField[T any](entity T, name string) T

func InitUpdateAuditFieldWhitJwt added in v0.0.5

func InitUpdateAuditFieldWhitJwt[T any](entity T, jwt common.JWTSession) T

func PaginationGorm

func PaginationGorm(page *Pagination) func(db *gorm.DB) *gorm.DB

PaginationGorm 返回一个用于配置分页的Gorm处理器 此函数旨在与Gorm库一起使用,以实现数据库查询的分页功能 参数page是分页配置的指针,包含当前页和每页大小的信息 如果当前页设置为-1,则表示不分页,函数将返回nil 否则,函数将返回一个闭包,用于配置Gorm的Offset和Limit方法,以实现分页查询

Types

type Pagination

type Pagination struct {
	Total    int64 `json:"total"`
	Current  int   `json:"current"`
	PageSize int   `json:"pageSize"`
}

func (*Pagination) Init

func (p *Pagination) Init(total int64, current, pageSize int)
Init 初始化分页

total 总数 current 当前页 pageSize 每页数量

type PaginationResult added in v0.0.5

type PaginationResult[T any] struct {
	Total    int64 `json:"total"`
	Current  int   `json:"current"`
	PageSize int   `json:"pageSize"`
	Row      []T   `json:"row"`
}

type RestFul

type RestFul struct {
	CodeConfig common.HttpCodeConfig
	RestFulMsg RestFulMsg
}

func (*RestFul) GetJson

func (r *RestFul) GetJson() RestFulMsg

func (*RestFul) SetData

func (r *RestFul) SetData(data interface{}) *RestFul

func (*RestFul) SetFail

func (r *RestFul) SetFail(status string) *RestFul

func (*RestFul) SetMessage

func (r *RestFul) SetMessage(message string) *RestFul

func (*RestFul) SetSuccess

func (r *RestFul) SetSuccess(status string) *RestFul

type RestFulMsg

type RestFulMsg struct {
	Success  bool        `json:"success"`
	Code     int         `json:"code"`
	Message  string      `json:"message"`
	Data     interface{} `json:"data,omitempty"`
	Info     string      `json:"info,omitempty"`
	DateTime string      `json:"dateTime,omitempty"`
	Version  string      `json:"version,omitempty"`
	Type     string      `json:"type,omitempty"`
}

func RestFulJson added in v0.0.18

func RestFulJson(data interface{}) RestFulMsg

func RestFulJsonFail added in v0.0.20

func RestFulJsonFail(err string, msg string) RestFulMsg

Jump to

Keyboard shortcuts

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