geo/docs/04-API文档/brands.md

2.2 KiB

品牌API

品牌API位于 backend/app/api/brands.py

端点列表

方法 路径 说明
GET /api/v1/brands 获取品牌列表
POST /api/v1/brands 创建品牌
GET /api/v1/brands/{id} 获取品牌详情
PUT /api/v1/brands/{id} 更新品牌
DELETE /api/v1/brands/{id} 删除品牌
GET /api/v1/brands/{id}/competitors 获取竞品列表
POST /api/v1/brands/{id}/competitors 添加竞品

获取品牌列表

GET /api/v1/brands

查询参数

参数 类型 说明
page int 页码
page_size int 每页数量
search string 搜索关键词

响应

{
  "success": true,
  "data": {
    "items": [
      {
        "id": "uuid",
        "name": "品牌名称",
        "domain": "example.com",
        "industry": "科技",
        "created_at": "2024-01-01T00:00:00Z"
      }
    ],
    "total": 100,
    "page": 1,
    "page_size": 20
  }
}

创建品牌

POST /api/v1/brands

请求体

{
  "name": "品牌名称",
  "domain": "example.com",
  "industry": "科技",
  "description": "品牌描述",
  "aliases": ["别名1", "别名2"]
}

响应

{
  "success": true,
  "data": {
    "id": "uuid",
    "name": "品牌名称",
    "domain": "example.com",
    "industry": "科技",
    "created_at": "2024-01-01T00:00:00Z"
  }
}

获取品牌详情

GET /api/v1/brands/{id}

响应

{
  "success": true,
  "data": {
    "id": "uuid",
    "name": "品牌名称",
    "domain": "example.com",
    "industry": "科技",
    "description": "品牌描述",
    "aliases": ["别名1", "别名2"],
    "competitors": [],
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
  }
}

更新品牌

PUT /api/v1/brands/{id}

请求体

{
  "name": "新品牌名称",
  "domain": "newexample.com",
  "industry": "金融",
  "description": "更新后的描述",
  "aliases": ["新别名"]
}

删除品牌

DELETE /api/v1/brands/{id}

响应

{
  "success": true,
  "message": "品牌已删除"
}