expressServer/models/Search.js
LingandRX 3cd150b106 feat(user): 添加用户列表查询功能
- 新增 findUserList 控制器方法,用于查询用户列表
- 创建 Search 模型类,用于处理查询参数
- 在用户仓库中实现 selectUserList 方法,用于数据库查询
- 更新用户服务,添加 find_user_list 方法
- 在路由中注册新的用户列表查询 endpoint
2024-12-31 00:17:13 +08:00

33 lines
757 B
JavaScript

class Search {
constructor({ size, page, sort, filters }) {
this.size = size
this.page = page
this.sort = sort
this.filters = filters
}
}
class SearchResult {
constructor({ list = [], num = 0, size = 0, total = 0 } = {}) {
if (typeof list !== 'object' || list === null) {
throw new Error('Invalid list parameter')
}
if (typeof num !== 'number') {
throw new Error('Invalid num parameter')
}
if (typeof size !== 'number') {
throw new Error('Invalid size parameter')
}
if (typeof total !== 'number') {
throw new Error('Invalid total parameter')
}
this.list = list
this.num = num
this.size = size
this.total = total
}
}
module.exports = { Search, SearchResult }