# 会员类型管理

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

## 1. 获取有效会员类型列表
**方法**：	GET

**路径**：				/api/members/types/valid-list

**功能说明**：
获取所有状态为有效（status=1）的会员类型列表，用于下拉选择。无需分页，返回简化的字段信息。

### 请求参数
```json
{}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "操作成功",
    "data": [
      {
        "id": "xxx",
        "_id": "xxx",
        "code": "VIP",
        "name": "VIP会员",
        "description": "VIP会员类型"
      },
      {
        "id": "yyy",
        "_id": "yyy",
        "code": "GOLD",
        "name": "黄金会员",
        "description": "黄金会员类型"
      }
    ],
    "timestamp": "2025-01-21T10:00:00.000Z"
  },
  "failure": {
    "code": "4000",
    "message": "获取失败",
    "data": null
  }
}
```

### 注意事项
- 该接口仅返回状态为有效（status=1）的会员类型
- 返回结果按创建时间升序排序
- 需要 memberTypes 的 read 权限
- 适用于下拉选择等场景，无需分页


## 2. 获取会员类型列表
**方法**：	GET

**路径**：				/api/members/types

**功能说明**：
分页获取会员类型列表，支持按名称、编码、状态筛选

### 请求参数
```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": "status",
      "type": "number",
      "required": false,
      "description": "状态过滤：1-有效，0-无效"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "获取成功",
    "data": {
      "list": [
        {
          "id": 1,
          "code": "VIP",
          "name": "VIP会员",
          "description": "VIP会员类型",
          "status": 1,
          "createTime": "2025-01-01T10:00:00.000Z",
          "updateTime": "2025-01-01T10:00:00.000Z"
        }
      ],
      "total": 100,
      "pageNum": 1,
      "pageSize": 10,
      "totalPages": 10
    }
  }
}
```


## 3. 创建会员类型
**方法**：	POST

**路径**：				/api/members/types

**功能说明**：
创建新的会员类型

### 请求参数
```json
{
  "body": {
    "name": "string｜必填，会员类型名称",
    "code": "string｜必填，会员类型编码",
    "status": "number｜可选，状态：1-有效，0-无效，默认1",
    "description": "string｜可选，描述信息"
  }
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "创建成功",
    "data": {
      "id": 1,
      "code": "VIP",
      "name": "VIP会员",
      "description": "VIP会员类型",
      "status": 1,
      "createTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4000",
    "message": "会员类型编码已存在",
    "data": null
  }
}
```


## 4. 更新会员类型
**方法**：	PUT

**路径**：				/api/members/types/{typeId}

**功能说明**：
更新指定会员类型的信息

### 请求参数
```json
{
  "body": {
    "name": "string｜可选，会员类型名称",
    "code": "string｜可选，会员类型编码",
    "status": "number｜可选，状态：1-有效，0-无效",
    "description": "string｜可选，描述信息"
  },
  "path": [
    {
      "name": "typeId",
      "type": "string",
      "required": true,
      "description": "会员类型ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "更新成功",
    "data": {
      "id": 1,
      "code": "VIP",
      "name": "VIP会员",
      "description": "VIP会员类型",
      "status": 1,
      "updateTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4000",
    "message": "会员类型编码已存在",
    "data": null
  }
}
```


## 5. 删除会员类型
**方法**：	DELETE

**路径**：				/api/members/types/{typeId}

**功能说明**：
删除指定的会员类型

### 请求参数
```json
{
  "path": [
    {
      "name": "typeId",
      "type": "string",
      "required": true,
      "description": "会员类型ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "删除成功",
    "data": null
  },
  "failure": {
    "code": "4000",
    "message": "会员类型仍与会员功能关联，请先解除关联",
    "data": null
  }
}
```


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

**路径**：				/api/members/types/{typeId}/status

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

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

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "状态更新成功",
    "data": {
      "id": 1,
      "code": "VIP",
      "name": "VIP会员",
      "status": 1,
      "updateTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4040",
    "message": "会员类型不存在",
    "data": null
  }
}
```

