qdefine

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

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 Context

type Context 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
	GetDateTime(key string) DateTime
	GetFiles(key string) []File
	GetStruct(refStruct any)
	Raw() any
}

Context 上下文

type Date

type Date uint32

Date 日期

func NewDate

func NewDate(t time.Time) Date

NewDate

@Description: 创建日期
@param t 时间
@return Date

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

DateTime 日期+时间

func NewDateTime

func NewDateTime(t time.Time) DateTime

NewDateTime

@Description: 创建日期+时间
@param t 时间
@return Date

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 ECommState added in v0.0.10

type ECommState string
const (
	ECommStateConnecting ECommState = "Connecting" //连接中
	ECommStateLinked     ECommState = "Linked"     //已连接
	ECommStateLinkLost   ECommState = "LinkLost"   //连接丢失
	ECommStateFault      ECommState = "Fault"      //故障
	ECommStateStopped    ECommState = "Stopped"    //已停止
)

type ELog added in v0.0.10

type ELog string

ELog 日志

const (
	ELogDebug ELog = "Debug"
	ELogWarn  ELog = "Warn"
	ELogError ELog = "Error"
)

type File

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

File 文件

Jump to

Keyboard shortcuts

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