|
|
|
# 1.Event API v2
|
|
|
|
## 1.1 Event API 概述
|
|
|
|
- Event API 主要提供各种类型的日程信息的管理,常见的有学校会议、个人日常等。
|
|
|
|
- Event API 有多种设置、更新、删除接口,具体的接口如下:
|
|
|
|
- 增加单个event
|
|
|
|
- 删除、查询、删除单个event
|
|
|
|
- 查询用户相关的event
|
|
|
|
- 新增event接口:[https://{site}/portal/api/v2/event/{bundle}](https://note.youdao.com/) POST
|
|
|
|
- 删除、更新、查询单个event接口:[https://{site}/portal/api/v2/event/{bundle}/{uuid}](https://note.youdao.com/) GET, PATCH, DELETE
|
|
|
|
- 查询用户相关的Event接口: [https://{site}/portal/api/v2/event?_format=hal_json](https://note.youdao.com/) GET
|
|
|
|
- 如需要额外接口满足项目需求,可以通过后台使用**Portal Views**配置
|
|
|
|
- 获取校历当前周 [https://{site}/portal/api/v2/event/schedule/currentweek](https://note.youdao.com/)
|
|
|
|
## 1.2.Event API 新增单个数据
|
|
|
|
```
|
|
|
|
POST /portal/api/v2/event/{bundle}? HTTP/1.1
|
|
|
|
Host: etl.dd:8083
|
|
|
|
Content-Type: application/vnd.api+json
|
|
|
|
Authorization: Bearer 5912c5c02e850202f04cb07684c95f11
|
|
|
|
Accept: application/vnd.api+json
|
|
|
|
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"type": "event--{bundle}",
|
|
|
|
"attributes": {
|
|
|
|
"title": "召开校职工大会",
|
|
|
|
"start_date":"2020-10-13T14:48:02+00:00",
|
|
|
|
"end_date":"2020-10-13T15:48:02+00:00",
|
|
|
|
"body":"<p>信息描述支持html</p>",
|
|
|
|
"location":"校大礼堂2楼",
|
|
|
|
"guests":"校行政人员和教职工",
|
|
|
|
"status":1,
|
|
|
|
"uuid":""
|
|
|
|
},
|
|
|
|
"relationships": {
|
|
|
|
"field_access_roles": {
|
|
|
|
"data": { "type": "user_role--user_role", "id": "b063ed18-e05f-4694-a2a3-0f2e1c584efd" }
|
|
|
|
},
|
|
|
|
"field_department": {
|
|
|
|
"data": { "type": "taxonomy_term--department", "id": "2d062779-4d71-47e1-8519-e8350659158c" }
|
|
|
|
},
|
|
|
|
"field_category": {
|
|
|
|
"data": { "type": "taxonomy_term--event_category", "id": "4354348c-9fb4-4226-9ea3-ab304dd89af8" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
## 1.2.1.Event API 新增单个数据的请求参数
|
|
|
|
具体的字段如下:
|
|
|
|
参数名 | 类型 | 是否必需 | 描述
|
|
|
|
---|---|--|----|---
|
|
|
|
type | string | 是 | {bundle} 值: 1、 personal_event (个人日程) 2、social_event (全校日程)
|
|
|
|
title | string | 是 | 信息标题
|
|
|
|
field_access_roles | string | 否 | 可以访问资源的用户角色的,后台可配置其他角色,默认key有:anonymous、authenticated
|
|
|
|
field_department | int | 否 | 根据用户所在的部门访问次资源。具体的key,根据后台配置得到。
|
|
|
|
field_category | int | 是 | 属于具体的类别,后台可配置
|
|
|
|
start_date | timestamp | 是 | 日程开始时间,
|
|
|
|
end_date | timestamp | 是 | 日程结束时间
|
|
|
|
location | string | 否 | 会议地点
|
|
|
|
status | int | 是 | 此资源是否发布,1)如果为0,则不发,2)如果为1,则发布。
|
|
|
|
guests | string | 否 | 邀请参加会议的人员
|
|
|
|
body | string | 否 | 会议简介
|
|
|
|
uuid | string | 否 | 防止重复提交可以使用uuid
|
|
|
|
## 1.3 更新单个数据
|
|
|
|
|
|
|
|
```
|
|
|
|
PATCH /portal/api/v2/event/{bundle}/{uuid}? HTTP/1.1
|
|
|
|
Host: etl.dd:8083
|
|
|
|
Content-Type: application/vnd.api+json
|
|
|
|
Authorization: Bearer 5912c5c02e850202f04cb07684c95f11
|
|
|
|
Accept: application/vnd.api+json
|
|
|
|
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"type": "event--{bundle}",
|
|
|
|
"id":"{{uuid}}",
|
|
|
|
"attributes": {
|
|
|
|
"title": "召开校职工大会 updated title"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## 1.3.1.Event API 更新单个数据的请求参数
|
|
|
|
具体的字段如下:
|
|
|
|
参数名 | 类型 | 是否必需 | 描述
|
|
|
|
---|---|--|----|---
|
|
|
|
type | string | 否 | {bundle} 值: 1、 personal_event (个人日程) 2、social_event (全校日程)
|
|
|
|
title | string | 否 | 信息标题
|
|
|
|
field_access_roles | string | 否 | 可以访问资源的用户角色的,后台可配置其他角色,默认key有:anonymous、authenticated
|
|
|
|
field_department | int | 否 | 根据用户所在的部门访问次资源。具体的key,根据后台配置得到。
|
|
|
|
field_category | int | 否 | 属于具体的类别,后台可配置
|
|
|
|
start_date | timestamp | 否 | 日程开始时间,
|
|
|
|
end_date | timestamp | 否 | 日程结束时间
|
|
|
|
location | string | 否 | 会议地点
|
|
|
|
status | int | 否 | 此资源是否发布,1)如果为0,则不发,2)如果为1,则发布。
|
|
|
|
guests | string | 否 | 邀请参加会议的人员
|
|
|
|
body | string | 否 | 会议简介
|
|
|
|
|
|
|
|
## 1.4. 删除单个数据
|
|
|
|
```
|
|
|
|
DELETE /portal/api/v2/event/{bundle}/{uuid} HTTP/1.1
|
|
|
|
Host: etl.dd:8083
|
|
|
|
Accept: application/vnd.api+json
|
|
|
|
Authorization: Bearer 49353835a83f30b26f81dc2351330a4b
|
|
|
|
|
|
|
|
```
|
|
|
|
## 1.5. 查询单个数据
|
|
|
|
```
|
|
|
|
GET /portal/api/v2/event/{bundle}/{uuid} HTTP/1.1
|
|
|
|
Host: etl.dd:8083
|
|
|
|
Authorization: Bearer 49353835a83f30b26f81dc2351330a4b
|
|
|
|
Accept: application/vnd.api+json
|
|
|
|
```
|
|
|
|
## 1.6.查询当前用户自己创建的所有数据
|
|
|
|
```
|
|
|
|
GET /portal/api/v2/event/me?_format=json HTTP/1.1
|
|
|
|
Host: portal.xx.edu.com.cn
|
|
|
|
Authorization: Bearer 39aec9c68b679d43de6803e0f14c223j
|
|
|
|
|
|
|
|
title={value}&start_date={value}&end_date={value}&field_tags={value}
|
|
|
|
```
|
|
|
|
## 1.7.基于当前用户角色和部门授权的数据查询
|
|
|
|
```
|
|
|
|
GET /portal/api/v2/event?_format=json HTTP/1.1
|
|
|
|
Host: portal.xx.edu.com.cn
|
|
|
|
Authorization: Bearer 39aec9c68b679d43de6803e0f14c223j
|
|
|
|
|
|
|
|
title={value}&field_category={value}&start_date={value}&end_date={value}
|
|
|
|
```
|
|
|
|
## 1.8.查询数据的请求参数说明
|
|
|
|
具体的字段如下:
|
|
|
|
参数名 | 类型 | 是否必需 | 描述
|
|
|
|
---|---|--|----|---
|
|
|
|
title | string | 否 | 根据关键字搜索相关性的数据
|
|
|
|
field_category | init | 否 | 分类id,根据后台配置确定
|
|
|
|
start_date | date | 否 | 开始时间,格式为CCYY-MM-DD HH:MM:SS
|
|
|
|
end_date | date | 否 | 结束时间,格式为CCYY-MM-DD HH:MM:SS
|
|
|
|
status | init | 否 | 是否发布, 值为1为置顶,值为0为不置顶,系统默认为1,前端无需传入
|
|
|
|
field_tags | init | 否 | tag id
|
|
|
|
field_access_roles | string | 否 | 授权可访问的角色,前端无需传入数值,后端根据当前用户角色自动匹配
|
|
|
|
field_department | int | 否 | 授权访问的部门,签到无需传入数值,后端根据当前用户所在部门自动匹配
|
|
|
|
|
|
|
|
## 1.9. 查询数据的响应信息
|
|
|
|
|
|
|
|
```
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": "2",
|
|
|
|
"uuid": "976dbf19-27e5-49e9-a9fc-4524a91b7d36",
|
|
|
|
"title": "全校教职工大会",
|
|
|
|
"start_date": "2020-07-21T09:11:08+0800",
|
|
|
|
"end_date": "2020-07-22T09:11:08+0800",
|
|
|
|
"location": "大礼堂2楼",
|
|
|
|
"guests": "全校教职工",
|
|
|
|
"body": "<p>总结大会</p>",
|
|
|
|
"created": "2020-07-21T09:29:12+0800",
|
|
|
|
"status": "1",
|
|
|
|
"field_category": "6",
|
|
|
|
"field_department": "3, 2",
|
|
|
|
"field_access_roles": "anonymous, authenticated"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": "1",
|
|
|
|
"uuid": "cd74bc23-ae23-49d9-8005-21db7235b3ee",
|
|
|
|
"title": "参加小组学习",
|
|
|
|
"start_date": "2020-07-21T09:11:08+0800",
|
|
|
|
"end_date": "2020-07-22T09:11:08+0800",
|
|
|
|
"location": "图书馆2楼",
|
|
|
|
"guests": "二班同学",
|
|
|
|
"body": "<p>重要的议题需要讨论</p>",
|
|
|
|
"created": "2020-07-21T09:28:14+0800",
|
|
|
|
"status": "1",
|
|
|
|
"field_tags": "14"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
## 1.9.1.响应信息字段说明
|
|
|
|
具体的字段如下:
|
|
|
|
参数名 | 类型 | 描述
|
|
|
|
---|---|--|---
|
|
|
|
id | int | 日程id
|
|
|
|
title | string | 根据关键字搜索相关性的数据
|
|
|
|
field_category | 否 | 分类id,根据后台配置确定
|
|
|
|
type | string | 日程类型
|
|
|
|
field_tag | string | 个人日程标签
|
|
|
|
start_date | date | 开始时间
|
|
|
|
end_date | date | 结束时间
|
|
|
|
guests | string | 邀请参会人员
|
|
|
|
location | string | 参会地址
|
|
|
|
body | string | 日程简介
|
|
|
|
created | date | 日程创建时间
|
|
|
|
status | int | 日程状态
|
|
|
|
field_access_roles | string | 授权可访问的角色,前端无需传入数值,后端根据当前用户角色自动匹配
|
|
|
|
field_department | int | 授权访问的部门,签到无需传入数值,后端根据当前用户所在部门自动匹配
|
|
|
|
|
|
|
|
## 1.10.校历
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /portal/api/v2/event/schedule/currentweek HTTP/1.1
|
|
|
|
Host: portal.xx.edu.com.cn
|
|
|
|
Authorization: Bearer 39aec9c68b679d43de6803e0f14c223j
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"semester": {
|
|
|
|
"first_semester": {
|
|
|
|
"start_date": "2020-08-04",
|
|
|
|
"end_date": "2020-08-20"
|
|
|
|
},
|
|
|
|
"second_semester": {
|
|
|
|
"start_date": "2020-08-12",
|
|
|
|
"end_date": "2020-08-13"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"current": {
|
|
|
|
"week": 1,
|
|
|
|
"term": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## 1.11.错误码
|
|
|
|
融合门户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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|