This commit is contained in:
xing 2023-02-05 18:29:55 +08:00
parent 285887d0e2
commit 09e99ac379
3 changed files with 11 additions and 11 deletions

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/fthvgb1/wp-go module github.com/fthvgb1/wp-go
go 1.18 go 1.19
require ( require (
github.com/dlclark/regexp2 v1.7.0 github.com/dlclark/regexp2 v1.7.0

View File

@ -165,12 +165,14 @@ func (h handle) bodyClass() string {
case plugins.Detail: case plugins.Detail:
s = fmt.Sprintf("postid-%d", h.ginH["post"].(models.Posts).Id) s = fmt.Sprintf("postid-%d", h.ginH["post"].(models.Posts).Id)
} }
return map[int]string{ return str.Join(class[h.scene], s)
}
var class = map[int]string{
plugins.Home: "home blog ", plugins.Home: "home blog ",
plugins.Archive: "archive date page-two-column", plugins.Archive: "archive date page-two-column",
plugins.Category: str.Join("archive category page-two-column ", s), plugins.Category: "archive category page-two-column",
plugins.Tag: str.Join("archive category page-two-column ", s), plugins.Tag: "archive category page-two-column ",
plugins.Search: str.Join("search ", s), plugins.Search: "search ",
plugins.Detail: str.Join("post-template-default single single-post single-format-standard ", s), plugins.Detail: "post-template-default single single-post single-format-standard ",
}[h.scene]
} }

View File

@ -6,7 +6,6 @@ import (
"golang.org/x/exp/constraints" "golang.org/x/exp/constraints"
"math/rand" "math/rand"
"strings" "strings"
"time"
) )
func SimplePagination[T Model](ctx context.Context, where ParseWhere, fields, group string, page, pageSize int, order SqlBuilder, join SqlBuilder, having SqlBuilder, in ...[]any) (r []T, total int, err error) { func SimplePagination[T Model](ctx context.Context, where ParseWhere, fields, group string, page, pageSize int, order SqlBuilder, join SqlBuilder, having SqlBuilder, in ...[]any) (r []T, total int, err error) {
@ -59,7 +58,6 @@ func SimplePagination[T Model](ctx context.Context, where ParseWhere, fields, gr
err = globalBb.Get(ctx, &n, sq, args...) err = globalBb.Get(ctx, &n, sq, args...)
} else { } else {
tpx := "select count(*) n from (select %s from %s %s %s %s %s ) %s" tpx := "select count(*) n from (select %s from %s %s %s %s %s ) %s"
rand.Seed(int64(time.Now().Nanosecond()))
sq := fmt.Sprintf(tpx, group, rr.Table(), j, w, groupBy, h, fmt.Sprintf("table%d", rand.Int())) sq := fmt.Sprintf(tpx, group, rr.Table(), j, w, groupBy, h, fmt.Sprintf("table%d", rand.Int()))
err = globalBb.Get(ctx, &n, sq, args...) err = globalBb.Get(ctx, &n, sq, args...)
} }