@@ -45,17 +45,6 @@ type CommentService struct {
45
45
client * Client
46
46
}
47
47
48
- type CreateCommentRequest struct {
49
- Title * string `json:"title,omitempty"` // 标题
50
- Description * string `json:"description,omitempty"` // 内容
51
- Author * string `json:"author,omitempty"` // 评论人
52
- EntryType * CommentEntryType `json:"entry_type,omitempty"` // 评论类型
53
- EntryID * int `json:"entry_id,omitempty"` // 评论所依附的业务对象实体id
54
- ReplyID * int `json:"reply_id,omitempty"` // 评论回复的ID
55
- RootID * int `json:"root_id,omitempty"` // 根评论ID
56
- WorkspaceID * int `json:"workspace_id,omitempty"` // 项目ID
57
- }
58
-
59
48
// CreateComment 添加评论接口
60
49
//
61
50
// https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/comment/add_comment.html
@@ -78,9 +67,47 @@ func (s *CommentService) CreateComment(
78
67
return response .Comment , resp , nil
79
68
}
80
69
70
+ type CreateCommentRequest struct {
71
+ Title * string `json:"title,omitempty"` // 标题
72
+ Description * string `json:"description,omitempty"` // 内容
73
+ Author * string `json:"author,omitempty"` // 评论人
74
+ EntryType * CommentEntryType `json:"entry_type,omitempty"` // 评论类型
75
+ EntryID * int64 `json:"entry_id,omitempty"` // 评论所依附的业务对象实体id
76
+ ReplyID * int64 `json:"reply_id,omitempty"` // 评论回复的ID
77
+ RootID * int64 `json:"root_id,omitempty"` // 根评论ID
78
+ WorkspaceID * int `json:"workspace_id,omitempty"` // 项目ID
79
+ }
80
+
81
+ // GetComments 获取评论
82
+ //
83
+ // https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/comment/get_comments.html
84
+ func (s * CommentService ) GetComments (
85
+ ctx context.Context , request * GetCommentsRequest , opts ... RequestOption ,
86
+ ) ([]* Comment , * Response , error ) {
87
+ req , err := s .client .NewRequest (ctx , http .MethodGet , "comments" , request , opts )
88
+ if err != nil {
89
+ return nil , nil , err
90
+ }
91
+
92
+ var items []struct {
93
+ Comment * Comment `json:"Comment"`
94
+ }
95
+ resp , err := s .client .Do (req , & items )
96
+ if err != nil {
97
+ return nil , resp , err
98
+ }
99
+
100
+ comments := make ([]* Comment , 0 , len (items ))
101
+ for _ , item := range items {
102
+ comments = append (comments , item .Comment )
103
+ }
104
+
105
+ return comments , resp , nil
106
+ }
107
+
81
108
type GetCommentsRequest struct {
82
109
// 评论ID 支持多ID查询
83
- ID * Multi [int ] `url:"id,omitempty"`
110
+ ID * Multi [int64 ] `url:"id,omitempty"`
84
111
85
112
// 标题
86
113
Title * string `url:"title,omitempty"`
@@ -95,7 +122,7 @@ type GetCommentsRequest struct {
95
122
EntryType * CommentEntryType `url:"entry_type,omitempty"`
96
123
97
124
// 评论所依附的业务对象实体id
98
- EntryID * int `url:"entry_id,omitempty"`
125
+ EntryID * int64 `url:"entry_id,omitempty"`
99
126
100
127
// 创建时间 支持时间查询
101
128
Created * string `url:"created,omitempty"`
@@ -107,10 +134,10 @@ type GetCommentsRequest struct {
107
134
WorkspaceID * int `url:"workspace_id,omitempty"`
108
135
109
136
// 根评论ID
110
- RootID * int `url:"root_id,omitempty"`
137
+ RootID * int64 `url:"root_id,omitempty"`
111
138
112
139
// 评论回复的ID
113
- ReplyID * int `url:"reply_id,omitempty"`
140
+ ReplyID * int64 `url:"reply_id,omitempty"`
114
141
115
142
// 设置返回数量限制,默认为30
116
143
Limit * int `url:"limit,omitempty"`
@@ -125,36 +152,29 @@ type GetCommentsRequest struct {
125
152
Fields * Multi [string ] `url:"fields,omitempty"`
126
153
}
127
154
128
- // GetComments 获取评论
155
+ // GetCommentsCount 获取评论数量
129
156
//
130
- // https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/comment/get_comments .html
131
- func (s * CommentService ) GetComments (
132
- ctx context.Context , request * GetCommentsRequest , opts ... RequestOption ,
133
- ) ([] * Comment , * Response , error ) {
134
- req , err := s .client .NewRequest (ctx , http .MethodGet , "comments" , request , opts )
157
+ // https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/comment/get_comments_count .html
158
+ func (s * CommentService ) GetCommentsCount (
159
+ ctx context.Context , request * GetCommentsCountRequest , opts ... RequestOption ,
160
+ ) (int , * Response , error ) {
161
+ req , err := s .client .NewRequest (ctx , http .MethodGet , "comments/count " , request , opts )
135
162
if err != nil {
136
- return nil , nil , err
163
+ return 0 , nil , err
137
164
}
138
165
139
- var items []struct {
140
- Comment * Comment `json:"Comment"`
141
- }
142
- resp , err := s .client .Do (req , & items )
166
+ var response CountResponse
167
+ resp , err := s .client .Do (req , & response )
143
168
if err != nil {
144
- return nil , resp , err
145
- }
146
-
147
- comments := make ([]* Comment , 0 , len (items ))
148
- for _ , item := range items {
149
- comments = append (comments , item .Comment )
169
+ return 0 , resp , err
150
170
}
151
171
152
- return comments , resp , nil
172
+ return response . Count , resp , nil
153
173
}
154
174
155
175
type GetCommentsCountRequest struct {
156
176
// 评论ID 支持多ID查询
157
- ID * Multi [int ] `url:"id,omitempty"`
177
+ ID * Multi [int64 ] `url:"id,omitempty"`
158
178
159
179
// 标题
160
180
Title * string `url:"title,omitempty"`
@@ -169,7 +189,7 @@ type GetCommentsCountRequest struct {
169
189
EntryType * CommentEntryType `url:"entry_type,omitempty"`
170
190
171
191
// 评论所依附的业务对象实体id
172
- EntryID * int `url:"entry_id,omitempty"`
192
+ EntryID * int64 `url:"entry_id,omitempty"`
173
193
174
194
// 创建时间 支持时间查询
175
195
Created * string `url:"created,omitempty"`
@@ -181,37 +201,10 @@ type GetCommentsCountRequest struct {
181
201
WorkspaceID * int `url:"workspace_id,omitempty"`
182
202
183
203
// 根评论ID
184
- RootID * int `url:"root_id,omitempty"`
204
+ RootID * int64 `url:"root_id,omitempty"`
185
205
186
206
// 评论回复的ID
187
- ReplyID * int `url:"reply_id,omitempty"`
188
- }
189
-
190
- // GetCommentsCount 获取评论数量
191
- //
192
- // https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/comment/get_comments_count.html
193
- func (s * CommentService ) GetCommentsCount (
194
- ctx context.Context , request * GetCommentsCountRequest , opts ... RequestOption ,
195
- ) (int , * Response , error ) {
196
- req , err := s .client .NewRequest (ctx , http .MethodGet , "comments/count" , request , opts )
197
- if err != nil {
198
- return 0 , nil , err
199
- }
200
-
201
- var response CountResponse
202
- resp , err := s .client .Do (req , & response )
203
- if err != nil {
204
- return 0 , resp , err
205
- }
206
-
207
- return response .Count , resp , nil
208
- }
209
-
210
- type UpdateCommentRequest struct {
211
- WorkspaceID * int `json:"workspace_id,omitempty"` // [必须]项目ID
212
- ID * int `json:"id,omitempty"` // [必须]评论ID
213
- Description * string `json:"description,omitempty"` // [必须]内容
214
- ChangeCreator * string `json:"change_creator,omitempty"` // 变更人
207
+ ReplyID * int64 `url:"reply_id,omitempty"`
215
208
}
216
209
217
210
// UpdateComment 更新评论接口
@@ -235,3 +228,10 @@ func (s *CommentService) UpdateComment(
235
228
236
229
return response .Comment , resp , nil
237
230
}
231
+
232
+ type UpdateCommentRequest struct {
233
+ WorkspaceID * int `json:"workspace_id,omitempty"` // [必须]项目ID
234
+ ID * int64 `json:"id,omitempty"` // [必须]评论ID
235
+ Description * string `json:"description,omitempty"` // [必须]内容
236
+ ChangeCreator * string `json:"change_creator,omitempty"` // 变更人
237
+ }
0 commit comments