model

package
v0.0.0-...-88f3d6a Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Orm *xorm.Engine
)

Functions

func AssignClientID

func AssignClientID(account, hwFeature string) (cid string, code uint64, err error)

AssignClientID .

func ClearTempDB

func ClearTempDB(timems int64) (code uint64, err error)

ClearTempDB 清空临时数据

func DeleteConnection

func DeleteConnection(cid string) (code uint64, err error)

DeleteConnection .

func MsgLogInsertRows

func MsgLogInsertRows(rows []*MsgLog) (code uint64, err error)

MsgLogInsertRows .

func MySQL

func MySQL(cfg svc.ValueDbconf) (err error)

MySQL init mysql db

func SQLite3

func SQLite3(cfg svc.ValueDbconf) (err error)

SQLite3 .

func SaveMsg

func SaveMsg(raw *MsgRaw, info *MsgInfo) (code uint64, err error)

SaveMsg .

func SetMsgStatus

func SetMsgStatus(msgID, cid, account, sid string, status int32) (code uint64, err error)

SetMsgStatus .

func SetOnlineStatusByServerID

func SetOnlineStatusByServerID(serverID string, isOnline int32) (err error)

SetOnlineStatusByServerID set device online stataus by serverid

func SubscribeInsertRows

func SubscribeInsertRows(rows []*Subscribe) (code uint64, err error)

SubscribeInsertRows .

Types

type Account

type Account struct {
	ID       uint32 `json:"_" xorm:"id"`
	UserID   int64  `json:"user_id" xorm:"user_id"`
	Account  string `json:"account" xorm:"account"`
	Password string `json:"password"`
}

Account table name account struct define

func (*Account) Add

func (obj *Account) Add() (code uint64, err error)

Add add record

func (*Account) Delete

func (obj *Account) Delete() (code uint64, err error)

Delete delete record

func (*Account) Get

func (obj *Account) Get() (code uint64, err error)

Get get record

func (*Account) GetAdv

func (obj *Account) GetAdv() (code uint64, err error)

GetAdv get record

func (*Account) Reset

func (obj *Account) Reset() (code uint64, err error)

Reset reset struct

func (*Account) Set

func (obj *Account) Set() (code uint64, err error)

Set add or update record

func (*Account) Update

func (obj *Account) Update() (code uint64, err error)

Update update record

type Clientid

type Clientid struct {
	ID        uint32 `json:"_" xorm:"id"`
	Account   string `json:"account" xorm:"account"`
	ClientID  string `json:"client_id" xorm:"client_id"`
	HwFeature string `json:"hw_feature"`
}

Clientid table name client_id struct define

func (*Clientid) Add

func (obj *Clientid) Add() (code uint64, err error)

Add add record

func (*Clientid) Delete

func (obj *Clientid) Delete() (code uint64, err error)

Delete delete record

func (*Clientid) Get

func (obj *Clientid) Get() (code uint64, err error)

Get get record

func (*Clientid) GetAdv

func (obj *Clientid) GetAdv() (code uint64, err error)

GetAdv get record

func (*Clientid) Reset

func (obj *Clientid) Reset() (code uint64, err error)

Reset reset struct

func (*Clientid) Set

func (obj *Clientid) Set() (code uint64, err error)

Set add or update record

func (*Clientid) Update

func (obj *Clientid) Update() (code uint64, err error)

Update update record

type Connection

type Connection struct {
	ID           uint32 `json:"_" xorm:"id"`
	UserID       int64  `json:"user_id" xorm:"user_id"`
	Account      string `json:"account"`
	ServerID     string `json:"server_id" xorm:"server_id"`
	ClearSession int32  `json:"clear_session" xorm:"clear_session"` //
	ClientID     string `json:"client_id" xorm:"client_id"`
	// will message
	WillFlag   uint32 `json:"will_flag"`
	WillRetain uint32 `json:"will_retain"`
	WillQOS    uint32 `json:"will_qos" xorm:"will_qos"`
	WillTopic  string `json:"will_topic"`
	WillBody   string `json:"will_body"`
	// connection info
	ConnType int32  `json:"conn_type"` //  	1,tcp ppmq;2,udp; 3, mqtt
	ConnInfo string `json:"conn_info"`
	ISOnline int32  `json:"is_online" xorm:"is_online"` // 1, online 2, offline
	ISSleep  int32  `json:"is_sleep" xorm:"is_sleep"`   // 0: normal; 1 sleep
	// history message
	HistorymsgType  int32 `json:"historymsg_type"`
	HistorymsgCount int32 `json:"historymsg_count"`
	LastTime        int64 `json:"last_time"`
	GlobalSync      int32 `json:"global_sync"`
}

