Commit a8a504f4 authored by Xuguangxing's avatar Xuguangxing

feat: 查询条件增加模糊搜索,列表排序按照id倒序

parent c7f26271
......@@ -54,22 +54,32 @@ export default class ArticeService extends Service {
}
// 获取导航列表
async getList(pageNo, pageSize, name = '', author = '') {
const offset = (+pageNo - 1) * pageSize;;
const offset = (+pageNo - 1) * pageSize;
const condition = {
author: null,
name: null
};
// 模糊匹配作者
if (author) condition.author = author;
// 模糊匹配名称
if (name) condition.name = name;
if (author) {
condition.author = {
$like: '%' + author + '%'
};
}
if (name) {
condition.name = {
$like: '%' + name + '%'
};
}
if (!condition.author) delete condition.author;
if (!condition.name) delete condition.name;
const res = await this.context.model.NavigatorConfig
.findAndCountAll({
where: condition,
limit: +pageSize,
offset
offset,
order: [
['id', 'DESC']
],
})
const result = {
total: res.count || 0,
......@@ -85,10 +95,16 @@ export default class ArticeService extends Service {
name: null,
id: null
};
// 模糊匹配作者
if (author) condition.author = author;
// 模糊匹配名称
if (name) condition.name = name;
if (author) {
condition.author = {
$like: '%' + author + '%'
};
}
if (name) {
condition.name = {
$like: '%' + name + '%'
};
}
if (id) {
condition.id = {
$notIn: [id]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment