mirror of
https://github.com/m5stack/StackChan.git
synced 2026-04-28 03:22:39 +00:00
server code 4/27
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
|
||||
"stackChan/api/device/v1"
|
||||
"stackChan/api/device/v2"
|
||||
)
|
||||
|
||||
type IDeviceV1 interface {
|
||||
@@ -17,3 +18,11 @@ type IDeviceV1 interface {
|
||||
GetDeviceInfo(ctx context.Context, req *v1.GetDeviceInfoReq) (res *v1.GetDeviceInfoRes, err error)
|
||||
UpdateDeviceInfo(ctx context.Context, req *v1.UpdateDeviceInfoReq) (res *v1.UpdateDeviceInfoRes, err error)
|
||||
}
|
||||
|
||||
type IDeviceV2 interface {
|
||||
GetDevices(ctx context.Context, req *v2.GetDevicesReq) (res *v2.GetDevicesRes, err error)
|
||||
BindDevice(ctx context.Context, req *v2.BindDeviceReq) (res *v2.BindDeviceRes, err error)
|
||||
UnbindDevice(ctx context.Context, req *v2.UnbindDeviceReq) (res *v2.UnbindDeviceRes, err error)
|
||||
UpdateDevice(ctx context.Context, req *v2.UpdateDeviceReq) (res *v2.UpdateDeviceRes, err error)
|
||||
AgentRestoreDefault(ctx context.Context, req *v2.AgentRestoreDefaultReq) (res *v2.AgentRestoreDefaultRes, err error)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
|
||||
type CreateReq struct {
|
||||
g.Meta `path:"/device" method:"post" tags:"Device" summary:"Device create request"`
|
||||
Mac string `json:"mac" v:"required" description:"Mac address"`
|
||||
Name string `json:"name,omitempty" description:"Device name"`
|
||||
}
|
||||
|
||||
@@ -24,29 +23,26 @@ type CreateRes struct {
|
||||
|
||||
type UpdateReq struct {
|
||||
g.Meta `path:"/device" method:"put" tags:"Device" summary:"Device update request"`
|
||||
Mac string `json:"mac" v:"required" description:"Mac address"`
|
||||
Name string `json:"name" description:"Device name"`
|
||||
}
|
||||
|
||||
type UpdateRes struct{}
|
||||
|
||||
type GetRandomDeviceReq struct {
|
||||
g.Meta `path:"/device/randomList" method:"get" tags:"Device" summary:"Device get Random"`
|
||||
Mac string `json:"mac" v:"required" description:"Mac address"`
|
||||
g.Meta `path:"/device/randomList" method:"get" tags:"Device" summary:"Device get Random"`
|
||||
PageSize int `json:"pageSize" v:"required" d:"6" description:"Page size"`
|
||||
}
|
||||
|
||||
type GetRandomDeviceRes []entity.Device
|
||||
|
||||
type GetDeviceInfoReq struct {
|
||||
g.Meta `path:"/device/info" method:"get" tags:"Device" summary:"Device Info Get request"`
|
||||
Mac string `json:"mac" v:"required" description:"Mac address"`
|
||||
}
|
||||
|
||||
type GetDeviceInfoRes model.DeviceInfo
|
||||
|
||||
type UpdateDeviceInfoReq struct {
|
||||
g.Meta `path:"/device/info" method:"put" tags:"Device" summary:"Device Info Put request"`
|
||||
Mac string `json:"mac" v:"required" description:"Mac address"`
|
||||
Name string `json:"name" description:"Device name"`
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
package v2
|
||||
|
||||
import (
|
||||
"stackChan/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type GetDevicesReq struct {
|
||||
g.Meta `path:"/devices" method:"get" tags:"Device" summary:"Devices Get request"`
|
||||
}
|
||||
|
||||
type GetDevicesRes []model.DeviceInfo
|
||||
|
||||
type BindDeviceReq struct {
|
||||
g.Meta `path:"/device/bind" method:"post" tags:"Device" summary:"Bind device to current user"`
|
||||
Mac string `json:"mac" v:"required" dc:"Device MAC address"`
|
||||
}
|
||||
|
||||
type BindDeviceRes bool
|
||||
|
||||
type UnbindDeviceReq struct {
|
||||
g.Meta `path:"/device/unbind" method:"post" tags:"Device" summary:"Unbind device from current user"`
|
||||
Mac string `json:"mac" v:"required" dc:"Device MAC address"`
|
||||
}
|
||||
|
||||
type UnbindDeviceRes bool
|
||||
|
||||
type UpdateDeviceReq struct {
|
||||
g.Meta `path:"/device/update" method:"put" tags:"Device" summary:"Update device name for current user's bound device"`
|
||||
Mac string `json:"mac" v:"required" dc:"Device MAC address"`
|
||||
Name string `json:"name" dc:"New device name"`
|
||||
Longitude float64 `json:"longitude" dc:"Device longitude"`
|
||||
Latitude float64 `json:"latitude" dc:"Device latitude"`
|
||||
}
|
||||
|
||||
type UpdateDeviceRes bool
|
||||
|
||||
type AgentRestoreDefaultReq struct {
|
||||
g.Meta `path:"/device/agent/restore" method:"post" tags:"Device" summary:"Restore Agent to default template settings"`
|
||||
Mac string `json:"mac" v:"required" dc:"Device MAC address"`
|
||||
}
|
||||
|
||||
type AgentRestoreDefaultRes bool
|
||||
Reference in New Issue
Block a user