# 无状态会员管理

> 模块标识：statelessMember  |  接口数量：6

## 1. 获取无状态会员列表
**方法**：	GET

**路径**：				/api/stateless-members

**功能说明**：
分页获取无状态会员列表

### 请求参数
```json
{
  "query": [
    {
      "name": "pageNum",
      "type": "number",
      "required": false,
      "description": "页码，默认1"
    },
    {
      "name": "pageSize",
      "type": "number",
      "required": false,
      "description": "每页数量，默认10"
    },
    {
      "name": "name",
      "type": "string",
      "required": false,
      "description": "会员名称关键词"
    },
    {
      "name": "code",
      "type": "string",
      "required": false,
      "description": "会员编码"
    },
    {
      "name": "memberTypeId",
      "type": "string",
      "required": false,
      "description": "按会员类型ID筛选（会员类型管理记录的_id）"
    },
    {
      "name": "status",
      "type": "number",
      "required": false,
      "description": "状态过滤"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "获取成功",
    "data": {
      "list": [
        {
          "id": 1,
          "code": "SM0001",
          "name": "开放平台会员",
          "secretKey": "sk-xxx",
          "memberTypeId": "xxx",
          "status": 1
        }
      ],
      "total": 100,
      "pageNum": 1,
      "pageSize": 10
    }
  }
}
```


## 2. 获取无状态会员详情
**方法**：	GET

**路径**：				/api/stateless-members/{id}

**功能说明**：
根据无状态会员ID获取详细信息

### 请求参数
```json
{
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "无状态会员ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "获取成功",
    "data": {
      "id": 1,
      "code": "SM0001",
      "name": "开放平台会员",
      "secretKey": "sk-xxx",
      "memberTypeId": "xxx",
      "status": 1
    }
  },
  "failure": {
    "code": "4040",
    "message": "无状态会员不存在",
    "data": null
  }
}
```


## 3. 创建无状态会员
**方法**：	POST

**路径**：				/api/stateless-members

**功能说明**：
创建新的无状态会员

### 请求参数
```json
{
  "body": {
    "name": "string｜必填，会员名称",
    "memberTypeId": "string｜可选，会员类型ID（会员类型管理记录的_id），如果提供会校验会员类型是否存在",
    "effectiveDate": "string｜必填，生效日期",
    "validityDays": "number｜必填，有效期天数（最小7天）",
    "firstEffectiveDate": "string｜可选，首次生效日期",
    "status": "number｜可选，状态：1-有效，0-无效，默认0"
  }
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "创建无状态会员成功",
    "data": {
      "id": 1,
      "code": "SM0001",
      "name": "开放平台会员",
      "secretKey": "sk-xxx",
      "memberTypeId": "xxx",
      "status": 1
    }
  },
  "failure": {
    "code": "4000",
    "message": "关联的会员类型不存在",
    "data": null
  }
}
```

### 注意事项
- secretKey会自动生成，无需手动提供
- 如果提供了memberTypeId，会校验会员类型是否存在，不存在返回错误：关联的会员类型不存在


## 4. 更新无状态会员
**方法**：	PUT

**路径**：				/api/stateless-members/{id}

**功能说明**：
更新指定无状态会员的信息

### 请求参数
```json
{
  "body": {
    "name": "string｜可选，会员名称",
    "memberTypeId": "string｜可选，会员类型ID（会员类型管理记录的_id），如果提供会校验会员类型是否存在",
    "effectiveDate": "string｜可选，生效日期",
    "validityDays": "number｜可选，有效期天数（最小7天）",
    "firstEffectiveDate": "string｜可选，首次生效日期",
    "status": "number｜可选，状态：1-有效，0-无效"
  },
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "无状态会员ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "更新无状态会员成功",
    "data": {
      "id": 1,
      "code": "SM0001",
      "name": "开放平台会员",
      "secretKey": "sk-xxx",
      "memberTypeId": "xxx",
      "status": 1
    }
  },
  "failure": {
    "code": "4000",
    "message": "关联的会员类型不存在",
    "data": null
  }
}
```

### 注意事项
- 如果提供了memberTypeId，会校验会员类型是否存在，不存在返回错误：关联的会员类型不存在
- 有效状态（status=1）的无状态会员不允许修改，会返回错误：有效状态的无状态会员不允许修改


## 5. 删除无状态会员
**方法**：	DELETE

**路径**：				/api/stateless-members/{id}

**功能说明**：
删除指定的无状态会员

### 请求参数
```json
{
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "无状态会员ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "删除无状态会员成功",
    "data": {
      "result": true
    }
  },
  "failure": {
    "code": "4000",
    "message": "删除无状态会员失败",
    "data": null
  }
}
```

### 注意事项
- 有效状态（status=1）的无状态会员不允许删除，会返回错误：有效状态的无状态会员不允许删除


## 6. 切换无状态会员状态
**方法**：	PUT

**路径**：				/api/stateless-members/{id}/status

**功能说明**：
切换无状态会员的启用/禁用状态

### 请求参数
```json
{
  "body": {
    "status": "number｜必填，状态：1-有效，0-无效"
  },
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "无状态会员ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "状态更新成功",
    "data": {
      "id": 1,
      "code": "SM0001",
      "name": "开放平台会员",
      "secretKey": "sk-xxx",
      "memberTypeId": "xxx",
      "effectiveDate": "2025-01-01",
      "validityDays": 365,
      "firstEffectiveDate": "2025-01-01",
      "status": 1,
      "updateTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4040",
    "message": "无状态会员不存在",
    "data": null
  }
}
```

### 注意事项
- 该接口用于切换无状态会员的启用/禁用状态
- 只有通过状态切换接口才能修改有效状态的无状态会员

