feat: ent select fields.

This commit is contained in:
tx7do
2023-11-06 17:02:55 +08:00
parent da82d442cc
commit 18755155ba
5 changed files with 90 additions and 9 deletions

View File

@@ -34,6 +34,14 @@ func QueryCommandToOrderConditions(orderBys []string) (error, func(s *sql.Select
}
}
func BuildOrderSelect(s *sql.Selector, field string, desc bool) {
if desc {
s.OrderBy(sql.Desc(s.C(field)))
} else {
s.OrderBy(sql.Asc(s.C(field)))
}
}
func BuildOrderSelector(orderBys []string, defaultOrderField string) (error, func(s *sql.Selector)) {
if len(orderBys) == 0 {
return nil, func(s *sql.Selector) {
@@ -43,11 +51,3 @@ func BuildOrderSelector(orderBys []string, defaultOrderField string) (error, fun
return QueryCommandToOrderConditions(orderBys)
}
}
func BuildOrderSelect(s *sql.Selector, field string, desc bool) {
if desc {
s.OrderBy(sql.Desc(s.C(field)))
} else {
s.OrderBy(sql.Asc(s.C(field)))
}
}