修复设备WiFi上游请求参数
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m40s

This commit is contained in:
2026-04-27 15:19:23 +08:00
parent 66cec7515a
commit c3ae7fcfbc
10 changed files with 50 additions and 52 deletions

View File

@@ -6318,9 +6318,6 @@ components:
type: object
DtoSetWiFiRequest:
properties:
card_no:
description: 流量卡号ICCID
type: string
enabled:
description: 启用状态
type: boolean
@@ -6333,7 +6330,6 @@ components:
minLength: 1
type: string
required:
- card_no
- ssid
type: object
DtoShopCascadeItem:

View File

@@ -470,27 +470,30 @@ fmt.Println("限速设置成功")
### 4. 设置设备 WiFi
设置设备的 WiFi 名称、密码和启用状态
设置设备的 WiFi 信息
**方法**: `SetWiFi`
**请求参数**:
```go
type WiFiReq struct {
DeviceID string `json:"deviceId" validate:"required"`
SSID string `json:"ssid" validate:"required,min=1,max=32"`
Password string `json:"password" validate:"required,min=8,max=63"`
Enabled int `json:"enabled" validate:"required,oneof=0 1"`
Extend string `json:"extend,omitempty"`
CardNo string `json:"cardNo" validate:"required"`
Params WiFiParams `json:"params" validate:"required"`
Extend string `json:"extend,omitempty"`
}
type WiFiParams struct {
SSIDName string `json:"ssidName" validate:"required,min=1,max=32"`
SSIDPassword string `json:"ssidPassword,omitempty"`
}
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| DeviceID | string | ✅ | 设备 ID/IMEI |
| SSID | string | ✅ | WiFi 名称1-32字符 |
| Password | string | ✅ | WiFi 密码8-63字符) |
| Enabled | int | | 启用状态0:禁用, 1:启用) |
| CardNo | string | ✅ | 设备 IMEI |
| Params | object | ✅ | WiFi 配置参数 |
| SSIDName | string | ✅ | WiFi 名称1-32字符) |
| SSIDPassword | string | | WiFi 密码 |
| Extend | string | ❌ | 扩展字段 |
**响应参数**: 无(成功返回 nil失败返回 error
@@ -498,10 +501,11 @@ type WiFiReq struct {
**使用示例**:
```go
err := client.SetWiFi(ctx, &gateway.WiFiReq{
DeviceID: "123456789012345",
SSID: "MyWiFi",
Password: "password123",
Enabled: 1,
CardNo: "123456789012345",
Params: gateway.WiFiParams{
SSIDName: "MyWiFi",
SSIDPassword: "password123",
},
})
if err != nil {
return err

View File

@@ -237,17 +237,13 @@ func (s *Service) SetDeviceSpeed(ctx context.Context, imei string, uploadKBps, d
#### 设置设备 WiFi
```go
func (s *Service) ConfigureWiFi(ctx context.Context, imei, ssid, password string, enabled bool) error {
enabledInt := 0
if enabled {
enabledInt = 1
}
func (s *Service) ConfigureWiFi(ctx context.Context, imei, ssid, password string) error {
err := s.gatewayClient.SetWiFi(ctx, &gateway.WiFiReq{
DeviceID: imei,
SSID: ssid,
Password: password,
Enabled: enabledInt,
CardNo: imei,
Params: gateway.WiFiParams{
SSIDName: ssid,
SSIDPassword: password,
},
})
if err != nil {
return errors.Wrap(errors.CodeGatewayError, err, "设置WiFi失败")