From c92d6003264fc9b21def1029cdc759d90b3a7f11 Mon Sep 17 00:00:00 2001 From: "wuqiujun.1024" Date: Wed, 25 Oct 2023 15:57:34 +0800 Subject: [PATCH 01/20] init --- .gitignore | 32 + LICENSE | 201 ++++++ NOTICE | 224 ++++++ README.md | 428 ++++++++++++ pom.xml | 129 ++++ src/main/java/com/lark/project/Client.java | 239 +++++++ .../java/com/lark/project/core/Config.java | 119 ++++ .../java/com/lark/project/core/Constants.java | 38 + .../java/com/lark/project/core/Transport.java | 94 +++ .../lark/project/core/annotation/Body.java | 25 + .../lark/project/core/annotation/Header.java | 28 + .../lark/project/core/annotation/Path.java | 25 + .../lark/project/core/annotation/Query.java | 25 + .../com/lark/project/core/cache/ICache.java | 24 + .../lark/project/core/cache/LocalCache.java | 71 ++ .../AccessTokenNotGivenException.java | 20 + .../exception/AppTicketIsEmptyException.java | 20 + .../exception/ClientTimeoutException.java | 20 + .../core/exception/DecryptException.java | 36 + .../project/core/exception/ErrConstants.java | 11 + .../EventTypeAlreadyHasHandlerException.java | 20 + .../IllegalAccessTokenTypeException.java | 20 + .../IllegalHttpStatusCodeException.java | 20 + .../IncorrectChallengeException.java | 20 + .../IncorrectSignatureException.java | 20 + .../exception/ObtainAccessTokenException.java | 20 + .../exception/ServerTimeoutException.java | 20 + .../core/httpclient/HttpTransport.java | 99 +++ .../core/httpclient/IHttpTransport.java | 21 + .../project/core/request/BaseRequest.java | 33 + .../lark/project/core/request/EventReq.java | 73 ++ .../lark/project/core/request/FormData.java | 55 ++ .../project/core/request/FormDataFile.java | 60 ++ .../lark/project/core/request/RawRequest.java | 106 +++ .../project/core/request/ReqTranslator.java | 253 +++++++ .../project/core/request/RequestOptions.java | 124 ++++ .../project/core/response/BaseResponse.java | 86 +++ .../com/lark/project/core/response/Err.java | 41 ++ .../core/response/GetAccessTokenResp.java | 43 ++ .../project/core/response/RawResponse.java | 91 +++ .../project/core/token/AccessTokenType.java | 37 + .../core/token/GlobalTokenManager.java | 31 + .../lark/project/core/token/TokenManager.java | 85 +++ .../project/core/utils/FileNameParser.java | 200 ++++++ .../java/com/lark/project/core/utils/IOs.java | 39 ++ .../com/lark/project/core/utils/Jsons.java | 35 + .../com/lark/project/core/utils/Lists.java | 31 + .../com/lark/project/core/utils/Logs.java | 16 + .../com/lark/project/core/utils/Sets.java | 43 ++ .../com/lark/project/core/utils/Strings.java | 33 + .../project/core/utils/UnmarshalRespUtil.java | 26 + .../java/com/lark/project/sample/Sample.java | 68 ++ .../service/attachment/AttachmentService.java | 17 + .../attachment/AttachmentServiceImpl.java | 107 +++ .../builder/DownloadAttachmentReq.java | 104 +++ .../builder/DownloadAttachmentReqBody.java | 17 + .../builder/DownloadAttachmentResp.java | 28 + .../builder/SpecialUploadAttachmentReq.java | 68 ++ .../SpecialUploadAttachmentReqBody.java | 19 + .../builder/SpecialUploadAttachmentResp.java | 6 + .../builder/UploadAttachmentReq.java | 118 ++++ .../builder/UploadAttachmentReqBody.java | 41 ++ .../builder/UploadAttachmentResp.java | 6 + .../project/service/chat/ChatService.java | 28 + .../project/service/chat/ChatServiceImpl.java | 64 ++ .../service/chat/builder/BotJoinChatReq.java | 108 +++ .../chat/builder/BotJoinChatReqBody.java | 45 ++ .../service/chat/builder/BotJoinChatResp.java | 36 + .../service/chat/model/BotJoinChatInfo.java | 58 ++ .../service/comment/CommentService.java | 36 + .../service/comment/CommentServiceImpl.java | 132 ++++ .../comment/builder/CreateCommentReq.java | 119 ++++ .../comment/builder/CreateCommentReqBody.java | 33 + .../comment/builder/CreateCommentResp.java | 35 + .../comment/builder/DeleteCommentReq.java | 116 +++ .../comment/builder/DeleteCommentResp.java | 24 + .../comment/builder/QueryCommentsReq.java | 135 ++++ .../comment/builder/QueryCommentsResp.java | 49 ++ .../comment/builder/UpdateCommentReq.java | 137 ++++ .../comment/builder/UpdateCommentReqBody.java | 33 + .../comment/builder/UpdateCommentResp.java | 24 + .../service/comment/model/Comment.java | 89 +++ .../service/common/model/Pagination.java | 56 ++ .../service/common/model/UserDetail.java | 78 +++ .../project/service/field/FieldService.java | 33 + .../service/field/FieldServiceImpl.java | 109 +++ .../service/field/builder/CreateFieldReq.java | 168 +++++ .../field/builder/CreateFieldReqBody.java | 165 +++++ .../field/builder/CreateFieldResp.java | 35 + .../field/builder/QueryProjectFieldsReq.java | 83 +++ .../builder/QueryProjectFieldsReqBody.java | 33 + .../field/builder/QueryProjectFieldsResp.java | 38 + .../service/field/builder/UpdateFieldReq.java | 143 ++++ .../field/builder/UpdateFieldReqBody.java | 115 +++ .../field/builder/UpdateFieldResp.java | 24 + .../service/field/model/FieldValuePair.java | 78 +++ .../service/field/model/MultiSignal.java | 47 ++ .../field/model/MultiSignalDetail.java | 78 +++ .../project/service/field/model/Option.java | 69 ++ .../service/field/model/QueryLink.java | 78 +++ .../service/field/model/SimpleField.java | 135 ++++ .../service/field/model/TargetState.java | 45 ++ .../service/measure/MeasureService.java | 28 + .../service/measure/MeasureServiceImpl.java | 64 ++ .../measure/builder/QueryChartDataReq.java | 80 +++ .../measure/builder/QueryChartDataResp.java | 36 + .../service/measure/model/ChartData.java | 47 ++ .../service/measure/model/MeasureData.java | 80 +++ .../project/service/plugin/PluginService.java | 15 + .../service/plugin/PluginServiceImpl.java | 101 +++ .../plugin/builder/GetPluginTokenReq.java | 64 ++ .../plugin/builder/GetPluginTokenReqBody.java | 37 + .../plugin/builder/GetPluginTokenResp.java | 50 ++ .../plugin/builder/GetUserPluginTokenReq.java | 60 ++ .../builder/GetUserPluginTokenReqBody.java | 28 + .../builder/GetUserPluginTokenResp.java | 50 ++ .../plugin/builder/RefreshTokenReq.java | 60 ++ .../plugin/builder/RefreshTokenReqBody.java | 28 + .../plugin/builder/RefreshTokenResp.java | 50 ++ .../service/plugin/model/PluginToken.java | 27 + .../service/plugin/model/RefreshToken.java | 50 ++ .../service/plugin/model/TokenErr.java | 28 + .../service/plugin/model/UserPluginToken.java | 72 ++ .../service/project/ProjectService.java | 23 + .../service/project/ProjectServiceImpl.java | 155 ++++ .../project/builder/GetProjectDetailReq.java | 80 +++ .../builder/GetProjectDetailReqBody.java | 65 ++ .../project/builder/GetProjectDetailResp.java | 38 + .../builder/ListProjectBusinessReq.java | 62 ++ .../builder/ListProjectBusinessResp.java | 38 + .../project/builder/ListProjectReq.java | 80 +++ .../project/builder/ListProjectReqBody.java | 65 ++ .../project/builder/ListProjectResp.java | 37 + .../project/builder/ListProjectTeamReq.java | 62 ++ .../project/builder/ListProjectTeamResp.java | 38 + .../builder/ListProjectWorkItemTypeReq.java | 62 ++ .../builder/ListProjectWorkItemTypeResp.java | 38 + .../service/project/model/Business.java | 159 +++++ .../service/project/model/Project.java | 69 ++ .../project/service/project/model/Team.java | 69 ++ .../ProjectRelationService.java | 36 + .../ProjectRelationServiceImpl.java | 132 ++++ .../CreateProjectRelationInstancesReq.java | 127 ++++ ...CreateProjectRelationInstancesReqBody.java | 46 ++ .../CreateProjectRelationInstancesResp.java | 24 + .../DeleteProjectRelationInstanceReq.java | 124 ++++ .../DeleteProjectRelationInstanceReqBody.java | 43 ++ .../DeleteProjectRelationInstanceResp.java | 24 + .../QueryProjectRelationInstanceReq.java | 134 ++++ .../QueryProjectRelationInstanceReqBody.java | 63 ++ .../QueryProjectRelationInstanceResp.java | 38 + .../builder/QueryProjectRelationReq.java | 85 +++ .../builder/QueryProjectRelationReqBody.java | 35 + .../builder/QueryProjectRelationResp.java | 38 + .../model/ProjectRelationRule.java | 58 ++ .../model/RelationBindInstance.java | 67 ++ .../model/RelationInstance.java | 111 +++ .../project_relation/model/RelationRule.java | 133 ++++ .../service/role_conf/RoleConfService.java | 28 + .../role_conf/RoleConfServiceImpl.java | 64 ++ .../builder/QueryRoleConfDetailsReq.java | 80 +++ .../builder/QueryRoleConfDetailsResp.java | 38 + .../role_conf/model/RoleConfDetail.java | 124 ++++ .../role_conf/model/SimpleRoleConf.java | 56 ++ .../project/service/task/TaskService.java | 42 ++ .../project/service/task/TaskServiceImpl.java | 178 +++++ .../task/builder/CreateSubTaskReq.java | 153 ++++ .../task/builder/CreateSubTaskReqBody.java | 97 +++ .../task/builder/CreateSubTaskResp.java | 35 + .../task/builder/DeleteSubTaskReq.java | 116 +++ .../task/builder/DeleteSubTaskResp.java | 24 + .../task/builder/ModifySubtaskReq.java | 159 +++++ .../task/builder/ModifySubtaskReqBody.java | 108 +++ .../task/builder/ModifySubtaskResp.java | 24 + .../task/builder/SearchSubtaskReq.java | 101 +++ .../task/builder/SearchSubtaskReqBody.java | 106 +++ .../task/builder/SearchSubtaskResp.java | 49 ++ .../service/task/builder/TaskDetailReq.java | 117 ++++ .../service/task/builder/TaskDetailResp.java | 38 + .../task/builder/UpdateSubTaskReq.java | 185 +++++ .../task/builder/UpdateSubTaskReqBody.java | 88 +++ .../task/builder/UpdateSubTaskResp.java | 24 + .../project/service/task/model/SubDetail.java | 68 ++ .../project/service/user/UserService.java | 33 + .../project/service/user/UserServiceImpl.java | 89 +++ .../user/builder/QueryUserDetailReq.java | 80 +++ .../user/builder/QueryUserDetailReqBody.java | 65 ++ .../user/builder/QueryUserDetailResp.java | 38 + .../service/user/builder/SearchUserReq.java | 68 ++ .../user/builder/SearchUserReqBody.java | 43 ++ .../service/user/builder/SearchUserResp.java | 38 + .../project/service/user/model/Channel.java | 45 ++ .../service/user/model/RoleAssign.java | 91 +++ .../project/service/user/model/RoleOwner.java | 58 ++ .../service/user/model/UserBasicInfo.java | 135 ++++ .../project/service/view/ViewService.java | 42 ++ .../project/service/view/ViewServiceImpl.java | 178 +++++ .../view/builder/CreateFixViewReq.java | 123 ++++ .../view/builder/CreateFixViewReqBody.java | 75 ++ .../view/builder/CreateFixViewResp.java | 47 ++ .../view/builder/DeleteFixViewReq.java | 80 +++ .../view/builder/DeleteFixViewResp.java | 24 + .../QueryWorkItemDetailsByViewIDReq.java | 112 +++ .../QueryWorkItemDetailsByViewIDReqBody.java | 54 ++ .../QueryWorkItemDetailsByViewIDResp.java | 49 ++ .../view/builder/UpdateFixViewReq.java | 141 ++++ .../view/builder/UpdateFixViewReqBody.java | 75 ++ .../view/builder/UpdateFixViewResp.java | 47 ++ .../service/view/builder/ViewListReq.java | 111 +++ .../service/view/builder/ViewListReqBody.java | 86 +++ .../service/view/builder/ViewListResp.java | 49 ++ .../service/view/builder/WorkItemListReq.java | 117 ++++ .../view/builder/WorkItemListResp.java | 47 ++ .../project/service/view/model/FixView.java | 102 +++ .../project/service/view/model/ViewConf.java | 124 ++++ .../service/workitem/WorkItemService.java | 105 +++ .../service/workitem/WorkItemServiceImpl.java | 661 ++++++++++++++++++ .../workitem/builder/AbortWorkItemReq.java | 124 ++++ .../builder/AbortWorkItemReqBody.java | 43 ++ .../workitem/builder/AbortWorkItemResp.java | 24 + .../builder/CompositiveSearchReq.java | 95 +++ .../builder/CompositiveSearchReqBody.java | 95 +++ .../builder/CompositiveSearchResp.java | 49 ++ .../builder/CreateWorkItemRelationReq.java | 81 +++ .../CreateWorkItemRelationReqBody.java | 66 ++ .../builder/CreateWorkItemRelationResp.java | 36 + .../workitem/builder/CreateWorkItemReq.java | 101 +++ .../builder/CreateWorkItemReqBody.java | 66 ++ .../workitem/builder/CreateWorkItemResp.java | 35 + .../builder/CreateWorkingHourRecordReq.java | 137 ++++ .../CreateWorkingHourRecordReqBody.java | 66 ++ .../builder/CreateWorkingHourRecordResp.java | 38 + .../builder/DeleteWorkItemRelationReq.java | 68 ++ .../DeleteWorkItemRelationReqBody.java | 43 ++ .../builder/DeleteWorkItemRelationResp.java | 35 + .../workitem/builder/DeleteWorkItemReq.java | 98 +++ .../workitem/builder/DeleteWorkItemResp.java | 24 + .../builder/DeleteWorkingHourRecordReq.java | 121 ++++ .../DeleteWorkingHourRecordReqBody.java | 35 + .../builder/DeleteWorkingHourRecordResp.java | 24 + .../builder/FilterAcrossProjectReq.java | 149 ++++ .../builder/FilterAcrossProjectReqBody.java | 199 ++++++ .../builder/FilterAcrossProjectResp.java | 49 ++ .../service/workitem/builder/FilterReq.java | 153 ++++ .../workitem/builder/FilterReqBody.java | 168 +++++ .../service/workitem/builder/FilterResp.java | 49 ++ .../service/workitem/builder/GetMetaReq.java | 80 +++ .../service/workitem/builder/GetMetaResp.java | 38 + .../builder/GetWorkItemManHourRecordsReq.java | 83 +++ .../GetWorkItemManHourRecordsReqBody.java | 73 ++ .../GetWorkItemManHourRecordsResp.java | 49 ++ .../builder/GetWorkItemTypeInfoByKeyReq.java | 80 +++ .../builder/GetWorkItemTypeInfoByKeyResp.java | 36 + .../workitem/builder/NodeOperateReq.java | 172 +++++ .../workitem/builder/NodeOperateReqBody.java | 98 +++ .../workitem/builder/NodeOperateResp.java | 24 + .../workitem/builder/NodeStateChangeReq.java | 133 ++++ .../builder/NodeStateChangeReqBody.java | 57 ++ .../workitem/builder/NodeStateChangeResp.java | 24 + .../workitem/builder/NodeUpdateReq.java | 162 +++++ .../workitem/builder/NodeUpdateReqBody.java | 78 +++ .../workitem/builder/NodeUpdateResp.java | 24 + .../builder/QueryWorkItemDetailReq.java | 114 +++ .../builder/QueryWorkItemDetailReqBody.java | 56 ++ .../builder/QueryWorkItemDetailResp.java | 38 + .../builder/QueryWorkItemRelationReq.java | 62 ++ .../builder/QueryWorkItemRelationResp.java | 38 + .../workitem/builder/QueryWorkflowReq.java | 132 ++++ .../builder/QueryWorkflowReqBody.java | 56 ++ .../workitem/builder/QueryWorkflowResp.java | 36 + .../workitem/builder/SearchByParamsReq.java | 125 ++++ .../builder/SearchByParamsReqBody.java | 77 ++ .../workitem/builder/SearchByParamsResp.java | 49 ++ .../workitem/builder/SearchByRelationReq.java | 145 ++++ .../builder/SearchByRelationReqBody.java | 84 +++ .../builder/SearchByRelationResp.java | 49 ++ .../builder/UpdateMultiSignalReq.java | 137 ++++ .../builder/UpdateMultiSignalReqBody.java | 66 ++ .../builder/UpdateMultiSignalResp.java | 36 + .../builder/UpdateWorkItemRelationReq.java | 86 +++ .../UpdateWorkItemRelationReqBody.java | 76 ++ .../builder/UpdateWorkItemRelationResp.java | 35 + .../workitem/builder/UpdateWorkItemReq.java | 122 ++++ .../builder/UpdateWorkItemReqBody.java | 36 + .../workitem/builder/UpdateWorkItemResp.java | 24 + .../builder/UpdateWorkItemTypeInfoReq.java | 143 ++++ .../UpdateWorkItemTypeInfoReqBody.java | 115 +++ .../builder/UpdateWorkItemTypeInfoResp.java | 24 + .../builder/UpdateWorkingHourRecordReq.java | 122 ++++ .../UpdateWorkingHourRecordReqBody.java | 36 + .../builder/UpdateWorkingHourRecordResp.java | 24 + .../service/workitem/builder/WbsViewReq.java | 120 ++++ .../workitem/builder/WbsViewReqBody.java | 34 + .../service/workitem/builder/WbsViewResp.java | 36 + .../service/workitem/model/Checker.java | 56 ++ .../service/workitem/model/CompInfo.java | 124 ++++ .../service/workitem/model/Connection.java | 56 ++ .../model/CreateWorkItemRelationData.java | 34 + .../model/CreateWorkingHourRecord.java | 67 ++ .../service/workitem/model/DefaultValue.java | 45 ++ .../service/workitem/model/Expand.java | 78 +++ .../service/workitem/model/FieldConf.java | 158 +++++ .../service/workitem/model/FieldDetail.java | 56 ++ .../service/workitem/model/ManHourRecord.java | 166 +++++ .../service/workitem/model/MultiText.java | 45 ++ .../workitem/model/MultiTextDetail.java | 91 +++ .../service/workitem/model/NodeBasicInfo.java | 69 ++ .../service/workitem/model/NodeTask.java | 58 ++ .../workitem/model/NodesConnections.java | 70 ++ .../service/workitem/model/OptionConf.java | 80 +++ .../workitem/model/RelationDetail.java | 67 ++ .../workitem/model/RelationFieldDetail.java | 47 ++ .../service/workitem/model/Schedule.java | 80 +++ .../service/workitem/model/SearchGroup.java | 58 ++ .../service/workitem/model/SearchParam.java | 56 ++ .../service/workitem/model/SearchUser.java | 58 ++ .../service/workitem/model/StateFlowNode.java | 104 +++ .../service/workitem/model/StateTime.java | 67 ++ .../service/workitem/model/SubTask.java | 170 +++++ .../workitem/model/SubTaskParentInfo.java | 67 ++ .../service/workitem/model/TimeInterval.java | 45 ++ .../model/UpdateWorkingHourRecord.java | 56 ++ .../workitem/model/WBSParentWorkItem.java | 157 +++++ .../service/workitem/model/WBSWorkItem.java | 182 +++++ .../workitem/model/WbsViewResponse.java | 103 +++ .../service/workitem/model/WorkItemInfo.java | 291 ++++++++ .../workitem/model/WorkItemKeyType.java | 67 ++ .../workitem/model/WorkItemRelation.java | 91 +++ .../workitem/model/WorkItemStatus.java | 91 +++ .../workitem/model/WorkItemTypeInfo.java | 191 +++++ .../service/workitem/model/WorkflowNode.java | 203 ++++++ .../workitem_conf/WorkItemConfService.java | 42 ++ .../WorkItemConfServiceImpl.java | 178 +++++ .../builder/CreateTemplateDetailReq.java | 78 +++ .../builder/CreateTemplateDetailReqBody.java | 63 ++ .../builder/CreateTemplateDetailResp.java | 35 + .../builder/DeleteTemplateDetailReq.java | 80 +++ .../builder/DeleteTemplateDetailResp.java | 24 + .../builder/QueryTemplateDetailReq.java | 80 +++ .../builder/QueryTemplateDetailResp.java | 36 + .../builder/QueryWbsTemplateConfReq.java | 83 +++ .../builder/QueryWbsTemplateConfReqBody.java | 33 + .../builder/QueryWbsTemplateConfResp.java | 36 + .../builder/QueryWorkItemTemplatesReq.java | 80 +++ .../builder/QueryWorkItemTemplatesResp.java | 38 + .../builder/UpdateTemplateDetailReq.java | 82 +++ .../builder/UpdateTemplateDetailReqBody.java | 67 ++ .../builder/UpdateTemplateDetailResp.java | 24 + .../workitem_conf/model/ConfirmForm.java | 45 ++ .../workitem_conf/model/Connection.java | 45 ++ .../service/workitem_conf/model/NodeConf.java | 135 ++++ .../workitem_conf/model/OwnerConf.java | 58 ++ .../model/StateFlowConfInfo.java | 69 ++ .../workitem_conf/model/StatusConf.java | 56 ++ .../workitem_conf/model/SubProcessConf.java | 78 +++ .../service/workitem_conf/model/TaskConf.java | 89 +++ .../workitem_conf/model/TemplateConf.java | 89 +++ .../workitem_conf/model/TemplateDetail.java | 103 +++ .../workitem_conf/model/WbsNodeMap.java | 45 ++ .../workitem_conf/model/WbsStatusMap.java | 45 ++ .../workitem_conf/model/WbsTemplate.java | 89 +++ .../workitem_conf/model/WorkflowConf.java | 58 ++ .../workitem_conf/model/WorkflowConfInfo.java | 201 ++++++ src/main/resources/static/img_1.png | Bin 0 -> 68895 bytes src/main/resources/static/img_2.png | Bin 0 -> 175423 bytes 365 files changed, 27550 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/com/lark/project/Client.java create mode 100644 src/main/java/com/lark/project/core/Config.java create mode 100644 src/main/java/com/lark/project/core/Constants.java create mode 100644 src/main/java/com/lark/project/core/Transport.java create mode 100644 src/main/java/com/lark/project/core/annotation/Body.java create mode 100644 src/main/java/com/lark/project/core/annotation/Header.java create mode 100644 src/main/java/com/lark/project/core/annotation/Path.java create mode 100644 src/main/java/com/lark/project/core/annotation/Query.java create mode 100644 src/main/java/com/lark/project/core/cache/ICache.java create mode 100644 src/main/java/com/lark/project/core/cache/LocalCache.java create mode 100644 src/main/java/com/lark/project/core/exception/AccessTokenNotGivenException.java create mode 100644 src/main/java/com/lark/project/core/exception/AppTicketIsEmptyException.java create mode 100644 src/main/java/com/lark/project/core/exception/ClientTimeoutException.java create mode 100644 src/main/java/com/lark/project/core/exception/DecryptException.java create mode 100644 src/main/java/com/lark/project/core/exception/ErrConstants.java create mode 100644 src/main/java/com/lark/project/core/exception/EventTypeAlreadyHasHandlerException.java create mode 100644 src/main/java/com/lark/project/core/exception/IllegalAccessTokenTypeException.java create mode 100644 src/main/java/com/lark/project/core/exception/IllegalHttpStatusCodeException.java create mode 100644 src/main/java/com/lark/project/core/exception/IncorrectChallengeException.java create mode 100644 src/main/java/com/lark/project/core/exception/IncorrectSignatureException.java create mode 100644 src/main/java/com/lark/project/core/exception/ObtainAccessTokenException.java create mode 100644 src/main/java/com/lark/project/core/exception/ServerTimeoutException.java create mode 100644 src/main/java/com/lark/project/core/httpclient/HttpTransport.java create mode 100644 src/main/java/com/lark/project/core/httpclient/IHttpTransport.java create mode 100644 src/main/java/com/lark/project/core/request/BaseRequest.java create mode 100644 src/main/java/com/lark/project/core/request/EventReq.java create mode 100644 src/main/java/com/lark/project/core/request/FormData.java create mode 100644 src/main/java/com/lark/project/core/request/FormDataFile.java create mode 100644 src/main/java/com/lark/project/core/request/RawRequest.java create mode 100644 src/main/java/com/lark/project/core/request/ReqTranslator.java create mode 100644 src/main/java/com/lark/project/core/request/RequestOptions.java create mode 100644 src/main/java/com/lark/project/core/response/BaseResponse.java create mode 100644 src/main/java/com/lark/project/core/response/Err.java create mode 100644 src/main/java/com/lark/project/core/response/GetAccessTokenResp.java create mode 100644 src/main/java/com/lark/project/core/response/RawResponse.java create mode 100644 src/main/java/com/lark/project/core/token/AccessTokenType.java create mode 100644 src/main/java/com/lark/project/core/token/GlobalTokenManager.java create mode 100644 src/main/java/com/lark/project/core/token/TokenManager.java create mode 100644 src/main/java/com/lark/project/core/utils/FileNameParser.java create mode 100644 src/main/java/com/lark/project/core/utils/IOs.java create mode 100644 src/main/java/com/lark/project/core/utils/Jsons.java create mode 100644 src/main/java/com/lark/project/core/utils/Lists.java create mode 100644 src/main/java/com/lark/project/core/utils/Logs.java create mode 100644 src/main/java/com/lark/project/core/utils/Sets.java create mode 100644 src/main/java/com/lark/project/core/utils/Strings.java create mode 100644 src/main/java/com/lark/project/core/utils/UnmarshalRespUtil.java create mode 100644 src/main/java/com/lark/project/sample/Sample.java create mode 100644 src/main/java/com/lark/project/service/attachment/AttachmentService.java create mode 100644 src/main/java/com/lark/project/service/attachment/AttachmentServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentReq.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentReqBody.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentResp.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentReq.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentReqBody.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentResp.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentReq.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentReqBody.java create mode 100644 src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentResp.java create mode 100644 src/main/java/com/lark/project/service/chat/ChatService.java create mode 100644 src/main/java/com/lark/project/service/chat/ChatServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/chat/builder/BotJoinChatReq.java create mode 100644 src/main/java/com/lark/project/service/chat/builder/BotJoinChatReqBody.java create mode 100644 src/main/java/com/lark/project/service/chat/builder/BotJoinChatResp.java create mode 100644 src/main/java/com/lark/project/service/chat/model/BotJoinChatInfo.java create mode 100644 src/main/java/com/lark/project/service/comment/CommentService.java create mode 100644 src/main/java/com/lark/project/service/comment/CommentServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/CreateCommentReq.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/CreateCommentReqBody.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/CreateCommentResp.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/DeleteCommentReq.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/DeleteCommentResp.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/QueryCommentsReq.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/QueryCommentsResp.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/UpdateCommentReq.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/UpdateCommentReqBody.java create mode 100644 src/main/java/com/lark/project/service/comment/builder/UpdateCommentResp.java create mode 100644 src/main/java/com/lark/project/service/comment/model/Comment.java create mode 100644 src/main/java/com/lark/project/service/common/model/Pagination.java create mode 100644 src/main/java/com/lark/project/service/common/model/UserDetail.java create mode 100644 src/main/java/com/lark/project/service/field/FieldService.java create mode 100644 src/main/java/com/lark/project/service/field/FieldServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/field/builder/CreateFieldReq.java create mode 100644 src/main/java/com/lark/project/service/field/builder/CreateFieldReqBody.java create mode 100644 src/main/java/com/lark/project/service/field/builder/CreateFieldResp.java create mode 100644 src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsReq.java create mode 100644 src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsReqBody.java create mode 100644 src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsResp.java create mode 100644 src/main/java/com/lark/project/service/field/builder/UpdateFieldReq.java create mode 100644 src/main/java/com/lark/project/service/field/builder/UpdateFieldReqBody.java create mode 100644 src/main/java/com/lark/project/service/field/builder/UpdateFieldResp.java create mode 100644 src/main/java/com/lark/project/service/field/model/FieldValuePair.java create mode 100644 src/main/java/com/lark/project/service/field/model/MultiSignal.java create mode 100644 src/main/java/com/lark/project/service/field/model/MultiSignalDetail.java create mode 100644 src/main/java/com/lark/project/service/field/model/Option.java create mode 100644 src/main/java/com/lark/project/service/field/model/QueryLink.java create mode 100644 src/main/java/com/lark/project/service/field/model/SimpleField.java create mode 100644 src/main/java/com/lark/project/service/field/model/TargetState.java create mode 100644 src/main/java/com/lark/project/service/measure/MeasureService.java create mode 100644 src/main/java/com/lark/project/service/measure/MeasureServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/measure/builder/QueryChartDataReq.java create mode 100644 src/main/java/com/lark/project/service/measure/builder/QueryChartDataResp.java create mode 100644 src/main/java/com/lark/project/service/measure/model/ChartData.java create mode 100644 src/main/java/com/lark/project/service/measure/model/MeasureData.java create mode 100644 src/main/java/com/lark/project/service/plugin/PluginService.java create mode 100644 src/main/java/com/lark/project/service/plugin/PluginServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/GetPluginTokenReq.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/GetPluginTokenReqBody.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/GetPluginTokenResp.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/GetUserPluginTokenReq.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/GetUserPluginTokenReqBody.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/GetUserPluginTokenResp.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/RefreshTokenReq.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/RefreshTokenReqBody.java create mode 100644 src/main/java/com/lark/project/service/plugin/builder/RefreshTokenResp.java create mode 100644 src/main/java/com/lark/project/service/plugin/model/PluginToken.java create mode 100644 src/main/java/com/lark/project/service/plugin/model/RefreshToken.java create mode 100644 src/main/java/com/lark/project/service/plugin/model/TokenErr.java create mode 100644 src/main/java/com/lark/project/service/plugin/model/UserPluginToken.java create mode 100644 src/main/java/com/lark/project/service/project/ProjectService.java create mode 100644 src/main/java/com/lark/project/service/project/ProjectServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/project/builder/GetProjectDetailReq.java create mode 100644 src/main/java/com/lark/project/service/project/builder/GetProjectDetailReqBody.java create mode 100644 src/main/java/com/lark/project/service/project/builder/GetProjectDetailResp.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectBusinessReq.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectBusinessResp.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectReq.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectReqBody.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectResp.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectTeamReq.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectTeamResp.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectWorkItemTypeReq.java create mode 100644 src/main/java/com/lark/project/service/project/builder/ListProjectWorkItemTypeResp.java create mode 100644 src/main/java/com/lark/project/service/project/model/Business.java create mode 100644 src/main/java/com/lark/project/service/project/model/Project.java create mode 100644 src/main/java/com/lark/project/service/project/model/Team.java create mode 100644 src/main/java/com/lark/project/service/project_relation/ProjectRelationService.java create mode 100644 src/main/java/com/lark/project/service/project_relation/ProjectRelationServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/CreateProjectRelationInstancesReq.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/CreateProjectRelationInstancesReqBody.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/CreateProjectRelationInstancesResp.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/DeleteProjectRelationInstanceReq.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/DeleteProjectRelationInstanceReqBody.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/DeleteProjectRelationInstanceResp.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/QueryProjectRelationInstanceReq.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/QueryProjectRelationInstanceReqBody.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/QueryProjectRelationInstanceResp.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/QueryProjectRelationReq.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/QueryProjectRelationReqBody.java create mode 100644 src/main/java/com/lark/project/service/project_relation/builder/QueryProjectRelationResp.java create mode 100644 src/main/java/com/lark/project/service/project_relation/model/ProjectRelationRule.java create mode 100644 src/main/java/com/lark/project/service/project_relation/model/RelationBindInstance.java create mode 100644 src/main/java/com/lark/project/service/project_relation/model/RelationInstance.java create mode 100644 src/main/java/com/lark/project/service/project_relation/model/RelationRule.java create mode 100644 src/main/java/com/lark/project/service/role_conf/RoleConfService.java create mode 100644 src/main/java/com/lark/project/service/role_conf/RoleConfServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/role_conf/builder/QueryRoleConfDetailsReq.java create mode 100644 src/main/java/com/lark/project/service/role_conf/builder/QueryRoleConfDetailsResp.java create mode 100644 src/main/java/com/lark/project/service/role_conf/model/RoleConfDetail.java create mode 100644 src/main/java/com/lark/project/service/role_conf/model/SimpleRoleConf.java create mode 100644 src/main/java/com/lark/project/service/task/TaskService.java create mode 100644 src/main/java/com/lark/project/service/task/TaskServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/task/builder/CreateSubTaskReq.java create mode 100644 src/main/java/com/lark/project/service/task/builder/CreateSubTaskReqBody.java create mode 100644 src/main/java/com/lark/project/service/task/builder/CreateSubTaskResp.java create mode 100644 src/main/java/com/lark/project/service/task/builder/DeleteSubTaskReq.java create mode 100644 src/main/java/com/lark/project/service/task/builder/DeleteSubTaskResp.java create mode 100644 src/main/java/com/lark/project/service/task/builder/ModifySubtaskReq.java create mode 100644 src/main/java/com/lark/project/service/task/builder/ModifySubtaskReqBody.java create mode 100644 src/main/java/com/lark/project/service/task/builder/ModifySubtaskResp.java create mode 100644 src/main/java/com/lark/project/service/task/builder/SearchSubtaskReq.java create mode 100644 src/main/java/com/lark/project/service/task/builder/SearchSubtaskReqBody.java create mode 100644 src/main/java/com/lark/project/service/task/builder/SearchSubtaskResp.java create mode 100644 src/main/java/com/lark/project/service/task/builder/TaskDetailReq.java create mode 100644 src/main/java/com/lark/project/service/task/builder/TaskDetailResp.java create mode 100644 src/main/java/com/lark/project/service/task/builder/UpdateSubTaskReq.java create mode 100644 src/main/java/com/lark/project/service/task/builder/UpdateSubTaskReqBody.java create mode 100644 src/main/java/com/lark/project/service/task/builder/UpdateSubTaskResp.java create mode 100644 src/main/java/com/lark/project/service/task/model/SubDetail.java create mode 100644 src/main/java/com/lark/project/service/user/UserService.java create mode 100644 src/main/java/com/lark/project/service/user/UserServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/user/builder/QueryUserDetailReq.java create mode 100644 src/main/java/com/lark/project/service/user/builder/QueryUserDetailReqBody.java create mode 100644 src/main/java/com/lark/project/service/user/builder/QueryUserDetailResp.java create mode 100644 src/main/java/com/lark/project/service/user/builder/SearchUserReq.java create mode 100644 src/main/java/com/lark/project/service/user/builder/SearchUserReqBody.java create mode 100644 src/main/java/com/lark/project/service/user/builder/SearchUserResp.java create mode 100644 src/main/java/com/lark/project/service/user/model/Channel.java create mode 100644 src/main/java/com/lark/project/service/user/model/RoleAssign.java create mode 100644 src/main/java/com/lark/project/service/user/model/RoleOwner.java create mode 100644 src/main/java/com/lark/project/service/user/model/UserBasicInfo.java create mode 100644 src/main/java/com/lark/project/service/view/ViewService.java create mode 100644 src/main/java/com/lark/project/service/view/ViewServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/view/builder/CreateFixViewReq.java create mode 100644 src/main/java/com/lark/project/service/view/builder/CreateFixViewReqBody.java create mode 100644 src/main/java/com/lark/project/service/view/builder/CreateFixViewResp.java create mode 100644 src/main/java/com/lark/project/service/view/builder/DeleteFixViewReq.java create mode 100644 src/main/java/com/lark/project/service/view/builder/DeleteFixViewResp.java create mode 100644 src/main/java/com/lark/project/service/view/builder/QueryWorkItemDetailsByViewIDReq.java create mode 100644 src/main/java/com/lark/project/service/view/builder/QueryWorkItemDetailsByViewIDReqBody.java create mode 100644 src/main/java/com/lark/project/service/view/builder/QueryWorkItemDetailsByViewIDResp.java create mode 100644 src/main/java/com/lark/project/service/view/builder/UpdateFixViewReq.java create mode 100644 src/main/java/com/lark/project/service/view/builder/UpdateFixViewReqBody.java create mode 100644 src/main/java/com/lark/project/service/view/builder/UpdateFixViewResp.java create mode 100644 src/main/java/com/lark/project/service/view/builder/ViewListReq.java create mode 100644 src/main/java/com/lark/project/service/view/builder/ViewListReqBody.java create mode 100644 src/main/java/com/lark/project/service/view/builder/ViewListResp.java create mode 100644 src/main/java/com/lark/project/service/view/builder/WorkItemListReq.java create mode 100644 src/main/java/com/lark/project/service/view/builder/WorkItemListResp.java create mode 100644 src/main/java/com/lark/project/service/view/model/FixView.java create mode 100644 src/main/java/com/lark/project/service/view/model/ViewConf.java create mode 100644 src/main/java/com/lark/project/service/workitem/WorkItemService.java create mode 100644 src/main/java/com/lark/project/service/workitem/WorkItemServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/AbortWorkItemReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/AbortWorkItemReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/AbortWorkItemResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CompositiveSearchReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CompositiveSearchReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CompositiveSearchResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkItemRelationReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkItemRelationReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkItemRelationResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkItemReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkItemReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkItemResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkingHourRecordReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkingHourRecordReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/CreateWorkingHourRecordResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/DeleteWorkItemRelationReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/DeleteWorkItemRelationReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/DeleteWorkItemRelationResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/DeleteWorkItemReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/DeleteWorkItemResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/DeleteWorkingHourRecordReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/DeleteWorkingHourRecordReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/DeleteWorkingHourRecordResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/FilterAcrossProjectReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/FilterAcrossProjectReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/FilterAcrossProjectResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/FilterReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/FilterReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/FilterResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/GetMetaReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/GetMetaResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/GetWorkItemManHourRecordsReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/GetWorkItemManHourRecordsReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/GetWorkItemManHourRecordsResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/GetWorkItemTypeInfoByKeyReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/GetWorkItemTypeInfoByKeyResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeOperateReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeOperateReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeOperateResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeStateChangeReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeStateChangeReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeStateChangeResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeUpdateReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeUpdateReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/NodeUpdateResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/QueryWorkItemDetailReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/QueryWorkItemDetailReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/QueryWorkItemDetailResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/QueryWorkItemRelationReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/QueryWorkItemRelationResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/QueryWorkflowReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/QueryWorkflowReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/QueryWorkflowResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/SearchByParamsReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/SearchByParamsReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/SearchByParamsResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/SearchByRelationReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/SearchByRelationReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/SearchByRelationResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateMultiSignalReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateMultiSignalReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateMultiSignalResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemRelationReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemRelationReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemRelationResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemTypeInfoReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemTypeInfoReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkItemTypeInfoResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkingHourRecordReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkingHourRecordReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/UpdateWorkingHourRecordResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/WbsViewReq.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/WbsViewReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem/builder/WbsViewResp.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/Checker.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/CompInfo.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/Connection.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/CreateWorkItemRelationData.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/CreateWorkingHourRecord.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/DefaultValue.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/Expand.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/FieldConf.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/FieldDetail.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/ManHourRecord.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/MultiText.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/MultiTextDetail.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/NodeBasicInfo.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/NodeTask.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/NodesConnections.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/OptionConf.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/RelationDetail.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/RelationFieldDetail.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/Schedule.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/SearchGroup.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/SearchParam.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/SearchUser.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/StateFlowNode.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/StateTime.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/SubTask.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/SubTaskParentInfo.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/TimeInterval.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/UpdateWorkingHourRecord.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WBSParentWorkItem.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WBSWorkItem.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WbsViewResponse.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WorkItemInfo.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WorkItemKeyType.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WorkItemRelation.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WorkItemStatus.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WorkItemTypeInfo.java create mode 100644 src/main/java/com/lark/project/service/workitem/model/WorkflowNode.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/WorkItemConfService.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/WorkItemConfServiceImpl.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/CreateTemplateDetailReq.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/CreateTemplateDetailReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/CreateTemplateDetailResp.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/DeleteTemplateDetailReq.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/DeleteTemplateDetailResp.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/QueryTemplateDetailReq.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/QueryTemplateDetailResp.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/QueryWbsTemplateConfReq.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/QueryWbsTemplateConfReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/QueryWbsTemplateConfResp.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/QueryWorkItemTemplatesReq.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/QueryWorkItemTemplatesResp.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/UpdateTemplateDetailReq.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/UpdateTemplateDetailReqBody.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/builder/UpdateTemplateDetailResp.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/ConfirmForm.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/Connection.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/NodeConf.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/OwnerConf.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/StateFlowConfInfo.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/StatusConf.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/SubProcessConf.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/TaskConf.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/TemplateConf.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/TemplateDetail.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/WbsNodeMap.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/WbsStatusMap.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/WbsTemplate.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/WorkflowConf.java create mode 100644 src/main/java/com/lark/project/service/workitem_conf/model/WorkflowConfInfo.java create mode 100644 src/main/resources/static/img_1.png create mode 100644 src/main/resources/static/img_2.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f94dfd --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +.idea +*.iml +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +target/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# OS generated files # +###################### +.DS_Store* +*.DS_Store* + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..4e21c18 --- /dev/null +++ b/NOTICE @@ -0,0 +1,224 @@ +NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THIS PRODUCT. + +Components: + +Apache Commons Codec 1.15 : Apache License 2.0 +google-gson 2.9.0 : Apache License 2.0 +larksuite-oapi 1.0.6 : Apache License 2.0 +OkIO 1.17.5 : Apache License 2.0 +SLF4J API Module 1.7.30 : MIT License + +License: + +Apache License 2.0 +(Apache Commons Codec 1.15, google-gson 2.9.0, larksuite-oapi 1.0.6, OkIO 1.17.5) + +Apache License +Version 2.0, January 2004 +========================= + + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions +granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is +based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work by +the copyright owner or by an individual or Legal Entity authorized to submit on +behalf of the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent to the +Licensor or its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue tracking systems +that are managed by, or on behalf of, the Licensor for the purpose of discussing +and improving the Work, but excluding communication that is conspicuously marked +or otherwise designated in writing by the copyright owner as "Not a +Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of +whom a Contribution has been received by Licensor and subsequently incorporated +within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this +License, each Contributor hereby grants to You a perpetual, worldwide, +non-exclusive, no-charge, royalty-free, irrevocable copyright license to +reproduce, prepare Derivative Works of, publicly display, publicly perform, +sublicense, and distribute the Work and such Derivative Works in Source or Object +form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, +each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) patent +license to make, have made, use, offer to sell, sell, import, and otherwise +transfer the Work, where such license applies only to those patent claims +licensable by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) with the Work to +which such Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Work or a Contribution incorporated within the Work constitutes +direct or contributory patent infringement, then any patent licenses granted to +You under this License for that Work shall terminate as of the date such +litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or +Derivative Works thereof in any medium, with or without modifications, and in +Source or Object form, provided that You meet the following conditions: + + a. You must give any other recipients of the Work or Derivative Works a copy of + this License; and + + b. You must cause any modified files to carry prominent notices stating that + You changed the files; and + + c. You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices from + the Source form of the Work, excluding those notices that do not pertain to + any part of the Derivative Works; and + + d. If the Work includes a "NOTICE" text file as part of its distribution, then + any Derivative Works that You distribute must include a readable copy of the + attribution notices contained within such NOTICE file, excluding those + notices that do not pertain to any part of the Derivative Works, in at least + one of the following places: within a NOTICE text file distributed as part of + the Derivative Works; within the Source form or documentation, if provided + along with the Derivative Works; or, within a display generated by the + Derivative Works, if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only and do + not modify the License. You may add Your own attribution notices within + Derivative Works that You distribute, alongside or as an addendum to the + NOTICE text from the Work, provided that such additional attribution notices + cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any +Contribution intentionally submitted for inclusion in the Work by You to the +Licensor shall be under the terms and conditions of this License, without any +additional terms or conditions. Notwithstanding the above, nothing herein shall +supersede or modify the terms of any separate license agreement you may have +executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, +trademarks, service marks, or product names of the Licensor, except as required +for reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in +writing, Licensor provides the Work (and each Contributor provides its +Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +either express or implied, including, without limitation, any warranties or +conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any risks +associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in +tort (including negligence), contract, or otherwise, unless required by +applicable law (such as deliberate and grossly negligent acts) or agreed to in +writing, shall any Contributor be liable to You for damages, including any +direct, indirect, special, incidental, or consequential damages of any character +arising as a result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, work stoppage, +computer failure or malfunction, or any and all other commercial damages or +losses), even if such Contributor has been advised of the possibility of such +damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or +Derivative Works thereof, You may choose to offer, and charge a fee for, +acceptance of support, warranty, indemnity, or other liability obligations and/or +rights consistent with this License. However, in accepting such obligations, You +may act only on Your own behalf and on Your sole responsibility, not on behalf of +any other Contributor, and only if You agree to indemnify, defend, and hold each +Contributor harmless for any liability incurred by, or claims asserted against, +such Contributor by reason of your accepting any such warranty or additional +liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also recommend +that a file or class name and description of purpose be included on the same +"printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, + Version 2.0 (the "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law + or agreed to in writing, software distributed under the License is + distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the specific language + governing permissions and limitations under the License. + +--- + +MIT License +(SLF4J API Module 1.7.30) + +The MIT License +=============== + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in the +Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..389a449 --- /dev/null +++ b/README.md @@ -0,0 +1,428 @@ +# 飞书项目开放接口SDK + +旨在让开发者便捷的调用飞书项目OPEN API + +## 目录 + + + +- [安装](#安装) +- [API Client](#api-client) + - [创建API Client](#创建api-client) + - [配置API Client](#配置api-client) + +- [API调用](#api调用) + - [基本用法](#基本用法) + - [设置请求选项](#设置请求选项) +- [错误自查](#错误自查) +- [FAQ](#FAQ) + + + +## 安装 + +- 运行环境:JDK 1.8及以上 + +- 请将以下配置复制并添加 settings.xml文件中: + +```shell + + + + lark-project + + true + + + + lark-project + https://artifacts-cn-beijing.volces.com/repository/meego/ + + true + + + true + + + + + + +``` + +- 请将以下配置复制并添加到 pom.xml文件中: + +```shell + + com.larksuite.project + oapi-sdk + 1.0.8 + +``` + +## API Client + +开发者在调用 API 前,需要先创建一个 API Client,然后才可以基于 API Client 发起 API 调用,Client对象线程安全,全局初始化一次即可。 + +### 创建API Client + +```java +import com.lark.project.Client; + +public class Sample { + + public static void main(String[] args) throws Exception { + // 默认插件身份凭证 + Client client = Client.newBuilder("pluginID", "pluginSecret").build(); + } +} +``` + +### 配置API Client + +创建 API Client 时,可对 API Client 进行一定的配置,比如我们可以在创建 API Client 时设置日志级别、设置 http 请求超时时间等等: + +```java +import com.lark.project.Client; + +public class Sample { + + public static void main(String[] args) throws Exception { + Client client = Client.newBuilder("pluginID", "pluginSecret") + .openBaseUrl("https://project.feishu.cn/") // 设置域名 + .requestTimeout(3000) // 设置httpclient 超时时间,默认永不超时 + .disableTokenCache() // 禁用token管理,禁用后需要开发者自己传递token + .logReqAtDebug(true) // 在 debug 模式下会打印 http 请求和响应的 headers,body 等信息。 + .build(); + } +} +``` + +每个配置选项的具体含义,如下表格: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 配置选项 + + 配置方式 + + 描述 +
+ logReqAtDebug + + client.logReqAtDebug(boolean logReqAtDebug) + +设置是否开启 Http 请求参数和响应参数的日志打印开关; 开启后,在 debug 模式下会打印 http 请求和响应的 headers,body 等信息。 +在排查问题时,开启该选项,有利于问题的排查。 + +
+ BaseUrl + + client.openBaseUrl(String baseUrl) + +设置飞书项目域名,默认为https://project.feishu.cn + +
+ AccessTokenType + + client.accessTokenType(AccessTokenType accessTokenType) + +设置 plugin_token 类型,枚举值如下: + +- AccessTokenTypePlugin(插件身份凭证) +- AccessTokenTypeVirtualPlugin(虚拟plugin_token) + +
+ TokenCache + + client.tokenCache(ICache cache) + +设置 token 缓存器,用来缓存 token, 默认实现为内存。 + +如开发者想要定制 token 缓存器,需实现下面 Cache 接口: + +```java +public interface ICache { + + // 获取缓存值 + String get(String key); + + // 设置缓存值 + void set(String key, String value, int expire, TimeUnit timeUnit); +} +``` + +
+ disableTokenCache + + client.disableTokenCache() + +设置是否开启 Token 的自动获取与缓存。 + +默认开启,如需要关闭可传递 false。 +
+ requestTimeout + + client.requestTimeout(long timeout) + +设置 SDK 内置的 Http Client 的请求超时时间单位为毫秒,默认为0代表永不超时。 +
+ httpTransport + + client.httpTransport(IHttpTransport httpTransport) + +设置传输层实现,用于替换 SDK 提供的默认实现。 +开发者可通过实现下面的 IHttpTransport 接口来设置自定义的 传输实现: + +```java +public interface IHttpTransport { + + RawResponse execute(RawRequest request) throws Exception; +} + +``` + +
+ +## API调用 + +创建完毕 API Client,我们可以使用 ``Client.业务域.方法名称`` 来定位具体的 API 方法,然后对具体的 API 发起调用。 + +飞书项目开放平台开放的所有 API 列表,可点击[这里查看](https://bytedance.feishu.cn/docs/doccntEfMPoh8Qv3hDCshfRLEuY#9kPTAz) + +### 基本用法 + +如下示例我们通过 client 调用空间业务的 ListProjectWorkItemType +方法,获取空间下的工作项类型列表: + +``` java +import com.lark.project.Client; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.utils.Jsons; +import com.lark.project.service.project.builder.ListProjectWorkItemTypeReq; +import com.lark.project.service.project.builder.ListProjectWorkItemTypeResp; + +public class Sample { + + public static void main(String[] args) throws Exception { + // 构建client + Client client = Client.newBuilder("pluginID", "pluginSecret") + .openBaseUrl("https://project.feishu.cn/").build(); + // 创建请求对象 + ListProjectWorkItemTypeReq req = ListProjectWorkItemTypeReq.newBuilder() + .projectKey("project_key") + .build(); + // 发起请求 + ListProjectWorkItemTypeResp resp = client.getProjectService().listProjectWorkItemType(req, RequestOptions.newBuilder() + .userKey("user_key") + .build()); + + // 处理服务端错误 + if (!resp.success()) { + System.out.println(String.format("code:%s,msg:%s,reqId:%s" + , resp.getErrCode(), resp.getErrMsg(), resp.getRequestId())); + return; + } + + // 业务数据处理 + System.out.println(Jsons.DEFAULT.toJson(resp.getData())); + } +} + +``` + +### 设置请求选项 + +开发者在每次发起 API 调用时,可以设置请求级别的一些参数,比如传递 UserPluginAccessToken ,自定义 Headers 等: + +```java +import com.lark.project.Client; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.utils.Jsons; +import com.lark.project.core.utils.Lists; +import com.lark.project.service.project.builder.ListProjectWorkItemTypeReq; +import com.lark.project.service.project.builder.ListProjectWorkItemTypeResp; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Sample { + + public static void main(String[] args) throws Exception { + // 构建client + Client client = Client.newBuilder("pluginID", "pluginSecret") + .openBaseUrl("https://project.feishu.cn/").build(); + // 创建请求对象 + ListProjectWorkItemTypeReq req = ListProjectWorkItemTypeReq.newBuilder() + .projectKey("project_key") + .build(); + + // 创建自定义 Headers + Map> headers = new HashMap<>(); + headers.put("key1", Lists.newArrayList("value1")); + headers.put("key2", Lists.newArrayList("value2")); + + // 发起请求 + ListProjectWorkItemTypeResp resp = client.getProjectService().listProjectWorkItemType(req, RequestOptions.newBuilder() + .accessToken("user_token") // 传递用户token + .headers(headers) // 传递自定义 Headers + .build()); + + // 处理服务端错误 + if (!resp.success()) { + System.out.println(String.format("code:%s,msg:%s,reqId:%s" + , resp.getErrCode(), resp.getErrMsg(), resp.getRequestId())); + return; + } + + // 业务数据处理 + System.out.println(Jsons.DEFAULT.toJson(resp.getData())); + } +} + +``` + +如下表格,展示了所有请求级别可设置的选项: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 配置选项 + + 配置方式 + + 描述 +
+ headers + + requestOptions.headers(Map<String, List<String>> headers) + +设置自定义请求头,开发者可在发起请求时,这些请求头会被透传到飞书项目开放平台服务端。 + +
+ accessToken + + requestOptions.accessToken(String accessToken) + +设置token。 + +
+ userKey + + requestOptions.userKey(String userKey) + +设置X-USER-KEY。 + +
+ idemUUID + + requestOptions.idemUUID(String idemUUID) + +设置X-IDEM-UUID。 +
+ +## 错误自查 + +[查看错误码](https://bytedance.feishu.cn/docs/doccn3CyRRA52nL9HiYR2v9XC8K) + +## FAQ + +### project_key如何获取 + +飞书项目中双击空间名称,如下图所示 + +![img_1.png](src/main/resources/static/img_1.png) + +### user_key如何获取 + +飞书项目左下角双击个人头像,如下图所示 + +![img_2.png](src/main/resources/static/img_2.png) + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..f059dee --- /dev/null +++ b/pom.xml @@ -0,0 +1,129 @@ + + + 4.0.0 + + com.larksuite.project + oapi-sdk + 1.0.8 + + + + maven-compiler-plugin + + UTF-8 + 1.8 + 1.8 + + ${maven-compiler-plugin.version} + + + maven-resources-plugin + + UTF-8 + + ${maven-resources-plugin.version} + + + maven-source-plugin + + + + jar + + attach-sources + + + ${maven-source-plugin.version} + + + maven-surefire-plugin + + true + + org.apache.maven.plugins + ${maven-surefire-plugin.version} + + + maven-jar-plugin + + + + true + + + + org.apache.maven.plugins + ${maven-jar-plugin.version} + + + maven-javadoc-plugin + + UTF-8 + UTF-8 + none + UTF-8 + + http://docs.oracle.com/javase/8/docs/api + + public + + + + + jar + + attach-javadoc + + + org.apache.maven.plugins + ${maven-javadoc-plugin.version} + + + + + + + gson + com.google.code.gson + ${gson.version} + + + slf4j-api + org.slf4j + ${slf4j.version} + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + org.apache.httpcomponents + httpmime + ${httpclient.version} + + + + 4.5.14 + 2.9.0 + 1.7.30 + 3.8.1 + 1.6 + 3.2.0 + 3.2.0 + 2.5.3 + 2.6 + 3.0.1 + 2.12.4 + 2.7 + UTF-8 + + + + meego + https://artifacts-cn-beijing.volces.com/repository/meego/ + + + \ No newline at end of file diff --git a/src/main/java/com/lark/project/Client.java b/src/main/java/com/lark/project/Client.java new file mode 100644 index 0000000..4cc2bfc --- /dev/null +++ b/src/main/java/com/lark/project/Client.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project; + +import com.lark.project.core.Config; +import com.lark.project.core.Constants; +import com.lark.project.core.cache.ICache; +import com.lark.project.core.cache.LocalCache; +import com.lark.project.core.httpclient.HttpTransport; +import com.lark.project.core.httpclient.IHttpTransport; +import com.lark.project.core.token.AccessTokenType; +import com.lark.project.core.token.GlobalTokenManager; +import com.lark.project.core.token.TokenManager; +import com.lark.project.service.chat.ChatService; +import com.lark.project.service.chat.ChatServiceImpl; +import com.lark.project.service.comment.CommentService; +import com.lark.project.service.comment.CommentServiceImpl; +import com.lark.project.service.field.FieldService; +import com.lark.project.service.field.FieldServiceImpl; +import com.lark.project.service.measure.MeasureService; +import com.lark.project.service.measure.MeasureServiceImpl; +import com.lark.project.service.plugin.PluginService; +import com.lark.project.service.plugin.PluginServiceImpl; +import com.lark.project.service.project.ProjectService; +import com.lark.project.service.project.ProjectServiceImpl; +import com.lark.project.service.project_relation.ProjectRelationService; +import com.lark.project.service.project_relation.ProjectRelationServiceImpl; +import com.lark.project.service.role_conf.RoleConfService; +import com.lark.project.service.role_conf.RoleConfServiceImpl; +import com.lark.project.service.task.TaskService; +import com.lark.project.service.task.TaskServiceImpl; +import com.lark.project.service.user.UserService; +import com.lark.project.service.user.UserServiceImpl; +import com.lark.project.service.view.ViewService; +import com.lark.project.service.view.ViewServiceImpl; +import com.lark.project.service.workitem.WorkItemService; +import com.lark.project.service.workitem.WorkItemServiceImpl; +import com.lark.project.service.workitem_conf.WorkItemConfService; +import com.lark.project.service.workitem_conf.WorkItemConfServiceImpl; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; + + +public class Client { + + private Config config; + + private PluginService plugin; // token + + private ProjectService project; // 空间 + + private UserService user; // 用户 + + private WorkItemService workItem; // 工作项 + + private TaskService task; // 子任务 + + private ViewService view; // 视图 + + private FieldService field; // 字段 + + private ChatService chat; // 群组 + + private CommentService comment; // 评论 + + private WorkItemConfService workItemConf; // 工作项配置 + + private ProjectRelationService projectRelation; // 空间关联 + + private MeasureService measure; // 度量 + + private RoleConfService roleConf; // 角色 + + public static Builder newBuilder(String pluginId, String pluginSecret) { + return new Builder(pluginId, pluginSecret); + } + + public void setConfig(Config config) { + this.config = config; + } + + public PluginService getPluginService() { + return plugin; + } + + public ProjectService getProjectService() { + return project; + } + + public UserService getUserService() { + return user; + } + + public WorkItemService getWorkItemService() { + return workItem; + } + + public TaskService getTaskService() { + return task; + } + + public ViewService getViewService() { + return view; + } + + public FieldService getFieldService() { + return field; + } + + public ChatService getChatService() { + return chat; + } + + public CommentService getCommentService() { + return comment; + } + + public WorkItemConfService getWorkItemConfService() { + return workItemConf; + } + + public ProjectRelationService getProjectRelationService() { + return projectRelation; + } + + public MeasureService getMeasureService() { + return measure; + } + + public RoleConfService getRoleConfService() { + return roleConf; + } + + public static final class Builder { + private Config config = new Config(); + + public Builder(String pluginID, String pluginSecret) { + config.setPluginID(pluginID); + config.setPluginSecret(pluginSecret); + config.setDisableTokenCache(false); + config.setAccessTokenType(AccessTokenType.AccessTokenTypePlugin); + config.setBaseUrl(Constants.BASE_URL); + } + + public Builder disableTokenCache() { + config.setDisableTokenCache(true); + return this; + } + + public Builder logReqAtDebug(boolean logReqAtDebug) { + config.setLogReqAtDebug(logReqAtDebug); + return this; + } + + public Builder accessTokenType(AccessTokenType accessTokenType) { + config.setAccessTokenType(accessTokenType); + return this; + } + + public Builder openBaseUrl(String baseUrl) { + config.setBaseUrl(baseUrl); + return this; + } + + public Builder tokenCache(ICache cache) { + config.setCache(cache); + return this; + } + + public Builder requestTimeout(long timeout) { + config.setRequestTimeOut(timeout); + return this; + } + + public Builder httpTransport(IHttpTransport httpTransport) { + config.setHttpTransport(httpTransport); + return this; + } + + private void initCache(Config config) { + if (config.getCache() != null) { + GlobalTokenManager.setTokenManager(new TokenManager(config.getCache())); + } else { + ICache cache = LocalCache.getInstance(); + GlobalTokenManager.setTokenManager(new TokenManager(cache)); + } + } + + private void initHttpTransport(Config config) { + if (config.getHttpTransport() == null) { + if (config.getRequestTimeOut() > 0) { + HttpClientBuilder builder = HttpClientBuilder.create(); + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout((int) config.getRequestTimeOut()).build(); + builder.setDefaultRequestConfig(requestConfig); + config.setHttpTransport(new HttpTransport(builder.build())); + } else { + config.setHttpTransport(new HttpTransport(HttpClients.createDefault())); + } + } + } + + public Client build() { + Client client = new Client(); + client.setConfig(config); + initCache(config); + initHttpTransport(config); + client.plugin = new PluginServiceImpl(config); + client.project = new ProjectServiceImpl(config); + client.user = new UserServiceImpl(config); + client.workItem = new WorkItemServiceImpl(config); + client.task = new TaskServiceImpl(config); + client.view = new ViewServiceImpl(config); + client.field = new FieldServiceImpl(config); + client.comment = new CommentServiceImpl(config); + client.workItemConf = new WorkItemConfServiceImpl(config); + client.chat = new ChatServiceImpl(config); + client.projectRelation = new ProjectRelationServiceImpl(config); + client.measure = new MeasureServiceImpl(config); + client.roleConf = new RoleConfServiceImpl(config); + return client; + } + } +} + diff --git a/src/main/java/com/lark/project/core/Config.java b/src/main/java/com/lark/project/core/Config.java new file mode 100644 index 0000000..8cc2e94 --- /dev/null +++ b/src/main/java/com/lark/project/core/Config.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.core; + + +import com.lark.project.core.cache.ICache; +import com.lark.project.core.httpclient.IHttpTransport; +import com.lark.project.core.token.AccessTokenType; + +public class Config { + + private String baseUrl; + private long requestTimeOut; + private ICache cache; + private boolean disableTokenCache; + private String tokenCache; + private String pluginID; + private String pluginSecret; + private IHttpTransport httpTransport; + private boolean logReqAtDebug; + private AccessTokenType accessTokenType; + + public Config() { + } + + public IHttpTransport getHttpTransport() { + return httpTransport; + } + + public void setHttpTransport(IHttpTransport httpTransport) { + this.httpTransport = httpTransport; + } + + public boolean isLogReqAtDebug() { + return logReqAtDebug; + } + + public void setLogReqAtDebug(boolean logReqAtDebug) { + this.logReqAtDebug = logReqAtDebug; + } + + public long getRequestTimeOut() { + return requestTimeOut; + } + + public void setRequestTimeOut(long requestTimeOut) { + this.requestTimeOut = requestTimeOut; + } + + public ICache getCache() { + return cache; + } + + public void setCache(ICache cache) { + this.cache = cache; + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + public boolean isDisableTokenCache() { + return disableTokenCache; + } + + public void setDisableTokenCache(boolean disableTokenCache) { + this.disableTokenCache = disableTokenCache; + } + + public String getTokenCache() { + return tokenCache; + } + + public void setTokenCache(String tokenCache) { + this.tokenCache = tokenCache; + } + + public String getPluginID() { + return pluginID; + } + + public void setPluginID(String pluginID) { + this.pluginID = pluginID; + } + + public String getPluginSecret() { + return pluginSecret; + } + + public void setPluginSecret(String pluginSecret) { + this.pluginSecret = pluginSecret; + } + + public AccessTokenType getAccessTokenType() { + return accessTokenType; + } + + public void setAccessTokenType(AccessTokenType accessTokenType) { + this.accessTokenType = accessTokenType; + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/core/Constants.java b/src/main/java/com/lark/project/core/Constants.java new file mode 100644 index 0000000..85687a3 --- /dev/null +++ b/src/main/java/com/lark/project/core/Constants.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.core; + +public interface Constants { + + String CONTENT_DISPOSITION = "Content-Disposition"; + String CONTENT_TYPE = "Content-Type"; + String APPLICATION_JSON = "application/json"; + String JSON_CONTENT_TYPE = APPLICATION_JSON + "; charset=utf-8"; + String HTTP_HEADER_KEY_REQUEST_ID = "X-Request-Id"; + String HTTP_HEADER_KEY_LOG_ID = "X-Tt-Logid"; + + String HTTP_HEADER_USER_KEY = "X-USER-KEY"; + + String HTTP_HEADER_ACCESS_TOKEN = "X-PLUGIN-TOKEN"; + + String HTTP_HEADER_IDEM_UUID = "X-IDEM-UUID"; + String VERSION = "v1.0.0"; + + String BASE_URL = "https://project.feishu.cn"; + + +} diff --git a/src/main/java/com/lark/project/core/Transport.java b/src/main/java/com/lark/project/core/Transport.java new file mode 100644 index 0000000..814ba41 --- /dev/null +++ b/src/main/java/com/lark/project/core/Transport.java @@ -0,0 +1,94 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core; + +import com.lark.project.core.exception.ServerTimeoutException; +import com.lark.project.core.httpclient.HttpTransport; +import com.lark.project.core.httpclient.IHttpTransport; +import com.lark.project.core.request.RawRequest; +import com.lark.project.core.request.ReqTranslator; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.response.RawResponse; +import com.lark.project.core.utils.Jsons; +import org.apache.http.impl.client.HttpClients; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.charset.StandardCharsets; + +public class Transport { + + private static final Logger log = LoggerFactory.getLogger(Transport.class); + private static final ReqTranslator REQ_TRANSLATOR = new ReqTranslator(); + + private static void logReq(RawRequest req, String httpPath, boolean isUpload) { + try { + if (null == req) { + return; + } + + if (!isUpload) { + log.debug("req,path:{},header:{},body:{}", httpPath + , Jsons.DEFAULT.toJson(req.getHeaders()) + , req.getBody() == null ? "" : Jsons.DEFAULT.toJson(req.getBody())); + } else { + log.debug("req,path:{},header:{}", httpPath, req.getHeaders()); + } + } catch (Throwable e) { + log.error("logReq error:{}", e); + } + } + + public static RawResponse doSend(Config config, RequestOptions requestOptions, String httpMethod, String httpPath, boolean skipAuth, + Object req) throws Exception { + try { + // 参数转换 + RawRequest request = REQ_TRANSLATOR.translate(req, config, httpMethod, + httpPath, skipAuth, requestOptions); + + // 打印日志 + if (config.isLogReqAtDebug()) { + logReq(request, httpPath, requestOptions.isSupportUpload()); + } + + // 执行调用 + IHttpTransport httpTransport = config.getHttpTransport(); + if (httpTransport == null) { + httpTransport = new HttpTransport(HttpClients.createDefault()); + } + RawResponse rawResponse = httpTransport.execute(request); + + // 打印日志 + if (config.isLogReqAtDebug() || !skipAuth) { + if (requestOptions.isSupportDownLoad()) { + log.debug("resp,path:{},code:{},header:{}", httpPath, rawResponse.getStatusCode(), + rawResponse.getHeaders()); + } else { + log.debug("resp,path:{},code:{},header:{},body:{}", httpPath, + rawResponse.getStatusCode(), rawResponse.getHeaders(), + new String(rawResponse.getBody(), StandardCharsets.UTF_8)); + } + } + + // 服务端超时 + if (rawResponse.getStatusCode() == 504) { + log.error(String.format("httpMethod:%s,httpPath:%s, server time out,reqId:%s", httpMethod, + httpPath, rawResponse.getRequestID())); + throw new ServerTimeoutException(); + } + return rawResponse; + } catch (Exception e) { + throw e; + } + } +} diff --git a/src/main/java/com/lark/project/core/annotation/Body.java b/src/main/java/com/lark/project/core/annotation/Body.java new file mode 100644 index 0000000..648ec72 --- /dev/null +++ b/src/main/java/com/lark/project/core/annotation/Body.java @@ -0,0 +1,25 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Target({FIELD}) +@Retention(RUNTIME) +public @interface Body { + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/core/annotation/Header.java b/src/main/java/com/lark/project/core/annotation/Header.java new file mode 100644 index 0000000..158a204 --- /dev/null +++ b/src/main/java/com/lark/project/core/annotation/Header.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.core.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Target({FIELD}) +@Retention(RUNTIME) +public @interface Header { +} diff --git a/src/main/java/com/lark/project/core/annotation/Path.java b/src/main/java/com/lark/project/core/annotation/Path.java new file mode 100644 index 0000000..0480f3b --- /dev/null +++ b/src/main/java/com/lark/project/core/annotation/Path.java @@ -0,0 +1,25 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Target({FIELD}) +@Retention(RUNTIME) +public @interface Path { + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/core/annotation/Query.java b/src/main/java/com/lark/project/core/annotation/Query.java new file mode 100644 index 0000000..78e88d0 --- /dev/null +++ b/src/main/java/com/lark/project/core/annotation/Query.java @@ -0,0 +1,25 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Target({FIELD}) +@Retention(RUNTIME) +public @interface Query { + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/core/cache/ICache.java b/src/main/java/com/lark/project/core/cache/ICache.java new file mode 100644 index 0000000..5dde737 --- /dev/null +++ b/src/main/java/com/lark/project/core/cache/ICache.java @@ -0,0 +1,24 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.cache; + +import java.util.concurrent.TimeUnit; + +public interface ICache { + + // 获取缓存值 + String get(String key); + + // 设置缓存值 + void set(String key, String value, int expire, TimeUnit timeUnit); +} diff --git a/src/main/java/com/lark/project/core/cache/LocalCache.java b/src/main/java/com/lark/project/core/cache/LocalCache.java new file mode 100644 index 0000000..d9f8541 --- /dev/null +++ b/src/main/java/com/lark/project/core/cache/LocalCache.java @@ -0,0 +1,71 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.cache; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Calendar; +import java.util.Date; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; + +public class LocalCache implements ICache { + + private static final Logger log = LoggerFactory.getLogger(LocalCache.class); + private static final ConcurrentMap CACHE = new ConcurrentHashMap<>(64); + + private LocalCache() { + } + + public static LocalCache getInstance() { + return Inner.LOCAL_CACHE; + } + + @Override + public String get(String key) { + Value v = CACHE.get(key); + if (v == null || new Date().after(v.end)) { + return ""; + } + + log.debug("get key:{},time left:{}s", key, (v.end.getTime() - new Date().getTime()) / 1000); + return v.value; + } + + @Override + public void set(String key, String value, int expire, TimeUnit timeUnit) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.SECOND, (int) timeUnit.toSeconds(expire)); + Value v = new Value(value, calendar.getTime()); + log.debug("put key:{}, expire time:{} ", key, calendar.getTime()); + CACHE.put(key, v); + } + + private static class Value { + + String value; + Date end; + + public Value(String value, Date time) { + this.value = value; + this.end = time; + } + } + + private static class Inner { + + private static final LocalCache LOCAL_CACHE = new LocalCache(); + } +} diff --git a/src/main/java/com/lark/project/core/exception/AccessTokenNotGivenException.java b/src/main/java/com/lark/project/core/exception/AccessTokenNotGivenException.java new file mode 100644 index 0000000..84699ec --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/AccessTokenNotGivenException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class AccessTokenNotGivenException extends RuntimeException { + + public AccessTokenNotGivenException() { + super("Need pass an access token value"); + } +} diff --git a/src/main/java/com/lark/project/core/exception/AppTicketIsEmptyException.java b/src/main/java/com/lark/project/core/exception/AppTicketIsEmptyException.java new file mode 100644 index 0000000..9589e7e --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/AppTicketIsEmptyException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class AppTicketIsEmptyException extends RuntimeException { + + public AppTicketIsEmptyException() { + super("app ticket is empty"); + } +} diff --git a/src/main/java/com/lark/project/core/exception/ClientTimeoutException.java b/src/main/java/com/lark/project/core/exception/ClientTimeoutException.java new file mode 100644 index 0000000..ce2fc9a --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/ClientTimeoutException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class ClientTimeoutException extends RuntimeException { + + public ClientTimeoutException() { + super("client time out"); + } +} diff --git a/src/main/java/com/lark/project/core/exception/DecryptException.java b/src/main/java/com/lark/project/core/exception/DecryptException.java new file mode 100644 index 0000000..664daeb --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/DecryptException.java @@ -0,0 +1,36 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class DecryptException extends RuntimeException { + + public DecryptException() { + } + + public DecryptException(String message) { + super(message); + } + + public DecryptException(String message, Throwable cause) { + super(message, cause); + } + + public DecryptException(Throwable cause) { + super(cause); + } + + public DecryptException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/com/lark/project/core/exception/ErrConstants.java b/src/main/java/com/lark/project/core/exception/ErrConstants.java new file mode 100644 index 0000000..d0b1026 --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/ErrConstants.java @@ -0,0 +1,11 @@ +package com.lark.project.core.exception; + +public interface ErrConstants { + + String RESULT_ILLEGAL = "The result returned by the server is illegal"; + + String CONTENT_DISPOSITION_INVALID = "Invalid content disposition format"; + + String CONTENT_DISPOSITION_HEADER_EMPTY = "Content-Disposition header must not be empty"; + +} diff --git a/src/main/java/com/lark/project/core/exception/EventTypeAlreadyHasHandlerException.java b/src/main/java/com/lark/project/core/exception/EventTypeAlreadyHasHandlerException.java new file mode 100644 index 0000000..2f9d79b --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/EventTypeAlreadyHasHandlerException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class EventTypeAlreadyHasHandlerException extends RuntimeException { + + public EventTypeAlreadyHasHandlerException(String eventType) { + super(String.format("The event type of %s already has handler", eventType)); + } +} diff --git a/src/main/java/com/lark/project/core/exception/IllegalAccessTokenTypeException.java b/src/main/java/com/lark/project/core/exception/IllegalAccessTokenTypeException.java new file mode 100644 index 0000000..1de449e --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/IllegalAccessTokenTypeException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class IllegalAccessTokenTypeException extends RuntimeException { + + public IllegalAccessTokenTypeException() { + super(); + } +} diff --git a/src/main/java/com/lark/project/core/exception/IllegalHttpStatusCodeException.java b/src/main/java/com/lark/project/core/exception/IllegalHttpStatusCodeException.java new file mode 100644 index 0000000..7158744 --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/IllegalHttpStatusCodeException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class IllegalHttpStatusCodeException extends RuntimeException { + + public IllegalHttpStatusCodeException(int statusCode) { + super(String.format("The status code %s of custom response is illegal", statusCode)); + } +} diff --git a/src/main/java/com/lark/project/core/exception/IncorrectChallengeException.java b/src/main/java/com/lark/project/core/exception/IncorrectChallengeException.java new file mode 100644 index 0000000..3318ff7 --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/IncorrectChallengeException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class IncorrectChallengeException extends RuntimeException { + + public IncorrectChallengeException() { + super("The result of auth by challenge failed"); + } +} diff --git a/src/main/java/com/lark/project/core/exception/IncorrectSignatureException.java b/src/main/java/com/lark/project/core/exception/IncorrectSignatureException.java new file mode 100644 index 0000000..998a8ed --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/IncorrectSignatureException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class IncorrectSignatureException extends RuntimeException { + + public IncorrectSignatureException() { + super("The result of signature verification failed"); + } +} diff --git a/src/main/java/com/lark/project/core/exception/ObtainAccessTokenException.java b/src/main/java/com/lark/project/core/exception/ObtainAccessTokenException.java new file mode 100644 index 0000000..37e36b8 --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/ObtainAccessTokenException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class ObtainAccessTokenException extends RuntimeException { + + public ObtainAccessTokenException(String messagePrefix, String msg) { + super(messagePrefix + msg); + } +} diff --git a/src/main/java/com/lark/project/core/exception/ServerTimeoutException.java b/src/main/java/com/lark/project/core/exception/ServerTimeoutException.java new file mode 100644 index 0000000..aa42639 --- /dev/null +++ b/src/main/java/com/lark/project/core/exception/ServerTimeoutException.java @@ -0,0 +1,20 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.exception; + +public class ServerTimeoutException extends RuntimeException { + + public ServerTimeoutException() { + super("server time out"); + } +} diff --git a/src/main/java/com/lark/project/core/httpclient/HttpTransport.java b/src/main/java/com/lark/project/core/httpclient/HttpTransport.java new file mode 100644 index 0000000..471dbe1 --- /dev/null +++ b/src/main/java/com/lark/project/core/httpclient/HttpTransport.java @@ -0,0 +1,99 @@ +package com.lark.project.core.httpclient; + +import com.lark.project.core.request.FormData; +import com.lark.project.core.request.FormDataFile; +import com.lark.project.core.request.RawRequest; +import com.lark.project.core.response.RawResponse; +import com.lark.project.core.utils.IOs; +import com.lark.project.core.utils.Jsons; +import com.lark.project.core.utils.Strings; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.RequestBuilder; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.util.EntityUtils; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class HttpTransport implements IHttpTransport { + + private HttpClient httpClient; + + public HttpTransport(HttpClient httpClient) { + this.httpClient = httpClient; + } + + private HttpEntity buildHttpEntity(RawRequest request) throws UnsupportedEncodingException { + if (request == null || request.getBody() == null) { + return null; + } + + Object body = request.getBody(); + if (body instanceof FormData) { + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + for (Map.Entry entry : ((FormData) body).getParams().entrySet()) { + builder.addTextBody(entry.getKey(), entry.getValue().toString()); + } + for (FormDataFile file : ((FormData) body).getFiles()) { + final File uploadFile = file.getFile(); + builder.addBinaryBody(file.getFieldName(), uploadFile, ContentType.APPLICATION_OCTET_STREAM, Strings.isEmpty(file.getFileName()) ? "unknown" : file.getFileName()); + } + return builder.build(); + } + return new StringEntity(Jsons.DEFAULT.toJson(request.getBody())); + } + + private Map> convertRespHeader(Header[] allHeaders) { + Map> respHeaders = new HashMap<>(); + for (int i = 0; i < allHeaders.length; i++) { + String name = allHeaders[i].getName(); + String value = allHeaders[i].getValue(); + List values = respHeaders.get(name); + if (values == null) { + values = new ArrayList<>(); + respHeaders.put(name, values); + } + values.add(value); + } + return respHeaders; + } + + @Override + public RawResponse execute(RawRequest request) throws Exception { + RequestBuilder requestBuilder = RequestBuilder.create(request.getHttpMethod()).setUri(request.getReqUrl()). + setEntity(buildHttpEntity(request)); + // 设置请求header + for (Map.Entry> entry : request.getHeaders().entrySet()) { + for (String value : entry.getValue()) { + requestBuilder.setHeader(entry.getKey(), value); + } + } + + if (!(request.getBody() instanceof FormData)) { + requestBuilder.setHeader("content-type", "application/json; charset=utf-8"); + } + HttpResponse httpResponse = httpClient.execute(requestBuilder.build()); + RawResponse rawResponse = new RawResponse(); + rawResponse.setStatusCode(httpResponse.getStatusLine().getStatusCode()); + rawResponse.setHeaders(convertRespHeader(httpResponse.getAllHeaders())); + + HttpEntity entity = httpResponse.getEntity(); + if (entity != null) { + if (request.isSupportDownLoad()) { + rawResponse.setBody(IOs.readAll(entity.getContent())); + } else { + rawResponse.setBody(EntityUtils.toByteArray(entity)); + } + } + return rawResponse; + } +} diff --git a/src/main/java/com/lark/project/core/httpclient/IHttpTransport.java b/src/main/java/com/lark/project/core/httpclient/IHttpTransport.java new file mode 100644 index 0000000..d1cbc30 --- /dev/null +++ b/src/main/java/com/lark/project/core/httpclient/IHttpTransport.java @@ -0,0 +1,21 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.httpclient; + +import com.lark.project.core.request.RawRequest; +import com.lark.project.core.response.RawResponse; + +public interface IHttpTransport { + + RawResponse execute(RawRequest request) throws Exception; +} diff --git a/src/main/java/com/lark/project/core/request/BaseRequest.java b/src/main/java/com/lark/project/core/request/BaseRequest.java new file mode 100644 index 0000000..3e148c8 --- /dev/null +++ b/src/main/java/com/lark/project/core/request/BaseRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.core.request; + +import java.util.List; +import java.util.Map; + +public class BaseRequest { + + private Map> headers; + + public Map> getHeaders() { + return headers; + } + + public void setHeaders(Map> headers) { + this.headers = headers; + } +} diff --git a/src/main/java/com/lark/project/core/request/EventReq.java b/src/main/java/com/lark/project/core/request/EventReq.java new file mode 100644 index 0000000..6463aaa --- /dev/null +++ b/src/main/java/com/lark/project/core/request/EventReq.java @@ -0,0 +1,73 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.request; + + +import com.lark.project.core.Constants; +import com.lark.project.core.utils.Strings; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class EventReq { + + private byte[] body; + private String httpPath; + private Map> headers = new HashMap(); + + public String getHttpPath() { + return httpPath; + } + + public void setHttpPath(String httpPath) { + this.httpPath = httpPath; + } + + public byte[] getBody() { + return body; + } + + public void setBody(byte[] body) { + this.body = body; + } + + public Map> getHeaders() { + return headers; + } + + public void setHeaders(Map> headers) { + this.headers = headers; + } + + private String normalizeKey(String name) { + return name != null ? name.toLowerCase() : null; + } + + public String getHeaderFirstValue(String name) { + List values = this.headers.get(normalizeKey(name)); + if (values != null && values.size() > 0) { + return values.get(0); + } else { + return ""; + } + } + + public String getRequestID() { + String logID = getHeaderFirstValue(Constants.HTTP_HEADER_KEY_LOG_ID); + if (!Strings.isEmpty(logID)) { + return logID; + } + return getHeaderFirstValue(Constants.HTTP_HEADER_KEY_REQUEST_ID); + } +} diff --git a/src/main/java/com/lark/project/core/request/FormData.java b/src/main/java/com/lark/project/core/request/FormData.java new file mode 100644 index 0000000..fe1d08b --- /dev/null +++ b/src/main/java/com/lark/project/core/request/FormData.java @@ -0,0 +1,55 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.request; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class FormData { + + private final Map params; + private final List files; + + public FormData() { + this.params = new HashMap<>(); + this.files = new ArrayList<>(); + } + + public Map getParams() { + return params; + } + + public List getFiles() { + return files; + } + + public void addFile(String field, FormDataFile file) { + file.setFieldName(field); + this.files.add(file); + } + + public void addFile(String field, File file) { + FormDataFile formDataFile = new FormDataFile(); + formDataFile.setFileName(field); + formDataFile.setFile(file); + this.files.add(formDataFile); + } + + public void addField(String field, Object val) { + this.params.put(field, val); + } + +} diff --git a/src/main/java/com/lark/project/core/request/FormDataFile.java b/src/main/java/com/lark/project/core/request/FormDataFile.java new file mode 100644 index 0000000..382b03d --- /dev/null +++ b/src/main/java/com/lark/project/core/request/FormDataFile.java @@ -0,0 +1,60 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.request; + + +import java.io.File; + +public class FormDataFile { + + private String fieldName; + private String fileName; + private String type; + private File file; + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getFileName() { + return fileName; + } + + public FormDataFile setFileName(String name) { + this.fileName = name; + return this; + } + + public String getType() { + return type; + } + + public FormDataFile setType(String type) { + this.type = type; + return this; + } + + +} diff --git a/src/main/java/com/lark/project/core/request/RawRequest.java b/src/main/java/com/lark/project/core/request/RawRequest.java new file mode 100644 index 0000000..8d4512a --- /dev/null +++ b/src/main/java/com/lark/project/core/request/RawRequest.java @@ -0,0 +1,106 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.request; + + +import com.lark.project.core.Config; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RawRequest { + + private int statusCode; + private String contentType; + private Map> headers = new HashMap<>(); + private Object body; + private String reqUrl; + private String httpMethod; + private Config config; + private boolean supportDownLoad; + private boolean supportLong2String; + + public boolean isSupportLong2String() { + return supportLong2String; + } + + public void setSupportLong2String(boolean supportLong2String) { + this.supportLong2String = supportLong2String; + } + + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public Map> getHeaders() { + return headers; + } + + public void setHeaders(Map> headers) { + this.headers = headers; + } + + public Object getBody() { + return body; + } + + public void setBody(Object body) { + this.body = body; + } + + public String getReqUrl() { + return reqUrl; + } + + public void setReqUrl(String reqUrl) { + this.reqUrl = reqUrl; + } + + public String getHttpMethod() { + return httpMethod; + } + + public void setHttpMethod(String httpMethod) { + this.httpMethod = httpMethod; + } + + public Config getConfig() { + return config; + } + + public void setConfig(Config config) { + this.config = config; + } + + public boolean isSupportDownLoad() { + return supportDownLoad; + } + + public void setSupportDownLoad(boolean supportDownLoad) { + this.supportDownLoad = supportDownLoad; + } +} + diff --git a/src/main/java/com/lark/project/core/request/ReqTranslator.java b/src/main/java/com/lark/project/core/request/ReqTranslator.java new file mode 100644 index 0000000..65fe2ca --- /dev/null +++ b/src/main/java/com/lark/project/core/request/ReqTranslator.java @@ -0,0 +1,253 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.request; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.Config; +import com.lark.project.core.Constants; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; +import com.lark.project.core.annotation.Query; +import com.lark.project.core.token.GlobalTokenManager; +import com.lark.project.core.utils.Lists; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.*; + +public class ReqTranslator { + + private static String encode(String value) { + try { + return URLEncoder.encode(value, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + // won't happen + } + return ""; + } + + public RawRequest translate(Object req + , Config config, String httpMethod, String httpPath + , boolean skipAuth, RequestOptions requestOptions) throws Exception { + + // 解析path,query,body 参数 + ParsedReq parsedReq = parseInput(req, requestOptions); + + // 拼接URL + String reqUrl = getFullReqUrl(config.getBaseUrl(), httpPath, parsedReq.pathMap, + parsedReq.queryMap); + + // headers + Map> headers = requestOptions.getHeaders(); + if (headers == null) { + headers = new HashMap<>(); + } + + headers.put("User-Agent", Lists.newArrayList("oapi-sdk-java/" + Constants.VERSION)); + + + // 获取并缓存token + if (!skipAuth) { + List values = headers.get(Constants.HTTP_HEADER_ACCESS_TOKEN); + if (!config.isDisableTokenCache() && values == null) { + headers.put("X-PLUGIN-TOKEN", Lists.newArrayList(GlobalTokenManager.getTokenManager() + .getAccessTokenThenCache(config))); + } + } + + RawRequest rawRequest = new RawRequest(); + rawRequest.setBody(parsedReq.body); + rawRequest.setReqUrl(reqUrl); + rawRequest.setHeaders(headers); + rawRequest.setHttpMethod(httpMethod); + rawRequest.setConfig(config); + rawRequest.setSupportDownLoad(requestOptions.isSupportUpload()); + return rawRequest; + } + + private ParsedReq parseInput(Object req, RequestOptions requestOptions) + throws IllegalAccessException { + // 解析 path,body,query注解 + ParsedReq parsedReq = new ParsedReq(); + if (req == null) { + return parsedReq; + } + Field[] fields = req.getClass().getDeclaredFields(); + boolean hasHttpAnnotation = false; + if (fields != null) { + for (Field field : fields) { + // 解析body注解 + field.setAccessible(true); + Body body = field.getAnnotation(Body.class); + if (body != null) { + hasHttpAnnotation = true; + parsedReq.body = field.get(req); + } + + // 解析Path注解 + Path path = field.getAnnotation(Path.class); + if (path != null) { + hasHttpAnnotation = true; + SerializedName serializedName = field.getAnnotation(SerializedName.class); + if (null != field.get(req)) { + parsedReq.pathMap.put(serializedName.value(), field.get(req)); + } + } + + // 解析Query注解 + Query query = field.getAnnotation(Query.class); + if (query != null) { + hasHttpAnnotation = true; + SerializedName serializedName = field.getAnnotation(SerializedName.class); + if (null != field.get(req)) { + parsedReq.queryMap.put(serializedName.value(), field.get(req)); + } + } + } + } + + if (!hasHttpAnnotation) { + parsedReq.body = req; + } + + if (parsedReq.body != null) { + if (requestOptions.isSupportUpload()) { + parsedReq.body = buildFormData(parsedReq.body); + } + } + + return parsedReq; + } + + private FormData buildFormData(Object body) throws IllegalAccessException { + // 构建form-data格式的数据 + FormData formData = new FormData(); + Field[] fields = body.getClass().getDeclaredFields(); + if (fields != null) { + for (Field field : fields) { + field.setAccessible(true); + if (field.getType() == File.class) { + SerializedName serializedName = field.getAnnotation(SerializedName.class); + FormDataFile formDataFile = new FormDataFile(); + formDataFile.setFile((File) field.get(body)); + formDataFile.setFieldName(serializedName.value().trim()); + formData.addFile(serializedName.value().trim(), formDataFile); + } else { + SerializedName serializedName = field.getAnnotation(SerializedName.class); + if (serializedName != null && field.get(body) != null) { + formData.addField(serializedName.value().trim(), field.get(body)); + } + } + } + } + + return formData; + } + + private String getFullReqUrl(String domain, String httpPath, Map pathMap, + Map queryMap) { + String reqUrl = joinPathParam(httpPath, pathMap); + if (!reqUrl.startsWith("http")) { + reqUrl = domain + reqUrl; + } + + if (queryMap.size() > 0) { + reqUrl += "?" + this.buildQuery(queryMap); + } + + return reqUrl; + } + + private String joinPathParam(String path, Map pathMap) { + if (pathMap.size() == 0) { + return path; + } + String tmpPath = path; + StringBuilder newPath = new StringBuilder(); + for (; true; ) { + int i = tmpPath.indexOf(":"); + if (i == -1) { + newPath.append(tmpPath); + break; + } + newPath.append(tmpPath, 0, i); + String subPath = tmpPath.substring(i); + int j = subPath.indexOf("/"); + if (j == -1) { + j = subPath.length(); + } + String varName = subPath.substring(1, j); + if (varName.equals("")) { + newPath.append(subPath.substring(0, j)); + } else { + Object v = pathMap.get(varName); + if (v == null) { + throw new IllegalArgumentException( + "path:" + path + ", param name:" + varName + " not found value"); + } + newPath.append(v.toString()); + } + if (j == subPath.length()) { + break; + } + tmpPath = subPath.substring(j); + } + return newPath.toString(); + } + + private String buildQuery(Map params) { + if (params == null || params.isEmpty()) { + return ""; + } + Set> entries = params.entrySet(); + List list = new ArrayList<>(); + for (Map.Entry entry : entries) { + String name = entry.getKey(); + Object value = entry.getValue(); + if (value == null) { + continue; + } + if (value instanceof List) { + for (Object o : (List) value) { + list.add(name + "=" + encode(o.toString())); + } + } else if (value.getClass().isArray()) { + int len = Array.getLength(value); + for (int i = 0; i < len; i++) { + list.add(name + "=" + encode(Array.get(value, i).toString())); + } + } else { + list.add(name + "=" + encode(value.toString())); + } + } + if (list.isEmpty()) { + return ""; + } + StringBuilder query = new StringBuilder(); + for (String s : list) { + query.append(s).append("&"); + } + return query.deleteCharAt(query.length() - 1).toString(); + } + + private class ParsedReq { + private HashMap pathMap = new HashMap<>(); + private HashMap queryMap = new HashMap<>(); + private Object body; + } + +} diff --git a/src/main/java/com/lark/project/core/request/RequestOptions.java b/src/main/java/com/lark/project/core/request/RequestOptions.java new file mode 100644 index 0000000..ab5ac76 --- /dev/null +++ b/src/main/java/com/lark/project/core/request/RequestOptions.java @@ -0,0 +1,124 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.request; + +import com.lark.project.core.Constants; +import com.lark.project.core.utils.Lists; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RequestOptions { + private boolean supportUpload; + + private boolean supportDownLoad; + + private Map> headers; + + public RequestOptions() { + this.headers = new HashMap<>(); + } + + public RequestOptions(Builder builder) { + this.supportDownLoad = builder.supportDownLoad; + this.supportUpload = builder.supportUpload; + this.headers = builder.headers; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public boolean isSupportUpload() { + return supportUpload; + } + + public void setSupportUpload(boolean supportUpload) { + this.supportUpload = supportUpload; + } + + public boolean isSupportDownLoad() { + return supportDownLoad; + } + + public void setSupportDownLoad(boolean supportDownLoad) { + this.supportDownLoad = supportDownLoad; + } + + public Map> getHeaders() { + return headers; + } + + public void setHeaders(Map> headers) { + this.headers = headers; + } + + public static final class Builder { + + private boolean supportUpload; + private boolean supportDownLoad; + private Map> headers; + + private Builder() { + headers = new HashMap<>(); + } + + public Builder headers(Map> headers) { + if (headers != null) { + for (Map.Entry> header : headers.entrySet()) { + List values = this.headers.get(header.getKey()); + if (values == null) { + values = new ArrayList<>(); + this.headers.put(header.getKey(), values); + } + for (String value : header.getValue()) { + values.add(value); + } + } + } + return this; + } + + public Builder userKey(String userKey) { + headers.put(Constants.HTTP_HEADER_USER_KEY, Lists.newArrayList(userKey)); + return this; + } + + public Builder accessToken(String accessToken) { + headers.put(Constants.HTTP_HEADER_ACCESS_TOKEN, Lists.newArrayList(accessToken)); + return this; + } + + public Builder idemUUID(String idemUUID) { + headers.put(Constants.HTTP_HEADER_IDEM_UUID, Lists.newArrayList(idemUUID)); + return this; + } + + public Builder supportUpload() { + this.supportUpload = true; + return this; + } + + public Builder supportDownLoad() { + this.supportDownLoad = true; + return this; + } + + public RequestOptions build() { + return new RequestOptions(this); + } + } + +} diff --git a/src/main/java/com/lark/project/core/response/BaseResponse.java b/src/main/java/com/lark/project/core/response/BaseResponse.java new file mode 100644 index 0000000..8403bb7 --- /dev/null +++ b/src/main/java/com/lark/project/core/response/BaseResponse.java @@ -0,0 +1,86 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.response; + + +import com.google.gson.annotations.SerializedName; + +public class BaseResponse { + + private RawResponse rawResponse; + private Object request; + + @SerializedName("err") + private Err err; + @SerializedName("err_code") + private int errCode; + @SerializedName("err_msg") + private String errMsg; + + + public BaseResponse() { + } + + public Object getRequest() { + return request; + } + + public void setRequest(Object request) { + this.request = request; + } + + + public Err getErr() { + return err; + } + + public void setErr(Err err) { + this.err = err; + } + + public RawResponse getRawResponse() { + return rawResponse; + } + + public void setRawResponse(RawResponse rawResponse) { + this.rawResponse = rawResponse; + } + + public String getRequestId() { + if (rawResponse != null) { + return rawResponse.getRequestID(); + } + return ""; + } + + public int getErrCode() { + return errCode; + } + + public void setErrCode(int errCode) { + this.errCode = errCode; + } + + public String getErrMsg() { + return errMsg; + } + + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; + } + + public boolean success() { + return errCode == 0; + } + +} diff --git a/src/main/java/com/lark/project/core/response/Err.java b/src/main/java/com/lark/project/core/response/Err.java new file mode 100644 index 0000000..d287ffd --- /dev/null +++ b/src/main/java/com/lark/project/core/response/Err.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.core.response; + +public class Err { + + private int code; + + private String msg; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + +} diff --git a/src/main/java/com/lark/project/core/response/GetAccessTokenResp.java b/src/main/java/com/lark/project/core/response/GetAccessTokenResp.java new file mode 100644 index 0000000..0e60452 --- /dev/null +++ b/src/main/java/com/lark/project/core/response/GetAccessTokenResp.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.core.response; + +import com.google.gson.annotations.SerializedName; + +public class GetAccessTokenResp extends BaseResponse { + + @SerializedName("expire_time") + private int expireTime; + @SerializedName("token") + private String token; + + public int getExpireTime() { + return expireTime; + } + + public void setExpireTime(int expireTime) { + this.expireTime = expireTime; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } +} diff --git a/src/main/java/com/lark/project/core/response/RawResponse.java b/src/main/java/com/lark/project/core/response/RawResponse.java new file mode 100644 index 0000000..70e61d4 --- /dev/null +++ b/src/main/java/com/lark/project/core/response/RawResponse.java @@ -0,0 +1,91 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.response; + +import com.lark.project.core.Constants; +import com.lark.project.core.utils.FileNameParser; +import com.lark.project.core.utils.Strings; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RawResponse { + + private int statusCode; + private String contentType; + private Map> headers = new HashMap<>(); + private byte[] body; + + public RawResponse() { + } + + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + List ct = new ArrayList<>(); + ct.add(contentType); + this.headers.put(Constants.CONTENT_TYPE, ct); + } + + public Map> getHeaders() { + return headers; + } + + public void setHeaders(Map> headers) { + this.headers = headers; + } + + public byte[] getBody() { + return body; + } + + public void setBody(byte[] body) { + this.body = body; + } + + private String getHeaderFirstValue(String name) { + List values = this.headers.get(name); + if (values != null && values.size() > 0) { + return values.get(0); + } else { + return ""; + } + } + + public String getRequestID() { + String logID = getHeaderFirstValue(Constants.HTTP_HEADER_KEY_LOG_ID); + if (!Strings.isEmpty(logID)) { + return logID; + } + return getHeaderFirstValue(Constants.HTTP_HEADER_KEY_REQUEST_ID); + } + + public String getFileName() { + String contentDisposition = getHeaderFirstValue(Constants.CONTENT_DISPOSITION); + return FileNameParser.parseFileName(contentDisposition); + } + +} diff --git a/src/main/java/com/lark/project/core/token/AccessTokenType.java b/src/main/java/com/lark/project/core/token/AccessTokenType.java new file mode 100644 index 0000000..d236807 --- /dev/null +++ b/src/main/java/com/lark/project/core/token/AccessTokenType.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.core.token; + +public enum AccessTokenType { + + AccessTokenTypePlugin(0), + + AccessTokenTypeVirtualPlugin(1), + + AccessTokenTypeUserPlugin(0);; + + private final int value; + + AccessTokenType(int value) { + this.value = value; + } + + + public int getValue() { + return value; + } +} diff --git a/src/main/java/com/lark/project/core/token/GlobalTokenManager.java b/src/main/java/com/lark/project/core/token/GlobalTokenManager.java new file mode 100644 index 0000000..5487c70 --- /dev/null +++ b/src/main/java/com/lark/project/core/token/GlobalTokenManager.java @@ -0,0 +1,31 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.token; + + +import com.lark.project.core.cache.LocalCache; + +public class GlobalTokenManager { + + private static volatile TokenManager globalTokenManager = new TokenManager( + LocalCache.getInstance()); + + public static TokenManager getTokenManager() { + return globalTokenManager; + } + + public static void setTokenManager(TokenManager tokenManager) { + globalTokenManager = tokenManager; + } + +} diff --git a/src/main/java/com/lark/project/core/token/TokenManager.java b/src/main/java/com/lark/project/core/token/TokenManager.java new file mode 100644 index 0000000..3f8d4d8 --- /dev/null +++ b/src/main/java/com/lark/project/core/token/TokenManager.java @@ -0,0 +1,85 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.token; + +import com.lark.project.core.Config; +import com.lark.project.core.Transport; +import com.lark.project.core.cache.ICache; +import com.lark.project.core.exception.ErrConstants; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.response.GetAccessTokenResp; +import com.lark.project.core.response.RawResponse; +import com.lark.project.core.utils.Logs; +import com.lark.project.core.utils.Strings; +import com.lark.project.core.utils.UnmarshalRespUtil; +import com.lark.project.service.plugin.builder.GetPluginTokenReq; +import com.lark.project.service.plugin.builder.GetPluginTokenResp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class TokenManager { + + private static final Logger log = LoggerFactory.getLogger(TokenManager.class); + private static final int EXPIRY_DELTA_OF_SECOND = 3 * 60; + private static final String ACCESS_TOKEN_KEY_PREFIX = "access_token"; + + private ICache cache; + + public TokenManager(ICache cache) { + this.cache = cache; + } + + private String getAccessTokenKey(String pluginID) { + return String.format("%s-%s", ACCESS_TOKEN_KEY_PREFIX, pluginID); + } + + public String getAccessTokenThenCache(Config config) throws Exception { + String token = cache.get(getAccessTokenKey(config.getPluginID())); + if (Strings.isNotEmpty(token)) { + return token; + } + + GetAccessTokenResp resp = getInternalAccessToken(config, config.getAccessTokenType().getValue()); + token = resp.getToken(); + int timeOut = resp.getExpireTime(); + cache.set(getAccessTokenKey(config.getPluginID()), token, timeOut - EXPIRY_DELTA_OF_SECOND, + TimeUnit.SECONDS); + return token; + } + + public GetAccessTokenResp getInternalAccessToken(Config config, int type) throws Exception { + + GetPluginTokenReq req = GetPluginTokenReq.newBuilder() + .pluginID(config.getPluginID()) + .pluginSecret(config.getPluginSecret()) + .type(type) + .build(); + RawResponse httpResponse = Transport.doSend(config, new RequestOptions(), "POST" + , "/open_api/authen/plugin_token" + , true + , req); + + GetPluginTokenResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, GetPluginTokenResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/authen/plugin_token")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + GetAccessTokenResp getAccessTokenResp = new GetAccessTokenResp(); + getAccessTokenResp.setToken(resp.getData().getToken()); + getAccessTokenResp.setExpireTime(resp.getData().getExpireTime()); + return getAccessTokenResp; + } + +} diff --git a/src/main/java/com/lark/project/core/utils/FileNameParser.java b/src/main/java/com/lark/project/core/utils/FileNameParser.java new file mode 100644 index 0000000..fd455a0 --- /dev/null +++ b/src/main/java/com/lark/project/core/utils/FileNameParser.java @@ -0,0 +1,200 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.utils; + +import com.lark.project.core.exception.ErrConstants; + +import java.io.ByteArrayOutputStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.Base64; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class FileNameParser { + + private static final Pattern BASE64_ENCODED_PATTERN = Pattern.compile( + "=\\?([0-9a-zA-Z-_]+)\\?B\\?([+/0-9a-zA-Z]+=*)\\?="); + + public static String parseFileName(String contentDisposition) { + if (Strings.isEmpty(contentDisposition)) { + return ""; + } + List parts = tokenize(contentDisposition); + String type = (String) parts.get(0); + String name = null; + String filename = null; + Charset charset = null; + Long size = null; + ZonedDateTime creationDate = null; + ZonedDateTime modificationDate = null; + ZonedDateTime readDate = null; + + for (int i = 1; i < parts.size(); ++i) { + String part = (String) parts.get(i); + int eqIndex = part.indexOf(61); + if (eqIndex == -1) { + throw new IllegalArgumentException(ErrConstants.CONTENT_DISPOSITION_INVALID); + } + + String attribute = part.substring(0, eqIndex); + String value = + part.startsWith("\"", eqIndex + 1) && part.endsWith("\"") ? part.substring(eqIndex + 2, + part.length() - 1) : part.substring(eqIndex + 1); + if (attribute.equals("name")) { + name = value; + } else if (!attribute.equals("filename*")) { + if (attribute.equals("filename") && filename == null) { + if (value.startsWith("=?")) { + Matcher matcher = BASE64_ENCODED_PATTERN.matcher(value); + if (matcher.find()) { + String match1 = matcher.group(1); + String match2 = matcher.group(2); + filename = new String(Base64.getDecoder().decode(match2), Charset.forName(match1)); + } else { + filename = value; + } + } else { + filename = value; + } + } else if (attribute.equals("size")) { + size = Long.parseLong(value); + } else if (attribute.equals("creation-date")) { + try { + creationDate = ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME); + } catch (DateTimeParseException var20) { + } + } else if (attribute.equals("modification-date")) { + try { + modificationDate = ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME); + } catch (DateTimeParseException var19) { + } + } else if (attribute.equals("read-date")) { + try { + readDate = ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME); + } catch (DateTimeParseException var18) { + } + } + } else { + int idx1 = value.indexOf(39); + int idx2 = value.indexOf(39, idx1 + 1); + if (idx1 != -1 && idx2 != -1) { + charset = Charset.forName(value.substring(0, idx1).trim()); + // Assert.isTrue(StandardCharsets.UTF_8.equals(charset) || StandardCharsets.ISO_8859_1.equals(charset), "Charset should be UTF-8 or ISO-8859-1"); + filename = decodeFilename(value.substring(idx2 + 1), charset); + } else { + filename = decodeFilename(value, StandardCharsets.US_ASCII); + } + } + } + + return filename; + + } + + private static List tokenize(String headerValue) { + int index = headerValue.indexOf(59); + String type = (index >= 0 ? headerValue.substring(0, index) : headerValue).trim(); + if (type.isEmpty()) { + throw new IllegalArgumentException(ErrConstants.CONTENT_DISPOSITION_HEADER_EMPTY); + } else { + List parts = new ArrayList(); + parts.add(type); + int nextIndex; + if (index >= 0) { + do { + nextIndex = index + 1; + boolean quoted = false; + + for (boolean escaped = false; nextIndex < headerValue.length(); ++nextIndex) { + char ch = headerValue.charAt(nextIndex); + if (ch == ';') { + if (!quoted) { + break; + } + } else if (!escaped && ch == '"') { + quoted = !quoted; + } + + escaped = !escaped && ch == '\\'; + } + + String part = headerValue.substring(index + 1, nextIndex).trim(); + if (!part.isEmpty()) { + parts.add(part); + } + + index = nextIndex; + } while (nextIndex < headerValue.length()); + } + + return parts; + } + } + + private static String decodeFilename(String filename, Charset charset) { + byte[] value = filename.getBytes(charset); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int index = 0; + + while (true) { + while (index < value.length) { + byte b = value[index]; + if (!isRFC5987AttrChar(b)) { + if (b != 37 || index >= value.length - 2) { + throw new IllegalArgumentException( + "Invalid header field parameter format (as defined in RFC 5987)"); + } + + char[] array = new char[]{(char) value[index + 1], (char) value[index + 2]}; + + try { + baos.write(Integer.parseInt(String.valueOf(array), 16)); + } catch (NumberFormatException var8) { + throw new IllegalArgumentException( + "Invalid header field parameter format (as defined in RFC 5987)", var8); + } + + index += 3; + } else { + baos.write((char) b); + ++index; + } + } + + return copyToString(baos, charset); + } + } + + public static String copyToString(ByteArrayOutputStream baos, Charset charset) { + + try { + return baos.toString(charset.name()); + } catch (UnsupportedEncodingException var3) { + throw new IllegalArgumentException("Invalid charset name: " + charset, var3); + } + } + + private static boolean isRFC5987AttrChar(byte c) { + return c >= 48 && c <= 57 || c >= 97 && c <= 122 || c >= 65 && c <= 90 || c == 33 || c == 35 + || c == 36 || c == 38 || c == 43 || c == 45 || c == 46 || c == 94 || c == 95 || c == 96 + || c == 124 || c == 126; + } + +} diff --git a/src/main/java/com/lark/project/core/utils/IOs.java b/src/main/java/com/lark/project/core/utils/IOs.java new file mode 100644 index 0000000..66ca42f --- /dev/null +++ b/src/main/java/com/lark/project/core/utils/IOs.java @@ -0,0 +1,39 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.utils; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public class IOs { + + public static void copy(InputStream input, OutputStream output) throws IOException { + byte[] bs = new byte[4096]; + while (true) { + int c = input.read(bs); + if (c == -1) { + break; + } + output.write(bs, 0, c); + } + } + + public static byte[] readAll(InputStream input) throws IOException { + try (ByteArrayOutputStream bos = new ByteArrayOutputStream();) { + copy(input, bos); + return bos.toByteArray(); + } + } +} diff --git a/src/main/java/com/lark/project/core/utils/Jsons.java b/src/main/java/com/lark/project/core/utils/Jsons.java new file mode 100644 index 0000000..d752130 --- /dev/null +++ b/src/main/java/com/lark/project/core/utils/Jsons.java @@ -0,0 +1,35 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.utils; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.LongSerializationPolicy; + +public class Jsons { + + public static final Gson LONG_TO_STR = createGSON(false, true); + public static final Gson DEFAULT = createGSON(false, false); + + public static Gson createGSON(boolean isPretty, boolean longToStr) { + GsonBuilder gsonBuilder = new GsonBuilder(); + if (longToStr) { + gsonBuilder.setLongSerializationPolicy(LongSerializationPolicy.STRING); + } + if (isPretty) { + gsonBuilder.setPrettyPrinting(); + } + gsonBuilder.disableHtmlEscaping(); + return gsonBuilder.create(); + } +} diff --git a/src/main/java/com/lark/project/core/utils/Lists.java b/src/main/java/com/lark/project/core/utils/Lists.java new file mode 100644 index 0000000..8b251f9 --- /dev/null +++ b/src/main/java/com/lark/project/core/utils/Lists.java @@ -0,0 +1,31 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.utils; + + +import java.util.ArrayList; +import java.util.Collections; + +public class Lists { + + public static ArrayList newArrayList() { + return new ArrayList(); + } + + public static ArrayList newArrayList(E... elements) { + int capacity = elements.length * 110 / 100 + 5; + ArrayList list = new ArrayList(capacity); + Collections.addAll(list, elements); + return list; + } +} diff --git a/src/main/java/com/lark/project/core/utils/Logs.java b/src/main/java/com/lark/project/core/utils/Logs.java new file mode 100644 index 0000000..832cf0a --- /dev/null +++ b/src/main/java/com/lark/project/core/utils/Logs.java @@ -0,0 +1,16 @@ +package com.lark.project.core.utils; + +import com.lark.project.core.response.RawResponse; + +import java.nio.charset.StandardCharsets; + +public class Logs { + + public static String formatReq(Object req, RawResponse httpResponse, String path) { + return String.format( + "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", path + , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), + httpResponse.getStatusCode(), new String(httpResponse.getBody(), + StandardCharsets.UTF_8)); + } +} diff --git a/src/main/java/com/lark/project/core/utils/Sets.java b/src/main/java/com/lark/project/core/utils/Sets.java new file mode 100644 index 0000000..3f52aaa --- /dev/null +++ b/src/main/java/com/lark/project/core/utils/Sets.java @@ -0,0 +1,43 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.utils; + +import java.util.Collections; +import java.util.HashSet; +import java.util.SortedSet; +import java.util.TreeSet; + +public class Sets { + + public static HashSet newHashSet() { + return new HashSet(); + } + + public static HashSet newHashSet(E... elements) { + int capacity = elements.length * 4 / 3 + 1; + HashSet set = new HashSet(capacity); + Collections.addAll(set, elements); + return set; + } + + public static SortedSet newSortedSet() { + return new TreeSet(); + } + + public static SortedSet newSortedSet(E... elements) { + SortedSet set = new TreeSet(); + Collections.addAll(set, elements); + return set; + } + +} diff --git a/src/main/java/com/lark/project/core/utils/Strings.java b/src/main/java/com/lark/project/core/utils/Strings.java new file mode 100644 index 0000000..bf1d049 --- /dev/null +++ b/src/main/java/com/lark/project/core/utils/Strings.java @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.utils; + +public class Strings { + + public static boolean isNotEmpty(String value) { + return !isEmpty(value); + } + + public static boolean isEmpty(String value) { + int strLen; + if (value == null || (strLen = value.length()) == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if ((!Character.isWhitespace(value.charAt(i)))) { + return false; + } + } + return true; + } +} diff --git a/src/main/java/com/lark/project/core/utils/UnmarshalRespUtil.java b/src/main/java/com/lark/project/core/utils/UnmarshalRespUtil.java new file mode 100644 index 0000000..61494f4 --- /dev/null +++ b/src/main/java/com/lark/project/core/utils/UnmarshalRespUtil.java @@ -0,0 +1,26 @@ +/* + * MIT License + * + * Copyright (c) 2022 Lark Technologies Pte. Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.lark.project.core.utils; + +import com.lark.project.core.response.RawResponse; + +import java.nio.charset.StandardCharsets; + +public class UnmarshalRespUtil { + + public static T unmarshalResp(RawResponse resp, Class respClass) { + String body = new String(resp.getBody(), StandardCharsets.UTF_8); + return Jsons.DEFAULT.fromJson(body, + respClass); + } +} diff --git a/src/main/java/com/lark/project/sample/Sample.java b/src/main/java/com/lark/project/sample/Sample.java new file mode 100644 index 0000000..9017be8 --- /dev/null +++ b/src/main/java/com/lark/project/sample/Sample.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.sample; + +import com.lark.project.Client; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.utils.Jsons; +import com.lark.project.core.utils.Lists; +import com.lark.project.service.project.builder.ListProjectWorkItemTypeReq; +import com.lark.project.service.project.builder.ListProjectWorkItemTypeResp; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Sample { + + public static void main(String[] args) { + // 构建client + Client client = Client.newBuilder("pluginID", "pluginSecret") + .openBaseUrl("https://project.feishu.cn/").build(); + // 创建请求对象 + ListProjectWorkItemTypeReq req = ListProjectWorkItemTypeReq.newBuilder() + .projectKey("project_key") + .build(); + + // 创建自定义 Headers + Map> headers = new HashMap<>(); + headers.put("key1", Lists.newArrayList("value1")); + headers.put("key2", Lists.newArrayList("value2")); + + // 发起请求 + ListProjectWorkItemTypeResp resp = null; + try { + resp = client.getProjectService().listProjectWorkItemType(req, RequestOptions.newBuilder() + .accessToken("user_token") // 传递用户token + .headers(headers) // 传递自定义 Headers + .build()); + } catch (Exception e) { + // 处理异常 + throw new RuntimeException(e); + } + + // 处理服务端错误 + if (!resp.success()) { + System.out.println(String.format("code:%s,msg:%s,reqId:%s" + , resp.getErrCode(), resp.getErrMsg(), resp.getRequestId())); + return; + } + + // 业务数据处理 + System.out.println(Jsons.DEFAULT.toJson(resp.getData())); + } +} diff --git a/src/main/java/com/lark/project/service/attachment/AttachmentService.java b/src/main/java/com/lark/project/service/attachment/AttachmentService.java new file mode 100644 index 0000000..b4fa813 --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/AttachmentService.java @@ -0,0 +1,17 @@ +package com.lark.project.service.attachment; + +import com.lark.project.core.request.RequestOptions; +import com.lark.project.service.attachment.builder.*; + +public interface AttachmentService { + + // 添加附件 + public UploadAttachmentResp uploadAttachment(UploadAttachmentReq req, RequestOptions reqOptions) throws Exception; + + // 下载附件 + public DownloadAttachmentResp downloadAttachment(DownloadAttachmentReq req, RequestOptions reqOptions) throws Exception; + + // 附件上传 + public SpecialUploadAttachmentResp specialUploadAttachment(SpecialUploadAttachmentReq req, RequestOptions reqOptions) throws Exception; + +} diff --git a/src/main/java/com/lark/project/service/attachment/AttachmentServiceImpl.java b/src/main/java/com/lark/project/service/attachment/AttachmentServiceImpl.java new file mode 100644 index 0000000..a4e2b50 --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/AttachmentServiceImpl.java @@ -0,0 +1,107 @@ +package com.lark.project.service.attachment; + +import com.lark.project.core.Config; +import com.lark.project.core.Transport; +import com.lark.project.core.exception.ErrConstants; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.response.RawResponse; +import com.lark.project.core.utils.Logs; +import com.lark.project.core.utils.UnmarshalRespUtil; +import com.lark.project.service.attachment.builder.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.ByteArrayOutputStream; + +public class AttachmentServiceImpl implements AttachmentService{ + + private static final Logger log = LoggerFactory.getLogger(AttachmentServiceImpl.class); + + private Config config; + + public AttachmentServiceImpl(Config config) { + this.config = config; + } + + // 添加附件 + public UploadAttachmentResp uploadAttachment(UploadAttachmentReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + reqOptions.setSupportUpload(true); + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "POST" + , "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/file/upload" + , false + , req); + + UploadAttachmentResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, UploadAttachmentResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/file/upload")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + + // 下载附件 + public DownloadAttachmentResp downloadAttachment(DownloadAttachmentReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + reqOptions.setSupportDownLoad(true); + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "POST" + , "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/file/download" + , false + , req); + + if (httpResponse.getStatusCode() == 200) { + DownloadAttachmentResp resp = new DownloadAttachmentResp(); + resp.setRawResponse(httpResponse); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + outputStream.write(httpResponse.getBody()); + resp.setData(outputStream); + resp.setFileName(httpResponse.getFileName()); + return resp; + } + + DownloadAttachmentResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, DownloadAttachmentResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/file/download")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + + // 附件上传 + public SpecialUploadAttachmentResp specialUploadAttachment(SpecialUploadAttachmentReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + reqOptions.setSupportUpload(true); + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "POST" + , "/open_api/:project_key/file/upload" + , false + , req); + + SpecialUploadAttachmentResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, SpecialUploadAttachmentResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/file/upload")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentReq.java b/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentReq.java new file mode 100644 index 0000000..fb9a0b4 --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentReq.java @@ -0,0 +1,104 @@ +package com.lark.project.service.attachment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; + + +public class DownloadAttachmentReq { + + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @Path + @SerializedName("work_item_id") + private Long workItemID; + @Body + private DownloadAttachmentReqBody body; + + public DownloadAttachmentReq() { + } + + public DownloadAttachmentReq(DownloadAttachmentReq.Builder builder) { + this.projectKey = builder.projectKey; + this.workItemTypeKey = builder.workItemTypeKey; + this.workItemID = builder.workItemID; + this.body = builder.body; + } + + public static DownloadAttachmentReq.Builder newBuilder() { + return new DownloadAttachmentReq.Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public Long getWorkItemID() { + return this.workItemID; + } + + public void setWorkItemID(Long workItemID) { + this.workItemID = workItemID; + } + + public String getWorkItemTypeKey() { + return workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public DownloadAttachmentReqBody getDownloadAttachmentReqBody() { + return this.body; + } + + public void setDownloadAttachmentReqBody(DownloadAttachmentReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private String workItemTypeKey; + private Long workItemID; + private DownloadAttachmentReqBody body; + + public Builder() { + body = new DownloadAttachmentReqBody(); + } + + public DownloadAttachmentReq.Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public DownloadAttachmentReq.Builder workItemID(Long workItemID) { + this.workItemID = workItemID; + return this; + } + + public DownloadAttachmentReq.Builder workItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + return this; + } + + public DownloadAttachmentReq.Builder uuid(String uuid) { + this.body.setUUID(uuid); + return this; + } + + public DownloadAttachmentReq build() { + return new DownloadAttachmentReq(this); + } + + } + +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentReqBody.java b/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentReqBody.java new file mode 100644 index 0000000..f791589 --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentReqBody.java @@ -0,0 +1,17 @@ +package com.lark.project.service.attachment.builder; + +import com.google.gson.annotations.SerializedName; + +public class DownloadAttachmentReqBody { + + @SerializedName("uuid") + private String UUID; + + public String getUUID() { + return UUID; + } + + public void setUUID(String UUID) { + this.UUID = UUID; + } +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentResp.java b/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentResp.java new file mode 100644 index 0000000..b05c408 --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/DownloadAttachmentResp.java @@ -0,0 +1,28 @@ +package com.lark.project.service.attachment.builder; + +import com.lark.project.core.response.BaseResponse; + +import java.io.ByteArrayOutputStream; + +public class DownloadAttachmentResp extends BaseResponse { + + private ByteArrayOutputStream data; + + private String fileName; + + public ByteArrayOutputStream getData() { + return data; + } + + public void setData(ByteArrayOutputStream data) { + this.data = data; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentReq.java b/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentReq.java new file mode 100644 index 0000000..3547b8f --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentReq.java @@ -0,0 +1,68 @@ +package com.lark.project.service.attachment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; + +import java.io.File; + +public class SpecialUploadAttachmentReq { + + @Path + @SerializedName("project_key") + private String projectKey; + @Body + private SpecialUploadAttachmentReqBody body; + + public SpecialUploadAttachmentReq() { + } + + public SpecialUploadAttachmentReq(SpecialUploadAttachmentReq.Builder builder) { + this.projectKey = builder.projectKey; + this.body = builder.body; + } + + public static SpecialUploadAttachmentReq.Builder newBuilder() { + return new SpecialUploadAttachmentReq.Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public SpecialUploadAttachmentReqBody getSpecialUploadAttachmentReqBody() { + return this.body; + } + + public void setSpecialUploadAttachmentReqBody(SpecialUploadAttachmentReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private SpecialUploadAttachmentReqBody body; + + public Builder() { + body = new SpecialUploadAttachmentReqBody(); + } + + public SpecialUploadAttachmentReq.Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public SpecialUploadAttachmentReq.Builder file(File file) { + this.body.setFile(file); + return this; + } + + public SpecialUploadAttachmentReq build() { + return new SpecialUploadAttachmentReq(this); + } + + } +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentReqBody.java b/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentReqBody.java new file mode 100644 index 0000000..ccd3775 --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentReqBody.java @@ -0,0 +1,19 @@ +package com.lark.project.service.attachment.builder; + +import com.google.gson.annotations.SerializedName; + +import java.io.File; + +public class SpecialUploadAttachmentReqBody { + + @SerializedName("file") + private java.io.File file; + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentResp.java b/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentResp.java new file mode 100644 index 0000000..c335fc4 --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/SpecialUploadAttachmentResp.java @@ -0,0 +1,6 @@ +package com.lark.project.service.attachment.builder; + +import com.lark.project.core.response.BaseResponse; + +public class SpecialUploadAttachmentResp extends BaseResponse { +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentReq.java b/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentReq.java new file mode 100644 index 0000000..3bf0b9a --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentReq.java @@ -0,0 +1,118 @@ +package com.lark.project.service.attachment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; +import com.lark.project.service.chat.builder.BotJoinChatReq; +import com.lark.project.service.chat.builder.BotJoinChatReqBody; + +import java.io.File; +import java.util.List; + +public class UploadAttachmentReq { + + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @Path + @SerializedName("work_item_id") + private Long workItemID; + @Body + private UploadAttachmentReqBody body; + + public UploadAttachmentReq() { + } + + public UploadAttachmentReq(UploadAttachmentReq.Builder builder) { + this.projectKey = builder.projectKey; + this.workItemTypeKey = builder.workItemTypeKey; + this.workItemID = builder.workItemID; + this.body = builder.body; + } + + public static UploadAttachmentReq.Builder newBuilder() { + return new UploadAttachmentReq.Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public Long getWorkItemID() { + return this.workItemID; + } + + public void setWorkItemID(Long workItemID) { + this.workItemID = workItemID; + } + + public String getWorkItemTypeKey() { + return workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public UploadAttachmentReqBody getUploadAttachmentReqBody() { + return this.body; + } + + public void setUploadAttachmentReqBody(UploadAttachmentReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private String workItemTypeKey; + private Long workItemID; + private UploadAttachmentReqBody body; + + public Builder() { + body = new UploadAttachmentReqBody(); + } + + public UploadAttachmentReq.Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public UploadAttachmentReq.Builder workItemID(Long workItemID) { + this.workItemID = workItemID; + return this; + } + + public UploadAttachmentReq.Builder workItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + return this; + } + + public UploadAttachmentReq.Builder file(File file) { + this.body.setFile(file); + return this; + } + + public UploadAttachmentReq.Builder fieldKey(String fieldKey) { + this.body.setFieldKey(fieldKey); + return this; + } + + public UploadAttachmentReq.Builder fieldAlias(String fieldAlias) { + this.body.setFieldAlias(fieldAlias); + return this; + } + + public UploadAttachmentReq build() { + return new UploadAttachmentReq(this); + } + + } + +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentReqBody.java b/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentReqBody.java new file mode 100644 index 0000000..9bc3fe2 --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentReqBody.java @@ -0,0 +1,41 @@ +package com.lark.project.service.attachment.builder; + +import com.google.gson.annotations.SerializedName; + +import java.io.File; + +public class UploadAttachmentReqBody { + + @SerializedName("file") + private java.io.File file; + + @SerializedName("field_key") + private String fieldKey; + + @SerializedName("field_alias") + private String fieldAlias; + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + public String getFieldKey() { + return fieldKey; + } + + public void setFieldKey(String fieldKey) { + this.fieldKey = fieldKey; + } + + public String getFieldAlias() { + return fieldAlias; + } + + public void setFieldAlias(String fieldAlias) { + this.fieldAlias = fieldAlias; + } +} diff --git a/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentResp.java b/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentResp.java new file mode 100644 index 0000000..8c9d4dd --- /dev/null +++ b/src/main/java/com/lark/project/service/attachment/builder/UploadAttachmentResp.java @@ -0,0 +1,6 @@ +package com.lark.project.service.attachment.builder; + +import com.lark.project.core.response.BaseResponse; + +public class UploadAttachmentResp extends BaseResponse { +} diff --git a/src/main/java/com/lark/project/service/chat/ChatService.java b/src/main/java/com/lark/project/service/chat/ChatService.java new file mode 100644 index 0000000..ea4d0e0 --- /dev/null +++ b/src/main/java/com/lark/project/service/chat/ChatService.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.chat; + +import com.lark.project.core.request.RequestOptions; +import com.lark.project.service.chat.builder.BotJoinChatReq; +import com.lark.project.service.chat.builder.BotJoinChatResp; + +public interface ChatService { + + // 拉机器人入群 + public BotJoinChatResp botJoinChat(BotJoinChatReq req, RequestOptions reqOptions) throws Exception; + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/chat/ChatServiceImpl.java b/src/main/java/com/lark/project/service/chat/ChatServiceImpl.java new file mode 100644 index 0000000..b054651 --- /dev/null +++ b/src/main/java/com/lark/project/service/chat/ChatServiceImpl.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.chat; + +import com.lark.project.core.Config; +import com.lark.project.core.Transport; +import com.lark.project.core.exception.ErrConstants; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.response.RawResponse; +import com.lark.project.core.utils.Logs; +import com.lark.project.core.utils.UnmarshalRespUtil; +import com.lark.project.service.chat.builder.BotJoinChatReq; +import com.lark.project.service.chat.builder.BotJoinChatResp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ChatServiceImpl implements ChatService { + + private static final Logger log = LoggerFactory.getLogger(ChatServiceImpl.class); + + private Config config; + + public ChatServiceImpl(Config config) { + this.config = config; + } + + // 拉机器人入群 + public BotJoinChatResp botJoinChat(BotJoinChatReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "POST" + , "/open_api/:project_key/work_item/:work_item_id/bot_join_chat" + , false + , req); + + BotJoinChatResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, BotJoinChatResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/work_item/:work_item_id/bot_join_chat")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/chat/builder/BotJoinChatReq.java b/src/main/java/com/lark/project/service/chat/builder/BotJoinChatReq.java new file mode 100644 index 0000000..96f3741 --- /dev/null +++ b/src/main/java/com/lark/project/service/chat/builder/BotJoinChatReq.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.chat.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; + +import java.util.List; + +public class BotJoinChatReq { + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_id") + private Long workItemID; + @Body + private BotJoinChatReqBody body; + + + public BotJoinChatReq() { + } + + public BotJoinChatReq(Builder builder) { + this.projectKey = builder.projectKey; + this.workItemID = builder.workItemID; + this.body = builder.body; + + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public Long getWorkItemID() { + return this.workItemID; + } + + public void setWorkItemID(Long workItemID) { + this.workItemID = workItemID; + } + + public BotJoinChatReqBody getBotJoinChatReqBody() { + return this.body; + } + + public void setBotJoinChatReqBody(BotJoinChatReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private Long workItemID; + private BotJoinChatReqBody body; + + public Builder() { + body = new BotJoinChatReqBody(); + } + + public Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public Builder workItemID(Long workItemID) { + this.workItemID = workItemID; + return this; + } + + public Builder workItemTypeKey(String workItemTypeKey) { + this.body.setWorkItemTypeKey(workItemTypeKey); + return this; + } + + public Builder appIDs(List appIDs) { + this.body.setAppIDs(appIDs); + return this; + } + + public BotJoinChatReq build() { + return new BotJoinChatReq(this); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/chat/builder/BotJoinChatReqBody.java b/src/main/java/com/lark/project/service/chat/builder/BotJoinChatReqBody.java new file mode 100644 index 0000000..a55cfc0 --- /dev/null +++ b/src/main/java/com/lark/project/service/chat/builder/BotJoinChatReqBody.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.chat.builder; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + + +public class BotJoinChatReqBody { + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @SerializedName("app_ids") + private List appIDs; + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public List getAppIDs() { + return this.appIDs; + } + + public void setAppIDs(List appIDs) { + this.appIDs = appIDs; + } +} diff --git a/src/main/java/com/lark/project/service/chat/builder/BotJoinChatResp.java b/src/main/java/com/lark/project/service/chat/builder/BotJoinChatResp.java new file mode 100644 index 0000000..91cf524 --- /dev/null +++ b/src/main/java/com/lark/project/service/chat/builder/BotJoinChatResp.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.chat.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.response.BaseResponse; +import com.lark.project.service.chat.model.BotJoinChatInfo; + + +public class BotJoinChatResp extends BaseResponse { + @SerializedName("data") + private BotJoinChatInfo data; + + public BotJoinChatInfo getData() { + return this.data; + } + + public void setData(BotJoinChatInfo data) { + this.data = data; + } +} + diff --git a/src/main/java/com/lark/project/service/chat/model/BotJoinChatInfo.java b/src/main/java/com/lark/project/service/chat/model/BotJoinChatInfo.java new file mode 100644 index 0000000..3d05726 --- /dev/null +++ b/src/main/java/com/lark/project/service/chat/model/BotJoinChatInfo.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.chat.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + + +public class BotJoinChatInfo { + @SerializedName("chat_id") + private String chatID; + + @SerializedName("success_members") + private List successMembers; + + @SerializedName("failed_members") + private List failedMembers; + + public String getChatID() { + return this.chatID; + } + + public void setChatID(String chatID) { + this.chatID = chatID; + } + + public List getSuccessMembers() { + return this.successMembers; + } + + public void setSuccessMembers(List successMembers) { + this.successMembers = successMembers; + } + + public List getFailedMembers() { + return this.failedMembers; + } + + public void setFailedMembers(List failedMembers) { + this.failedMembers = failedMembers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/comment/CommentService.java b/src/main/java/com/lark/project/service/comment/CommentService.java new file mode 100644 index 0000000..27800a2 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/CommentService.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment; + +import com.lark.project.core.request.RequestOptions; +import com.lark.project.service.comment.builder.*; + +public interface CommentService { + + // 添加评论 + public CreateCommentResp createComment(CreateCommentReq req, RequestOptions reqOptions) throws Exception; + + // 删除评论 + public DeleteCommentResp deleteComment(DeleteCommentReq req, RequestOptions reqOptions) throws Exception; + + // 查询评论 + public QueryCommentsResp queryComments(QueryCommentsReq req, RequestOptions reqOptions) throws Exception; + + // 更新评论 + public UpdateCommentResp updateComment(UpdateCommentReq req, RequestOptions reqOptions) throws Exception; + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/comment/CommentServiceImpl.java b/src/main/java/com/lark/project/service/comment/CommentServiceImpl.java new file mode 100644 index 0000000..44f28f0 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/CommentServiceImpl.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment; + +import com.lark.project.core.Config; +import com.lark.project.core.Transport; +import com.lark.project.core.exception.ErrConstants; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.response.RawResponse; +import com.lark.project.core.utils.Logs; +import com.lark.project.core.utils.UnmarshalRespUtil; +import com.lark.project.service.comment.builder.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CommentServiceImpl implements CommentService { + + private static final Logger log = LoggerFactory.getLogger(CommentServiceImpl.class); + + private Config config; + + public CommentServiceImpl(Config config) { + this.config = config; + } + + // 添加评论 + public CreateCommentResp createComment(CreateCommentReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "POST" + , "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/comment/create" + , false + , req); + + CreateCommentResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, CreateCommentResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/comment/create")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + + // 删除评论 + public DeleteCommentResp deleteComment(DeleteCommentReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "DELETE" + , "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/comment/:comment_id" + , false + , req); + + DeleteCommentResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, DeleteCommentResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/comment/:comment_id")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + + // 查询评论 + public QueryCommentsResp queryComments(QueryCommentsReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "GET" + , "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/comments" + , false + , req); + + QueryCommentsResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, QueryCommentsResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/comments")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + + // 更新评论 + public UpdateCommentResp updateComment(UpdateCommentReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "PUT" + , "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/comment/:comment_id" + , false + , req); + + UpdateCommentResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, UpdateCommentResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/work_item/:work_item_type_key/:work_item_id/comment/:comment_id")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/comment/builder/CreateCommentReq.java b/src/main/java/com/lark/project/service/comment/builder/CreateCommentReq.java new file mode 100644 index 0000000..fd52200 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/CreateCommentReq.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; + +public class CreateCommentReq { + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_id") + private Long workItemID; + @Path + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @Body + private CreateCommentReqBody body; + + + public CreateCommentReq() { + } + + public CreateCommentReq(Builder builder) { + this.projectKey = builder.projectKey; + this.workItemID = builder.workItemID; + this.workItemTypeKey = builder.workItemTypeKey; + this.body = builder.body; + + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public Long getWorkItemID() { + return this.workItemID; + } + + public void setWorkItemID(Long workItemID) { + this.workItemID = workItemID; + } + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public CreateCommentReqBody getCreateCommentReqBody() { + return this.body; + } + + public void setCreateCommentReqBody(CreateCommentReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private Long workItemID; + private String workItemTypeKey; + private CreateCommentReqBody body; + + public Builder() { + body = new CreateCommentReqBody(); + } + + public Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public Builder workItemID(Long workItemID) { + this.workItemID = workItemID; + return this; + } + + public Builder workItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + return this; + } + + public Builder content(String content) { + this.body.setContent(content); + return this; + } + + public CreateCommentReq build() { + return new CreateCommentReq(this); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/comment/builder/CreateCommentReqBody.java b/src/main/java/com/lark/project/service/comment/builder/CreateCommentReqBody.java new file mode 100644 index 0000000..8e132c0 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/CreateCommentReqBody.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.google.gson.annotations.SerializedName; + + +public class CreateCommentReqBody { + @SerializedName("content") + private String content; + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/src/main/java/com/lark/project/service/comment/builder/CreateCommentResp.java b/src/main/java/com/lark/project/service/comment/builder/CreateCommentResp.java new file mode 100644 index 0000000..e7954e3 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/CreateCommentResp.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.response.BaseResponse; + + +public class CreateCommentResp extends BaseResponse { + @SerializedName("data") + private Long data; + + public Long getData() { + return this.data; + } + + public void setData(Long data) { + this.data = data; + } +} + diff --git a/src/main/java/com/lark/project/service/comment/builder/DeleteCommentReq.java b/src/main/java/com/lark/project/service/comment/builder/DeleteCommentReq.java new file mode 100644 index 0000000..c3612c8 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/DeleteCommentReq.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Path; + +public class DeleteCommentReq { + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @Path + @SerializedName("work_item_id") + private Long workItemID; + @Path + @SerializedName("comment_id") + private Long commentID; + + public DeleteCommentReq() { + } + + public DeleteCommentReq(Builder builder) { + this.projectKey = builder.projectKey; + this.workItemTypeKey = builder.workItemTypeKey; + this.workItemID = builder.workItemID; + this.commentID = builder.commentID; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public Long getWorkItemID() { + return this.workItemID; + } + + public void setWorkItemID(Long workItemID) { + this.workItemID = workItemID; + } + + public Long getCommentID() { + return this.commentID; + } + + public void setCommentID(Long commentID) { + this.commentID = commentID; + } + + public static class Builder { + private String projectKey; + private String workItemTypeKey; + private Long workItemID; + private Long commentID; + + public Builder() { + } + + public Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public Builder workItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + return this; + } + + public Builder workItemID(Long workItemID) { + this.workItemID = workItemID; + return this; + } + + public Builder commentID(Long commentID) { + this.commentID = commentID; + return this; + } + + public DeleteCommentReq build() { + return new DeleteCommentReq(this); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/comment/builder/DeleteCommentResp.java b/src/main/java/com/lark/project/service/comment/builder/DeleteCommentResp.java new file mode 100644 index 0000000..1bd2c31 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/DeleteCommentResp.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.lark.project.core.response.BaseResponse; + + +public class DeleteCommentResp extends BaseResponse { +} + diff --git a/src/main/java/com/lark/project/service/comment/builder/QueryCommentsReq.java b/src/main/java/com/lark/project/service/comment/builder/QueryCommentsReq.java new file mode 100644 index 0000000..a09df51 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/QueryCommentsReq.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Path; +import com.lark.project.core.annotation.Query; + +public class QueryCommentsReq { + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_id") + private Long workItemID; + @Path + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @Query + @SerializedName("page_size") + private Long pageSize; + @Query + @SerializedName("page_num") + private Long pageNum; + + public QueryCommentsReq() { + } + + public QueryCommentsReq(Builder builder) { + this.projectKey = builder.projectKey; + this.workItemID = builder.workItemID; + this.workItemTypeKey = builder.workItemTypeKey; + this.pageSize = builder.pageSize; + this.pageNum = builder.pageNum; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public Long getWorkItemID() { + return this.workItemID; + } + + public void setWorkItemID(Long workItemID) { + this.workItemID = workItemID; + } + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public Long getPageSize() { + return this.pageSize; + } + + public void setPageSize(Long pageSize) { + this.pageSize = pageSize; + } + + public Long getPageNum() { + return this.pageNum; + } + + public void setPageNum(Long pageNum) { + this.pageNum = pageNum; + } + + public static class Builder { + private String projectKey; + private Long workItemID; + private String workItemTypeKey; + private Long pageSize; + private Long pageNum; + + public Builder() { + } + + public Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public Builder workItemID(Long workItemID) { + this.workItemID = workItemID; + return this; + } + + public Builder workItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + return this; + } + + public Builder pageSize(Long pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageNum(Long pageNum) { + this.pageNum = pageNum; + return this; + } + + public QueryCommentsReq build() { + return new QueryCommentsReq(this); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/comment/builder/QueryCommentsResp.java b/src/main/java/com/lark/project/service/comment/builder/QueryCommentsResp.java new file mode 100644 index 0000000..3653e58 --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/QueryCommentsResp.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.response.BaseResponse; +import com.lark.project.service.comment.model.Comment; +import com.lark.project.service.common.model.Pagination; + +import java.util.List; + + +public class QueryCommentsResp extends BaseResponse { + @SerializedName("data") + private List data; + @SerializedName("pagination") + private Pagination pagination; + + public List getData() { + return this.data; + } + + public void setData(List data) { + this.data = data; + } + + public Pagination getPagination() { + return this.pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } +} + diff --git a/src/main/java/com/lark/project/service/comment/builder/UpdateCommentReq.java b/src/main/java/com/lark/project/service/comment/builder/UpdateCommentReq.java new file mode 100644 index 0000000..24e08cb --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/UpdateCommentReq.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; + +public class UpdateCommentReq { + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_id") + private Long workItemID; + @Path + @SerializedName("comment_id") + private Long commentID; + @Path + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @Body + private UpdateCommentReqBody body; + + + public UpdateCommentReq() { + } + + public UpdateCommentReq(Builder builder) { + this.projectKey = builder.projectKey; + this.workItemID = builder.workItemID; + this.commentID = builder.commentID; + this.workItemTypeKey = builder.workItemTypeKey; + this.body = builder.body; + + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public Long getWorkItemID() { + return this.workItemID; + } + + public void setWorkItemID(Long workItemID) { + this.workItemID = workItemID; + } + + public Long getCommentID() { + return this.commentID; + } + + public void setCommentID(Long commentID) { + this.commentID = commentID; + } + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public UpdateCommentReqBody getUpdateCommentReqBody() { + return this.body; + } + + public void setUpdateCommentReqBody(UpdateCommentReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private Long workItemID; + private Long commentID; + private String workItemTypeKey; + private UpdateCommentReqBody body; + + public Builder() { + body = new UpdateCommentReqBody(); + } + + public Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public Builder workItemID(Long workItemID) { + this.workItemID = workItemID; + return this; + } + + public Builder commentID(Long commentID) { + this.commentID = commentID; + return this; + } + + public Builder workItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + return this; + } + + public Builder content(String content) { + this.body.setContent(content); + return this; + } + + public UpdateCommentReq build() { + return new UpdateCommentReq(this); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/comment/builder/UpdateCommentReqBody.java b/src/main/java/com/lark/project/service/comment/builder/UpdateCommentReqBody.java new file mode 100644 index 0000000..11ce3fd --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/UpdateCommentReqBody.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.google.gson.annotations.SerializedName; + + +public class UpdateCommentReqBody { + @SerializedName("content") + private String content; + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/src/main/java/com/lark/project/service/comment/builder/UpdateCommentResp.java b/src/main/java/com/lark/project/service/comment/builder/UpdateCommentResp.java new file mode 100644 index 0000000..f1f944b --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/builder/UpdateCommentResp.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.builder; + +import com.lark.project.core.response.BaseResponse; + + +public class UpdateCommentResp extends BaseResponse { +} + diff --git a/src/main/java/com/lark/project/service/comment/model/Comment.java b/src/main/java/com/lark/project/service/comment/model/Comment.java new file mode 100644 index 0000000..08b8fdf --- /dev/null +++ b/src/main/java/com/lark/project/service/comment/model/Comment.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.comment.model; + +import com.google.gson.annotations.SerializedName; + + +public class Comment { + @SerializedName("id") + private Long id; + + @SerializedName("work_item_id") + private Long workItemID; + + @SerializedName("work_item_type_key") + private String workItemTypeKey; + + @SerializedName("created_at") + private Long createdAt; + + @SerializedName("operator") + private String operator; + + @SerializedName("content") + private String content; + + public Long getID() { + return this.id; + } + + public void setID(Long id) { + this.id = id; + } + + public Long getWorkItemID() { + return this.workItemID; + } + + public void setWorkItemID(Long workItemID) { + this.workItemID = workItemID; + } + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public Long getCreatedAt() { + return this.createdAt; + } + + public void setCreatedAt(Long createdAt) { + this.createdAt = createdAt; + } + + public String getOperator() { + return this.operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/common/model/Pagination.java b/src/main/java/com/lark/project/service/common/model/Pagination.java new file mode 100644 index 0000000..2b6f46a --- /dev/null +++ b/src/main/java/com/lark/project/service/common/model/Pagination.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.common.model; + +import com.google.gson.annotations.SerializedName; + + +public class Pagination { + @SerializedName("page_num") + private Long pageNum; + + @SerializedName("page_size") + private Long pageSize; + + @SerializedName("total") + private Long total; + + public Long getPageNum() { + return this.pageNum; + } + + public void setPageNum(Long pageNum) { + this.pageNum = pageNum; + } + + public Long getPageSize() { + return this.pageSize; + } + + public void setPageSize(Long pageSize) { + this.pageSize = pageSize; + } + + public Long getTotal() { + return this.total; + } + + public void setTotal(Long total) { + this.total = total; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/common/model/UserDetail.java b/src/main/java/com/lark/project/service/common/model/UserDetail.java new file mode 100644 index 0000000..4b56dc6 --- /dev/null +++ b/src/main/java/com/lark/project/service/common/model/UserDetail.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.common.model; + +import com.google.gson.annotations.SerializedName; + + +public class UserDetail { + @SerializedName("user_key") + private String userKey; + + @SerializedName("username") + private String username; + + @SerializedName("email") + private String email; + + @SerializedName("name_cn") + private String nameCn; + + @SerializedName("name_en") + private String nameEn; + + public String getUserKey() { + return this.userKey; + } + + public void setUserKey(String userKey) { + this.userKey = userKey; + } + + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getNameCn() { + return this.nameCn; + } + + public void setNameCn(String nameCn) { + this.nameCn = nameCn; + } + + public String getNameEn() { + return this.nameEn; + } + + public void setNameEn(String nameEn) { + this.nameEn = nameEn; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/FieldService.java b/src/main/java/com/lark/project/service/field/FieldService.java new file mode 100644 index 0000000..8ef4202 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/FieldService.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field; + +import com.lark.project.core.request.RequestOptions; +import com.lark.project.service.field.builder.*; + +public interface FieldService { + + // 创建自定义字段 + public CreateFieldResp createField(CreateFieldReq req, RequestOptions reqOptions) throws Exception; + + // 获取空间字段 + public QueryProjectFieldsResp queryProjectFields(QueryProjectFieldsReq req, RequestOptions reqOptions) throws Exception; + + // 更新自定义字段 + public UpdateFieldResp updateField(UpdateFieldReq req, RequestOptions reqOptions) throws Exception; + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/FieldServiceImpl.java b/src/main/java/com/lark/project/service/field/FieldServiceImpl.java new file mode 100644 index 0000000..cb18396 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/FieldServiceImpl.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field; + +import com.lark.project.core.Config; +import com.lark.project.core.Transport; +import com.lark.project.core.exception.ErrConstants; +import com.lark.project.core.request.RequestOptions; +import com.lark.project.core.response.RawResponse; +import com.lark.project.core.utils.Logs; +import com.lark.project.core.utils.UnmarshalRespUtil; +import com.lark.project.service.field.builder.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class FieldServiceImpl implements FieldService { + + private static final Logger log = LoggerFactory.getLogger(FieldServiceImpl.class); + + private Config config; + + public FieldServiceImpl(Config config) { + this.config = config; + } + + // 创建自定义字段 + public CreateFieldResp createField(CreateFieldReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "POST" + , "/open_api/:project_key/field/:work_item_type_key/create" + , false + , req); + + CreateFieldResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, CreateFieldResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/field/:work_item_type_key/create")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + + // 获取空间字段 + public QueryProjectFieldsResp queryProjectFields(QueryProjectFieldsReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "POST" + , "/open_api/:project_key/field/all" + , false + , req); + + QueryProjectFieldsResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, QueryProjectFieldsResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/field/all")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + + // 更新自定义字段 + public UpdateFieldResp updateField(UpdateFieldReq req, RequestOptions reqOptions) throws Exception { + if (reqOptions == null) { + reqOptions = new RequestOptions(); + } + + RawResponse httpResponse = Transport.doSend(config, reqOptions, "PUT" + , "/open_api/:project_key/field/:work_item_type_key" + , false + , req); + + UpdateFieldResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, UpdateFieldResp.class); + if (resp == null) { + log.error(Logs.formatReq(req, httpResponse, "/open_api/:project_key/field/:work_item_type_key")); + throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL); + } + + resp.setRawResponse(httpResponse); + resp.setRequest(req); + + return resp; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/builder/CreateFieldReq.java b/src/main/java/com/lark/project/service/field/builder/CreateFieldReq.java new file mode 100644 index 0000000..37c3d59 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/CreateFieldReq.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; + +import java.util.List; + +public class CreateFieldReq { + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @Body + private CreateFieldReqBody body; + + + public CreateFieldReq() { + } + + public CreateFieldReq(Builder builder) { + this.projectKey = builder.projectKey; + this.workItemTypeKey = builder.workItemTypeKey; + this.body = builder.body; + + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public CreateFieldReqBody getCreateFieldReqBody() { + return this.body; + } + + public void setCreateFieldReqBody(CreateFieldReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private String workItemTypeKey; + private CreateFieldReqBody body; + + public Builder() { + body = new CreateFieldReqBody(); + } + + public Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public Builder workItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + return this; + } + + public Builder fieldName(String fieldName) { + this.body.setFieldName(fieldName); + return this; + } + + public Builder fieldTypeKey(String fieldTypeKey) { + this.body.setFieldTypeKey(fieldTypeKey); + return this; + } + + public Builder valueType(Long valueType) { + this.body.setValueType(valueType); + return this; + } + + public Builder referenceWorkItemTypeKey(String referenceWorkItemTypeKey) { + this.body.setReferenceWorkItemTypeKey(referenceWorkItemTypeKey); + return this; + } + + public Builder referenceFieldKey(String referenceFieldKey) { + this.body.setReferenceFieldKey(referenceFieldKey); + return this; + } + + public Builder fieldValue(Object fieldValue) { + this.body.setFieldValue(fieldValue); + return this; + } + + public Builder freeAdd(Long freeAdd) { + this.body.setFreeAdd(freeAdd); + return this; + } + + public Builder workItemRelationUUID(String workItemRelationUUID) { + this.body.setWorkItemRelationUUID(workItemRelationUUID); + return this; + } + + public Builder defaultValue(Object defaultValue) { + this.body.setDefaultValue(defaultValue); + return this; + } + + public Builder fieldAlias(String fieldAlias) { + this.body.setFieldAlias(fieldAlias); + return this; + } + + public Builder helpDescription(String helpDescription) { + this.body.setHelpDescription(helpDescription); + return this; + } + + public Builder authorizedRoles(List authorizedRoles) { + this.body.setAuthorizedRoles(authorizedRoles); + return this; + } + + public Builder isMulti(Boolean isMulti) { + this.body.setIsMulti(isMulti); + return this; + } + + public Builder format(Boolean format) { + this.body.setFormat(format); + return this; + } + + public CreateFieldReq build() { + return new CreateFieldReq(this); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/builder/CreateFieldReqBody.java b/src/main/java/com/lark/project/service/field/builder/CreateFieldReqBody.java new file mode 100644 index 0000000..d298ce3 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/CreateFieldReqBody.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + + +public class CreateFieldReqBody { + @SerializedName("field_name") + private String fieldName; + @SerializedName("field_type_key") + private String fieldTypeKey; + @SerializedName("value_type") + private Long valueType; + @SerializedName("reference_work_item_type_key") + private String referenceWorkItemTypeKey; + @SerializedName("reference_field_key") + private String referenceFieldKey; + @SerializedName("field_value") + private Object fieldValue; + @SerializedName("free_add") + private Long freeAdd; + @SerializedName("work_item_relation_uuid") + private String workItemRelationUUID; + @SerializedName("default_value") + private Object defaultValue; + @SerializedName("field_alias") + private String fieldAlias; + @SerializedName("help_description") + private String helpDescription; + @SerializedName("authorized_roles") + private List authorizedRoles; + @SerializedName("is_multi") + private Boolean isMulti; + @SerializedName("format") + private Boolean format; + + public String getFieldName() { + return this.fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getFieldTypeKey() { + return this.fieldTypeKey; + } + + public void setFieldTypeKey(String fieldTypeKey) { + this.fieldTypeKey = fieldTypeKey; + } + + public Long getValueType() { + return this.valueType; + } + + public void setValueType(Long valueType) { + this.valueType = valueType; + } + + public String getReferenceWorkItemTypeKey() { + return this.referenceWorkItemTypeKey; + } + + public void setReferenceWorkItemTypeKey(String referenceWorkItemTypeKey) { + this.referenceWorkItemTypeKey = referenceWorkItemTypeKey; + } + + public String getReferenceFieldKey() { + return this.referenceFieldKey; + } + + public void setReferenceFieldKey(String referenceFieldKey) { + this.referenceFieldKey = referenceFieldKey; + } + + public Object getFieldValue() { + return this.fieldValue; + } + + public void setFieldValue(Object fieldValue) { + this.fieldValue = fieldValue; + } + + public Long getFreeAdd() { + return this.freeAdd; + } + + public void setFreeAdd(Long freeAdd) { + this.freeAdd = freeAdd; + } + + public String getWorkItemRelationUUID() { + return this.workItemRelationUUID; + } + + public void setWorkItemRelationUUID(String workItemRelationUUID) { + this.workItemRelationUUID = workItemRelationUUID; + } + + public Object getDefaultValue() { + return this.defaultValue; + } + + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } + + public String getFieldAlias() { + return this.fieldAlias; + } + + public void setFieldAlias(String fieldAlias) { + this.fieldAlias = fieldAlias; + } + + public String getHelpDescription() { + return this.helpDescription; + } + + public void setHelpDescription(String helpDescription) { + this.helpDescription = helpDescription; + } + + public List getAuthorizedRoles() { + return this.authorizedRoles; + } + + public void setAuthorizedRoles(List authorizedRoles) { + this.authorizedRoles = authorizedRoles; + } + + public Boolean getIsMulti() { + return this.isMulti; + } + + public void setIsMulti(Boolean isMulti) { + this.isMulti = isMulti; + } + + public Boolean getFormat() { + return this.format; + } + + public void setFormat(Boolean format) { + this.format = format; + } +} diff --git a/src/main/java/com/lark/project/service/field/builder/CreateFieldResp.java b/src/main/java/com/lark/project/service/field/builder/CreateFieldResp.java new file mode 100644 index 0000000..0246f13 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/CreateFieldResp.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.response.BaseResponse; + + +public class CreateFieldResp extends BaseResponse { + @SerializedName("data") + private String data; + + public String getData() { + return this.data; + } + + public void setData(String data) { + this.data = data; + } +} + diff --git a/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsReq.java b/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsReq.java new file mode 100644 index 0000000..0cf0417 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsReq.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; + +public class QueryProjectFieldsReq { + @Path + @SerializedName("project_key") + private String projectKey; + @Body + private QueryProjectFieldsReqBody body; + + + public QueryProjectFieldsReq() { + } + + public QueryProjectFieldsReq(Builder builder) { + this.projectKey = builder.projectKey; + this.body = builder.body; + + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public QueryProjectFieldsReqBody getQueryProjectFieldsReqBody() { + return this.body; + } + + public void setQueryProjectFieldsReqBody(QueryProjectFieldsReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private QueryProjectFieldsReqBody body; + + public Builder() { + body = new QueryProjectFieldsReqBody(); + } + + public Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public Builder workItemTypeKey(String workItemTypeKey) { + this.body.setWorkItemTypeKey(workItemTypeKey); + return this; + } + + public QueryProjectFieldsReq build() { + return new QueryProjectFieldsReq(this); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsReqBody.java b/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsReqBody.java new file mode 100644 index 0000000..ea588a9 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsReqBody.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.google.gson.annotations.SerializedName; + + +public class QueryProjectFieldsReqBody { + @SerializedName("work_item_type_key") + private String workItemTypeKey; + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } +} diff --git a/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsResp.java b/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsResp.java new file mode 100644 index 0000000..6d52e89 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/QueryProjectFieldsResp.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.response.BaseResponse; +import com.lark.project.service.field.model.SimpleField; + +import java.util.List; + + +public class QueryProjectFieldsResp extends BaseResponse { + @SerializedName("data") + private List data; + + public List getData() { + return this.data; + } + + public void setData(List data) { + this.data = data; + } +} + diff --git a/src/main/java/com/lark/project/service/field/builder/UpdateFieldReq.java b/src/main/java/com/lark/project/service/field/builder/UpdateFieldReq.java new file mode 100644 index 0000000..7b1948c --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/UpdateFieldReq.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.google.gson.annotations.SerializedName; +import com.lark.project.core.annotation.Body; +import com.lark.project.core.annotation.Path; + +import java.util.List; + +public class UpdateFieldReq { + @Path + @SerializedName("project_key") + private String projectKey; + @Path + @SerializedName("work_item_type_key") + private String workItemTypeKey; + @Body + private UpdateFieldReqBody body; + + + public UpdateFieldReq() { + } + + public UpdateFieldReq(Builder builder) { + this.projectKey = builder.projectKey; + this.workItemTypeKey = builder.workItemTypeKey; + this.body = builder.body; + + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getProjectKey() { + return this.projectKey; + } + + public void setProjectKey(String projectKey) { + this.projectKey = projectKey; + } + + public String getWorkItemTypeKey() { + return this.workItemTypeKey; + } + + public void setWorkItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + } + + public UpdateFieldReqBody getUpdateFieldReqBody() { + return this.body; + } + + public void setUpdateFieldReqBody(UpdateFieldReqBody body) { + this.body = body; + } + + public static class Builder { + private String projectKey; + private String workItemTypeKey; + private UpdateFieldReqBody body; + + public Builder() { + body = new UpdateFieldReqBody(); + } + + public Builder projectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public Builder workItemTypeKey(String workItemTypeKey) { + this.workItemTypeKey = workItemTypeKey; + return this; + } + + public Builder fieldName(String fieldName) { + this.body.setFieldName(fieldName); + return this; + } + + public Builder fieldKey(String fieldKey) { + this.body.setFieldKey(fieldKey); + return this; + } + + public Builder fieldValue(Object fieldValue) { + this.body.setFieldValue(fieldValue); + return this; + } + + public Builder freeAdd(Long freeAdd) { + this.body.setFreeAdd(freeAdd); + return this; + } + + public Builder workItemRelationUUID(String workItemRelationUUID) { + this.body.setWorkItemRelationUUID(workItemRelationUUID); + return this; + } + + public Builder defaultValue(Object defaultValue) { + this.body.setDefaultValue(defaultValue); + return this; + } + + public Builder fieldAlias(String fieldAlias) { + this.body.setFieldAlias(fieldAlias); + return this; + } + + public Builder helpDescription(String helpDescription) { + this.body.setHelpDescription(helpDescription); + return this; + } + + public Builder authorizedRoles(List authorizedRoles) { + this.body.setAuthorizedRoles(authorizedRoles); + return this; + } + + public UpdateFieldReq build() { + return new UpdateFieldReq(this); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/builder/UpdateFieldReqBody.java b/src/main/java/com/lark/project/service/field/builder/UpdateFieldReqBody.java new file mode 100644 index 0000000..9c98e2a --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/UpdateFieldReqBody.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + + +public class UpdateFieldReqBody { + @SerializedName("field_name") + private String fieldName; + @SerializedName("field_key") + private String fieldKey; + @SerializedName("field_value") + private Object fieldValue; + @SerializedName("free_add") + private Long freeAdd; + @SerializedName("work_item_relation_uuid") + private String workItemRelationUUID; + @SerializedName("default_value") + private Object defaultValue; + @SerializedName("field_alias") + private String fieldAlias; + @SerializedName("help_description") + private String helpDescription; + @SerializedName("authorized_roles") + private List authorizedRoles; + + public String getFieldName() { + return this.fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getFieldKey() { + return this.fieldKey; + } + + public void setFieldKey(String fieldKey) { + this.fieldKey = fieldKey; + } + + public Object getFieldValue() { + return this.fieldValue; + } + + public void setFieldValue(Object fieldValue) { + this.fieldValue = fieldValue; + } + + public Long getFreeAdd() { + return this.freeAdd; + } + + public void setFreeAdd(Long freeAdd) { + this.freeAdd = freeAdd; + } + + public String getWorkItemRelationUUID() { + return this.workItemRelationUUID; + } + + public void setWorkItemRelationUUID(String workItemRelationUUID) { + this.workItemRelationUUID = workItemRelationUUID; + } + + public Object getDefaultValue() { + return this.defaultValue; + } + + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } + + public String getFieldAlias() { + return this.fieldAlias; + } + + public void setFieldAlias(String fieldAlias) { + this.fieldAlias = fieldAlias; + } + + public String getHelpDescription() { + return this.helpDescription; + } + + public void setHelpDescription(String helpDescription) { + this.helpDescription = helpDescription; + } + + public List getAuthorizedRoles() { + return this.authorizedRoles; + } + + public void setAuthorizedRoles(List authorizedRoles) { + this.authorizedRoles = authorizedRoles; + } +} diff --git a/src/main/java/com/lark/project/service/field/builder/UpdateFieldResp.java b/src/main/java/com/lark/project/service/field/builder/UpdateFieldResp.java new file mode 100644 index 0000000..01bdd71 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/builder/UpdateFieldResp.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.builder; + +import com.lark.project.core.response.BaseResponse; + + +public class UpdateFieldResp extends BaseResponse { +} + diff --git a/src/main/java/com/lark/project/service/field/model/FieldValuePair.java b/src/main/java/com/lark/project/service/field/model/FieldValuePair.java new file mode 100644 index 0000000..500acfa --- /dev/null +++ b/src/main/java/com/lark/project/service/field/model/FieldValuePair.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.model; + +import com.google.gson.annotations.SerializedName; + + +public class FieldValuePair { + @SerializedName("field_key") + private String fieldKey; + + @SerializedName("field_value") + private Object fieldValue; + + @SerializedName("target_state") + private TargetState targetState; + + @SerializedName("field_type_key") + private String fieldTypeKey; + + @SerializedName("field_alias") + private String fieldAlias; + + public String getFieldKey() { + return this.fieldKey; + } + + public void setFieldKey(String fieldKey) { + this.fieldKey = fieldKey; + } + + public Object getFieldValue() { + return this.fieldValue; + } + + public void setFieldValue(Object fieldValue) { + this.fieldValue = fieldValue; + } + + public TargetState getTargetState() { + return this.targetState; + } + + public void setTargetState(TargetState targetState) { + this.targetState = targetState; + } + + public String getFieldTypeKey() { + return this.fieldTypeKey; + } + + public void setFieldTypeKey(String fieldTypeKey) { + this.fieldTypeKey = fieldTypeKey; + } + + public String getFieldAlias() { + return this.fieldAlias; + } + + public void setFieldAlias(String fieldAlias) { + this.fieldAlias = fieldAlias; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/model/MultiSignal.java b/src/main/java/com/lark/project/service/field/model/MultiSignal.java new file mode 100644 index 0000000..8d54da6 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/model/MultiSignal.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + + +public class MultiSignal { + @SerializedName("status") + private String status; + + @SerializedName("detail") + private List detail; + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getDetail() { + return this.detail; + } + + public void setDetail(List detail) { + this.detail = detail; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/model/MultiSignalDetail.java b/src/main/java/com/lark/project/service/field/model/MultiSignalDetail.java new file mode 100644 index 0000000..a8db2e4 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/model/MultiSignalDetail.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.model; + +import com.google.gson.annotations.SerializedName; + + +public class MultiSignalDetail { + @SerializedName("id") + private String id; + + @SerializedName("title") + private String title; + + @SerializedName("status") + private String status; + + @SerializedName("view_link") + private String viewLink; + + @SerializedName("query_link") + private QueryLink queryLink; + + public String getID() { + return this.id; + } + + public void setID(String id) { + this.id = id; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getViewLink() { + return this.viewLink; + } + + public void setViewLink(String viewLink) { + this.viewLink = viewLink; + } + + public QueryLink getQueryLink() { + return this.queryLink; + } + + public void setQueryLink(QueryLink queryLink) { + this.queryLink = queryLink; + } + +} \ No newline at end of file diff --git a/src/main/java/com/lark/project/service/field/model/Option.java b/src/main/java/com/lark/project/service/field/model/Option.java new file mode 100644 index 0000000..ce5ddc7 --- /dev/null +++ b/src/main/java/com/lark/project/service/field/model/Option.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Lark Technologies Pte. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lark.project.service.field.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + + +public class Option { + @SerializedName("label") + private String label; + + @SerializedName("value") + private String value; + + @SerializedName("children") + private List