Skip to content

Commit

Permalink
refactor(api_task.go): Change type of several fields from *Multi[int]… (
Browse files Browse the repository at this point in the history
#41)

* refactor(api_task.go): Change type of several fields from *Multi[int] to *Multi[string] and *Enum[int] to *Enum[string] for better type compatibility and consistency

* refactor(api_task.go): Change type of several fields from *Multi[int] to *Multi[string] and *Enum[int] to *Enum[string] for better type compatibility and consistency
  • Loading branch information
flc1125 authored Dec 30, 2024
1 parent 462c49d commit 0b06117
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 78 deletions.
158 changes: 81 additions & 77 deletions api_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const (
TaskStatusDone TaskStatus = "done" // 已完成
)

func (s TaskStatus) String() string {
return string(s)
}

// Task 任务
type Task struct {
ID string `json:"id,omitempty"` // 任务ID
Expand Down Expand Up @@ -279,83 +283,83 @@ func (s *TaskService) GetTaskChangesCount(
// -----------------------------------------------------------------------------

type GetTasksRequest struct {
ID *Multi[int] `url:"id,omitempty"` // 支持多ID查询、模糊匹配
Name *string `url:"name,omitempty"` // 任务标题 支持模糊匹配
Description *string `url:"description,omitempty"` // 任务详细描述
WorkspaceID *int `url:"workspace_id,omitempty"` // [必须]项目ID
Creator *string `url:"creator,omitempty"` // 创建人 支持多人员查询
Created *string `url:"created,omitempty"` // 创建时间 支持时间查询
Modified *string `url:"modified,omitempty"` // 最后修改时间 支持时间查询
Status *Enum[TaskStatus] `url:"status,omitempty"` // 状态 支持枚举查询
Label *Enum[string] `url:"label,omitempty"` // 标签查询 支持枚举查询
Owner *string `url:"owner,omitempty"` // 任务当前处理人 支持模糊匹配
CC *string `url:"cc,omitempty"` // 抄送人
Begin *string `url:"begin,omitempty"` // 预计开始 支持时间查询
Due *string `url:"due,omitempty"` // 预计结束 支持时间查询
StoryID *Multi[int] `url:"story_id,omitempty"` // 关联需求的ID 支持多ID查询
IterationID *Enum[int] `url:"iteration_id,omitempty"` // 所属迭代的ID 支持枚举查询
Priority *string `url:"priority,omitempty"` //nolint:lll // 优先级。为了兼容自定义优先级,请使用 priority_label 字段,详情参考:如何兼容自定义优先级
PriorityLabel *PriorityLabel `url:"priority_label,omitempty"` // 优先级。推荐使用这个字段
Progress *int `url:"progress,omitempty"` // 进度
Completed *string `url:"completed,omitempty"` // 完成时间 支持时间查询
EffortCompleted *string `url:"effort_completed,omitempty"` // 完成工时
Exceed *float64 `url:"exceed,omitempty"` // 超出工时
Remain *float64 `url:"remain,omitempty"` // 剩余工时
Effort *string `url:"effort,omitempty"` // 预估工时
CustomFieldOne *string `url:"custom_field_one,omitempty"`
CustomFieldTwo *string `url:"custom_field_two,omitempty"`
CustomFieldThree *string `url:"custom_field_three,omitempty"`
CustomFieldFour *string `url:"custom_field_four,omitempty"`
CustomFieldFive *string `url:"custom_field_five,omitempty"`
CustomFieldSix *string `url:"custom_field_six,omitempty"`
CustomFieldSeven *string `url:"custom_field_seven,omitempty"`
CustomFieldEight *string `url:"custom_field_eight,omitempty"`
CustomField9 *string `url:"custom_field_9,omitempty"`
CustomField10 *string `url:"custom_field_10,omitempty"`
CustomField11 *string `url:"custom_field_11,omitempty"`
CustomField12 *string `url:"custom_field_12,omitempty"`
CustomField13 *string `url:"custom_field_13,omitempty"`
CustomField14 *string `url:"custom_field_14,omitempty"`
CustomField15 *string `url:"custom_field_15,omitempty"`
CustomField16 *string `url:"custom_field_16,omitempty"`
CustomField17 *string `url:"custom_field_17,omitempty"`
CustomField18 *string `url:"custom_field_18,omitempty"`
CustomField19 *string `url:"custom_field_19,omitempty"`
CustomField20 *string `url:"custom_field_20,omitempty"`
CustomField21 *string `url:"custom_field_21,omitempty"`
CustomField22 *string `url:"custom_field_22,omitempty"`
CustomField23 *string `url:"custom_field_23,omitempty"`
CustomField24 *string `url:"custom_field_24,omitempty"`
CustomField25 *string `url:"custom_field_25,omitempty"`
CustomField26 *string `url:"custom_field_26,omitempty"`
CustomField27 *string `url:"custom_field_27,omitempty"`
CustomField28 *string `url:"custom_field_28,omitempty"`
CustomField29 *string `url:"custom_field_29,omitempty"`
CustomField30 *string `url:"custom_field_30,omitempty"`
CustomField31 *string `url:"custom_field_31,omitempty"`
CustomField32 *string `url:"custom_field_32,omitempty"`
CustomField33 *string `url:"custom_field_33,omitempty"`
CustomField34 *string `url:"custom_field_34,omitempty"`
CustomField35 *string `url:"custom_field_35,omitempty"`
CustomField36 *string `url:"custom_field_36,omitempty"`
CustomField37 *string `url:"custom_field_37,omitempty"`
CustomField38 *string `url:"custom_field_38,omitempty"`
CustomField39 *string `url:"custom_field_39,omitempty"`
CustomField40 *string `url:"custom_field_40,omitempty"`
CustomField41 *string `url:"custom_field_41,omitempty"`
CustomField42 *string `url:"custom_field_42,omitempty"`
CustomField43 *string `url:"custom_field_43,omitempty"`
CustomField44 *string `url:"custom_field_44,omitempty"`
CustomField45 *string `url:"custom_field_45,omitempty"`
CustomField46 *string `url:"custom_field_46,omitempty"`
CustomField47 *string `url:"custom_field_47,omitempty"`
CustomField48 *string `url:"custom_field_48,omitempty"`
CustomField49 *string `url:"custom_field_49,omitempty"`
CustomField50 *string `url:"custom_field_50,omitempty"`
Limit *int `url:"limit,omitempty"` // 设置返回数量限制,默认为30
Page *int `url:"page,omitempty"` // 返回当前数量限制下第N页的数据,默认为1(第一页)
Order *Order `url:"order,omitempty"` //nolint:lll // 排序规则,规则:字段名 ASC或者DESC,然后 urlencode 如按创建时间逆序:order=created%20desc
Fields *Multi[string] `url:"fields,omitempty"` // 设置获取的字段,多个字段间以','逗号隔开
ID *Multi[string] `url:"id,omitempty"` // 支持多ID查询、模糊匹配
Name *string `url:"name,omitempty"` // 任务标题 支持模糊匹配
Description *string `url:"description,omitempty"` // 任务详细描述
WorkspaceID *int `url:"workspace_id,omitempty"` // [必须]项目ID
Creator *string `url:"creator,omitempty"` // 创建人 支持多人员查询
Created *string `url:"created,omitempty"` // 创建时间 支持时间查询
Modified *string `url:"modified,omitempty"` // 最后修改时间 支持时间查询
Status *Enum[string] `url:"status,omitempty"` // 状态 支持枚举查询
Label *Enum[string] `url:"label,omitempty"` // 标签查询 支持枚举查询
Owner *string `url:"owner,omitempty"` // 任务当前处理人 支持模糊匹配
CC *string `url:"cc,omitempty"` // 抄送人
Begin *string `url:"begin,omitempty"` // 预计开始 支持时间查询
Due *string `url:"due,omitempty"` // 预计结束 支持时间查询
StoryID *Multi[string] `url:"story_id,omitempty"` // 关联需求的ID 支持多ID查询
IterationID *Enum[string] `url:"iteration_id,omitempty"` // 所属迭代的ID 支持枚举查询
Priority *string `url:"priority,omitempty"` //nolint:lll // 优先级。为了兼容自定义优先级,请使用 priority_label 字段,详情参考:如何兼容自定义优先级
PriorityLabel *PriorityLabel `url:"priority_label,omitempty"` // 优先级。推荐使用这个字段
Progress *int `url:"progress,omitempty"` // 进度
Completed *string `url:"completed,omitempty"` // 完成时间 支持时间查询
EffortCompleted *string `url:"effort_completed,omitempty"` // 完成工时
Exceed *float64 `url:"exceed,omitempty"` // 超出工时
Remain *float64 `url:"remain,omitempty"` // 剩余工时
Effort *string `url:"effort,omitempty"` // 预估工时
CustomFieldOne *string `url:"custom_field_one,omitempty"`
CustomFieldTwo *string `url:"custom_field_two,omitempty"`
CustomFieldThree *string `url:"custom_field_three,omitempty"`
CustomFieldFour *string `url:"custom_field_four,omitempty"`
CustomFieldFive *string `url:"custom_field_five,omitempty"`
CustomFieldSix *string `url:"custom_field_six,omitempty"`
CustomFieldSeven *string `url:"custom_field_seven,omitempty"`
CustomFieldEight *string `url:"custom_field_eight,omitempty"`
CustomField9 *string `url:"custom_field_9,omitempty"`
CustomField10 *string `url:"custom_field_10,omitempty"`
CustomField11 *string `url:"custom_field_11,omitempty"`
CustomField12 *string `url:"custom_field_12,omitempty"`
CustomField13 *string `url:"custom_field_13,omitempty"`
CustomField14 *string `url:"custom_field_14,omitempty"`
CustomField15 *string `url:"custom_field_15,omitempty"`
CustomField16 *string `url:"custom_field_16,omitempty"`
CustomField17 *string `url:"custom_field_17,omitempty"`
CustomField18 *string `url:"custom_field_18,omitempty"`
CustomField19 *string `url:"custom_field_19,omitempty"`
CustomField20 *string `url:"custom_field_20,omitempty"`
CustomField21 *string `url:"custom_field_21,omitempty"`
CustomField22 *string `url:"custom_field_22,omitempty"`
CustomField23 *string `url:"custom_field_23,omitempty"`
CustomField24 *string `url:"custom_field_24,omitempty"`
CustomField25 *string `url:"custom_field_25,omitempty"`
CustomField26 *string `url:"custom_field_26,omitempty"`
CustomField27 *string `url:"custom_field_27,omitempty"`
CustomField28 *string `url:"custom_field_28,omitempty"`
CustomField29 *string `url:"custom_field_29,omitempty"`
CustomField30 *string `url:"custom_field_30,omitempty"`
CustomField31 *string `url:"custom_field_31,omitempty"`
CustomField32 *string `url:"custom_field_32,omitempty"`
CustomField33 *string `url:"custom_field_33,omitempty"`
CustomField34 *string `url:"custom_field_34,omitempty"`
CustomField35 *string `url:"custom_field_35,omitempty"`
CustomField36 *string `url:"custom_field_36,omitempty"`
CustomField37 *string `url:"custom_field_37,omitempty"`
CustomField38 *string `url:"custom_field_38,omitempty"`
CustomField39 *string `url:"custom_field_39,omitempty"`
CustomField40 *string `url:"custom_field_40,omitempty"`
CustomField41 *string `url:"custom_field_41,omitempty"`
CustomField42 *string `url:"custom_field_42,omitempty"`
CustomField43 *string `url:"custom_field_43,omitempty"`
CustomField44 *string `url:"custom_field_44,omitempty"`
CustomField45 *string `url:"custom_field_45,omitempty"`
CustomField46 *string `url:"custom_field_46,omitempty"`
CustomField47 *string `url:"custom_field_47,omitempty"`
CustomField48 *string `url:"custom_field_48,omitempty"`
CustomField49 *string `url:"custom_field_49,omitempty"`
CustomField50 *string `url:"custom_field_50,omitempty"`
Limit *int `url:"limit,omitempty"` // 设置返回数量限制,默认为30
Page *int `url:"page,omitempty"` // 返回当前数量限制下第N页的数据,默认为1(第一页)
Order *Order `url:"order,omitempty"` //nolint:lll // 排序规则,规则:字段名 ASC或者DESC,然后 urlencode 如按创建时间逆序:order=created%20desc
Fields *Multi[string] `url:"fields,omitempty"` // 设置获取的字段,多个字段间以','逗号隔开
}

// GetTasks 获取任务
Expand Down
2 changes: 1 addition & 1 deletion api_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestTaskService_GetTasks(t *testing.T) {

tasks, _, err := client.TaskService.GetTasks(ctx, &GetTasksRequest{
WorkspaceID: Ptr(11112222),
Status: NewEnum(TaskStatusOpen, TaskStatusDone),
Status: NewEnum(TaskStatusOpen.String(), TaskStatusDone.String()),
Fields: NewMulti("id", "workspace_id"),
})
assert.NoError(t, err)
Expand Down

0 comments on commit 0b06117

Please sign in to comment.