Compare commits
No commits in common. "26950a37bb1ac9bbba15e39281780170b5441024" and "1b1e3bf8f351ae1e527172a717ea936fc400f25b" have entirely different histories.
26950a37bb
...
1b1e3bf8f3
|
@ -92,10 +92,8 @@ func GetPostsByIds(a ...any) (m map[uint64]models.Posts, err error) {
|
|||
func SearchPostIds(args ...any) (ids PostIds, err error) {
|
||||
ctx := args[0].(context.Context)
|
||||
q := args[1].(model.QueryCondition)
|
||||
page := args[2].(int)
|
||||
pageSize := args[3].(int)
|
||||
q.Fields = "ID"
|
||||
res, total, err := model.Pagination[models.Posts](ctx, q, page, pageSize)
|
||||
res, total, err := model.Pagination[models.Posts](ctx, q)
|
||||
for _, posts := range res {
|
||||
ids.Ids = append(ids.Ids, posts.Id)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func (h *Handle) CalBodyClass() {
|
|||
|
||||
func (h *Handle) BodyClass(class ...string) string {
|
||||
if constraints.Ok != h.Stats {
|
||||
class = append(class, "error404")
|
||||
return "error404"
|
||||
}
|
||||
switch h.Scene {
|
||||
case constraints.Home:
|
||||
|
|
|
@ -40,6 +40,8 @@ func NewHandle(c *gin.Context, scene int, theme string) *Handle {
|
|||
Session: sessions.Default(c),
|
||||
GinH: gin.H{},
|
||||
Scene: scene,
|
||||
Code: http.StatusOK,
|
||||
Stats: constraints.Ok,
|
||||
ThemeMods: mods,
|
||||
Scripts: make(map[string][]func(*Handle) string),
|
||||
}
|
||||
|
@ -73,42 +75,21 @@ func (h *Handle) GetPassword() {
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Handle) ExecHandleFns() {
|
||||
for _, fn := range h.HandleFns {
|
||||
fn(h)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handle) PreTemplate() {
|
||||
func (h *Handle) Render() {
|
||||
if h.Templ == "" {
|
||||
h.Templ = str.Join(h.Theme, "/posts/index.gohtml")
|
||||
if h.Scene == constraints.Detail {
|
||||
h.Templ = str.Join(h.Theme, "/posts/detail.gohtml")
|
||||
}
|
||||
}
|
||||
}
|
||||
func (h *Handle) PreCodeAndStats() {
|
||||
if h.Stats != 0 && h.Code != 0 {
|
||||
return
|
||||
for _, fn := range h.HandleFns {
|
||||
fn(h)
|
||||
}
|
||||
switch h.Stats {
|
||||
case constraints.Ok:
|
||||
h.Code = http.StatusOK
|
||||
case constraints.ParamError, constraints.Error404:
|
||||
h.Code = http.StatusNotFound
|
||||
case constraints.InternalErr:
|
||||
h.Code = http.StatusInternalServerError
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handle) Render() {
|
||||
h.PreCodeAndStats()
|
||||
h.PreTemplate()
|
||||
h.ExecHandleFns()
|
||||
h.PushHeadScript(constraints.HeadScript, CalSiteIcon, CalCustomCss)
|
||||
h.PlushComponent("customLogo", CalCustomLogo)
|
||||
h.CalMultipleScript()
|
||||
h.CalBodyClass()
|
||||
|
||||
h.C.HTML(h.Code, h.Templ, h.GinH)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||
"github.com/fthvgb1/wp-go/internal/pkg/cache"
|
||||
|
@ -10,6 +9,7 @@ import (
|
|||
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
||||
"github.com/fthvgb1/wp-go/internal/plugins"
|
||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DetailHandle struct {
|
||||
|
@ -38,19 +38,11 @@ func (d *DetailHandle) CheckAndGetPost() (err error) {
|
|||
id := str.ToInteger[uint64](d.C.Param("id"), 0)
|
||||
maxId, err := cache.GetMaxPostId(d.C)
|
||||
logs.ErrPrintln(err, "get max post id")
|
||||
if id > maxId || id <= 0 {
|
||||
d.Stats = constraints.ParamError
|
||||
err = errors.New("无效的文档id")
|
||||
d.Class = append(d.Class, "error404")
|
||||
}
|
||||
if err != nil {
|
||||
if id > maxId || id <= 0 || err != nil {
|
||||
return
|
||||
}
|
||||
post, err := cache.GetPostById(d.C, id)
|
||||
if post.Id == 0 || err != nil || post.PostStatus != "publish" {
|
||||
d.Stats = constraints.Error404
|
||||
logs.ErrPrintln(err, "获取id失败")
|
||||
err = errors.New(str.Join("无效的文档id "))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -108,6 +100,12 @@ func (d *DetailHandle) Render() {
|
|||
}
|
||||
|
||||
func (d *DetailHandle) Details() {
|
||||
_ = d.BuildDetailData()
|
||||
err := d.BuildDetailData()
|
||||
if err != nil {
|
||||
d.Stats = constraints.Error404
|
||||
d.Code = http.StatusNotFound
|
||||
d.C.HTML(d.Code, d.Templ, d.GinH)
|
||||
return
|
||||
}
|
||||
d.Render()
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/fthvgb1/wp-go/internal/plugins"
|
||||
"github.com/fthvgb1/wp-go/model"
|
||||
"github.com/fthvgb1/wp-go/plugin/pagination"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type IndexHandle struct {
|
||||
|
@ -57,6 +58,8 @@ func (i *IndexHandle) GetIndexData() (posts []models.Posts, totalRaw int, err er
|
|||
|
||||
q := model.QueryCondition{
|
||||
Where: i.Param.Where,
|
||||
Page: i.Param.Page,
|
||||
Limit: i.Param.PageSize,
|
||||
Order: model.SqlBuilder{{i.Param.OrderBy, i.Param.Order}},
|
||||
Join: i.Param.Join,
|
||||
In: [][]any{i.Param.PostType, i.Param.PostStatus},
|
||||
|
@ -64,11 +67,11 @@ func (i *IndexHandle) GetIndexData() (posts []models.Posts, totalRaw int, err er
|
|||
switch i.Scene {
|
||||
case constraints.Home, constraints.Category, constraints.Tag, constraints.Author:
|
||||
|
||||
posts, totalRaw, err = cache.PostLists(i.C, i.Param.CacheKey, i.C, q, i.Param.Page, i.Param.PageSize)
|
||||
posts, totalRaw, err = cache.PostLists(i.C, i.Param.CacheKey, i.C, q)
|
||||
|
||||
case constraints.Search:
|
||||
|
||||
posts, totalRaw, err = cache.SearchPost(i.C, i.Param.CacheKey, i.C, q, i.Param.Page, i.Param.PageSize)
|
||||
posts, totalRaw, err = cache.SearchPost(i.C, i.Param.CacheKey, i.C, q)
|
||||
|
||||
case constraints.Archive:
|
||||
|
||||
|
@ -88,6 +91,7 @@ func (i *IndexHandle) Pagination() {
|
|||
q = fmt.Sprintf("?%s", q)
|
||||
}
|
||||
paginations := pagination.NewParsePagination(i.TotalRows, i.Param.PageSize, i.Param.Page, i.Param.PaginationStep, q, i.C.Request.URL.Path)
|
||||
|
||||
i.GinH["pagination"] = pagination.Paginate(i.PageEle, paginations)
|
||||
|
||||
}
|
||||
|
@ -95,14 +99,13 @@ func (i *IndexHandle) Pagination() {
|
|||
func (i *IndexHandle) BuildIndexData(parm *IndexParams) (err error) {
|
||||
err = i.ParseIndex(parm)
|
||||
if err != nil {
|
||||
i.Stats = constraints.ParamError
|
||||
return
|
||||
}
|
||||
posts, totalRows, err := i.GetIndexData()
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
i.Stats = constraints.Error404
|
||||
return
|
||||
}
|
||||
i.GinH["posts"] = posts
|
||||
i.Posts = posts
|
||||
i.TotalRows = totalRows
|
||||
|
||||
|
@ -132,6 +135,12 @@ func (i *IndexHandle) Render() {
|
|||
}
|
||||
|
||||
func (i *IndexHandle) Indexs() {
|
||||
_ = i.BuildIndexData(NewIndexParams(i.C))
|
||||
err := i.BuildIndexData(NewIndexParams(i.C))
|
||||
if err != nil {
|
||||
i.Stats = constraints.Error404
|
||||
i.Code = http.StatusNotFound
|
||||
i.C.HTML(i.Code, i.Templ, i.GinH)
|
||||
return
|
||||
}
|
||||
i.Render()
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
{{template "layout/base" .}}
|
||||
|
||||
{{define "content"}}
|
||||
<div class="site-content-contain">
|
||||
<div id="content" class="site-content">
|
||||
<div class="wrap">
|
||||
<div id="primary" class="content-area">
|
||||
<main id="main" class="site-main">
|
||||
{{template "layout/empty"}}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/fthvgb1/wp-go/internal/theme/common"
|
||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -56,8 +57,10 @@ var listPostsPlugins = func() map[string]common.Plugin[models.Posts, *common.Han
|
|||
func index(next common.HandleFn[*common.Handle], i *common.IndexHandle) {
|
||||
err := i.BuildIndexData(common.NewIndexParams(i.C))
|
||||
if err != nil {
|
||||
i.Templ = str.Join(ThemeName, "/posts/error.gohtml")
|
||||
i.Render()
|
||||
i.Stats = constraints.Error404
|
||||
i.Code = http.StatusNotFound
|
||||
i.CalBodyClass()
|
||||
i.C.HTML(i.Code, i.Templ, i.GinH)
|
||||
return
|
||||
}
|
||||
i.PostsPlugins = listPostsPlugins
|
||||
|
@ -68,8 +71,10 @@ func index(next common.HandleFn[*common.Handle], i *common.IndexHandle) {
|
|||
func detail(next common.HandleFn[*common.Handle], d *common.DetailHandle) {
|
||||
err := d.BuildDetailData()
|
||||
if err != nil {
|
||||
d.Templ = str.Join(ThemeName, "/posts/error.gohtml")
|
||||
d.Render()
|
||||
d.Code = http.StatusNotFound
|
||||
d.Stats = constraints.Error404
|
||||
d.GinH["bodyClass"] = d.BodyClass()
|
||||
d.C.HTML(d.Code, d.Templ, d.GinH)
|
||||
return
|
||||
}
|
||||
if d.Post.Thumbnail.Path != "" {
|
||||
|
|
|
@ -8,6 +8,7 @@ type QueryCondition struct {
|
|||
Order SqlBuilder
|
||||
Join SqlBuilder
|
||||
Having SqlBuilder
|
||||
Page int
|
||||
Limit int
|
||||
Offset int
|
||||
In [][]any
|
||||
|
@ -67,6 +68,12 @@ func Having(having SqlBuilder) Condition {
|
|||
}
|
||||
}
|
||||
|
||||
func Page(page int) Condition {
|
||||
return func(c *QueryCondition) {
|
||||
c.Page = page
|
||||
}
|
||||
}
|
||||
|
||||
func Limit(limit int) Condition {
|
||||
return func(c *QueryCondition) {
|
||||
c.Limit = limit
|
||||
|
|
|
@ -9,11 +9,10 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
func pagination[T Model](db dbQuery, ctx context.Context, q QueryCondition, page, pageSize int) (r []T, total int, err error) {
|
||||
if page < 1 || pageSize < 1 {
|
||||
func pagination[T Model](db dbQuery, ctx context.Context, q QueryCondition) (r []T, total int, err error) {
|
||||
if q.Page < 1 {
|
||||
return
|
||||
}
|
||||
q.Limit = pageSize
|
||||
qx := QueryCondition{
|
||||
Where: q.Where,
|
||||
Having: q.Having,
|
||||
|
@ -43,41 +42,45 @@ func pagination[T Model](db dbQuery, ctx context.Context, q QueryCondition, page
|
|||
return
|
||||
}
|
||||
offset := 0
|
||||
if page > 1 {
|
||||
offset = (page - 1) * q.Limit
|
||||
if q.Page > 1 {
|
||||
offset = (q.Page - 1) * q.Limit
|
||||
}
|
||||
if offset >= total {
|
||||
return
|
||||
}
|
||||
q.Offset = offset
|
||||
m := ctx.Value("handle=>toMap")
|
||||
m := ctx.Value("handle=>")
|
||||
if m == nil {
|
||||
r, err = finds[T](db, ctx, q)
|
||||
return
|
||||
}
|
||||
mm, ok := m.(*[]map[string]string)
|
||||
if ok {
|
||||
mm, ok := m.(string)
|
||||
if ok && mm == "toMap" {
|
||||
v := ctx.Value("map")
|
||||
mx, er := findToStringMap[T](db, ctx, q)
|
||||
if er != nil {
|
||||
err = er
|
||||
return
|
||||
}
|
||||
*mm = mx
|
||||
vv := v.(*[]map[string]string)
|
||||
*vv = mx
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func paginationToMap[T Model](db dbQuery, ctx context.Context, q QueryCondition, page, pageSize int) (r []map[string]string, total int, err error) {
|
||||
ctx = context.WithValue(ctx, "handle=>toMap", &r)
|
||||
_, total, err = pagination[T](db, ctx, q, page, pageSize)
|
||||
func paginationToMap[T Model](db dbQuery, ctx context.Context, q QueryCondition) (r []map[string]string, total int, err error) {
|
||||
ctx = context.WithValue(ctx, "handle=>", "toMap")
|
||||
ctx = context.WithValue(ctx, "map", &r)
|
||||
_, total, err = pagination[T](db, ctx, q)
|
||||
return
|
||||
}
|
||||
|
||||
func PaginationToMap[T Model](ctx context.Context, q QueryCondition, page, pageSize int) (r []map[string]string, total int, err error) {
|
||||
return paginationToMap[T](globalBb, ctx, q, page, pageSize)
|
||||
func PaginationToMap[T Model](ctx context.Context, q QueryCondition) (r []map[string]string, total int, err error) {
|
||||
return paginationToMap[T](globalBb, ctx, q)
|
||||
}
|
||||
func PaginationToMapFromDB[T Model](db dbQuery, ctx context.Context, q QueryCondition, page, pageSize int) (r []map[string]string, total int, err error) {
|
||||
return paginationToMap[T](db, ctx, q, page, pageSize)
|
||||
func PaginationToMapFromDB[T Model](db dbQuery, ctx context.Context, q QueryCondition) (r []map[string]string, total int, err error) {
|
||||
return paginationToMap[T](db, ctx, q)
|
||||
}
|
||||
|
||||
func FindOneById[T Model, I constraints.Integer](ctx context.Context, id I) (T, error) {
|
||||
|
|
|
@ -465,11 +465,9 @@ func TestSimpleFind(t *testing.T) {
|
|||
|
||||
func Test_pagination(t *testing.T) {
|
||||
type args struct {
|
||||
db dbQuery
|
||||
ctx context.Context
|
||||
q QueryCondition
|
||||
page int
|
||||
pageSize int
|
||||
db dbQuery
|
||||
ctx context.Context
|
||||
q QueryCondition
|
||||
}
|
||||
type testCase[T Model] struct {
|
||||
name string
|
||||
|
@ -489,12 +487,10 @@ func Test_pagination(t *testing.T) {
|
|||
Group: "post_type",
|
||||
Having: SqlBuilder{{"ID", ">", "1", "int"}},
|
||||
},
|
||||
page: 1,
|
||||
pageSize: 2,
|
||||
},
|
||||
wantR: func() (r []post) {
|
||||
|
||||
err := glob.Selects(ctx, &r, "select post_type,count(*) ID from wp_posts group by post_type having `ID`> 1 limit 2")
|
||||
err := glob.Selects(ctx, &r, "select post_type,count(*) ID from wp_posts group by post_type having `ID`> 1")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -506,7 +502,7 @@ func Test_pagination(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotR, gotTotal, err := pagination[post](tt.args.db, tt.args.ctx, tt.args.q, tt.args.page, tt.args.pageSize)
|
||||
gotR, gotTotal, err := pagination[post](tt.args.db, tt.args.ctx, tt.args.q)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("pagination() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
|
@ -523,11 +519,9 @@ func Test_pagination(t *testing.T) {
|
|||
|
||||
func Test_paginationToMap(t *testing.T) {
|
||||
type args struct {
|
||||
db dbQuery
|
||||
ctx context.Context
|
||||
q QueryCondition
|
||||
page int
|
||||
pageSize int
|
||||
db dbQuery
|
||||
ctx context.Context
|
||||
q QueryCondition
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
|
@ -543,10 +537,10 @@ func Test_paginationToMap(t *testing.T) {
|
|||
ctx: ctx,
|
||||
q: QueryCondition{
|
||||
Fields: "ID",
|
||||
Limit: 2,
|
||||
Page: 1,
|
||||
Where: SqlBuilder{{"ID < 200"}},
|
||||
},
|
||||
page: 1,
|
||||
pageSize: 2,
|
||||
},
|
||||
wantR: []map[string]string{{"ID": "63"}, {"ID": "64"}},
|
||||
wantTotal: 4,
|
||||
|
@ -558,10 +552,10 @@ func Test_paginationToMap(t *testing.T) {
|
|||
ctx: ctx,
|
||||
q: QueryCondition{
|
||||
Fields: "ID",
|
||||
Limit: 2,
|
||||
Page: 2,
|
||||
Where: SqlBuilder{{"ID < 200"}},
|
||||
},
|
||||
page: 2,
|
||||
pageSize: 2,
|
||||
},
|
||||
wantR: []map[string]string{{"ID": "190"}, {"ID": "193"}},
|
||||
wantTotal: 4,
|
||||
|
@ -569,11 +563,11 @@ func Test_paginationToMap(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotR, gotTotal, err := PaginationToMap[post](tt.args.ctx, tt.args.q, tt.args.page, tt.args.pageSize)
|
||||
gotR, gotTotal, err := PaginationToMap[post](tt.args.ctx, tt.args.q)
|
||||
fmt.Println(gotR, gotTotal, err)
|
||||
gotR, gotTotal, err = PaginationToMapFromDB[post](tt.args.db, tt.args.ctx, tt.args.q, tt.args.page, tt.args.pageSize)
|
||||
gotR, gotTotal, err = PaginationToMapFromDB[post](tt.args.db, tt.args.ctx, tt.args.q)
|
||||
fmt.Println(gotR, gotTotal, err)
|
||||
gotR, gotTotal, err = paginationToMap[post](tt.args.db, tt.args.ctx, tt.args.q, tt.args.page, tt.args.pageSize)
|
||||
gotR, gotTotal, err = paginationToMap[post](tt.args.db, tt.args.ctx, tt.args.q)
|
||||
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("paginationToMap() error = %v, wantErr %v", err, tt.wantErr)
|
||||
|
|
|
@ -41,7 +41,7 @@ func chunkFind[T Model](db dbQuery, ctx context.Context, perLimit int, q QueryCo
|
|||
var offset int
|
||||
for {
|
||||
if 1 == i {
|
||||
rr, total, err = pagination[T](db, ctx, q, 1, perLimit)
|
||||
rr, total, err = pagination[T](db, ctx, q)
|
||||
} else {
|
||||
q.Offset = offset
|
||||
q.Limit = perLimit
|
||||
|
@ -100,7 +100,7 @@ func chunk[T Model, R any](db dbQuery, ctx context.Context, perLimit int, fn fun
|
|||
var offset int
|
||||
for {
|
||||
if 1 == i {
|
||||
rr, total, err = pagination[T](db, ctx, q, 1, perLimit)
|
||||
rr, total, err = pagination[T](db, ctx, q)
|
||||
} else {
|
||||
q.Offset = offset
|
||||
q.Limit = perLimit
|
||||
|
@ -127,16 +127,16 @@ func chunk[T Model, R any](db dbQuery, ctx context.Context, perLimit int, fn fun
|
|||
|
||||
// Pagination 同
|
||||
//
|
||||
// Condition 中可使用 Where Fields From Group Having Join Order Limit In 函数
|
||||
func Pagination[T Model](ctx context.Context, q QueryCondition, page, pageSize int) ([]T, int, error) {
|
||||
return pagination[T](globalBb, ctx, q, page, pageSize)
|
||||
// Condition 中可使用 Where Fields From Group Having Join Order Page Limit In 函数
|
||||
func Pagination[T Model](ctx context.Context, q QueryCondition) ([]T, int, error) {
|
||||
return pagination[T](globalBb, ctx, q)
|
||||
}
|
||||
|
||||
// PaginationFromDB 同 Pagination 方便多个db使用
|
||||
//
|
||||
// Condition 中可使用 Where Fields Group Having Join Order Limit In 函数
|
||||
func PaginationFromDB[T Model](db dbQuery, ctx context.Context, q QueryCondition, page, pageSize int) ([]T, int, error) {
|
||||
return pagination[T](db, ctx, q, page, pageSize)
|
||||
// Condition 中可使用 Where Fields Group Having Join Order Page Limit In 函数
|
||||
func PaginationFromDB[T Model](db dbQuery, ctx context.Context, q QueryCondition) ([]T, int, error) {
|
||||
return pagination[T](db, ctx, q)
|
||||
}
|
||||
|
||||
func Column[V Model, T any](ctx context.Context, fn func(V) (T, bool), q QueryCondition) ([]T, error) {
|
||||
|
|
|
@ -178,10 +178,8 @@ func TestChunk(t *testing.T) {
|
|||
|
||||
func TestPagination(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
q QueryCondition
|
||||
page int
|
||||
pageSize int
|
||||
ctx context.Context
|
||||
q QueryCondition
|
||||
}
|
||||
type testCase[T Model] struct {
|
||||
name string
|
||||
|
@ -199,10 +197,10 @@ func TestPagination(t *testing.T) {
|
|||
Where(SqlBuilder{
|
||||
{"ID", "in", ""},
|
||||
}),
|
||||
Page(1),
|
||||
Limit(5),
|
||||
In([][]any{slice.ToAnySlice(number.Range(431, 440, 1))}...),
|
||||
),
|
||||
page: 1,
|
||||
pageSize: 5,
|
||||
},
|
||||
want: func() (r []post) {
|
||||
r, err := Select[post](ctx, "select * from "+post{}.Table()+" where ID in (?,?,?,?,?)", slice.ToAnySlice(number.Range(431, 435, 1))...)
|
||||
|
@ -219,7 +217,7 @@ func TestPagination(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, got1, err := Pagination[post](tt.args.ctx, tt.args.q, tt.args.page, tt.args.pageSize)
|
||||
got, got1, err := Pagination[post](tt.args.ctx, tt.args.q)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Pagination() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
|
@ -335,7 +333,7 @@ func Test_getField(t *testing.T) {
|
|||
db := glob
|
||||
field := "count(*)"
|
||||
q := Conditions()
|
||||
wantR := "406"
|
||||
wantR := "385"
|
||||
wantErr := false
|
||||
t.Run(name, func(t *testing.T) {
|
||||
gotR, err := getField[options](db, ctx, field, q)
|
||||
|
|
Loading…
Reference in New Issue
Block a user