Connection table name connection struct define

func GetConnectionByClientID

func GetConnectionByClientID(cids []string) (rows []*Connection, err error)

GetConnectionByClientID .

func GetRowsByAccount

func GetRowsByAccount(account string) (rows []*Connection, code uint64, err error)

GetRowsByAccount .

func (*Connection) Add

func (obj *Connection) Add() (code uint64, err error)

Add add record

func (*Connection) Delete

func (obj *Connection) Delete() (code uint64, err error)

Delete delete record

func (*Connection) Get

func (obj *Connection) Get() (code uint64, err error)

Get get record

func (*Connection) GetAdv

func (obj *Connection) GetAdv() (code uint64, err error)

GetAdv get record

func (*Connection) QueryIn

func (obj *Connection) QueryIn(accounts []string) (rows []*Connection, code uint64, err error)

QueryIn .

func (*Connection) Reset

func (obj *Connection) Reset() (code uint64, err error)

Reset reset struct

func (*Connection) Set

func (obj *Connection) Set() (code uint64, err error)

Set add or update record

func (*Connection) SetOffline

func (obj *Connection) SetOffline() (code uint64, err error)

SetOffline 设置设备离线

func (*Connection) SetOfflineByServerID

func (obj *Connection) SetOfflineByServerID() (code uint64, err error)

SetOfflineByServerID .

func (*Connection) Update

func (obj *Connection) Update() (code uint64, err error)

Update update record

func (*Connection) UpdateSleep

func (obj *Connection) UpdateSleep() (code uint64, err error)

UpdateSleep .

type MsgInfo

type MsgInfo struct {
	ID         uint32 `json:"_" xorm:"id"`
	MsgID      string `json:"msg_id" xorm:"msg_id"`
	SrcMsgid   string `json:"src_msgid" xorm:"src_msgid"`
	Account    string `json:"account"`
	ClientID   string `json:"client_id" xorm:"client_id"`
	Dup        int32  `json:"dup"`
	Retain     int32  `json:"retain"`
	Qos        int32  `json:"qos"`
	Topic      string `json:"topic"`
	Format     int32  `json:"format"`      //   4, PB-BIN; 5, PB-JSON;
	Cmdid      uint64 `json:"cmdid"`       //
	CmdType    int32  `json:"cmd_type"`    //   0 request:  1 response
	MsgTimems  int64  `json:"msg_timems"`  //
	CreateTime int64  `json:"create_time"` //
}

MsgInfo table name msg_info struct define

func (*MsgInfo) Add

func (obj *MsgInfo) Add() (code uint64, err error)

Add add record

func (*MsgInfo) Delete

func (obj *MsgInfo) Delete() (code uint64, err error)

Delete delete record

func (*MsgInfo) Get

func (obj *MsgInfo) Get() (code uint64, err error)

Get get record

func (*MsgInfo) GetAdv

func (obj *MsgInfo) GetAdv() (code uint64, err error)

GetAdv get record

func (*MsgInfo) Reset

func (obj *MsgInfo) Reset() (code uint64, err error)

Reset reset struct

func (*MsgInfo) Set

func (obj *MsgInfo) Set() (code uint64, err error)

Set add or update record

func (*MsgInfo) Update

func (obj *MsgInfo) Update() (code uint64, err error)

Update update record

type MsgLog

type MsgLog struct {
	ID         uint32 `json:"_" xorm:"id"`
	MsgID      string `json:"msg_id" xorm:"msg_id"`
	Account    string `json:"account"`
	ClientID   string `json:"client_id" xorm:"client_id"`
	ServerID   string `json:"server_id" xorm:"server_id"`
	Status     int32  `json:"status"` // QOS1: 1,send; 2, pubAns; QOS2: 1, pub; 2, pubrec;3, pubrel;4, pubcomp
	CreateTime int64  `json:"create_time"`
}

MsgLog table name msg_log struct define

func (*MsgLog) Add

func (obj *MsgLog) Add() (code uint64, err error)

Add add record

func (*MsgLog) Delete

func (obj *MsgLog) Delete() (code uint64, err error)

Delete delete record

func (*MsgLog) Get

func (obj *MsgLog) Get() (code uint64, err error)

Get get record

func (*MsgLog) GetAdv

func (obj *MsgLog) GetAdv() (code uint64, err error)

GetAdv get record

func (*MsgLog) GetCount

func (obj *MsgLog) GetCount() (count int64, code uint64, err error)

GetCount .

func (*MsgLog) Reset

func (obj *MsgLog) Reset() (code uint64, err error)

Reset reset struct

func (*MsgLog) Set

func (obj *MsgLog) Set() (code uint64, err error)

