Skip to content

创建日程

基本信息

中文名: 创建日程

接口名: /calendar/createCalendar

所在目录: 日程

调用方式: POST(HTTPS)

发布版本 :V1.8.2

最低可用版本V1.8.2

请求参数

公共请求参数

名称类型是否必填示例值描述
tenantIdLong租户ID
accountIdLong账号ID,需要创建者账号id一致或者是创建者的代理人

业务请求参数

名称子参数说明类型是否必填
attendees参与人List
accountId账号idlong
organizationId组织idlong废弃,无需再传
attendeeType参与角色String废弃,无需再传
creator日历创建者AccountDTO
accountId创建者idlong
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_idString
fileName文件名String
fileSize文件大小String
fileType文件类型String
encryptionType加密类型(默认app加密:appEncryption)String
reminder日程提醒ReminderDTO
reminderRule1. 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
calendarTypecalendarTypeCode分类参数,默认可选:conference/onDuty/work/othersString废弃,无需再传

返回参数

名称子参数子参数描述类型
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;
        }
    }