This commit is contained in:
parent
f70e08e5e8
commit
18207bee18
@ -77,9 +77,10 @@ impl UserPageFilter {
|
||||
));
|
||||
}
|
||||
if clauses.is_empty() {
|
||||
return "".to_string();
|
||||
"".to_string()
|
||||
} else {
|
||||
format!("WHERE {}", clauses.join(" AND "))
|
||||
}
|
||||
clauses.join(" AND ")
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,11 +371,27 @@ mod tests {
|
||||
];
|
||||
accessor.sync_user(users.as_slice()).await?;
|
||||
// 分页查询检查是否更新成功
|
||||
let page_result = accessor.query_user_page(page, filter.clone()).await?;
|
||||
let page_result = accessor
|
||||
.query_user_page(page.clone(), filter.clone())
|
||||
.await?;
|
||||
assert_eq!(page_result.total, 3);
|
||||
assert_eq!(page_result.data.len(), 3);
|
||||
println!("{:?}", page_result);
|
||||
|
||||
// 带过滤条件的分页查询
|
||||
let filter = UserPageFilter {
|
||||
id: Some(1),
|
||||
name: None,
|
||||
email: None,
|
||||
mobile: None,
|
||||
roles: None,
|
||||
};
|
||||
let page_result = accessor
|
||||
.query_user_page(page.clone(), filter.clone())
|
||||
.await?;
|
||||
assert_eq!(page_result.total, 1);
|
||||
assert_eq!(page_result.data.len(), 1);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user