feat: update
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
package conds
|
||||
|
||||
import (
|
||||
. "github.com/go-jet/jet/v2/postgres"
|
||||
)
|
||||
|
||||
type Cond func(BoolExpression) BoolExpression
|
||||
|
||||
func Default() BoolExpression {
|
||||
return BoolExp(Bool(true))
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package conds
|
||||
|
||||
import (
|
||||
"quyun/database/fields"
|
||||
"quyun/database/table"
|
||||
|
||||
. "github.com/go-jet/jet/v2/postgres"
|
||||
)
|
||||
|
||||
func Post_NotDeleted() Cond {
|
||||
return func(cond BoolExpression) BoolExpression {
|
||||
return cond.AND(table.Posts.DeletedAt.IS_NULL())
|
||||
}
|
||||
}
|
||||
|
||||
func Post_Status(s fields.PostStatus) Cond {
|
||||
return func(cond BoolExpression) BoolExpression {
|
||||
return cond.AND(table.Posts.Status.EQ(Int(int64(s))))
|
||||
}
|
||||
}
|
||||
|
||||
func Post_Like(key *string) Cond {
|
||||
return func(cond BoolExpression) BoolExpression {
|
||||
tbl := table.Posts
|
||||
if key == nil || *key == "" {
|
||||
return cond
|
||||
}
|
||||
|
||||
cond = cond.AND(
|
||||
tbl.Title.LIKE(String("%" + *key + "%")).
|
||||
OR(
|
||||
tbl.Content.LIKE(String("%" + *key + "%")),
|
||||
).
|
||||
OR(
|
||||
tbl.Description.LIKE(String("%" + *key + "%")),
|
||||
),
|
||||
)
|
||||
|
||||
return cond
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user