mirror of
https://github.com/m5stack/StackChan.git
synced 2026-05-20 11:49:45 -07:00
feat(server): deliver major backend expansion with v2 APIs, AI integration, and realtime infrastructure (#36)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
* linguist-language=GO
|
||||
@@ -0,0 +1,278 @@
|
||||
# StackChan Server
|
||||
|
||||
**StackChan Server** is the backend server for the open-source StackChan project. It provides RESTful APIs for device management, user authentication, post management, comment systems, and dance control functionalities.
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
- **Device Management**: Device binding, unbinding, and information updates
|
||||
- **User Authentication**: Login, registration, and JWT-based token authentication
|
||||
- **Post System**: Create, read, and manage posts with text and image support
|
||||
- **Comment System**: Full CRUD operations for post comments
|
||||
- **Dance Control**: Dance creation, management, and motion data handling
|
||||
- **App Store Integration**: App management and distribution
|
||||
- **AI Agent Integration**: XiaoZhi (小智) AI assistant integration with agent configuration
|
||||
- **Persistent Storage**: MySQL database with ORM-based data access
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Database Setup](#database-setup)
|
||||
- [Configuration](#configuration)
|
||||
- [Installation](#installation)
|
||||
- [Running the Server](#running-the-server)
|
||||
- [API Documentation](#api-documentation)
|
||||
- [Project Structure](#project-structure)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- **Go**: The project is developed in Go. Install **Go 1.24+** from
|
||||
the [official download page](https://golang.google.cn/dl/).
|
||||
|
||||
Verify installation:
|
||||
|
||||
```bash
|
||||
go version
|
||||
# Expected output: "go version go1.24.x ..." (or similar)
|
||||
```
|
||||
|
||||
- **MySQL**: Version 8.0+ for database storage
|
||||
- **Git**: For cloning the repository
|
||||
|
||||
---
|
||||
|
||||
## Database Setup
|
||||
|
||||
Before running the project, you need to create the MySQL database first:
|
||||
|
||||
```bash
|
||||
# Execute the database initialization script
|
||||
mysql -u your_username -p < check_list/create_mysql_database.sql
|
||||
```
|
||||
|
||||
This will create the `stackChan` database and all required tables.
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
Update the `manifest/config/config.yaml` file with your actual configuration:
|
||||
|
||||
### 1. Database Connection
|
||||
|
||||
```yaml
|
||||
database:
|
||||
default:
|
||||
link: "mysql:your_username:your_password@tcp(127.0.0.1:3306)/stackChan?charset=utf8mb4&collation=utf8mb4_0900_ai_ci"
|
||||
```
|
||||
|
||||
### 2. JWT Configuration
|
||||
|
||||
For production use, generate your own secure JWT secret key.
|
||||
|
||||
**Generate a secure JWT secret key:**
|
||||
|
||||
Option 1: Using OpenSSL (recommended)
|
||||
```bash
|
||||
# Generate a 32-byte (256-bit) random secret key encoded in base64
|
||||
openssl rand -base64 32
|
||||
```
|
||||
|
||||
Option 2: Using Python
|
||||
```bash
|
||||
python3 -c "import secrets; import base64; print(base64.b64encode(secrets.token_bytes(32)).decode())"
|
||||
```
|
||||
|
||||
Update the configuration in `manifest/config/config.yaml`:
|
||||
```yaml
|
||||
jwt:
|
||||
secret: "your_generated_secret_key_here"
|
||||
```
|
||||
|
||||
### 3. RSA Keys
|
||||
|
||||
For production use, generate your own RSA key pairs for encryption.
|
||||
|
||||
### 4. XiaoZhi Configuration
|
||||
|
||||
Set your XiaoZhi (小智) API secret key:
|
||||
|
||||
```yaml
|
||||
xiaozhi:
|
||||
secret_key: "your_xiaozhi_secret_key_here"
|
||||
generate_license_token: "your_xiaozhi_generate_license_token_here"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/m5stack/StackChan.git
|
||||
cd StackChan/server
|
||||
|
||||
# Download dependencies
|
||||
go mod download
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Running the Server
|
||||
|
||||
### Development Mode
|
||||
|
||||
```bash
|
||||
go run main.go
|
||||
```
|
||||
|
||||
### Build and Run
|
||||
|
||||
```bash
|
||||
# Build for current platform
|
||||
go build -o stackchan-server main.go
|
||||
|
||||
# Run
|
||||
./stackchan-server # Linux/macOS
|
||||
stackchan-server.exe # Windows
|
||||
```
|
||||
|
||||
### Using Makefile
|
||||
|
||||
```bash
|
||||
# Build
|
||||
make build
|
||||
|
||||
# Run
|
||||
make run
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API Documentation
|
||||
|
||||
The server provides RESTful APIs organized by module:
|
||||
|
||||
### Device APIs (`/api/device/*`)
|
||||
- `POST /device/bind` - Bind a device to the current user
|
||||
- `POST /device/unbind` - Unbind a device from the current user
|
||||
- `PUT /device/update` - Update device information
|
||||
- `GET /devices` - Get list of devices
|
||||
|
||||
### User APIs (`/api/user/*`)
|
||||
- `POST /user/login` - User login
|
||||
- `POST /user/registration` - User registration
|
||||
- `GET /user` - Get user information
|
||||
|
||||
### Dance APIs (`/api/dance/*`)
|
||||
- `POST /dance` - Create a new dance
|
||||
- `GET /dance` - Get dance information
|
||||
- `PUT /dance` - Update dance details
|
||||
- `DELETE /dance` - Delete a dance
|
||||
|
||||
### Post APIs (`/api/post/*`)
|
||||
- `GET /post/get` - Get post details
|
||||
- Post listing and comment operations
|
||||
|
||||
### Admin APIs (`/api/admin/*`)
|
||||
- App management operations
|
||||
- User management
|
||||
|
||||
---
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
stackChan/
|
||||
├── api/ # API definitions and request/response structures
|
||||
│ ├── admin/ # Admin module APIs
|
||||
│ ├── appstore/ # App store module APIs
|
||||
│ ├── dance/ # Dance module APIs
|
||||
│ ├── device/ # Device module APIs
|
||||
│ ├── friend/ # Friend module APIs
|
||||
│ ├── post/ # Post module APIs
|
||||
│ ├── user/ # User module APIs
|
||||
│ └── xiaozhi/ # XiaoZhi AI module APIs
|
||||
├── internal/ # Internal application code
|
||||
│ ├── boot/ # Boot initialization
|
||||
│ ├── cmd/ # Command entry
|
||||
│ ├── consts/ # Constants definitions
|
||||
│ ├── controller/ # API controllers
|
||||
│ ├── dao/ # Data Access Objects
|
||||
│ ├── logic/ # Business logic
|
||||
│ ├── middleware/ # HTTP middlewares
|
||||
│ ├── model/ # Data models
|
||||
│ ├── packed/ # Packed assets
|
||||
│ ├── service/ # Business services
|
||||
│ └── xiaozhi/ # XiaoZhi integration
|
||||
├── manifest/ # Deployment and configuration
|
||||
│ ├── config/ # Configuration files
|
||||
│ ├── deploy/ # Deployment scripts
|
||||
│ └── docker/ # Docker configurations
|
||||
├── utility/ # Utility functions (RSA, etc.)
|
||||
├── web/ # Web frontend assets
|
||||
├── main.go # Application entry
|
||||
├── go.mod # Go module definition
|
||||
├── go.sum # Go dependencies checksum
|
||||
├── Makefile # Build scripts
|
||||
└── README.MD # This file
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
The project follows a layered architecture:
|
||||
|
||||
1. **API Layer**: Defines request/response structures and routes
|
||||
2. **Controller Layer**: Handles HTTP requests and responses
|
||||
3. **Service Layer**: Implements business logic
|
||||
4. **DAO Layer**: Data access and database operations
|
||||
5. **Model Layer**: Data structures and entities
|
||||
|
||||
The project uses the GoFrame framework for rapid development and robust infrastructure.
|
||||
|
||||
---
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||
|
||||
For major changes, please open an issue first to discuss what you would like to change.
|
||||
|
||||
### Development Guidelines
|
||||
|
||||
- Follow Go conventions and best practices
|
||||
- Write clear, descriptive comments in English
|
||||
- Add tests for new features
|
||||
- Ensure all existing tests pass
|
||||
- Update documentation as needed
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
[SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD](LICENSE)
|
||||
|
||||
[SPDX-License-Identifier: MIT](LICENSE)
|
||||
|
||||
---
|
||||
|
||||
## Support
|
||||
|
||||
For questions and support, please open an issue in the GitHub repository or contact the M5Stack team.
|
||||
|
||||
---
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
- [GoFrame](https://goframe.org/) - The Go framework used in this project
|
||||
- [M5Stack](https://m5stack.com/) - For supporting open-source development
|
||||
- All contributors who help improve this project
|
||||
@@ -1,44 +0,0 @@
|
||||
# StackChan Server
|
||||
|
||||
**StackChan Server** is the Server of the open-source StackChan project. It handles core functionalities such
|
||||
as device interactions, post management, and comment systems, providing stable and efficient API support.
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
- App and StackChan communication and interaction
|
||||
- Device post creation and management (text and image support, similar to a social feed)
|
||||
- Comment CRUD (Create, Read, Update, Delete) operations
|
||||
- Dance control and data management
|
||||
- Persistent storage using a relational database
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **Go**: The project is developed in Go. Install **Go 1.24+** from
|
||||
the [official download page](https://golang.google.cn/dl/).
|
||||
|
||||
Verify installation:
|
||||
|
||||
```bash
|
||||
go version
|
||||
# Expected output: "go version go1.24.x ..." (or similar)
|
||||
|
||||
### Clone the Repository
|
||||
```bash
|
||||
git clone https://github.com/m5stack/StackChan # Replace with the actual repository URL
|
||||
cd StackChan/server
|
||||
|
||||
# Download dependencies
|
||||
go mod download
|
||||
|
||||
# build
|
||||
go build -o StackChan main.go
|
||||
|
||||
# Start running
|
||||
StackChan # Linux/macOS
|
||||
StackChan.exe # Windows
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"stackChan/api/admin/v1"
|
||||
)
|
||||
|
||||
type IAdminV1 interface {
|
||||
AdminLogin(ctx context.Context, req *v1.AdminLoginReq) (res *v1.AdminLoginRes, err error)
|
||||
AddApp(ctx context.Context, req *v1.AddAppReq) (res *v1.AddAppRes, err error)
|
||||
GetAppList(ctx context.Context, req *v1.GetAppListReq) (res *v1.GetAppListRes, err error)
|
||||
DeleteApp(ctx context.Context, req *v1.DeleteAppReq) (res *v1.DeleteAppRes, err error)
|
||||
UpdateApp(ctx context.Context, req *v1.UpdateAppReq) (res *v1.UpdateAppRes, err error)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
type AdminLoginReq struct {
|
||||
g.Meta `path:"/login" method:"post" tags:"Info" summary:"admin login info"`
|
||||
UserName string `json:"user_name" description:"Admin username"`
|
||||
Password string `json:"pass_word" description:"Admin password"`
|
||||
}
|
||||
|
||||
type AdminLoginRes struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"stackChan/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type AddAppReq struct {
|
||||
g.Meta `path:"/app/add" method:"post" tags:"App" summary:"App add request"`
|
||||
AppName string `json:"appName" orm:"app_name" v:"required" d:"" description:"App name (required)"`
|
||||
AppIconUrl string `json:"appIconUrl" orm:"app_icon_url" d:"" description:"App icon URL (optional)"`
|
||||
Description string `json:"description" orm:"description" d:"" description:"App description (optional)"`
|
||||
FirmwareUrl string `json:"firmwareUrl" orm:"firmware_url" d:"" description:"Firmware / installation package download URL (optional)"`
|
||||
}
|
||||
|
||||
type AddAppRes model.AppInfo
|
||||
|
||||
type GetAppListReq struct {
|
||||
g.Meta `path:"/apps" method:"get" tags:"App" summary:"App List Get"`
|
||||
}
|
||||
|
||||
type GetAppListRes []model.AppInfo
|
||||
|
||||
type DeleteAppReq struct {
|
||||
g.Meta `path:"/app/delete" method:"delete" tags:"App" summary:"App delete"`
|
||||
Id int64 `json:"id" orm:"id" description:"App ID"` // App ID
|
||||
}
|
||||
|
||||
type DeleteAppRes struct{}
|
||||
|
||||
type UpdateAppReq struct {
|
||||
g.Meta `path:"/app/update" method:"put" tags:"App" summary:"App put"`
|
||||
Id int64 `json:"id" orm:"id" v:"required" description:"App ID (required)"`
|
||||
AppName string `json:"appName" orm:"app_name" d:"" description:"App name (optional)"`
|
||||
AppIconUrl string `json:"appIconUrl" orm:"app_icon_url" d:"" description:"App icon URL (optional)"`
|
||||
Description string `json:"description" orm:"description" d:"" description:"App description (optional)"`
|
||||
FirmwareUrl string `json:"firmwareUrl" orm:"firmware_url" d:"" description:"Firmware / installation package download URL (optional)"`
|
||||
}
|
||||
|
||||
type UpdateAppRes model.AppInfo
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package appstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"stackChan/api/appstore/v1"
|
||||
)
|
||||
|
||||
type IAppstoreV1 interface {
|
||||
GetAppList(ctx context.Context, req *v1.GetAppListReq) (res *v1.GetAppListRes, err error)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"stackChan/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type GetAppListReq struct {
|
||||
g.Meta `path:"/apps" method:"get" tags:"App" summary:"App List Get"`
|
||||
}
|
||||
|
||||
type GetAppListRes []model.AppInfo
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
@@ -8,6 +13,7 @@ import (
|
||||
"context"
|
||||
|
||||
"stackChan/api/dance/v1"
|
||||
"stackChan/api/dance/v2"
|
||||
)
|
||||
|
||||
type IDanceV1 interface {
|
||||
@@ -15,4 +21,14 @@ type IDanceV1 interface {
|
||||
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
|
||||
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error)
|
||||
GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error)
|
||||
GetDanceInfo(ctx context.Context, req *v1.GetDanceInfoReq) (res *v1.GetDanceInfoRes, err error)
|
||||
GetMusicList(ctx context.Context, req *v1.GetMusicListReq) (res *v1.GetMusicListRes, err error)
|
||||
}
|
||||
|
||||
type IDanceV2 interface {
|
||||
GetList(ctx context.Context, req *v2.GetListReq) (res *v2.GetListRes, err error)
|
||||
Create(ctx context.Context, req *v2.CreateReq) (res *v2.CreateRes, err error)
|
||||
Delete(ctx context.Context, req *v2.DeleteReq) (res *v2.DeleteRes, err error)
|
||||
Update(ctx context.Context, req *v2.UpdateReq) (res *v2.UpdateRes, err error)
|
||||
GetDanceInfo(ctx context.Context, req *v2.GetDanceInfoReq) (res *v2.GetDanceInfoRes, err error)
|
||||
}
|
||||
|
||||
@@ -6,40 +6,53 @@ SPDX-License-Identifier: MIT
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"stackChan/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type CreateReq struct {
|
||||
g.Meta `path:"/dance" method:"post" tags:"Dance" summary:"Dance create request"`
|
||||
Mac string `json:"mac" v:"required"`
|
||||
Index int `json:"index" v:"required"`
|
||||
List []model.DanceData `json:"list" v:"required"`
|
||||
g.Meta `path:"/dance" method:"post" tags:"Dance" summary:"Dance create request"`
|
||||
DanceData json.RawMessage `json:"danceData"` // Dance motion data
|
||||
DanceName string `json:"danceName" v:"required"` // Dance name
|
||||
MusicUrl string `json:"musicUrl"` // Dance background music URL
|
||||
}
|
||||
|
||||
type CreateRes string
|
||||
|
||||
type DeleteReq struct {
|
||||
g.Meta `path:"/dance" method:"delete" tags:"Dance" summary:"Dance delete request"`
|
||||
Mac string `json:"mac" v:"required"`
|
||||
Index int `json:"index" v:"required"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
type DeleteRes string
|
||||
|
||||
type UpdateReq struct {
|
||||
g.Meta `path:"/dance" method:"put" tags:"Dance" summary:"Dance put request"`
|
||||
Mac string `json:"mac" v:"required"`
|
||||
Index int `json:"index" v:"required"`
|
||||
Data []model.DanceData `json:"list" v:"required"`
|
||||
g.Meta `path:"/dance" method:"put" tags:"Dance" summary:"Dance put request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
DanceData json.RawMessage `json:"danceData"` // Dance motion data
|
||||
DanceName string `json:"danceName"` // Dance name
|
||||
MusicUrl string `json:"musicUrl"` // Dance background music URL
|
||||
}
|
||||
|
||||
type UpdateRes string
|
||||
|
||||
type GetListReq struct {
|
||||
g.Meta `path:"/dance" method:"get" tags:"Dance" summary:"Dance get request"`
|
||||
Mac string `json:"mac" v:"required"`
|
||||
}
|
||||
|
||||
type GetListRes map[string][]model.DanceData
|
||||
type GetListRes []model.Dance
|
||||
|
||||
type GetDanceInfoReq struct {
|
||||
g.Meta `path:"/danceData" method:"get" tags:"Dance get request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
type GetDanceInfoRes model.Dance
|
||||
|
||||
type GetMusicListReq struct {
|
||||
g.Meta `path:"/musicList" method:"get" tags:"Dance get request"`
|
||||
}
|
||||
|
||||
type GetMusicListRes []string
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
package v2
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"stackChan/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type GetListReq struct {
|
||||
g.Meta `path:"/dance" method:"get" tags:"Dance" summary:"Dance get request"`
|
||||
Mac string `json:"mac" v:"required"` // mac address
|
||||
}
|
||||
|
||||
type GetListRes []model.Dance
|
||||
|
||||
type CreateReq struct {
|
||||
g.Meta `path:"/dance" method:"post" tags:"Dance" summary:"Dance create request"`
|
||||
Mac string `json:"mac" v:"required"` // mac address
|
||||
DanceData json.RawMessage `json:"danceData"` // Dance motion data
|
||||
DanceName string `json:"danceName" v:"required"` // Dance name
|
||||
MusicUrl string `json:"musicUrl"` // Dance background music URL
|
||||
}
|
||||
|
||||
type CreateRes string
|
||||
|
||||
type DeleteReq struct {
|
||||
g.Meta `path:"/dance" method:"delete" tags:"Dance" summary:"Dance delete request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
type DeleteRes string
|
||||
|
||||
type UpdateReq struct {
|
||||
g.Meta `path:"/dance" method:"put" tags:"Dance" summary:"Dance put request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
DanceData json.RawMessage `json:"danceData"` // Dance motion data
|
||||
DanceName string `json:"danceName"` // Dance name
|
||||
MusicUrl string `json:"musicUrl"` // Dance background music URL
|
||||
}
|
||||
|
||||
type UpdateRes string
|
||||
|
||||
type GetDanceInfoReq struct {
|
||||
g.Meta `path:"/danceData" method:"get" tags:"Dance get request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
type GetDanceInfoRes model.Dance
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
@@ -8,6 +13,7 @@ import (
|
||||
"context"
|
||||
|
||||
"stackChan/api/device/v1"
|
||||
"stackChan/api/device/v2"
|
||||
)
|
||||
|
||||
type IDeviceV1 interface {
|
||||
@@ -17,3 +23,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
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
@@ -9,7 +9,6 @@ import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
type AddReq struct {
|
||||
g.Meta `path:"/friend" method:"post" tags:"Friend" summary:"Friend add request"`
|
||||
Mac string `json:"mac" v:"required" description:"Mac address"`
|
||||
FriendMac string `json:"friendMac" v:"required" description:"Friend Mac address"`
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package pano
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"stackChan/api/pano/v1"
|
||||
)
|
||||
|
||||
type IPanoV1 interface {
|
||||
AddPano(ctx context.Context, req *v1.AddPanoReq) (res *v1.AddPanoRes, err error)
|
||||
GetPanoList(ctx context.Context, req *v1.GetPanoListReq) (res *v1.GetPanoListRes, err error)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"stackChan/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type AddPanoReq struct {
|
||||
g.Meta `path:"/pano" method:"post" tags:"Pano" summary:"Pano add request"`
|
||||
Url string `json:"url" v:"required" description:"Pano image url"`
|
||||
}
|
||||
|
||||
type AddPanoRes struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type GetPanoListReq struct {
|
||||
g.Meta `path:"/pano" method:"get" tags:"Pano" summary:"Pano list"`
|
||||
}
|
||||
|
||||
type GetPanoListRes []model.Pano
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user