-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIssue.php
122 lines (114 loc) · 4.35 KB
/
Issue.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
declare(strict_types=1);
namespace Coding;
use Illuminate\Validation\Rule;
class Issue extends Base
{
public const TYPE = ['DEFECT', 'REQUIREMENT', 'MISSION', 'EPIC', 'SUB_TASK'];
public const PRIORITY = [
'低' => '0',
'中' => '1',
'高' => '2',
'紧急' => '3',
];
public function create(array $data): array
{
$this->validate($data, [
'Name' => 'string|required',
'Priority' => [
'string',
'required',
Rule::in(array_values(self::PRIORITY)),
],
'Type' => [
'required',
Rule::in(self::TYPE),
],
// 事项类型 ID,比如「用户故事」属于「需求」,必须指定此 ID,而「缺陷」就一种,不需要
'IssueTypeId' => 'nullable|integer',
'ParentCode' => 'nullable|integer',
'StatusId' => 'nullable|integer',
'AssigneeId' => 'nullable|integer',
'Description' => 'nullable|string',
'StartDate' => 'nullable|date_format:Y-m-d',
'DueDate' => 'nullable|date_format:Y-m-d|after:StartDate',
'WorkingHours' => 'nullable|numeric',
// 项目模块 ID
'ProjectModuleId' => 'nullable|integer',
// 事项关注人 ID 列表
'WatcherIds' => 'nullable|array',
'WatcherIds.*' => 'integer',
// 项目缺陷类型 ID
'DefectTypeId' => 'nullable|integer',
// 项目需求类型 ID
'RequirementTypeId' => 'nullable|integer',
'IterationCode' => 'nullable|integer',
'EpicCode' => 'nullable|integer',
'StoryPoint' => 'nullable|string',
'LabelIds' => 'nullable|array',
'FileIds' => 'nullable|array',
// 排序目标位置的事项 code
'TargetSortCode' => 'nullable|integer',
// 第三方链接列表 Array of CreateThirdLinkForm
'ThirdLinks' => 'nullable|array',
// 自定义属性值列表 Array of IssueCustomFieldForm
'CustomFieldValues' => 'nullable|array',
]);
$response = $this->client->requestProjectApi('CreateIssue', $data);
return $response['Issue'];
}
public function delete(array $data): bool
{
$this->validate($data, [
'IssueCode' => 'integer|required',
]);
$this->client->requestProjectApi('DeleteIssue', $data);
return true;
}
public function get(array $data): array
{
$this->validate($data, [
'IssueCode' => 'integer|required',
]);
$response = $this->client->requestProjectApi('DescribeIssue', $data);
return $response['Issue'];
}
public function update(array $data): array
{
$this->validate($data, [
'IssueCode' => 'integer',
'ParentCode' => 'nullable|integer',
'Name' => 'nullable|string',
'StatusId' => 'nullable|integer',
'AssigneeId' => 'nullable|integer',
'DueDate' => 'nullable|date_format:Y-m-d|after:StartDate',
'StartDate' => 'nullable|date_format:Y-m-d',
'WorkingHours' => 'nullable|numeric',
// 项目模块 ID
'ProjectModuleId' => 'nullable|integer',
// 事项关注人 ID 列表
'WatcherIds' => 'nullable|array',
'WatcherIds.*' => 'integer',
// 删除的事项关注人 Id 列表
'DelWatcherIds' => 'nullable|array',
// 项目缺陷类型 ID
'DefectTypeId' => 'nullable|integer',
// 项目需求类型 ID
'RequirementTypeId' => 'nullable|integer',
'Priority' => [
'string',
'nullable',
Rule::in(array_values(self::PRIORITY)),
],
'StoryPoint' => 'nullable|string',
'LabelIds' => 'nullable|array',
'DelLabelIds' => 'nullable|array',
'FileIds' => 'nullable|array',
'DelFileIds' => 'nullable|array',
// 自定义属性值列表 Array of IssueCustomFieldForm
'CustomFieldValues' => 'nullable|array',
]);
$response = $this->client->requestProjectApi('ModifyIssue', $data);
return $response['Issue'];
}
}