From 45827118675759affb696e6f9717eb75af9cc64c Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 31 Jul 2022 15:00:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2=E8=AE=A2?= =?UTF-8?q?=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/subscription.ts | 57 ++++++++++------------------------- 1 file changed, 16 insertions(+), 41 deletions(-) diff --git a/back/services/subscription.ts b/back/services/subscription.ts index 264eaf95..fa36a3bd 100644 --- a/back/services/subscription.ts +++ b/back/services/subscription.ts @@ -42,47 +42,22 @@ export default class SubscriptionService { public async list(searchText?: string): Promise { let query = {}; if (searchText) { - const textArray = searchText.split(':'); - switch (textArray[0]) { - case 'name': - case 'command': - case 'schedule': - case 'label': - const column = textArray[0] === 'label' ? 'labels' : textArray[0]; - query = { - [column]: { - [Op.or]: [ - { [Op.like]: `%${textArray[1]}%` }, - { [Op.like]: `%${encodeURIComponent(textArray[1])}%` }, - ], - }, - }; - break; - default: - const reg = { - [Op.or]: [ - { [Op.like]: `%${searchText}%` }, - { [Op.like]: `%${encodeURIComponent(searchText)}%` }, - ], - }; - query = { - [Op.or]: [ - { - name: reg, - }, - { - command: reg, - }, - { - schedule: reg, - }, - { - labels: reg, - }, - ], - }; - break; - } + const reg = { + [Op.or]: [ + { [Op.like]: `%${searchText}%` }, + { [Op.like]: `%${encodeURIComponent(searchText)}%` }, + ], + }; + query = { + [Op.or]: [ + { + name: reg, + }, + { + url: reg, + }, + ], + }; } try { const result = await SubscriptionModel.findAll({