Skip to content

Commit ec9c203

Browse files
13791379
authored andcommitted
fix: pagination
1 parent d07cf6d commit ec9c203

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

service/impl/post_tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (p *postTagServiceImpl) PagePost(ctx context.Context, postQuery param.PostQ
4141
postDo = postDo.Where(postDAL.Status.In(statuesValue...))
4242
}
4343
if postQuery.TagID != nil {
44-
postDo.Join(&entity.PostTag{}, postDAL.ID.EqCol(postTagDAL.PostID)).Where(postTagDAL.ID.Eq(*postQuery.TagID))
44+
postDo.Join(&entity.PostTag{}, postDAL.ID.EqCol(postTagDAL.PostID)).Where(postTagDAL.TagID.Eq(*postQuery.TagID))
4545
}
4646
posts, totalCount, err := postDo.FindByPage(postQuery.PageNum*postQuery.PageSize, postQuery.PageSize)
4747
if err != nil {

template/extension/pagination.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (p *paginationExtension) addArchivesPagination() {
5353
if err != nil {
5454
return nil, err
5555
}
56-
return p.getPagination(ctx, page, total, display, prefix, suffix)
56+
return p.getPagination(ctx, page, total, display, "/"+prefix, suffix)
5757
}
5858
p.Template.AddFunc("archivesPagination", archivesPagination)
5959
}
@@ -81,7 +81,7 @@ func (p *paginationExtension) addTagPostsPagination() {
8181
if err != nil {
8282
return nil, err
8383
}
84-
return p.getPagination(ctx, page, total, display, tagPrefix.(string)+"/"+slug, suffix)
84+
return p.getPagination(ctx, page, total, display, "/"+tagPrefix.(string)+"/"+slug, suffix)
8585
}
8686
p.Template.AddFunc("tagPostsPagination", tagPostsPagination)
8787
}
@@ -97,7 +97,7 @@ func (p *paginationExtension) addCategoryPostsPagination() {
9797
if err != nil {
9898
return nil, err
9999
}
100-
return p.getPagination(ctx, page, total, display, categoryPrefix.(string)+"/"+slug, suffix)
100+
return p.getPagination(ctx, page, total, display, "/"+categoryPrefix.(string)+"/"+slug, suffix)
101101
}
102102
p.Template.AddFunc("categoryPostsPagination", categoryPostsPagination)
103103
}
@@ -113,7 +113,7 @@ func (p *paginationExtension) addPhotosPagination() {
113113
if err != nil {
114114
return nil, err
115115
}
116-
return p.getPagination(ctx, page, total, display, prefix, suffix)
116+
return p.getPagination(ctx, page, total, display, "/"+prefix, suffix)
117117
}
118118
p.Template.AddFunc("photosPagination", photosPagination)
119119
}
@@ -129,7 +129,7 @@ func (p *paginationExtension) addJournalsPagination() {
129129
if err != nil {
130130
return nil, err
131131
}
132-
return p.getPagination(ctx, page, total, display, prefix, suffix)
132+
return p.getPagination(ctx, page, total, display, "/"+prefix, suffix)
133133
}
134134
p.Template.AddFunc("journalsPagination", journalsPagination)
135135
}
@@ -154,12 +154,12 @@ func (p *paginationExtension) getPagination(ctx context.Context, page, total, di
154154

155155
rainbow := util.RainbowPage(page+1, total, display)
156156

157-
rainbowPages := make([]vo.RainbowPage, len(rainbow), len(rainbow))
157+
rainbowPages := make([]vo.RainbowPage, len(rainbow))
158158

159159
nextPageFullPath += prefix + "/page/" + strconv.Itoa(page+2) + suffix
160160

161161
if page == 1 {
162-
prevPageFullPath += "/"
162+
prevPageFullPath += prefix + "/"
163163
} else {
164164
prevPageFullPath += prefix + "/page/" + strconv.Itoa(page) + suffix
165165
}

0 commit comments

Comments
 (0)