Skip to content

Commit 225469c

Browse files
committed
feat.add service
1 parent 8e1f818 commit 225469c

File tree

10 files changed

+433
-0
lines changed

10 files changed

+433
-0
lines changed

src/main/java/com/lark/project/service/workitem/WorkItemService.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,17 @@ public interface WorkItemService {
117117
*/
118118
public UpdateCompoundFieldValueResp updateCompoundFieldValue(UpdateCompoundFieldValueReq req, RequestOptions reqOptions) throws Exception;
119119

120+
/**
121+
* 批量更新工作项。
122+
*
123+
* <p>对应 OpenAPI:{@code POST /open_api/:project_key/work_item/:work_item_type_key/batch_update}</p>
124+
*/
125+
public BatchUpdateWorkItemResp batchUpdateWorkItem(BatchUpdateWorkItemReq req, RequestOptions reqOptions) throws Exception;
126+
127+
/**
128+
* 获取任务结果。
129+
*
130+
* <p>对应 OpenAPI:{@code GET /open_api/:project_key/work_item/:work_item_type_key/:work_item_id/task_result}</p>
131+
*/
132+
public GetTaskResultResp getTaskResult(GetTaskResultReq req, RequestOptions reqOptions) throws Exception;
120133
}

src/main/java/com/lark/project/service/workitem/WorkItemServiceImpl.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,4 +680,50 @@ public UpdateCompoundFieldValueResp updateCompoundFieldValue(UpdateCompoundField
680680

681681
return resp;
682682
}
683+
684+
@Override
685+
public BatchUpdateWorkItemResp batchUpdateWorkItem(BatchUpdateWorkItemReq req, RequestOptions reqOptions) throws Exception {
686+
if (reqOptions == null) {
687+
reqOptions = new RequestOptions();
688+
}
689+
690+
RawResponse httpResponse = Transport.doSend(config, reqOptions, "POST"
691+
, "/open_api/work_item/batch_update"
692+
, false
693+
, req);
694+
695+
BatchUpdateWorkItemResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, BatchUpdateWorkItemResp.class);
696+
if (resp == null) {
697+
log.error(Logs.formatReq(req, httpResponse, "/open_api/work_item/batch_update"));
698+
throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL);
699+
}
700+
701+
resp.setRawResponse(httpResponse);
702+
resp.setRequest(req);
703+
704+
return resp;
705+
}
706+
707+
@Override
708+
public GetTaskResultResp getTaskResult(GetTaskResultReq req, RequestOptions reqOptions) throws Exception {
709+
if (reqOptions == null) {
710+
reqOptions = new RequestOptions();
711+
}
712+
713+
RawResponse httpResponse = Transport.doSend(config, reqOptions, "GET"
714+
, "/open_api/task_result"
715+
, false
716+
, req);
717+
718+
GetTaskResultResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, GetTaskResultResp.class);
719+
if (resp == null) {
720+
log.error(Logs.formatReq(req, httpResponse, "/open_api/task_result"));
721+
throw new IllegalArgumentException(ErrConstants.RESULT_ILLEGAL);
722+
}
723+
724+
resp.setRawResponse(httpResponse);
725+
resp.setRequest(req);
726+
727+
return resp;
728+
}
683729
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.lark.project.service.workitem.builder;
2+
3+
import com.lark.project.core.annotation.Body;
4+
import com.lark.project.service.field.model.FieldValuePair;
5+
6+
import java.util.List;
7+
8+
/**
9+
* 批量更新工作项的请求对象。
10+
*
11+
* <p>对应 OpenAPI:{@code POST /open_api/:project_key/work_item/:work_item_type_key/batch_update}</p>
12+
*/
13+
public class BatchUpdateWorkItemReq {
14+
@Body
15+
private BatchUpdateWorkItemReqBody body;
16+
17+
public BatchUpdateWorkItemReq() {
18+
}
19+
20+
public BatchUpdateWorkItemReq(Builder builder) {
21+
this.body = builder.body;
22+
}
23+
24+
public static Builder newBuilder() {
25+
return new Builder();
26+
}
27+
28+
public BatchUpdateWorkItemReqBody getBatchUpdateWorkItemReqBody() {
29+
return this.body;
30+
}
31+
32+
public void setBatchUpdateWorkItemReqBody(BatchUpdateWorkItemReqBody body) {
33+
this.body = body;
34+
}
35+
public static class Builder {
36+
private BatchUpdateWorkItemReqBody body;
37+
38+
public Builder() {
39+
body = new BatchUpdateWorkItemReqBody();
40+
}
41+
42+
public BatchUpdateWorkItemReq build() {
43+
return new BatchUpdateWorkItemReq(this);
44+
}
45+
46+
public BatchUpdateWorkItemReq.Builder projectKey(String projectKey) {
47+
body.setProjectKey(projectKey);
48+
return this;
49+
}
50+
51+
public BatchUpdateWorkItemReq.Builder workItemIds(List<Long> workItemIds) {
52+
body.setWorkItemIds(workItemIds);
53+
return this;
54+
}
55+
56+
public BatchUpdateWorkItemReq.Builder workItemTypeKey(String workItemTypeKey) {
57+
body.setWorkItemTypeKey(workItemTypeKey);
58+
return this;
59+
}
60+
61+
public BatchUpdateWorkItemReq.Builder updateMode(String updateMode) {
62+
body.setUpdateMode(updateMode);
63+
return this;
64+
}
65+
66+
public BatchUpdateWorkItemReq.Builder fieldKey(String fieldKey) {
67+
body.setFieldKey(fieldKey);
68+
return this;
69+
}
70+
71+
public BatchUpdateWorkItemReq.Builder beforeFieldValue(Object beforeFieldValue) {
72+
body.setBeforeFieldValue(beforeFieldValue);
73+
return this;
74+
}
75+
76+
77+
public BatchUpdateWorkItemReq.Builder afterFieldValue(Object afterFieldValue) {
78+
body.setAfterFieldValue(afterFieldValue);
79+
return this;
80+
}
81+
82+
}
83+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.lark.project.service.workitem.builder;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import com.lark.project.service.field.model.FieldValuePair;
5+
6+
import java.util.List;
7+
8+
public class BatchUpdateWorkItemReqBody {
9+
@SerializedName("project_key")
10+
private String projectKey;
11+
12+
@SerializedName("work_item_ids")
13+
private List<Long> workItemIds;
14+
15+
@SerializedName("work_item_type_key")
16+
private String workItemTypeKey;
17+
18+
@SerializedName("update_mode")
19+
private String updateMode;
20+
21+
@SerializedName("field_key")
22+
private String fieldKey;
23+
24+
@SerializedName("before_field_value")
25+
private Object beforeFieldValue;
26+
27+
@SerializedName("after_field_value")
28+
private Object afterFieldValue;
29+
30+
31+
public String getProjectKey() {
32+
return projectKey;
33+
}
34+
35+
public void setProjectKey(String projectKey) {
36+
this.projectKey = projectKey;
37+
}
38+
39+
public List<Long> getWorkItemIds() {
40+
return workItemIds;
41+
}
42+
43+
public void setWorkItemIds(List<Long> workItemIds) {
44+
this.workItemIds = workItemIds;
45+
}
46+
47+
public String getWorkItemTypeKey() {
48+
return workItemTypeKey;
49+
}
50+
51+
public void setWorkItemTypeKey(String workItemTypeKey) {
52+
this.workItemTypeKey = workItemTypeKey;
53+
}
54+
55+
public String getUpdateMode() {
56+
return updateMode;
57+
}
58+
59+
public void setUpdateMode(String updateMode) {
60+
this.updateMode = updateMode;
61+
}
62+
63+
public String getFieldKey() {
64+
return fieldKey;
65+
}
66+
67+
public void setFieldKey(String fieldKey) {
68+
this.fieldKey = fieldKey;
69+
}
70+
71+
public Object getBeforeFieldValue() {
72+
return beforeFieldValue;
73+
}
74+
75+
public void setBeforeFieldValue(Object beforeFieldValue) {
76+
this.beforeFieldValue = beforeFieldValue;
77+
}
78+
79+
public Object getAfterFieldValue() {
80+
return afterFieldValue;
81+
}
82+
83+
public void setAfterFieldValue(Object afterFieldValue) {
84+
this.afterFieldValue = afterFieldValue;
85+
}
86+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.lark.project.service.workitem.builder;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import com.lark.project.core.response.BaseResponse;
5+
import com.lark.project.service.workitem.model.BatchUpdateWorkItemResult;
6+
import com.lark.project.service.workitem.model.WorkItemInfo;
7+
8+
import java.util.List;
9+
10+
/**
11+
* 批量更新工作项的响应对象。
12+
*
13+
* <p>对应 OpenAPI:{@code POST /open_api/:project_key/work_item/:work_item_type_key/batch_update}</p>
14+
*/
15+
public class BatchUpdateWorkItemResp extends BaseResponse {
16+
@SerializedName("data")
17+
private BatchUpdateWorkItemResult data;
18+
public BatchUpdateWorkItemResult getData() {
19+
return this.data;
20+
}
21+
22+
public void setData(BatchUpdateWorkItemResult data) {
23+
this.data = data;
24+
}
25+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.lark.project.service.workitem.builder;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import com.lark.project.core.annotation.Query;
5+
6+
public class GetTaskResultReq {
7+
@Query
8+
@SerializedName("task_id")
9+
private String taskId;
10+
11+
public GetTaskResultReq() {
12+
}
13+
14+
public GetTaskResultReq(Builder builder) {
15+
this.taskId = builder.taskId;
16+
}
17+
18+
public static Builder newBuilder() {
19+
return new Builder();
20+
}
21+
22+
23+
public String getTaskId() {
24+
return this.taskId;
25+
}
26+
27+
public void setTaskId(String taskId) {
28+
this.taskId = taskId;
29+
}
30+
31+
public static class Builder {
32+
private String taskId;
33+
34+
public Builder() {
35+
}
36+
37+
public Builder taskId(String taskId) {
38+
this.taskId = taskId;
39+
return this;
40+
}
41+
42+
public GetTaskResultReq build() {
43+
return new GetTaskResultReq(this);
44+
}
45+
}
46+
47+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.lark.project.service.workitem.builder;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import com.lark.project.core.response.BaseResponse;
5+
import com.lark.project.service.workitem.model.GetTaskResult;
6+
7+
import java.util.List;
8+
9+
public class GetTaskResultResp extends BaseResponse {
10+
11+
@SerializedName("data")
12+
private GetTaskResult data;
13+
14+
public GetTaskResult getData() {
15+
return data;
16+
}
17+
18+
public void setData(GetTaskResult data) {
19+
this.data = data;
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.lark.project.service.workitem.model;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
5+
public class BatchUpdateWorkItemResult {
6+
@SerializedName("task_id")
7+
private String taskId;
8+
9+
public String getTaskId() {
10+
return taskId;
11+
}
12+
13+
public void setTaskId(String taskId) {
14+
this.taskId = taskId;
15+
}
16+
}

0 commit comments

Comments
 (0)