优化
This commit is contained in:
parent
285887d0e2
commit
09e99ac379
2
go.mod
2
go.mod
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
plugins.Home: "home blog ",
|
}
|
||||||
plugins.Archive: "archive date page-two-column",
|
|
||||||
plugins.Category: str.Join("archive category page-two-column ", s),
|
var class = map[int]string{
|
||||||
plugins.Tag: str.Join("archive category page-two-column ", s),
|
plugins.Home: "home blog ",
|
||||||
plugins.Search: str.Join("search ", s),
|
plugins.Archive: "archive date page-two-column",
|
||||||
plugins.Detail: str.Join("post-template-default single single-post single-format-standard ", s),
|
plugins.Category: "archive category page-two-column",
|
||||||
}[h.scene]
|
plugins.Tag: "archive category page-two-column ",
|
||||||
|
plugins.Search: "search ",
|
||||||
|
plugins.Detail: "post-template-default single single-post single-format-standard ",
|
||||||
}
|
}
|
||||||
|
|
|
@ -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...)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user