qdefine

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeSubmit  = iota + 500 // 提交操作失败(增删改)
	ErrorCodeTimeOut              // 执行超时
	ErrorCodeOSError              // 系统故障,不可恢复
)
View Source
const (
	RefuseCodeParamInvalid     = iota + 400 // 传入参数无效
	RefuseCodeTokenInvalid                  // token无效或过期
	RefuseCodePermissionDenied              // 权限不足,拒绝访问
)

Variables

This section is empty.

Functions

func ChangeDateFormat

func ChangeDateFormat(dtFormat, timeFormat string)

ChangeDateFormat

@Description: 修改系统全局时间格式
@param datef
@param timef

func Convert

func Convert[T any](sourceObj interface{}) T

Convert

@Description: 转换到指定对象
@param sourceObj
@return T

Types

type BaseBll

type BaseBll struct {
}

type BaseDao

type BaseDao[T any] struct {
	// contains filtered or unexported fields
}

func NewDao

func NewDao[T any](db *gorm.DB) *BaseDao[T]

NewDao

@Description: 创建Dao
@param db
@return *BaseDao[T]

func (*BaseDao[T]) CheckExist

func (dao *BaseDao[T]) CheckExist(id uint64) bool

CheckExist

@Description: 验证数据是否存在
@param id
@return bool
@return error

func (*BaseDao[T]) Create

func (dao *BaseDao[T]) Create(model *T) error

Create

@Description: 新建一条记录
@param model 对象
@return bool
@return error

func (*BaseDao[T]) CreateList

func (dao *BaseDao[T]) CreateList(list []T) error

CreateList

@Description: 创建一组列表
@param list
@return error

func (*BaseDao[T]) DB

func (dao *BaseDao[T]) DB() *gorm.DB

DB

@Description: 返回数据库
@return *gorm.DB

func (*BaseDao[T]) Delete

func (dao *BaseDao[T]) Delete(id uint64) error

Delete

@Description: 删除一条记录
@param id 记录Id
@return bool
@return error

func (*BaseDao[T]) GetAll

func (dao *BaseDao[T]) GetAll() ([]*T, error)

GetAll

@Description: 返回所有列表
@return []*T
@return error

func (*BaseDao[T]) GetCondition

func (dao *BaseDao[T]) GetCondition(query interface{}, args ...interface{}) (*T, error)

GetCondition

@Description: 条件查询一条记录
@param query 条件,如 id = ? 或 id IN (?) 等
@param args 条件参数,如 id, ids 等
@return []*T
@return error

func (*BaseDao[T]) GetConditions

func (dao *BaseDao[T]) GetConditions(query interface{}, args ...interface{}) ([]*T, error)

GetConditions

@Description: 条件查询一组列表
@param query 条件,如 id = ? 或 id IN (?) 等
@param args 条件参数,如 id, ids 等
@return []*T
@return error

func (*BaseDao[T]) GetConditionsLimit

func (dao *BaseDao[T]) GetConditionsLimit(maxCount int, query interface{}, args ...interface{}) ([]*T, error)

GetConditionsLimit

@Description: 条件查询一组列表
@param maxCount 最大数量
@param query 条件,如 id = ? 或 id IN (?) 等
@param args 条件参数,如 id, ids 等
@return []*T
@return error

func (*BaseDao[T]) GetList

func (dao *BaseDao[T]) GetList(startId uint64, maxCount int) ([]*T, error)

GetList

@Description: 查询一组列表
@param startId 起始Id
@param maxCount 最大数量
@return []*T
@return error

func (*BaseDao[T]) GetModel

func (dao *BaseDao[T]) GetModel(id uint64) (*T, error)

GetModel

@Description: 获取一条记录
@param id
@return *T
@return error

func (*BaseDao[T]) Save

func (dao *BaseDao[T]) Save(model *T) error

Save

@Description: 修改一条记录(不存在则新增)
@param model 对象
@return bool
@return error

func (*BaseDao[T]) Update

func (dao *BaseDao[T]) Update(model *T) error

Update

@Description: 修改一条记录
@param model 对象
@return bool
@return error

