fetch(modify):修复角色分配权限
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 2m36s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 2m36s
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# Change: 重命名 API 字段 series_allocation_id 为 series_id
|
||||
|
||||
## Why
|
||||
|
||||
后端 API 字段命名不一致。前端表单使用 `series_id`(套餐系列ID),但 API 参数仍使用 `series_allocation_id`(套餐系列分配ID)。这导致命名混淆且不符合实际业务含义(现在直接指向套餐系列 ID,而非分配记录 ID)。
|
||||
|
||||
## What Changes
|
||||
|
||||
- **BREAKING**: 重命名 4 个 API 端点的请求/响应字段
|
||||
- `PATCH /api/admin/iot-cards/series-binding` - 请求参数 `series_allocation_id` → `series_id`
|
||||
- `PATCH /api/admin/devices/series-binding` - 请求参数 `series_allocation_id` → `series_id`
|
||||
- `GET /api/admin/iot-cards/standalone` - 查询参数和响应字段 `series_allocation_id` → `series_id`
|
||||
- `GET /api/admin/devices` - 查询参数和响应字段 `series_allocation_id` → `series_id`
|
||||
|
||||
- 前端同步修改:
|
||||
- TypeScript 类型定义
|
||||
- API 方法参数
|
||||
- 页面组件调用代码
|
||||
- 移除临时注释
|
||||
|
||||
## Impact
|
||||
|
||||
- **Affected specs**: iot-card-api, device-api
|
||||
- **Affected code**:
|
||||
- `src/types/api/device.ts` (BatchSetDeviceSeriesBindingRequest)
|
||||
- `src/types/api/card.ts` (BatchSetCardSeriesBindingRequest)
|
||||
- `src/api/modules/device.ts` (batchSetDeviceSeriesBinding)
|
||||
- `src/api/modules/card.ts` (batchSetCardSeriesBinding)
|
||||
- `src/views/asset-management/device-list/index.vue`
|
||||
- `src/views/asset-management/iot-card-management/index.vue`
|
||||
- **Breaking change**: 需要后端先部署更新,前端再部署
|
||||
- **Migration**: 更新所有使用这些字段的 API 调用
|
||||
@@ -0,0 +1,100 @@
|
||||
# Device API Specification Delta
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Device Series ID Query Parameter
|
||||
|
||||
The system SHALL support filtering devices by package series ID in query parameters.
|
||||
|
||||
**Query Parameter**: `series_id` (number, optional)
|
||||
|
||||
#### Scenario: Filter devices by series
|
||||
|
||||
- **WHEN** admin queries devices with series_id parameter
|
||||
- **THEN** system returns only devices associated with that package series
|
||||
- **AND** returns empty list if no matches found
|
||||
|
||||
#### Scenario: Query without series filter
|
||||
|
||||
- **WHEN** admin queries devices without series_id parameter
|
||||
- **THEN** system returns all devices matching other filter criteria
|
||||
- **AND** series association is not considered
|
||||
|
||||
### Requirement: Device Series ID Response Field
|
||||
|
||||
The system SHALL include package series ID in device response data.
|
||||
|
||||
**Response Field**: `series_id` (number | null)
|
||||
- Value is package series ID if device is bound to a series
|
||||
- Value is null if device has no series binding
|
||||
|
||||
#### Scenario: Display series association
|
||||
|
||||
- **WHEN** system returns device in list response
|
||||
- **THEN** each device includes series_id field
|
||||
- **AND** field shows current series binding or null
|
||||
|
||||
#### Scenario: Null series binding
|
||||
|
||||
- **WHEN** device has no series binding
|
||||
- **THEN** series_id field is null
|
||||
- **AND** device can still be displayed in results
|
||||
|
||||
## RENAMED Requirements
|
||||
|
||||
### API Field Renaming
|
||||
|
||||
- FROM: `series_allocation_id` (in batch series binding endpoints)
|
||||
- TO: `series_id`
|
||||
|
||||
**Reason**: Field name `series_allocation_id` implied a reference to an allocation record ID, but it actually stores the package series ID directly. Renaming to `series_id` clarifies this relationship and aligns with frontend naming conventions.
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Batch Set Device Series Binding
|
||||
|
||||
The system SHALL provide an endpoint to batch set package series binding for devices.
|
||||
|
||||
**Endpoint**: `PATCH /api/admin/devices/series-binding`
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"device_ids": [1, 2, 3],
|
||||
"series_id": 123 // Changed from series_allocation_id
|
||||
}
|
||||
```
|
||||
|
||||
**Field Definitions**:
|
||||
- `device_ids`: Array of device IDs (max 500 items)
|
||||
- `series_id`: Package series ID (tb_package_series.id), 0 means clear association
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"data": {
|
||||
"success_count": 3,
|
||||
"fail_count": 0,
|
||||
"failed_items": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Scenario: Successful batch series binding
|
||||
|
||||
- **WHEN** admin calls batch series binding API with valid device IDs and series_id
|
||||
- **THEN** system updates series association for all valid devices
|
||||
- **AND** returns success count and failure details
|
||||
|
||||
#### Scenario: Clear series association
|
||||
|
||||
- **WHEN** admin calls batch series binding API with series_id = 0
|
||||
- **THEN** system clears series association for specified devices
|
||||
- **AND** returns success confirmation
|
||||
|
||||
#### Scenario: Partial failure handling
|
||||
|
||||
- **WHEN** some devices in the batch cannot be updated
|
||||
- **THEN** system processes valid devices successfully
|
||||
- **AND** returns failed_items list with reasons for failures
|
||||
@@ -0,0 +1,100 @@
|
||||
# IoT Card API Specification Delta
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: IoT Card Series ID Query Parameter
|
||||
|
||||
The system SHALL support filtering standalone IoT cards by package series ID in query parameters.
|
||||
|
||||
**Query Parameter**: `series_id` (number, optional)
|
||||
|
||||
#### Scenario: Filter cards by series
|
||||
|
||||
- **WHEN** admin queries standalone cards with series_id parameter
|
||||
- **THEN** system returns only cards associated with that package series
|
||||
- **AND** returns empty list if no matches found
|
||||
|
||||
#### Scenario: Query without series filter
|
||||
|
||||
- **WHEN** admin queries cards without series_id parameter
|
||||
- **THEN** system returns all cards matching other filter criteria
|
||||
- **AND** series association is not considered
|
||||
|
||||
### Requirement: IoT Card Series ID Response Field
|
||||
|
||||
The system SHALL include package series ID in standalone IoT card response data.
|
||||
|
||||
**Response Field**: `series_id` (number | null)
|
||||
- Value is package series ID if card is bound to a series
|
||||
- Value is null if card has no series binding
|
||||
|
||||
#### Scenario: Display series association
|
||||
|
||||
- **WHEN** system returns IoT card in list response
|
||||
- **THEN** each card includes series_id field
|
||||
- **AND** field shows current series binding or null
|
||||
|
||||
#### Scenario: Null series binding
|
||||
|
||||
- **WHEN** card has no series binding
|
||||
- **THEN** series_id field is null
|
||||
- **AND** card can still be displayed in results
|
||||
|
||||
## RENAMED Requirements
|
||||
|
||||
### API Field Renaming
|
||||
|
||||
- FROM: `series_allocation_id` (in batch series binding endpoints)
|
||||
- TO: `series_id`
|
||||
|
||||
**Reason**: Field name `series_allocation_id` implied a reference to an allocation record ID, but it actually stores the package series ID directly. Renaming to `series_id` clarifies this relationship and aligns with frontend naming conventions.
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Batch Set Card Series Binding
|
||||
|
||||
The system SHALL provide an endpoint to batch set package series binding for IoT cards.
|
||||
|
||||
**Endpoint**: `PATCH /api/admin/iot-cards/series-binding`
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"iccids": ["898600..."],
|
||||
"series_id": 123 // Changed from series_allocation_id
|
||||
}
|
||||
```
|
||||
|
||||
**Field Definitions**:
|
||||
- `iccids`: Array of ICCIDs (max 500 items)
|
||||
- `series_id`: Package series ID (tb_package_series.id), 0 means clear association
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"data": {
|
||||
"success_count": 100,
|
||||
"fail_count": 0,
|
||||
"failed_items": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Scenario: Successful batch series binding
|
||||
|
||||
- **WHEN** admin calls batch series binding API with valid ICCIDs and series_id
|
||||
- **THEN** system updates series association for all valid cards
|
||||
- **AND** returns success count and failure details
|
||||
|
||||
#### Scenario: Clear series association
|
||||
|
||||
- **WHEN** admin calls batch series binding API with series_id = 0
|
||||
- **THEN** system clears series association for specified cards
|
||||
- **AND** returns success confirmation
|
||||
|
||||
#### Scenario: Partial failure handling
|
||||
|
||||
- **WHEN** some cards in the batch cannot be updated
|
||||
- **THEN** system processes valid cards successfully
|
||||
- **AND** returns failed_items list with reasons for failures
|
||||
@@ -0,0 +1,34 @@
|
||||
# Implementation Tasks
|
||||
|
||||
## 1. 类型定义更新
|
||||
|
||||
### 1.1 批量设置接口参数重命名
|
||||
- [x] 1.1.1 更新 `src/types/api/device.ts` 中 BatchSetDeviceSeriesBindingRequest 接口,将 `series_allocation_id` 改为 `series_id`
|
||||
- [x] 1.1.2 更新 `src/types/api/card.ts` 中 BatchSetCardSeriesBindingRequest 接口,将 `series_allocation_id` 改为 `series_id`
|
||||
|
||||
### 1.2 查询参数新增字段
|
||||
- [x] 1.2.1 在 `src/types/api/device.ts` 的 DeviceQueryParams 接口中添加 `series_id?: number` 查询参数
|
||||
- [x] 1.2.2 在 `src/types/api/card.ts` 的 StandaloneCardQueryParams 接口中添加 `series_id?: number` 查询参数
|
||||
|
||||
### 1.3 响应类型新增字段
|
||||
- [x] 1.3.1 在 `src/types/api/device.ts` 的 Device 接口中添加 `series_id?: number | null` 响应字段(在 updated_at 后面)
|
||||
- [x] 1.3.2 在 `src/types/api/card.ts` 的 StandaloneIotCard 接口中添加 `series_id?: number | null` 响应字段(在 updated_at 后面)
|
||||
|
||||
## 2. API 方法更新
|
||||
|
||||
- [x] 2.1 更新 `src/api/modules/device.ts` 中 batchSetDeviceSeriesBinding 方法参数,将 `series_allocation_id` 改为 `series_id`
|
||||
- [x] 2.2 更新 `src/api/modules/card.ts` 中 batchSetCardSeriesBinding 方法参数,将 `series_allocation_id` 改为 `series_id`
|
||||
|
||||
## 3. 页面组件更新
|
||||
|
||||
- [x] 3.1 更新 `src/views/asset-management/device-list/index.vue` 中调用 batchSetDeviceSeriesBinding 的代码,将参数名从 `series_allocation_id` 改为 `series_id`
|
||||
- [x] 3.2 移除 device-list/index.vue 中第 1191 行的临时注释
|
||||
- [x] 3.3 更新 `src/views/asset-management/iot-card-management/index.vue` 中调用 batchSetCardSeriesBinding 的代码,将参数名从 `series_allocation_id` 改为 `series_id`
|
||||
- [x] 3.4 移除 iot-card-management/index.vue 中第 1326 行的临时注释
|
||||
|
||||
## 4. 验证
|
||||
|
||||
- [x] 4.1 运行 TypeScript 类型检查确认无类型错误
|
||||
- [ ] 4.2 本地测试批量设置 IoT 卡系列绑定功能
|
||||
- [ ] 4.3 本地测试批量设置设备系列绑定功能
|
||||
- [ ] 4.4 确认所有相关功能正常工作
|
||||
Reference in New Issue
Block a user