Appearance
创建日程
基本信息
中文名: 创建日程
接口名: /calendar/createCalendar
所在目录: 日程
调用方式: POST(HTTPS)
发布版本 :V1.8.2
最低可用版本 | V1.8.2 |
---|
请求参数
公共请求参数
名称 | 类型 | 是否必填 | 示例值 | 描述 |
---|---|---|---|---|
tenantId | Long | 是 | 租户ID | |
accountId | Long | 是 | 账号ID,需要创建者账号id一致或者是创建者的代理人 |
业务请求参数
名称 | 子参数 | 说明 | 类型 | 是否必填 |
---|---|---|---|---|
attendees | 参与人 | List | 是 | |
accountId | 账号id | long | 是 | |
organizationId | 组织id | long | 废弃,无需再传 | |
attendeeType | 参与角色 | String | 废弃,无需再传 | |
creator | 日历创建者 | AccountDTO | 是 | |
accountId | 创建者id | long | 是 | |
end | 结束时间<br/>重要 ** ** <br/>结束时间需要大于开始时间 | DateTimeDTO | 是 | |
dateTime | 结束日期 | String | 废弃,无需再传 | |
timeStamp | 结束时间戳 | long | 是 | |
timeZone | 时区 | String | 废弃,无需再传 | |
start | 开始时间 | DateTimeDTO | 是 | |
dateTime | 开始日期 | String | 废弃,无需再传 | |
timeStamp | 开始时间戳 | String | 否 | |
timeZone | 时区 | String | 废弃,无需再传 | |
event | 事件详情 | EvnetDTO | 是 | |
location | 地点 | String | 否 | |
subject | 主题 | String | 否 | |
description | 描述 | String | 否 | |
leaders | 参会领导,多人用逗号隔开,业务方扩展。 | String | 否 | |
noonStatus | 参会时间段, 业务方扩展 “morning”,“noon”,“afternoon” | String | 否 | |
seq | 日程顺序,业务方扩展字段 | String | 否 | |
mergeGroupId | 日程分组,业务方扩展字段 | String | 否 | |
eventType | 日历事件类型,参考最下面补充说明 | String | 是 | |
bizId | 三方应用日历唯一标示 | String(长度不小于32字符) | 否 | |
enclosures | 附件 | List | 否 | |
fileId | 文件id,媒体文件上传后返回的media_id | String | 是 | |
fileName | 文件名 | String | 是 | |
fileSize | 文件大小 | String | 是 | |
fileType | 文件类型 | String | 是 | |
encryptionType | 加密类型(默认app加密:appEncryption) | String | 否 | |
reminder | 日程提醒 | ReminderDTO | 否 | |
reminderRule | 1. routine: 默认提醒规则,提前15min 应用内提醒。如需提前其他时间或其他方式提醒,请选择userDefined<br/>2. userDefined:自定义提醒, 提醒规则为自定义(userDefined)时,reminderList字段不可以为空<br/>3. noReminder:无提醒 | String | 否 | |
reminderType | 提醒方式,默认:app,应用内提醒,参考最下面补充说明 | String | 否 | |
reminderList | 提醒时间列表,提醒规则为自定义(userDefined)时,该字段不可以为空。<br/>+ reminderList提醒时间列表值<br/>+ createTime:创建时<br/>+ startTime: 开始时<br/>+ fiveMinutes:5分钟前<br/>+ fifteenMinutes: 15分钟前<br/>+ halfHour:30分钟前<br/>+ anHour: 1小时前<br/>+ oneDay:1天前 | List | 否 | |
calendarType | calendarTypeCode | 分类参数,默认可选:conference/onDuty/work/others | String | 废弃,无需再传 |
返回参数
名称 | 子参数 | 子参数 | 描述 | 类型 |
---|---|---|---|---|
success | 请求响应状态 | boolean | ||
content | 请求响应内容 | Objec | ||
data | 业务响应内容 | Object | ||
calendarId | 日历唯一标示 | Long | ||
success | 业务响应状态 | boolean | ||
responseMessage | 业务响应描述 | String | ||
responseCode | 业务响应标示 | String |
出入参示例
创建日程请求参数:accountId=179937&creator={“accountId”:179937}&reminder={“reminderRule”:“userDefined”,“reminderType”:“app”,“reminderList”:[“createTime”]}&attendees=[{“accountId”:179937}]&bizId=id_1716794971018&tenantId=1&start={“timeStamp”:1716797410000}&end={“timeStamp”:1716798610000}&eventType=conference&event={“subject”:“写业务线周日志日志1”,“description”:“业务线周报篡写日程1”}
创建日程返回结果:{“success”:true,“content”:{“data”:{“calendarId”:“1794994525574807554”},“requestId”:null,“success”:true,“responseMessage”:“请求成功”,“responseCode”:“SUCCESS”}}
java
public static String createCalendar() {
CreateCalendarVO vo = new CreateCalendarVO();
vo.setCreatorId("179937");
vo.setBizId("id_"+System.currentTimeMillis());
vo.setAttendeesIdList(
Arrays.asList("179937")
);
vo.setStartTime("2024-05-27 16:10:10");
vo.setEndTime("2024-05-27 16:30:10");
vo.setSubject("写业务线周日志日志1");
vo.setDescription("业务线周报篡写日程1");
try {
List<Map<String, Long>> attendees = new ArrayList<>();
vo.getAttendeesIdList().forEach(accountId -> {
Map<String, Long> map = new HashMap<>();
map.put("accountId", Long.parseLong(accountId));
attendees.add(map);
});
Map<String, Object> contentBodyMap = new HashMap<>();
contentBodyMap.put("bizId", vo.getBizId());
contentBodyMap.put("tenantId", "1");
contentBodyMap.put("accountId", vo.getCreatorId());
contentBodyMap.put("creator", "{\"accountId\":" + Long.parseLong(vo.getCreatorId()) + "}");
contentBodyMap.put("attendees", JSON.toJSONString(attendees));
contentBodyMap.put("start", String.format("{\"timeStamp\":%d}", DateUtils.parseDateTime(vo.getStartTime()).getTime()));
contentBodyMap.put("end", String.format("{\"timeStamp\":%d}", DateUtils.parseDateTime(vo.getEndTime()).getTime()));
contentBodyMap.put("event", "{\"subject\":\"" + vo.getSubject() + "\",\"description\":\"" + vo.getDescription() + "\"}");
contentBodyMap.put("eventType", "conference");
contentBodyMap.put("reminder", "{\"reminderRule\":\"userDefined\",\"reminderType\":\"app\",\"reminderList\":[\"createTime\"]}");
ContentBody contentBody = new ContentBody(contentBodyMap.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.joining("&")));
System.out.println("创建日程请求参数:" + contentBody.getJsonBody());
HttpParameters parameters = HttpParameters.builder()
.api("/calendar/createCalendar")
.region("INTER")
.accessKey("xxxxxx")
.secretKey("xxxxxxx")
.contentBody(contentBody)
.requestUrl("https://api-one.digitalhainan.com.cn/apione")
.mediaType(MediaType.parse("application/x-www-form-urlencoded"))
.build();
HttpReturn call = HttpCaller.getInstance().call(parameters);
System.out.println("创建日程返回结果:" + call.getResponse());
JSONObject jsonObject = JSON.parseObject(call.getResponse());
JSONObject content = jsonObject.getJSONObject("content");
JSONObject data = content.getJSONObject("data");
return data.getString("calendarId");
} catch (Exception e) {
System.out.println("创建日程失败:" + e.getMessage());
e.printStackTrace();
return null;
}
}