新增审计日志的搜索功能

This commit is contained in:
lanrenwo
2022-07-25 09:23:58 +08:00
parent e761c1e111
commit b8c3d33f2e
5 changed files with 218 additions and 5 deletions

View File

@@ -3,6 +3,8 @@ package dbdata
import (
"errors"
"reflect"
"xorm.io/xorm"
)
const PageSize = 10
@@ -82,3 +84,12 @@ func Prefix(fieldName string, prefix string, data interface{}, limit, page int)
start := (page - 1) * limit
return where.Limit(limit, start).Find(data)
}
func FindAndCount(session *xorm.Session, data interface{}, limit, page int) (int64, error) {
if limit == 0 {
return session.FindAndCount(data)
}
start := (page - 1) * limit
totalCount, err := session.Limit(limit, start).FindAndCount(data)
return totalCount, err
}