Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TicketField): REST API #253

Merged
merged 6 commits into from
Apr 26, 2021
Merged

feat(TicketField): REST API #253

merged 6 commits into from
Apr 26, 2021

Conversation

sdjdd
Copy link
Contributor

@sdjdd sdjdd commented Apr 22, 2021

工单字段的 API
see: #243

API 文档

POST /api/1/ticket-fields 添加字段

Request:

{
  // 不展示给用户, 只是方便管理
  "title": "道具名称 for PCR",
  "type": "dropdown",
  "required": true,
  // 必须在 variants 中提供
  "defaultLocale": "zh-cn",
  "variants": [
    {
      "title": "道具名称",
      "locale": "zh-cn",
      // type 为 "dropdown" 和 "multi-select" 时必须提供
      "options": [
        {
          "title": "铁剑",
          "value": "sword01"
        }
      ]
    }
  ]
}

Response:

{
  "id": "6081496a00fb9b138f7f1b8c"
}

GET /api/1/ticket-fields 获取字段列表

Note:

  • 分页: ?page[size]=20&page[skip]=40
  • 筛选 active: ?active=true | ?active=false

Response:

{
  "fields": [
    {
      "id": "6081496a00fb9b138f7f1b8c",
      "title": "装备名称 for PCR",
      "type": "dropdown",
      "defaultLocale": "zh-cn",
      "active": true,
      "required": true
    }
  ]
}

GET /api/1/ticket-fields/{id} 获取字段详细信息

Response:

{
  "title": "装备名称 for PCR",
  "type": "dropdown",
  "active": true,
  "required": true,
  "defaultLocale": "zh-cn",
  "variants": [
    {
      "title": "道具名称",
      "locale": "zh-cn",
      "options": [
         {
          "title": "铁剑",
          "value": "sword01"
        }
      ]
    }
  ]
}

PATCH /api/1/ticket-fields/{id} 更新字段

Request:

{
  "title": "装备名称 (PCR)",
  "active": false,
  "required": false,
  "defaultLocale": "ja"
}

Response:

{}

POST /api/1/ticket-fields/{id}/variants 添加字段变体

Request:

{
  "title": "裝備名稱",
  "locale": "zh-tw",
  "options": [
    {
      "title": "鐵劍",
      "value": "sword01"
    }
  ]
}

Response:

{}

PATCH /api/1/ticket-fields/{id}/variants/{locale} 更新字段变体

Request:

{
  "title": "New title",
  "options": [
     {
        "title": "木剑",
        "value": "sword02"
      }
  ]
}

Response:

{}

DELETE /api/1/ticket-fields/{id}/variants/{locale} 删除字段变体

Note: 默认 locale 的变体不能被删除

Response:

{}

@sdjdd sdjdd requested review from leeyeh and lywTYH April 22, 2021 11:01
@sdjdd
Copy link
Contributor Author

sdjdd commented Apr 23, 2021

API 文档已更新。

@sdjdd
Copy link
Contributor Author

sdjdd commented Apr 25, 2021

又调整了下:

  • TicketField.name -> TicketField.title
  • 按 yw 的要求把 options 从 string[] 改成了 { title: string; value: string }[]

一个问题:
TicketFieldVariant 的 API 用 objectId 还是 locale ?那种比较好:
/api/1/ticket-fields/{id}/variants/{locale}/api/1/ticket-fields/{field_id}/variants/{variant_id}

@sdjdd
Copy link
Contributor Author

sdjdd commented Apr 25, 2021

争取今天合了吧,已经 block yw 一周拉 👀

@sdjdd
Copy link
Contributor Author

sdjdd commented Apr 25, 2021

👀

@sdjdd
Copy link
Contributor Author

sdjdd commented Apr 26, 2021

👀

@sdjdd
Copy link
Contributor Author

sdjdd commented Apr 26, 2021

cc @lywTYH

@sdjdd sdjdd merged commit 5bab23c into leancloud:master Apr 26, 2021
@sdjdd sdjdd deleted the feat/form-api branch April 26, 2021 07:11
@lywTYH
Copy link
Contributor

lywTYH commented Apr 28, 2021

移除

DELETE /api/1/ticket-fields/{id}/variants/{locale} 删除字段变体
PATCH /api/1/ticket-fields/{id}/variants/{locale} 更新字段变体
POST /api/1/ticket-fields/{id}/variants 添加字段变体

PATCH /api/1/ticket-fields/{id} 更新字段 (调整)

Request:

{
  "title": "装备名称 (PCR)",
  "active": false,
  "required": false,
  "defaultLocale": "ja",
  "varitans":[
    {
      "title": "道具名称",
      "locale": "zh-cn",
      // type 为 "dropdown" 和 "multi-select" 时必须提供
      "options": [
        {
          "title": "铁剑",
          "value": "sword01"
        }
      ]
    }
  ]
}

@sdjdd
Copy link
Contributor Author

sdjdd commented Apr 28, 2021

别移除了,直接添加批量更新的接口吧,逐个 CRUD 的接口也是有用处的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants