Compare commits
2 Commits
56f869c10f
...
df11d6522d
Author | SHA1 | Date | |
---|---|---|---|
|
df11d6522d | ||
|
b588b7e6d4 |
@ -32,6 +32,17 @@ func ToInteger[T constraints.Integer](s string, defaults T) T {
|
||||
}
|
||||
return T(i)
|
||||
}
|
||||
func ToInt[T constraints.Integer](s string) T {
|
||||
defaults := T(0)
|
||||
if s == "" {
|
||||
return defaults
|
||||
}
|
||||
i, err := strconv.ParseInt(s, 10, 64)
|
||||
if err != nil {
|
||||
return defaults
|
||||
}
|
||||
return T(i)
|
||||
}
|
||||
|
||||
func Md5(str string) string {
|
||||
h := md5.New()
|
||||
|
@ -271,3 +271,11 @@ func findScanner[T Model](db dbQuery, ctx context.Context, fn func(T), q *QueryC
|
||||
err = db.Select(ctx, &v, s, args...)
|
||||
return
|
||||
}
|
||||
|
||||
func FindScannerFromDB[T Model](db dbQuery, ctx context.Context, fn func(T), q *QueryCondition) error {
|
||||
return findScanner[T](db, ctx, fn, q)
|
||||
}
|
||||
|
||||
func FindScanner[T Model](ctx context.Context, fn func(T), q *QueryCondition) error {
|
||||
return findScanner[T](globalBb, ctx, fn, q)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user