@@ -230,15 +230,13 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
230230}
231231
232232func (as * AnswerService ) Update (ctx context.Context , req * schema.AnswerUpdateReq ) (string , error ) {
233- //req.NoNeedReview //true 不需要审核
234233 var canUpdate bool
235234 _ , existUnreviewed , err := as .revisionService .ExistUnreviewedByObjectID (ctx , req .ID )
236235 if err != nil {
237236 return "" , err
238237 }
239238 if existUnreviewed {
240- err = errors .BadRequest (reason .AnswerCannotUpdate )
241- return "" , err
239+ return "" , errors .BadRequest (reason .AnswerCannotUpdate )
242240 }
243241
244242 questionInfo , exist , err := as .questionRepo .GetQuestion (ctx , req .QuestionID )
@@ -254,28 +252,25 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
254252 return "" , err
255253 }
256254 if ! exist {
257- return "" , nil
255+ return "" , errors . BadRequest ( reason . AnswerNotFound )
258256 }
259257
260258 if answerInfo .Status == entity .AnswerStatusDeleted {
261- err = errors .BadRequest (reason .AnswerCannotUpdate )
262- return "" , err
259+ return "" , errors .BadRequest (reason .AnswerCannotUpdate )
263260 }
264261
265262 //If the content is the same, ignore it
266263 if answerInfo .OriginalText == req .Content {
267264 return "" , nil
268265 }
269266
270- now := time .Now ()
271- insertData := new (entity.Answer )
267+ insertData := & entity.Answer {}
272268 insertData .ID = req .ID
273269 insertData .UserID = answerInfo .UserID
274270 insertData .QuestionID = req .QuestionID
275271 insertData .OriginalText = req .Content
276272 insertData .ParsedText = req .HTML
277- insertData .UpdatedAt = now
278-
273+ insertData .UpdatedAt = time .Now ()
279274 insertData .LastEditUserID = "0"
280275 if answerInfo .UserID != req .UserID {
281276 insertData .LastEditUserID = req .UserID
@@ -284,7 +279,6 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
284279 revisionDTO := & schema.AddRevisionDTO {
285280 UserID : req .UserID ,
286281 ObjectID : req .ID ,
287- Title : "" ,
288282 Log : req .EditSummary ,
289283 }
290284
@@ -314,7 +308,7 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
314308 }
315309 if canUpdate {
316310 as .activityQueueService .Send (ctx , & schema.ActivityMsg {
317- UserID : insertData .UserID ,
311+ UserID : req .UserID ,
318312 ObjectID : insertData .ID ,
319313 OriginalObjectID : insertData .ID ,
320314 ActivityTypeKey : constant .ActAnswerEdited ,
0 commit comments