routerAdd('POST', '/api/system/users-count', function (e) {
    const { success } = require(`${__hooks}/bai_api_pb_hooks/bai_api_shared/utils/response.js`)

    const pageSize = 500
    let page = 1
    let total = 0

    while (true) {
        const records = $app.findRecordsByFilter(
            'tbl_auth_users',
            '',
            '',
            pageSize,
            (page - 1) * pageSize
        )

        const count = Array.isArray(records) ? records.length : 0
        total += count

        if (count < pageSize) {
            break
        }

        page += 1
    }

    return success(e, '查询成功', {
        total_users: total,
    })
})

