db

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BankRecodeDeposit int32 = iota
	BankRecodeWithdraw
	BankRecodePaid
)
View Source
const (
	CREATED int32 = iota
	PROPOSAL
	CONFIRM
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID     string `gorm:"primary_key"`
	Name   string `gorm:"not null"`
	Avatar string `gorm:"not null"`

	OperationTimes
}

func (*Account) TableName

func (*Account) TableName() string

type App

type App struct {
	ID      string `gorm:"primary_key"`
	Version string `gorm:"not null;default:''"`
	Uri     string `gorm:"not null;default:''"`
	Avatar  string `gorm:"not null;default:''"`
	Content string `gorm:"not null;default:''"`

	OperationTimes
}

func (*App) TableName

func (*App) TableName() string

type AppV2

type AppV2 struct {
	ID         string `gorm:"primary_key"`
	Slug       string `gorm:"not null;default:''"`
	Author     string `gorm:"not null;default:''"`
	Status     string `gorm:"not null;default:''"`
	Content    string `gorm:"not null;default:''"`
	Data       string `gorm:"not null;default:'{}'"`
	Previews   string `gorm:"not null;default:'[]'"`
	Date       string `gorm:"not null;default:''"`
	CreatedAt  string `gorm:"not null;default:''"`
	UpdatedAt  string `gorm:"not null;default:''"`
	URI        string `gorm:"not null;default:''"`
	Category   int32  `gorm:"not null;default:0"`
	DirectLink string `gorm:"not null;default:''"`
	Order      int32  `gorm:"not null;default:0"`
	Firmware   string `gorm:"not null;default:''"`

	OperationTimes
}

func (*AppV2) TableName

func (*AppV2) TableName() string

type Bank

type Bank struct {
	Address string `gorm:"primary_key"`
	Balance string `gorm:"not null;default:'0'"`

	OperationTimes
}

func (*Bank) TableName

func (*Bank) TableName() string

type BankRecord

type BankRecord struct {
	ID        string `gorm:"primary_key"`
	From      string `gorm:"not null;default:''"`
	To        string `gorm:"not null;default:''"`
	Amount    string `gorm:"not null;default:''"`
	Timestamp int64  `gorm:"not null;default:0"`
	Type      int32  `gorm:"not null;default:0"`

	OperationTimes
}

func (*BankRecord) TableName

func (*BankRecord) TableName() string

type DB

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

func New

func New(dsn string, ioidProjectID uint64) (*DB, error)

func (*DB) App

func (d *DB) App(id string) (*App, error)

func (*DB) CreateDeviceRecord

func (d *DB) CreateDeviceRecord(t *DeviceRecord) error

func (*DB) Device

func (d *DB) Device(id string) (*Device, error)

func (*DB) ScannedBlockNumber

func (d *DB) ScannedBlockNumber() (uint64, error)

func (*DB) UpdateByID

func (d *DB) UpdateByID(id string, values map[string]any) error

func (*DB) UpsertApp

func (d *DB) UpsertApp(projectID uint64, name string, key [32]byte, value []byte) error

func (*DB) UpsertDevice

func (d *DB) UpsertDevice(t *Device) error

func (*DB) UpsertScannedBlockNumber

func (d *DB) UpsertScannedBlockNumber(number uint64) error

type Device

type Device struct {
	ID                     string `gorm:"primary_key"`
	Name                   string `gorm:"not null;default:''"`
	Owner                  string `gorm:"not null;default:''"`
	Address                string `gorm:"not null;default:''"`
	Avatar                 string `gorm:"not null;default:''"`
	Status                 int32  `gorm:"not null;default:0"`
	Proposer               string `gorm:"not null;default:''"`
	Firmware               string `gorm:"not null;default:''"`
	Config                 string `gorm:"not null;default:''"`
	TotalGas               int32  `gorm:"not null;default:0"`
	BulkUpload             int32  `gorm:"not null;default:0"`
	DataChannel            int32  `gorm:"not null;default:0"`
	UploadPeriod           int32  `gorm:"not null;default:0"`
	BulkUploadSamplingCnt  int32  `gorm:"not null;default:0"`
	BulkUploadSamplingFreq int32  `gorm:"not null;default:0"`
	Beep                   int32  `gorm:"not null;default:0"`
	RealFirmware           string `gorm:"not null;default:''"`
	State                  int32  `gorm:"not null;default:0"`
	Type                   int32  `gorm:"not null;default:0"`
	Configurable           bool   `gorm:"not null;default:0;default:true"`

	OperationTimes
}

func (*Device) TableName

func (*Device) TableName() string

type DeviceRecord

type DeviceRecord struct {
	ID            string `gorm:"primary_key"`
	Imei          string `gorm:"index:device_record_imei;not null"`
	Operator      string `gorm:"not null"`
	Snr           string `gorm:"not null;type:numeric(10,2);default:0"`
	Vbat          string `gorm:"not null;type:numeric(10,2);default:0"`
	GasResistance string `gorm:"not null;type:numeric(10,2);default:0"`
	Temperature   string `gorm:"not null;type:numeric(10,2);default:0"`
	Temperature2  string `gorm:"not null;type:numeric(10,2);default:0"`
	Pressure      string `gorm:"not null;type:numeric(10,2);default:0"`
	Humidity      string `gorm:"not null;type:numeric(10,2);default:0"`
	Light         string `gorm:"not null;type:numeric(10,2);default:0"`
	Gyroscope     string `gorm:"not null;default:''"`
	Accelerometer string `gorm:"not null;default:''"`
	Latitude      string `gorm:"not null;default:0"`
	Longitude     string `gorm:"not null;default:0"`
	Signature     string `gorm:"not null;default:''"`
	Timestamp     int64  `gorm:"index:device_record_timestamp;not null;default:0"`

	OperationTimes
}

func (*DeviceRecord) TableName

func (*DeviceRecord) TableName() string

type Message

type Message struct {
	gorm.Model
	MessageID      string `gorm:"index:message_id,not null"`
	ClientID       string `gorm:"index:message_fetch,not null,default:''"`
	ProjectID      uint64 `gorm:"index:message_fetch,not null"`
	ProjectVersion string `gorm:"index:message_fetch,not null,default:'0.0'"`
	Data           []byte `gorm:"size:4096"`
	InternalTaskID string `gorm:"index:internal_task_id,not null,default:''"`
}

type OperationTimes

type OperationTimes struct {
	CreatedAt time.Time `gorm:"not null"`
	UpdatedAt time.Time `gorm:"not null"`
}

func NewOperationTimes

func NewOperationTimes() OperationTimes

type Task

type Task struct {
	gorm.Model
	ProjectID      uint64 `gorm:"index:task_fetch,not null"`
	InternalTaskID string `gorm:"index:internal_task_id,not null"`
	MessageIDs     []byte `gorm:"not null"`
	Signature      string `gorm:"not null,default:''"`
}

func (*Task) Sign

func (t *Task) Sign(sk *ecdsa.PrivateKey, msg *Message) error

Jump to

Keyboard shortcuts

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