Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
P portal
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Create a new issue
  • Jobs
  • Issue Boards
Collapse sidebar
  • 科探开源
  • portal
  • Wiki
    • 门户v2 api 文档
  • 092.Flag API v2

Last edited by asdu Dec 21, 2020
Page history

092.Flag API v2

1.1 Flag API 概述

  • Flag API 实现类似用户收藏、点赞的功能接口。
  • Flag API 有多种设置、更新、删除接口,具体的接口如下:
    • 增加单个flag
    • 删除、查询、删除单个flag
    • 查询用户相关的flag
  • 新增flag接口:https://{site}/portal/api/v2/portal_flag/{bundle} POST
  • 删除、更新、查询单个flag接口:https://{site}/portal/api/v2/portal_flag/{bundle}/{uuid} GET, PATCH, DELETE
  • 查询用户相关的flag接口: https://{site}/portal/api/v2/portal_flag/me?_format=json GET
  • 如需要额外接口满足项目需求,可以通过后台使用Portal Views配置

1.2.Flag API 新增单个数据

POST /portal/api/v2/portal_flag/{bundle} HTTP/1.1
Host: etl.dd:8083
Content-Type: application/vnd.api+json
Authorization: Bearer 50c8f237ecc91ac3f151e9d3cc615726
Accept: application/vnd.api+json

{
  "data": {
    "type": "portal_flag--{bundle}",
    "attributes": {
      "title": "注销申报程序",
      "entity_id": "88981",
      "bundle":"news",
      "entity_type":"resource",
      "flag_type":"favorite"
      "data":"{}",
      "status":1
    }
  }
}

1.2.1.Flag API 新增单个数据的请求参数

具体的字段如下: 参数名 类型 必需 描述
_links string 是 参数bundle为具体内容类型的key。系统已有bundle的key为portal_flag
type string 是 默认值为 portal_flag
title string 是 目标的title
entity_type string 否 默认类型有resource、app、event
entity_id string 是 具体的收藏或者点赞的目标id
bundle string 是 more系统值有app、news、file等。根据entity type定义而来。
flag_type string 是 默认有两种类型: 收藏:favorite,点赞:like,需要额外类型可以使用yml定义
data json 否 额外可以保存的数据,可以是一组序列化的数据。比如icon、path等额外信息
status int 是 1)如果为0,则不发,2)如果为1,则发布。

1.3 更新单个数据

PATCH /portal/api/v2/portal_flag/{bundle}/{uuid} HTTP/1.1
Host: etl.dd:8083
Content-Type: application/vnd.api+json
Authorization: Bearer 50c8f237ecc91ac3f151e9d3cc615726
Accept: application/vnd.api+json

{
  "data": {
    "type": "portal_flag--{bundle}",
    "id":"{uuid}",
    "attributes": {
      "title": "注销申报程序",
      "entity_id": "88981",
      "bundle":"news",
      "entity_type":"resource",
      "flag_type":"favorite"
      "data":"{}",
      "status":1
    }
  }
}

1.3.1.Flag API 更新单个数据的请求参数

具体的字段如下: 参数名 类型 必需 描述
type string 否 默认值为 portal_flag
title string 否 目标的title
entity_type string 否 默认类型有resource、app、event
entity_id string 否 具体的收藏或者点赞的目标id
bundle string 否 more系统值有app、news、file等。根据entity type定义而来。
flag_type string 否 默认有两种类型: 收藏:favorite,点赞:like,需要额外类型可以使用yml定义
data json 否 额外可以保存的数据,可以是一组序列化的数据。比如icon、path等额外信息
status int 否 1)如果为0,则不发,2)如果为1,则发布。

1.4. 删除单个数据

DELETE /portal/api/v2/portal_flag/{bundle}/{8beb578b-7557-4656-90e8-0f12395e35a2} HTTP/1.1
Host: etl.dd:8083
Accept: application/vnd.api+json
Authorization: Bearer 49353835a83f30b26f81dc2351330a4b

1.5. 查询单个数据

GET /portal/api/v2/portal_flag/{bundle}/{d1f94da3-990d-4d70-9441-a30bbed4d91e} HTTP/1.1
Host: etl.dd:8083
Authorization: Bearer 49353835a83f30b26f81dc2351330a4b
Accept: application/vnd.api+json

