内容分类操作

获取内容分类详情

接口

GET https://cloud.minapp.com/userve/v1/content/:content_group_id/category/:category_id/

其中 content_group_id 是内容库的 ID, category_id 是内容分类的 ID

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.get('https://cloud.minapp.com/userve/v1/content/1/category/1/').then(res => {
  5. console.log(res.data)
  6. })

返回示例

  1. {
  2. "id": 1,
  3. "name": "category",
  4. "parent": null,
  5. "subcategories": [
  6. {
  7. "id": 2,
  8. "name": "subcategory",
  9. "parent": {
  10. "id": 1,
  11. "name": "category"
  12. },
  13. "subcategories": [],
  14. "created_at": 1519901783,
  15. "updated_at": 1519901783
  16. }
  17. ],
  18. "created_at": 1516963449,
  19. "updated_at": 1516963449
  20. }

返回参数说明

参数 类型 说明
id Integer 分类 ID
name String 分类名称
parent Object 分类的父类
subcategories Object Array 子类名称
created_at Integer 分类创建时间
updated_at Integer 分类更新时间

获取内容分类列表

接口

GET https://cloud.minapp.com/userve/v1/content/:content_group_id/category/

提交参数

  • parent 内容分类父分类列表查询

    https://cloud.minapp.com/userve/v1/content/:content_group_id/category/?parent__isnull=true

  • name 内容分类名称的等值查询

    https://cloud.minapp.com/userve/v1/content/:content_group_id/category/?name=category

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.get('https://cloud.minapp.com/userve/v1/content/1/category/').then(res => {
  5. console.log(res.data)
  6. })

返回示例

  1. {
  2. "meta": {
  3. "limit": 20,
  4. "next": null,
  5. "offset": 0,
  6. "previous": null,
  7. "total_count": 2
  8. },
  9. "objects": [
  10. {
  11. "id": 1,
  12. "name": "category",
  13. "parent": null,
  14. "subcategories": [
  15. {
  16. "id": 2,
  17. "name": "subcategory",
  18. "parent": {
  19. "id": 1,
  20. "name": "category"
  21. },
  22. "subcategories": [],
  23. "created_at": 1519901783,
  24. "updated_at": 1519901783
  25. }
  26. ],
  27. "created_at": 1516963449,
  28. "updated_at": 1516963449
  29. },
  30. {
  31. "id": 2,
  32. "name": "subcategory",
  33. "parent": {
  34. "id": 1516963449144537,
  35. "name": "category"
  36. },
  37. "subcategories": [],
  38. "created_at": 1519901783,
  39. "updated_at": 1519901783
  40. }
  41. ]
  42. }

创建内容分类

接口

POST https://cloud.minapp.com/userve/v1/content/:content_group_id/category/

参数说明

Content-Type: application/json

参数 类型 必填 说明
name String Y 分类名称
parent Integer N 父分类 ID

warning
注意:最多只允许三层嵌套分类

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.post('https://cloud.minapp.com/userve/v1/content/1/category/', {"name": "分类1",}).then(res => {
  5. console.log(res.data)
  6. })

返回示例

  1. {
  2. "id": 3,
  3. "name": "分类1",
  4. "parent": null,
  5. "subcategories": [],
  6. "created_at": 1519910966,
  7. "updated_at": 1519910966
  8. }

状态码说明

201: 创建成功

400: 同一父分类下的子分类名不能相同;父分类 ID 不合法

编辑内容分类

接口

PUT https://cloud.minapp.com/userve/v1/content/:content_group_id/category/:category_id/

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.put('https://cloud.minapp.com/userve/v1/content/1/category/3/', {"name": "分类1",}).then(res => {
  5. console.log(res.data)
  6. })

返回示例

  1. {
  2. "id": 3,
  3. "name": "Test Category",
  4. "parent": null,
  5. "subcategories": [],
  6. "created_at": 1519910966,
  7. "updated_at": 1519910966
  8. }

状态码说明

200: 修改成功

400: 同一父分类下的子分类名不能相同;父分类 ID 不合法

删除内容分类

接口

DELETE https://cloud.minapp.com/userve/v1/content/:content_group_id/category/:category_id/

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.delete('https://cloud.minapp.com/userve/v1/content/1/category/1/').then(res => {
  5. console.log(res.data)
  6. })

状态码说明

204: 删除成功