models

package
v0.0.0-...-5ba78f1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceRunning = "running"
	DeviceIdle    = "idle"
	DeviceError   = "error"
)

Variables

This section is empty.

Functions

func CountDevice

func CountDevice(conditions interface{}) (int64, error)

func CountProtocol

func CountProtocol(conditions interface{}) (int64, error)

func DeleteDevice

func DeleteDevice(id int) error

func DeleteProtocol

func DeleteProtocol(id int) error

func GetDB

func GetDB() *gorm.DB

func InitDB

func InitDB()

func Paginate

func Paginate(pageNum int, pageSize int) func(db *gorm.DB) *gorm.DB

Paginate 通用分页逻辑

Types

type Device

type Device struct {
	Model

	Name       string `json:"name"`
	Type       string `json:"type"`
	ServerIp   string `json:"server_ip"`
	ServerPort string `json:"server_port"`
	State      string `json:"state"` // [running, idle, error]
}

func CreateDevice

func CreateDevice(device *Device) (*Device, error)

func GetDevice

func GetDevice(id int) (*Device, error)

func GetDevices

func GetDevices(pageNum int, pageSize int, conditions interface{}, order string) ([]*Device, error)

func UpdateDevice

func UpdateDevice(id int, data interface{}) (*Device, error)

type Model

type Model struct {
	ID        int            `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type Protocol

type Protocol struct {
	Model

	DeviceId int            `json:"device_id"`
	Name     string         `json:"name"`
	Content  datatypes.JSON `json:"content"`
	Qos      int            `json:"qos"`
	Type     int            `json:"type"` // 0--自发, 1--响应
	SubTopic string         `json:"sub_topic"`
	PubTopic string         `json:"pub_topic"`
	Strategy datatypes.JSON `json:"strategy"`
}

func CreateProtocol

func CreateProtocol(protocol *Protocol) (*Protocol, error)

func GetProtocol

func GetProtocol(id int) (*Protocol, error)

func GetProtocols

func GetProtocols(pageNum int, pageSize int, maps interface{}, order string) ([]*Protocol, error)

func GetProtocolsByDeviceId

func GetProtocolsByDeviceId(deviceId int) ([]*Protocol, error)

func UpdateProtocol

func UpdateProtocol(id int, data interface{}) (*Protocol, error)

Jump to

Keyboard shortcuts

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