device

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package device 设备,包括SA状态

Index

Constants

View Source
const (
	AllDevice     listType = iota // 所有设备
	ControlDevice                 // 有控制权限的设备
)

0:所有设备;1:有控制权限的设备

Variables

This section is empty.

Functions

func AddDevice

func AddDevice(c *gin.Context)

AddDevice 用于处理添加设备接口的请求

func BuildInfoDevice

func BuildInfoDevice(device entity.Device, user *session.User, req *http.Request) (iDevice infoDevice, err error)

func CheckSaDevice

func CheckSaDevice(c *gin.Context)

CheckSaDevice 用于处理检查SA设备绑定情况接口的请求

func ControlPermissions

func ControlPermissions(d entity.Device) ([]types.Permission, error)

ControlPermissions 根据配置获取设备所有控制权限

func DelDevice

func DelDevice(c *gin.Context)

DelDevice 用于处理删除设备接口的请求

func DeviceManagePermissions

func DeviceManagePermissions(d entity.Device) []types.Permission

DeviceManagePermissions 设备的管理权限,暂时只有固件升级

func DevicePermissions

func DevicePermissions(d entity.Device) (ps []types.Permission, err error)

DevicePermissions 根据配置获取设备所有权限

func InfoDevice

func InfoDevice(c *gin.Context)

InfoDevice 用于处理设备详情接口的请求

func IsAccessAllow

func IsAccessAllow(c *gin.Context)

IsAccessAllow 是否能访问该SA

func IsDeviceControlPermit

func IsDeviceControlPermit(areaID uint64, userID int, pluginID, identity string, data json.RawMessage) bool

IsDeviceControlPermit 控制设备的websocket命令 是否有权限

func ListAllDevice

func ListAllDevice(c *gin.Context)

ListAllDevice 用于处理设备列表接口的请求

func ListLocationDevices

func ListLocationDevices(c *gin.Context)

ListLocationDevices 用于处理房间设备列表接口的请求

func RegisterDeviceRouter

func RegisterDeviceRouter(r gin.IRouter)

RegisterDeviceRouter 注册与设备相关的路由及其处理函数

func TypeList

func TypeList(c *gin.Context)

func UpdateDevice

func UpdateDevice(c *gin.Context)

UpdateDevice 用于处理修改设备接口的请求

Types

type CheckSaDeviceResp

type CheckSaDeviceResp struct {
	IsBind   bool   `json:"is_bind"`
	Revision string `json:"revision"`
}

CheckSaDeviceResp 检查SA设备绑定情况接口请求参数

type Device

type Device struct {
	ID           int    `json:"id"`
	Identity     string `json:"identity"`
	Name         string `json:"name"`
	LogoURL      string `json:"logo_url"`
	PluginID     string `json:"plugin_id"`
	LocationID   int    `json:"location_id"`
	LocationName string `json:"location_name"`
	IsSA         bool   `json:"is_sa"`
	Control      string `json:"control"` // 控制页相对路径
	PluginURL    string `json:"plugin_url"`
	Type         string `json:"type"`
}

Device 设备信息

func WrapDevices

func WrapDevices(c *gin.Context, devices []entity.Device, listType listType) (result []Device)

type IsAccessAllowResp

type IsAccessAllowResp struct {
	AccessAllow bool `json:"access_allow"` // 是否允许访问(判断用户token是否在该SA中有效)
}

type ModelDevice

type ModelDevice struct {
	Name         string `json:"name"`
	Model        string `json:"model"`
	Manufacturer string `json:"manufacturer"`
	Provisioning string `json:"provisioning"` // 配置页地址
	PluginID     string `json:"plugin_id"`
}

type Permissions

type Permissions struct {
	UpdateDevice bool `json:"update_device"`
	DeleteDevice bool `json:"delete_device"`
}

Permissions 设备权限

type Response

type Response struct {
	Types []Type `json:"types"`
}

type Type

type Type struct {
	Name    string            `json:"name"`
	Type    plugin.DeviceType `json:"type"`
	Devices []ModelDevice     `json:"devices"`
}

type UpdateDeviceReq

type UpdateDeviceReq struct {
	Name       *string `json:"name"`
	LocationID int     `json:"location_id"`
}

UpdateDeviceReq 修改设备接口请求参数

func (*UpdateDeviceReq) Validate

func (req *UpdateDeviceReq) Validate() (updateDevice entity.Device, err error)

Jump to

Keyboard shortcuts

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