qdefine

package
v0.0.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUUID added in v0.0.2

func NewUUID() string

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]) GetCount added in v0.0.2

func (dao *BaseDao[T]) GetCount() int64

GetCount

@Description: 获取总记录数
@return int64

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]) SaveList added in v0.0.9

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

SaveList

@Description: 修改一组记录(不存在则新增)
@param list 列表
@return error

func (*BaseDao[T]) Update

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

Update

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

func (*BaseDao[T]) UpdateList added in v0.0.9

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

UpdateList

@Description: 修改一组记录
@param list 列表
@return error

type BrokerConfig

type BrokerConfig struct {
	Addr    string
	UId     string
	Pwd     string
	LogMode string
	TimeOut int
	Retry   int
}

BrokerConfig 主服务配置

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(key string, 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) AddDays added in v0.0.8

func (d Date) AddDays(day int) Date

AddDays

@Description: 增减天数
@param day 天数
@return Date

func (Date) AddMonths added in v0.0.8

func (d Date) AddMonths(month int) Date

AddMonths

@Description: 增减月数
@param month 月数
@return Date

func (Date) AddYears added in v0.0.8

func (d Date) AddYears(year int) Date

AddYears

@Description: 增减年数
@param year 年数
@return Date

func (Date) CurrentToWeekday added in v0.0.9

func (d Date) CurrentToWeekday(weekday time.Weekday) Date

CurrentToWeekday

@Description: 获取当前日期所在本周指定周几的日期
@param weekday 需要返回周几
@return date 周几日期

func (Date) ForTo added in v0.0.9

func (d Date) ForTo(endDate Date, interval uint, callback func(curr Date))

ForTo

@Description: 自动循环遍历日期,并按日返回每天日期
@param endDate 结束日期
@param interval 日期间隔
@param callback 回调
@return int YYYY年+WW周,如 202451

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

func (Date) Week added in v0.0.9

func (d Date) Week() time.Weekday

Week

@Description: 获取当前日期是周几
@return int YYYY年+WW周,如 202451

func (Date) YearWeek added in v0.0.9

func (d Date) YearWeek() int

YearWeek

@Description: 获取当前日期所在本年的周数
@return int YYYY年+WW周,如 202451

type DateTime

type DateTime uint64

DateTime 日期+时间

func NewDateTime

func NewDateTime(t time.Time) DateTime

NewDateTime

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

func (DateTime) AddDays added in v0.0.8

func (d DateTime) AddDays(day int) Date

AddDays

@Description: 增减天数
@param day 天数
@return Date

func (DateTime) AddHours added in v0.0.8

func (d DateTime) AddHours(hour int) Date

AddHours

@Description: 增减小时数
@param hour 小时数
@return Date

func (DateTime) AddMinutes added in v0.0.8

func (d DateTime) AddMinutes(minute int) Date

AddMinutes

@Description: 增减分钟数
@param minute 分钟数
@return Date

func (DateTime) AddMonths added in v0.0.8

func (d DateTime) AddMonths(month int) Date

AddMonths

@Description: 增减月数
@param month 月数
@return Date

func (DateTime) AddSeconds added in v0.0.8

func (d DateTime) AddSeconds(second int) Date

AddSeconds

@Description: 增减秒数
@param second 秒数
@return Date

func (DateTime) AddYears added in v0.0.8

func (d DateTime) AddYears(year int) Date

AddYears

@Description: 增减年数
@param year 年数
@return Date

func (DateTime) CurrentToWeekday added in v0.0.9

func (d DateTime) CurrentToWeekday(weekday time.Weekday) DateTime

CurrentToWeekday

@Description: 获取当前日期所在本周指定周几的日期
@param weekday 需要返回周几
@return date 周几日期

func (DateTime) ForTo added in v0.0.9

func (d DateTime) ForTo(endDate DateTime, interval uint, callback func(curr DateTime))

ForTo

@Description: 自动循环遍历日期,并按日返回每天日期
@param endDate 结束日期
@param interval 日期间隔
@param callback 回调
@return int YYYY年+WW周,如 202451

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

func (DateTime) Week added in v0.0.9

func (d DateTime) Week() time.Weekday

Week

@Description: 获取当前日期是周几
@return int YYYY年+WW周,如 202451

func (DateTime) YearWeek added in v0.0.9

func (d DateTime) YearWeek() int

YearWeek

@Description: 获取当前日期所在本能的周数
@return int YYYY年+WW周,如 202451

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 DetectedHandler added in v0.0.8

type DetectedHandler func(fromModule, route string, ctx Context)

DetectedHandler 检测回调

type DeviceInfo added in v0.0.3

type DeviceInfo struct {
	Id   string // 设备码
	Name string // 设备名称
}

DeviceInfo 本地设备信息

func (DeviceInfo) IsEmpty added in v0.0.3

func (dev DeviceInfo) IsEmpty() bool

type ECommState

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

type ELog

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 文件

type InitHandler

type InitHandler func(moduleName string)

InitHandler 初始化回调

type NoticeHandler

type NoticeHandler func(route string, ctx Context)

NoticeHandler 通知回调

type ReqHandler

type ReqHandler func(route string, ctx Context) (any, error)

ReqHandler 请求回调

type SendRequestHandler

type SendRequestHandler func(module, route string, params any) (Context, error)

SendRequestHandler 发送请求方法定义

type StateHandler

type StateHandler func(state ECommState)

StateHandler 状态回调

Jump to

Keyboard shortcuts

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