Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a8d393

Browse files
committed
判断内容是不是一样的,避免某种原因,重复发评论
1 parent 7d385ee commit 8a8d393

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/logic/comment.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ func (self CommentLogic) Publish(ctx context.Context, uid, objid int, form url.V
170170
} else {
171171
comment.Floor = tmpCmt.Floor + 1
172172
}
173+
174+
if tmpCmt.Uid == comment.Uid && tmpCmt.Content == comment.Content {
175+
objLog.Infof("had post comment: %+v", *comment)
176+
return tmpCmt, nil
177+
}
178+
173179
// 入评论库
174180
_, err = MasterDB.Insert(comment)
175181
if err != nil {

0 commit comments

Comments
 (0)