Set add or update record

func (*MsgLog) Update

func (obj *MsgLog) Update() (code uint64, err error)

Update update record

type MsgRaw

type MsgRaw struct {
	ID         uint32 `json:"_" xorm:"id"`
	MsgID      string `json:"msg_id" xorm:"msg_id"`
	MsgPayload []byte `json:"msg_payload" xorm:"msg_payload"`
}

MsgRaw table name msg_raw struct define

func (*MsgRaw) Add

func (obj *MsgRaw) Add() (code uint64, err error)

Add add record

func (*MsgRaw) Delete

func (obj *MsgRaw) Delete() (code uint64, err error)

Delete delete record

func (*MsgRaw) Get

func (obj *MsgRaw) Get() (code uint64, err error)

Get get record

func (*MsgRaw) GetAdv

func (obj *MsgRaw) GetAdv() (code uint64, err error)

GetAdv get record

func (*MsgRaw) Reset

func (obj *MsgRaw) Reset() (code uint64, err error)

Reset reset struct

func (*MsgRaw) Set

func (obj *MsgRaw) Set() (code uint64, err error)

Set add or update record

func (*MsgRaw) Update

func (obj *MsgRaw) Update() (code uint64, err error)

Update update record

type MsgStatus

type MsgStatus struct {
	ID         uint32 `json:"_" xorm:"id"`
	MsgID      string `json:"msg_id" xorm:"msg_id"`
	SrcMsgid   string `json:"src_msgid" xorm:"src_msgid"`
	Account    string `json:"account"`
	ClientID   string `json:"client_id" xorm:"client_id"`
	ServerID   string `json:"server_id" xorm:"server_id"`
	Dup        int32  `json:"dup"`
	Qos        int32  `json:"qos"`
	Status     int32  `json:"status"`      // QOS1: 1,send; 2, pubAns; QOS2: 1, pub; 2, pubrec;3, pubrel;4, pubcomp
	CreateTime int64  `json:"create_time"` //
}

MsgStatus table name msg_status struct define

func (*MsgStatus) Add

func (obj *MsgStatus) Add() (code uint64, err error)

Add add record

func (*MsgStatus) Delete

func (obj *MsgStatus) Delete() (code uint64, err error)

Delete delete record

func (*MsgStatus) Get

func (obj *MsgStatus) Get() (code uint64, err error)

Get get record

func (*MsgStatus) GetAdv

func (obj *MsgStatus) GetAdv() (code uint64, err error)

GetAdv get record

func (*MsgStatus) Reset

func (obj *MsgStatus) Reset() (code uint64, err error)

Reset reset struct

func (*MsgStatus) Set

func (obj *MsgStatus) Set() (code uint64, err error)

Set add or update record

func (*MsgStatus) Update

func (obj *MsgStatus) Update() (code uint64, err error)

Update update record

func (*MsgStatus) UpdateStatusByClientID

func (obj *MsgStatus) UpdateStatusByClientID(s int32) (code uint64, err error)

UpdateStatusByClientID update record

type Subscribe

type Subscribe struct {
	ID           uint32 `json:"_" xorm:"id"`
	Account      string `json:"account"`
	ClientID     string `json:"client_id" xorm:"client_id"`
	Topic        string `json:"topic"`
	Qos          uint32 `json:"qos"`
	Cluster      uint32 `json:"cluster"`
	ClusterSubid string `json:"cluster_subid"`
	LastTime     int64  `json:"last_time"`
	GlobalSync   int32  `json:"global_sync"`
}

Subscribe table name subscribe struct define

func (*Subscribe) Add

func (obj *Subscribe) Add() (code uint64, err error)

Add add record

func (*Subscribe) Delete

func (obj *Subscribe) Delete() (code uint64, err error)

Delete delete record

func (*Subscribe) DeleteTopic

func (obj *Subscribe) DeleteTopic() (code uint64, err error)

DeleteTopic delete record

func (*Subscribe) Get

func (obj *Subscribe) Get() (code uint64, err error)

Get get record

func (*Subscribe) GetAdv

func (obj *Subscribe) GetAdv() (code uint64, err error)

GetAdv get record

func (*Subscribe) GetByClientID

func (obj *Subscribe) GetByClientID() (total int64, lists []*Subscribe, code uint64, err error)

GetByClientID 获得多条记录

func (*Subscribe) Reset

func (obj *Subscribe) Reset() (code uint64, err error)

Reset reset struct

func (*Subscribe) Set

func (obj *Subscribe) Set() (code uint64, err error)

Set add or update record

func (*Subscribe) Update

func (obj *Subscribe) Update() (code uint64, err error)

Update update record

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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