1.6.查询当前用户自己创建的所有数据

GET /portal/api/v2/portal_flag/me?_format=hal_json HTTP/1.1
Host: portal.xx.edu.com.cn
Authorization: Bearer 39aec9c68b679d43de6803e0f14c223j

entity_type={value}&bundle={value}&flag_type={value}&page={}&items_per_page={}

1.7.查询系统默认flag

GET /portal/api/v2/portal_flag/default?_format=hal_json HTTP/1.1
Host: portal.xx.edu.com.cn
Authorization: Bearer 39aec9c68b679d43de6803e0f14c223j

entity_type={value}&bundle={value}&flag_type={value}&page={}&items_per_page={}

1.8.查询数据的请求参数说明

具体的字段如下: 参数名 类型 必需 描述
entity_type string 否 默认类型有resource、app、event
entity_id string 否 具体的收藏或者点赞的目标id
bundle string 否 more系统值有app、news、file等。根据entity type定义而来。
flag_type string 否 默认有两种类型: 收藏:favorite,点赞:like,需要额外类型可以使用yml定义
default_flag boolean 否 前端无需传入,后端默认true

1.9. 查询数据的响应信息

[
  {
    "uuid": "bfa63600-f1cf-471f-8657-67f63678f171",
    "id": "1",
    "title": "12fsfaf",
    "entity_id": "123132",
    "entity_type": "app",
    "bundle": "social_event",
    "flag_type": "favorite",
    "data": "a:13:{s:4:\"uuid\";s:36:\"44d307c5-16f0-4211-b0b8-5bbc5bf9beca\";s:8:\"langcode\";s:7:\"zh-hans\";s:6:\"status\";b:1;s:12:\"dependencies\";a:2:{s:6:\"module\";a:1:{i:0;s:6:\"system\";}s:5:\"theme\";a:1:{i:0;s:5:\"seven\";}}s:5:\"_core\";a:1:{s:19:\"default_config_hash\";s:43:\"YRY68JWkaUiGeZlWMv1nzeIgDm0ZZwXYgpqUpLFzwAY\";}s:2:\"id\";s:13:\"seven_content\";s:5:\"theme\";s:5:\"seven\";s:6:\"region\";s:7:\"content\";s:6:\"weight\";i:0;s:8:\"provider\";N;s:6:\"plugin\";s:17:\"system_main_block\";s:8:\"settings\";a:4:{s:2:\"id\";s:17:\"system_main_block\";s:5:\"label\";s:12:\"主页内容\";s:8:\"provider\";s:6:\"system\";s:13:\"label_display\";s:1:\"0\";}s:10:\"visibility\";a:0:{}}",
    "status": "1",
    "uid": "1",
    "created": "2020-07-20T12:40:23+0800",
    "default_flag": "1",
  }
]

1.9.1.响应信息字段说明

具体的字段如下: 参数名 类型 描述
id int 编号
uuid string 唯一标识符
title string 标题
entity_type string 实体类型
bundle string bundle
flag_type string flag类型
status int 是否发布
data string 额外保存的数据
created date 系统默认创建时间
default_flag boolean 系统默认flag数据的标识符

1.10.错误码

融合门户REST API接口较多,开发者使用过程中不可避难会遇到各种问题,这里提供了常见的错误码释义。

错误码 含义
200 OK
201 Created
202 Accepted
204 No Content
301 Moved Permanently
302 Found
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
415 Unsupported Media Type
500 Internal Server Error
501 Not Implemented
Clone repository
  • Home
  • 数据管理手册
    • 094.Views twig 配置
    • ETL01.数据管理使用手册 V2.0
    • ETL02.Source 数据请求 data_fetcher_plugin
    • ETL03.Source 解析 data_parser_plugin
    • ETL04.Source 认证插件 authentication
    • ETL05.Porcess plugins 明细
    • ETL06.URL endpoint 数据管理E
    • ETL07.Mysql 数据管理
    • ETL08.MSSQL 数据管理
    • ETL09.Oracle 数据管理
    • ETL10.Token 列表
  • 门户V2 API 文档
    • 01.Portal Rest API v2
    • 01.Resource API
    • 02.App API
View All Pages