@@ -45,17 +45,6 @@ type CommentService struct {
4545 client * Client
4646}
4747
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-
5948// CreateComment 添加评论接口
6049//
6150// 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(
7867 return response .Comment , resp , nil
7968}
8069
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+
81108type GetCommentsRequest struct {
82109 // 评论ID 支持多ID查询
83- ID * Multi [int ] `url:"id,omitempty"`
110+ ID * Multi [int64 ] `url:"id,omitempty"`
84111
85112 // 标题
86113 Title * string `url:"title,omitempty"`
@@ -95,7 +122,7 @@ type GetCommentsRequest struct {
95122 EntryType * CommentEntryType `url:"entry_type,omitempty"`
96123
97124 // 评论所依附的业务对象实体id
98- EntryID * int `url:"entry_id,omitempty"`
125+ EntryID * int64 `url:"entry_id,omitempty"`
99126
100127 // 创建时间 支持时间查询
101128 Created * string `url:"created,omitempty"`
@@ -107,10 +134,10 @@ type GetCommentsRequest struct {
107134 WorkspaceID * int `url:"workspace_id,omitempty"`
108135
109136 // 根评论ID
110- RootID * int `url:"root_id,omitempty"`
137+ RootID * int64 `url:"root_id,omitempty"`
111138
112139 // 评论回复的ID
113- ReplyID * int `url:"reply_id,omitempty"`
140+ ReplyID * int64 `url:"reply_id,omitempty"`
114141
115142 // 设置返回数量限制,默认为30
116143 Limit * int `url:"limit,omitempty"`
@@ -125,36 +152,29 @@ type GetCommentsRequest struct {
125152 Fields * Multi [string ] `url:"fields,omitempty"`
126153}
127154
128- // GetComments 获取评论
155+ // GetCommentsCount 获取评论数量
129156//
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 )
135162 if err != nil {
136- return nil , nil , err
163+ return 0 , nil , err
137164 }
138165
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 )
143168 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
150170 }
151171
152- return comments , resp , nil
172+ return response . Count , resp , nil
153173}
154174
155175type GetCommentsCountRequest struct {
156176 // 评论ID 支持多ID查询
157- ID * Multi [int ] `url:"id,omitempty"`
177+ ID * Multi [int64 ] `url:"id,omitempty"`
158178
159179 // 标题
160180 Title * string `url:"title,omitempty"`
@@ -169,7 +189,7 @@ type GetCommentsCountRequest struct {
169189 EntryType * CommentEntryType `url:"entry_type,omitempty"`
170190
171191 // 评论所依附的业务对象实体id
172- EntryID * int `url:"entry_id,omitempty"`
192+ EntryID * int64 `url:"entry_id,omitempty"`
173193
174194 // 创建时间 支持时间查询
175195 Created * string `url:"created,omitempty"`
@@ -181,37 +201,10 @@ type GetCommentsCountRequest struct {
181201 WorkspaceID * int `url:"workspace_id,omitempty"`
182202
183203 // 根评论ID
184- RootID * int `url:"root_id,omitempty"`
204+ RootID * int64 `url:"root_id,omitempty"`
185205
186206 // 评论回复的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"`
215208}
216209
217210// UpdateComment 更新评论接口
@@ -235,3 +228,10 @@ func (s *CommentService) UpdateComment(
235228
236229 return response .Comment , resp , nil
237230}
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