Skip to content

Commit 6c363d3

Browse files
committed
修改builder 排序方法名称
1 parent 96638c1 commit 6c363d3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

builder.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (b *builder) Count(countColumn string) *builder {
5151
//手动指定字段和排序
5252
//field 字段
5353
//order 排序 [ASC | DESC]
54-
func (b *builder) Order(field, order string) *builder {
54+
func (b *builder) OrderBy(field, order string) *builder {
5555
b.order.Field = field
5656
b.order.Order = order
5757
return b
@@ -60,13 +60,13 @@ func (b *builder) Order(field, order string) *builder {
6060
//升序(默认)
6161
//field 字段
6262
func (b *builder) ASC(field string) *builder {
63-
return b.Order(field, ASC)
63+
return b.OrderBy(field, ASC)
6464
}
6565

6666
//降序
6767
//field 字段
6868
func (b *builder) DESC(field string) *builder {
69-
return b.Order(field, DESC)
69+
return b.OrderBy(field, DESC)
7070
}
7171

7272
//获得含分页/排序信息的context

test/builder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
)
2020

2121
func TestBuilder(t *testing.T) {
22-
ctx := pagehelper.C(context.Background()).Page(1, 3).Order("test", pagehelper.ASC).Build()
22+
ctx := pagehelper.C(context.Background()).Page(1, 3).OrderBy("test", pagehelper.ASC).Build()
2323
ctx, _ = context.WithTimeout(ctx, time.Second)
2424
p := ctx.Value(pageHelperValue)
2525
o := ctx.Value(orderHelperValue)
@@ -29,7 +29,7 @@ func TestBuilder(t *testing.T) {
2929
}
3030

3131
func TestBuilder2(t *testing.T) {
32-
ctx := pagehelper.C(context.Background()).PageWithCount(1, 3, "").Order("test", pagehelper.ASC).Build()
32+
ctx := pagehelper.C(context.Background()).PageWithCount(1, 3, "").OrderBy("test", pagehelper.ASC).Build()
3333
ctx = pagehelper.C(ctx).DESC("new_field").Build()
3434
ctx, _ = context.WithTimeout(ctx, time.Second)
3535
p := ctx.Value(pageHelperValue)
@@ -40,7 +40,7 @@ func TestBuilder2(t *testing.T) {
4040
}
4141

4242
func TestBuilder3(t *testing.T) {
43-
ctx := pagehelper.C(context.Background()).Page(1, 3).Order("test", pagehelper.ASC).Build()
43+
ctx := pagehelper.C(context.Background()).Page(1, 3).OrderBy("test", pagehelper.ASC).Build()
4444
ctx = pagehelper.C(ctx).DESC("new_field").ASC("new_field2").Count("test").Page(2,100).Build()
4545
ctx, _ = context.WithTimeout(ctx, time.Second)
4646
p := ctx.Value(pageHelperValue)

0 commit comments

Comments
 (0)