qdefine

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeSubmit  = 501 + iota // 提交操作失败(增删改)
	ErrorCodeTimeOut              // 执行超时
	ErrorCodeOSError              // 系统故障,不可恢复

)
View Source
const (
	RefuseCodeTokenInvalid     = 401 + iota // Token无效或者已过期,需要重新登录
	RefuseCodePermissionDenied              // 权限不足,拒绝访问
	RefuseCodeParamInvalid                  // 传入参数无效
	RefuseCodeNoRecord                      // 记录不存在
	RefuseCodeRecordExist                   //记录已存在
	RefusePwdError                          //密码错误
)

Variables

This section is empty.

Functions

func Convert

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

Convert

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

Types

type BaseBll

type BaseBll struct {
	Fail fail
}

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]) DeleteCondition added in v0.0.6

func (dao *BaseDao[T]) DeleteCondition(condition string, args ...any) error

DeleteCondition

@Description: 自定义条件删除数据
@param condition
@param args
@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 FromTime added in v0.0.9

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

FromTime

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

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 File

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

File @Description: 文件

type QAdapter

type QAdapter interface {
	RegGet(router string, handler QApiHandler)
	RegPost(router string, handler QApiHandler)
	RegPut(router string, handler QApiHandler)
	RegDel(router string, handler QApiHandler)

	SendNotice(topic string, payload interface{})
}

type QApiHandler

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

type QBaseModule added in v0.0.9

type QBaseModule struct {
	Stop        func()
	StartInvoke func(route string, ctx QContext) *QFail
	EndInvoke   func(route string, ctx QContext)
}

func (*QBaseModule) OnEndInvoke added in v0.0.9

func (m *QBaseModule) OnEndInvoke(route string, ctx QContext)

func (*QBaseModule) OnStartInvoke added in v0.0.9

func (m *QBaseModule) OnStartInvoke(route string, ctx QContext) *QFail

func (*QBaseModule) OnStop added in v0.0.9

func (m *QBaseModule) OnStop()

type QBll added in v0.0.9

type QBll interface {
	Init()
	Bind(group string, adapter QAdapter)
	StartInvoke(funcName string, ctx QContext) QFail
	EndInvoke(funcName string, ctx QContext)
	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
	GetList(listType reflect.Type) any
	GetReturnValue() interface{}
	SetNewReturnValue(newValue interface{})
}

type QDao added in v0.0.9

type QDao interface {
	Init()
	Stop()
}

type QFail

type QFail struct {
	Code int
	Err  error
	Desc string
}

type QModule added in v0.0.9

type QModule interface {
	OnStop()
	Reg(routeGroup string, adapter QAdapter)
	OnStartInvoke(funcName string, ctx QContext) *QFail
	OnEndInvoke(funcName string, ctx QContext)
}

type QNoticeHandler

type QNoticeHandler func(ctx QContext)

type QWidget added in v0.0.9

type QWidget struct {
	ConfigSection string
	Modules       map[string]QModule
}

QWidget 微件

Jump to

Keyboard shortcuts

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