tspsdk

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: MIT Imports: 12 Imported by: 0

README

bluebird-sdk-go

TSP3.0(Bluebird)Go SDK

测试

请查看example目录下的测试案例

Documentation

Index

Constants

View Source
const (
	AuthURL = GateWay + "/auth/token" // 鉴权(auth)

	/** 体温管理 **/
	TSPTemperatureGetUrl       = GateWay + "/tsp/temperature"        // 获取最新体温数据
	TSPTemperaturesGetUrl      = GateWay + "/tsp/temperatures"       // 获取体温结果列表
	TSPTemperatureUploadGetUrl = GateWay + "/tsp/temperature/upload" // 获取体温测量间隔时间
	TSPTemperatureUploadPutUrl = GateWay + "/tsp/temperature/upload" // 设置体温测量间隔时间
)
View Source
const (
	GateWay = "http://192.168.16.191:18001"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Cfg *Config
}

func (*Auth) GetToken

func (p *Auth) GetToken() (*AuthResult, error)

获取token

type AuthResult

type AuthResult struct {
	Result
	Data struct {
		Token string `json:"token"` //权限令牌,调用其它接口时需要提供token,有效期为 1 小时,过期后无法使用
	} `json:"data,omitempty"` // 返回结果
}

获取token

type Config

type Config struct {
	HttpClient *Request
}

type Device

type Device struct {
	Cfg *Config
}

func (*Device) Create

func (p *Device) Create()

创建设备

func (*Device) GetOne

func (p *Device) GetOne(imeiSn string) (bool, error)

设备详情

func (*Device) IsOnline

func (p *Device) IsOnline() (bool, error)

判断设备是否在线

type Request

type Request struct {
	Token  string
	Method string
	Url    string
	AppKey string
	Secret string
}

func (*Request) HttpRequest

func (p *Request) HttpRequest() (*gjson.Json, error)

func (*Request) SetMethod

func (p *Request) SetMethod(method string) *Request

func (*Request) SetToken

func (p *Request) SetToken(token string) *Request

func (*Request) SetUrl

func (p *Request) SetUrl(url string) *Request

type Result

type Result struct {
	Status  int    `json:"status"`            // 必选,返回码
	Message string `json:"message,omitempty"` // 可选,返回消息
}

type Temperature

type Temperature struct {
	Cfg *Config
}

func (*Temperature) GetTemperature

func (p *Temperature) GetTemperature(query *TemperatureRecentQuery) (*TemperatureResult, error)

获取最新体温数据

func (*Temperature) GetTemperatureUpload

func (p *Temperature) GetTemperatureUpload(query *TemperatureUploadQuery) (*TemperatureUploadResult, error)

获取体温测量间隔时间

func (*Temperature) GetTemperatures

func (p *Temperature) GetTemperatures(query *TemperaturesQuery) (*TemperaturesResult, error)

获取体温列表

type TemperatureEntity

type TemperatureEntity struct {
	PrimaryKey  string `json:"primary_key"`
	Id          int64  `json:"id"`
	ImeiSn      string `json:"imei_sn"`
	Uuid        string `json:"uuid"`
	ProductId   int64  `json:"product_id"`
	Temperature string `json:"temperature"`
	CreateTime  string `json:"created"`
}

====================== 体温 ==========================

type TemperatureRecentQuery

type TemperatureRecentQuery struct {
	ImeiSn string
	Uuid   string
}

================== 体温 ====================

type TemperatureResult

type TemperatureResult struct {
	Result
	Data TemperatureEntity `json:"data,omitempty"` // 返回结果
}

体温最近测量数据

type TemperatureUploadQuery

type TemperatureUploadQuery struct {
	ImeiSn string // 设备号
}

type TemperatureUploadResult

type TemperatureUploadResult struct {
	Result
	Data float64 `json:"data,omitempty"` // 返回结果
}

体温测量间隔时间

type TemperaturesQuery

type TemperaturesQuery struct {
	StartTime string // 开始时间
	EndTime   string // 结束时间
	ImeiSn    string // 设备号
	Uuid      string // UUID
	Page      int32  // 页码
	Limit     int32  // 每页条数
	ProductId int64  // 按照ProductId查询
	Sort      string // 排序方向 DESC/ASC;默认倒序
}

type TemperaturesResult

type TemperaturesResult struct {
	Result
	Data struct {
		Total  int                 `json:"total"`
		Result []TemperatureEntity `json:"result"`
	} `json:"data,omitempty"` // 返回结果
}

体温测量数据列表

type Tsp

type Tsp struct {
	Cfg *Config
}

func NewAuth

func NewAuth(appKey, secret string) *Tsp

获取token(只用来获取token)

func NewClient

func NewClient(token string) *Tsp

获取其它接口数据时在header里面携带token

func (*Tsp) Auth

func (p *Tsp) Auth() *Auth

鉴权

func (*Tsp) Temperature

func (p *Tsp) Temperature() *Temperature

体温

Jump to

Keyboard shortcuts

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