From 3405a42d4434bb77026c029ed20f2898ba665107 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Thu, 11 Jan 2018 09:25:50 +0800 Subject: [PATCH] 框架升级 --- _mock/_rule.ts | 26 +++++++++++++++++--------- 1 files changed, 17 insertions(+), 9 deletions(-) diff --git a/_mock/rule.service.ts b/_mock/_rule.ts similarity index 75% rename from _mock/rule.service.ts rename to _mock/_rule.ts index 927c546..bd555c5 100644 --- a/_mock/rule.service.ts +++ b/_mock/_rule.ts @@ -1,3 +1,6 @@ +import { HttpRequest } from '@angular/common/http'; +import { MockRequest } from '@delon/mock'; + const list = []; for (let i = 0; i < 46; i += 1) { @@ -18,7 +21,7 @@ }); } -export function getRule(params: any) { +function getRule(params: any) { let ret = [...list]; if (params.sorter) { const s = params.sorter.split('_'); @@ -38,16 +41,15 @@ return ret; } -export function removeRule(no: string): boolean { - const idx = list.findIndex(w => w.no === no); - if (idx !== -1) { - list.splice(idx, 1); - return true; - } - return false; +function removeRule(nos: string): boolean { + nos.split(',').forEach(no => { + const idx = list.findIndex(w => w.no === no); + if (idx !== -1) list.splice(idx, 1); + }); + return true; } -export function saveRule(description: string) { +function saveRule(description: string) { const i = Math.ceil(Math.random() * 10000); list.unshift({ key: i, @@ -64,3 +66,9 @@ progress: Math.ceil(Math.random() * 100), }); } + +export const RULES = { + '/rule': (req: MockRequest) => getRule(req.queryString), + 'DELETE /rule': (req: MockRequest) => removeRule(req.queryString.nos), + 'POST /rule': (req: MockRequest) => saveRule(req.body.description) +}; -- Gitblit v1.8.0