{
  "openapi": "3.0.3",
  "info": {
    "title": "会员管理",
    "version": "1.0.0",
    "description": "会员管理相关接口文档"
  },
  "paths": {
    "/api/members/valid-list": {
      "get": {
        "summary": "获取有效会员列表",
        "description": "获取所有状态为有效（status=1）的会员套餐列表，用于下拉选择。无需分页，返回简化的字段信息。",
        "responses": {
          "200": {
            "description": "成功响应",
            "content": {
              "application/json": {
                "example": {
                  "success": {
                    "code": "0000",
                    "message": "操作成功",
                    "data": [
                      {
                        "id": "xxx",
                        "_id": "xxx",
                        "code": "MEM0001",
                        "name": "会员套餐1",
                        "description": "套餐描述"
                      },
                      {
                        "id": "yyy",
                        "_id": "yyy",
                        "code": "MEM0002",
                        "name": "会员套餐2",
                        "description": "套餐描述"
                      }
                    ],
                    "timestamp": "2025-01-21T10:00:00.000Z"
                  },
                  "failure": {
                    "code": "4000",
                    "message": "获取失败",
                    "data": null
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/members": {
      "get": {
        "summary": "获取会员列表",
        "description": "分页获取会员套餐列表",
        "parameters": [
          {
            "name": "pageNum",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "页码，默认1"
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "每页数量，默认10"
          },
          {
            "name": "name",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "套餐名称关键词"
          },
          {
            "name": "memberTypeId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "会员类型ID（会员类型管理记录的_id）"
          }
        ],
        "responses": {
          "200": {
            "description": "成功响应",
            "content": {
              "application/json": {
                "example": {
                  "success": {
                    "code": "0000",
                    "message": "获取成功",
                    "data": {
                      "list": [
                        {
                          "id": 1,
                          "code": "MEM0001",
                          "name": "会员套餐名称",
                          "memberTypeId": "xxx",
                          "price": "99.99",
                          "validityDays": 30,
                          "description": "套餐描述",
                          "status": 1
                        }
                      ],
                      "total": 100,
                      "pageNum": 1,
                      "pageSize": 10
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "创建会员",
        "description": "创建新的会员套餐",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "string｜必填，套餐名称"
                  },
                  "memberTypeId": {
                    "type": "string",
                    "description": "string｜可选，会员类型ID（会员类型管理记录的_id），如果提供会校验会员类型是否存在"
                  },
                  "price": {
                    "type": "string",
                    "description": "string｜可选，价格（两位小数，如：99.99）"
                  },
                  "validityDays": {
                    "type": "number",
                    "description": "number｜可选，有效期天数（最小值为1）"
                  },
                  "description": {
                    "type": "string",
                    "description": "string｜可选，套餐描述"
                  },
                  "status": {
                    "type": "number",
                    "description": "number｜可选，状态：1-有效，0-无效，默认0"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功响应",
            "content": {
              "application/json": {
                "example": {
                  "success": {
                    "code": "0000",
                    "message": "创建会员成功",
                    "data": {
                      "id": 1,
                      "code": "MEM0001",
                      "name": "会员套餐名称",
                      "memberTypeId": "xxx",
                      "price": "99.99",
                      "validityDays": 30,
                      "description": "套餐描述",
                      "status": 0
                    }
                  },
                  "failure": {
                    "code": "4000",
                    "message": "关联的会员类型不存在",
                    "data": null
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/members/{id}": {
      "get": {
        "summary": "获取会员详情",
        "description": "根据会员套餐ID获取会员套餐详细信息",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "会员套餐ID"
          }
        ],
        "responses": {
          "200": {
            "description": "成功响应",
            "content": {
              "application/json": {
                "example": {
                  "success": {
                    "code": "0000",
                    "message": "获取成功",
                    "data": {
                      "id": 1,
                      "code": "MEM0001",
                      "name": "会员套餐名称",
                      "memberTypeId": "xxx",
                      "price": "99.99",
                      "validityDays": 30,
                      "description": "套餐描述",
                      "status": 1
                    }
                  },
                  "failure": {
                    "code": "4040",
                    "message": "会员套餐不存在",
                    "data": null
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "更新会员",
        "description": "更新指定会员套餐的信息",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "会员套餐ID"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "string｜必填，套餐名称"
                  },
                  "memberTypeId": {
                    "type": "string",
                    "description": "string｜可选，会员类型ID（会员类型管理记录的_id），如果提供会校验会员类型是否存在"
                  },
                  "price": {
                    "type": "string",
                    "description": "string｜可选，价格（两位小数，如：99.99）"
                  },
                  "validityDays": {
                    "type": "number",
                    "description": "number｜可选，有效期天数（最小值为1）"
                  },
                  "description": {
                    "type": "string",
                    "description": "string｜可选，套餐描述"
                  },
                  "status": {
                    "type": "number",
                    "description": "number｜可选，状态：1-有效，0-无效，默认0"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功响应",
            "content": {
              "application/json": {
                "example": {
                  "success": {
                    "code": "0000",
                    "message": "更新会员成功",
                    "data": {
                      "id": 1,
                      "code": "MEM0001",
                      "name": "会员套餐名称",
                      "memberTypeId": "xxx",
                      "price": "99.99",
                      "validityDays": 30,
                      "description": "套餐描述",
                      "status": 1
                    }
                  },
                  "failure": {
                    "code": "4000",
                    "message": "关联的会员类型不存在",
                    "data": null
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "删除会员",
        "description": "删除指定的会员套餐",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "会员套餐ID"
          }
        ],
        "responses": {
          "200": {
            "description": "成功响应",
            "content": {
              "application/json": {
                "example": {
                  "success": {
                    "code": "0000",
                    "message": "删除会员成功",
                    "data": {
                      "result": true
                    }
                  },
                  "failure": {
                    "code": "4000",
                    "message": "删除会员失败",
                    "data": null
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/members/{id}/status": {
      "put": {
        "summary": "切换会员套餐状态",
        "description": "切换会员套餐的启用/禁用状态",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "会员套餐ID"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "number",
                    "description": "number｜必填，状态：1-有效，0-无效"
                  }
                },
                "required": [
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功响应",
            "content": {
              "application/json": {
                "example": {
                  "success": {
                    "code": "0000",
                    "message": "状态更新成功",
                    "data": {
                      "id": 1,
                      "code": "MEM0001",
                      "name": "会员套餐名称",
                      "memberTypeId": "xxx",
                      "price": "99.99",
                      "validityDays": 30,
                      "description": "套餐描述",
                      "status": 1,
                      "updateTime": "2025-01-01T10:00:00.000Z"
                    }
                  },
                  "failure": {
                    "code": "4040",
                    "message": "会员套餐不存在",
                    "data": null
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}