飞书任务回调
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
1、创建修改日程 2、创建修改日程的参与人于相涌/robot_optimize
parent
40f1f3deef
commit
59431a713e
@ -0,0 +1,230 @@
|
||||
package com.ruoyi.flyingbook.LarkHelper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lark.oapi.core.response.EmptyData;
|
||||
import com.lark.oapi.service.calendar.v4.enums.BatchDeleteCalendarEventAttendeeUserIdTypeEnum;
|
||||
import com.lark.oapi.service.calendar.v4.model.*;
|
||||
import com.ruoyi.flyingbook.domain.lark.LarkCalendarRequest;
|
||||
import com.ruoyi.flyingbook.domain.lark.LarkException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @author yuxiangyong
|
||||
* @create 2023-03-12 18:10
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class LarkCalendarHelper extends LarkHelper {
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
LarkCalendarHelper calendarHelper = new LarkCalendarHelper();
|
||||
LarkCalendarRequest calendarRequest = new LarkCalendarRequest(appId, secret);
|
||||
PrimaryCalendarRespBody primaryCalendar = calendarHelper.getPrimaryCalendar(calendarRequest);
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日历
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PrimaryCalendarRespBody getPrimaryCalendar(LarkCalendarRequest request) {
|
||||
try {
|
||||
PrimaryCalendarResp primary = buildClient(request)
|
||||
.calendar().calendar()
|
||||
.primary(
|
||||
PrimaryCalendarReq.newBuilder()
|
||||
.build()
|
||||
);
|
||||
if (primary.getCode() == 0) {
|
||||
return primary.getData();
|
||||
} else {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", JSONObject.toJSONString(primary.getError()), request).getErrorMessageBody());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", e.getMessage(), request).getErrorMessageBody());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日程
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public ListCalendarEventAttendeeRespBody getCalendarDetail(LarkCalendarRequest request) {
|
||||
try {
|
||||
ListCalendarEventAttendeeResp list = buildClient(request)
|
||||
.calendar().calendarEventAttendee()
|
||||
.list(
|
||||
ListCalendarEventAttendeeReq.newBuilder()
|
||||
.calendarId(request.getCalendarId())
|
||||
.eventId(request.getEventId())
|
||||
.build()
|
||||
);
|
||||
if (list.getCode() == 0) {
|
||||
return list.getData();
|
||||
} else {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", JSONObject.toJSONString(list.getError()), request).getErrorMessageBody());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", e.getMessage(), request).getErrorMessageBody());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建日程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CreateCalendarEventRespBody createCalendarDetail(LarkCalendarRequest request) {
|
||||
try {
|
||||
CreateCalendarEventResp createCalendarEventResp = buildClient(request)
|
||||
.calendar().calendarEvent()
|
||||
.create(
|
||||
CreateCalendarEventReq.newBuilder()
|
||||
.calendarId(request.getCalendarId())
|
||||
.calendarEvent(
|
||||
CalendarEvent.newBuilder()
|
||||
.summary(request.getSummary())
|
||||
.needNotification(request.getNeedNotification())
|
||||
.attendeeAbility(request.getAttendeeAbility())
|
||||
.startTime(
|
||||
TimeInfo.newBuilder()
|
||||
.timezone(request.getTimeZone())
|
||||
.date(request.getStartDate())
|
||||
.timestamp(request.getStartDateStamp())
|
||||
.build()
|
||||
)
|
||||
.endTime(
|
||||
TimeInfo.newBuilder()
|
||||
.timezone(request.getTimeZone())
|
||||
.date(request.getEndDate())
|
||||
.timestamp(request.getEndDateStamp())
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
);
|
||||
if (createCalendarEventResp.getCode() == 0) {
|
||||
return createCalendarEventResp.getData();
|
||||
} else {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", JSONObject.toJSONString(createCalendarEventResp.getError()), request).getErrorMessageBody());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", e.getMessage(), request).getErrorMessageBody());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改日程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PatchCalendarEventRespBody updateCalendarDetail(LarkCalendarRequest request) {
|
||||
try {
|
||||
PatchCalendarEventResp patch = buildClient(request)
|
||||
.calendar().calendarEvent()
|
||||
.patch(PatchCalendarEventReq.newBuilder()
|
||||
.calendarId(request.getCalendarId())
|
||||
.eventId(request.getEventId())
|
||||
.calendarEvent(
|
||||
CalendarEvent.newBuilder()
|
||||
.summary(request.getSummary())
|
||||
.needNotification(request.getNeedNotification())
|
||||
.attendeeAbility(request.getAttendeeAbility())
|
||||
.startTime(
|
||||
TimeInfo.newBuilder()
|
||||
.timezone(request.getTimeZone())
|
||||
.date(request.getStartDate())
|
||||
.timestamp(request.getStartDateStamp())
|
||||
.build()
|
||||
)
|
||||
.endTime(
|
||||
TimeInfo.newBuilder()
|
||||
.timezone(request.getTimeZone())
|
||||
.date(request.getEndDate())
|
||||
.timestamp(request.getEndDateStamp())
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
if (patch.getCode() == 0) {
|
||||
return patch.getData();
|
||||
} else {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", JSONObject.toJSONString(patch.getError()), request).getErrorMessageBody());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", e.getMessage(), request).getErrorMessageBody());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定日程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CreateCalendarEventAttendeeRespBody attendeesCalendarDetail(LarkCalendarRequest request) {
|
||||
try {
|
||||
CreateCalendarEventAttendeeResp createCalendarEventAttendeeResp = buildClient(request)
|
||||
.calendar().calendarEventAttendee()
|
||||
.create(
|
||||
CreateCalendarEventAttendeeReq.newBuilder()
|
||||
.calendarId(request.getCalendarId())
|
||||
.eventId(request.getEventId())
|
||||
.createCalendarEventAttendeeReqBody(
|
||||
CreateCalendarEventAttendeeReqBody.newBuilder()
|
||||
.needNotification(request.getNeedNotification())
|
||||
.attendees(request.getCalendarEventAttendeesArray())
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
);
|
||||
|
||||
if (createCalendarEventAttendeeResp.getCode() == 0) {
|
||||
return createCalendarEventAttendeeResp.getData();
|
||||
} else {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", JSONObject.toJSONString(createCalendarEventAttendeeResp.getError()), request).getErrorMessageBody());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", e.getMessage(), request).getErrorMessageBody());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑日程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public EmptyData unAttendeesCalendarDetail(LarkCalendarRequest request) {
|
||||
try {
|
||||
BatchDeleteCalendarEventAttendeeResp batchDeleteCalendarEventAttendeeResp = buildClient(request)
|
||||
.calendar().calendarEventAttendee()
|
||||
.batchDelete(
|
||||
BatchDeleteCalendarEventAttendeeReq.newBuilder()
|
||||
.calendarId(request.getCalendarId())
|
||||
.eventId(request.getEventId())
|
||||
.userIdType(BatchDeleteCalendarEventAttendeeUserIdTypeEnum.USER_ID)
|
||||
.batchDeleteCalendarEventAttendeeReqBody(
|
||||
BatchDeleteCalendarEventAttendeeReqBody.newBuilder()
|
||||
.deleteIds(request.getCalendarEventDeleteArray())
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
);
|
||||
|
||||
if (batchDeleteCalendarEventAttendeeResp.getCode() == 0) {
|
||||
return batchDeleteCalendarEventAttendeeResp.getData();
|
||||
} else {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", JSONObject.toJSONString(batchDeleteCalendarEventAttendeeResp.getError()), request).getErrorMessageBody());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(new LarkException("LarkCalendarHelper.getPrimaryCalendar", e.getMessage(), request).getErrorMessageBody());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue