feat: db分页取得页码页数量
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"be.ems/src/framework/config"
|
"be.ems/src/framework/config"
|
||||||
"be.ems/src/framework/logger"
|
"be.ems/src/framework/logger"
|
||||||
|
"be.ems/src/framework/utils/parse"
|
||||||
|
|
||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@@ -162,3 +163,19 @@ func ExecDB(source string, sql string, parameters []any) (int64, error) {
|
|||||||
}
|
}
|
||||||
return res.RowsAffected, nil
|
return res.RowsAffected, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PageNumSize 分页页码记录数
|
||||||
|
func PageNumSize(pageNum, pageSize any) (int, int) {
|
||||||
|
// 记录起始索引
|
||||||
|
num := parse.Number(pageNum)
|
||||||
|
if num < 1 {
|
||||||
|
num = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示记录数
|
||||||
|
size := parse.Number(pageSize)
|
||||||
|
if size < 0 {
|
||||||
|
size = 10
|
||||||
|
}
|
||||||
|
return int(num - 1), int(size)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user