File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -30,11 +30,17 @@ func RecentCommentByPage(c *fiber.Ctx) (err error) {
30
30
}
31
31
32
32
db := database .GetDB ()
33
- var comments []models. Comment
33
+
34
34
var count int64
35
- result := db .Preload ("User" ).Preload ("CourseGroup" ).Preload ("CourseGroup.Course" ).Preload ("CourseGroup.Teachers" ).Count (& count ).
36
- Order ("update_time DESC" ).Offset ((id - 1 ) * 30 ).Limit (30 ).Find (& comments )
37
- if err := result .Error ; err != nil {
35
+ err = db .Model (& models.Comment {}).Count (& count ).Error
36
+ if err != nil {
37
+ return errors .Wrap (err , errors .DatabaseError )
38
+ }
39
+
40
+ var comments []models.Comment
41
+ err = db .Preload ("User" ).Preload ("CourseGroup" ).Preload ("CourseGroup.Course" ).Preload ("CourseGroup.Teachers" ).
42
+ Order ("update_time DESC" ).Offset ((id - 1 ) * 30 ).Limit (30 ).Find (& comments ).Error
43
+ if err != nil {
38
44
return errors .Wrap (err , errors .DatabaseError )
39
45
}
40
46
You can’t perform that action at this time.
0 commit comments