type Date

type Date uint32

func (*Date) FromTime

func (d *Date) FromTime(time time.Time)

FromTime

@Description: 通过原生的time赋值
@param time

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON

@Description: 复写json转换
@return []byte
@return error

func (Date) ToString

func (d Date) ToString() string

ToString

@Description: 根据全局format格式化输出
@return string

func (Date) ToTime

func (d Date) ToTime() time.Time

ToTime

@Description: 转为原生时间对象
@return time.Time

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON

@Description: 复写json转换
@param data
@return error

type DateTime

type DateTime uint64

func NowTime

func NowTime() DateTime

NowTime

@Description: 当前系统时间
@return DateTime

func (DateTime) Add

func (d DateTime) Add(duration time.Duration) DateTime

Add

@Description: 添加时间
@param duration
@return DateTime

func (DateTime) Date

func (d DateTime) Date() Date

Date

@Description: 转为日期
@return Date

func (DateTime) DayFirstSecond

func (d DateTime) DayFirstSecond() DateTime

DayFirst

@Description: 返回日期的首秒,即 年月日000000
@return DateTime

func (DateTime) DayLastSecond

func (d DateTime) DayLastSecond() DateTime

DayLastSecond

@Description: 返回日期的最后一秒,即 年月日235959
@return DateTime

func (*DateTime) FromTime

func (d *DateTime) FromTime(time time.Time)

FromTime

@Description: 通过原生的time赋值
@param time

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

MarshalJSON

@Description: 复写json转换
@return []byte
@return error

func (DateTime) ToString

func (d DateTime) ToString() string

ToString

@Description: 根据全局format格式化输出
@return string

func (DateTime) ToTime

func (d DateTime) ToTime() time.Time

ToTime

@Description: 转为原生时间对象
@return time.Time

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON

@Description: 复写json转换
@param data
@return error

type DbFull

type DbFull struct {
	Id       uint64   `gorm:"primaryKey"` // 唯一号
	LastTime DateTime `gorm:"index"`      // 最后操作时间时间
	Summary  string   // 摘要
	FullInfo string   // 其他扩展内容
}

type DbSimple

type DbSimple struct {
	Id       uint64   `gorm:"primaryKey"` // 唯一号
	LastTime DateTime `gorm:"index"`      // 最后操作时间时间
}

type Error

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

func NewError

func NewError(code int, err error) Error

func (Error) Code

func (e Error) Code() int

func (Error) Desc

func (e Error) Desc() string

func (Error) Error

func (e Error) Error() string

type File

type File struct {
	Name string // 文件名
	Size int64  // 文件大小
	Data []byte // 内容
}

File @Description: 文件

type QAdapter

type QAdapter interface {
	RegApi(name string, handler QApiHandler)
	RegSubscribe(name string, handler QNoticeHandler)
	SendNotice(topic string, payload interface{})
	Invoke(funcName string, params map[string]interface{}) (interface{}, QFail)
}

type QApiHandler

type QApiHandler func(ctx QContext) (interface{}, QFail)

type QBllSvc

type QBllSvc interface {
	Init()
	Bind()
	Middleware(funcName string, ctx QContext) QFail
	Stop()
}

type QContext

type QContext interface {
	GetString(key string) string
	GetInt(key string) int
	GetUInt(key string) uint64
	GetByte(key string) byte
	GetBool(key string) bool
	GetDate(key string) Date
	GetTime(key string) DateTime
	GetStruct(key string, objType reflect.Type) any
}

type QDaoSvc

type QDaoSvc interface {
	Init()
	Stop()
}

type QFail

type QFail interface {
	Code() int
	Desc() string
	Error() string
}

type QNoticeHandler

type QNoticeHandler func(ctx QContext)

type Refuse

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

func NewRefuse

func NewRefuse(code int, desc string) Refuse

func (Refuse) Code

func (r Refuse) Code() int

func (Refuse) Desc

func (r Refuse) Desc() string

func (Refuse) Error

func (r Refuse) Error() string

Jump to

Keyboard shortcuts

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