forked from opentiny/tiny-engine
Fix mockServer block group deleted bug (#279)
This commit is contained in:
parent
e79853cb09
commit
422c62dbdb
|
|
@ -10,13 +10,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import KoaRouter from 'koa-router'
|
||||
import * as glob from 'glob'
|
||||
import path from 'path'
|
||||
import fs from 'fs-extra'
|
||||
import * as glob from 'glob'
|
||||
import KoaRouter from 'koa-router'
|
||||
import path from 'path'
|
||||
import MockService from '../services/mockService'
|
||||
|
||||
import { getResponseData } from '../tool/Common'
|
||||
|
||||
const router = new KoaRouter()
|
||||
export const mockService = new MockService()
|
||||
const getJsonPathData = (jpath, method = 'get') => {
|
||||
|
|
@ -140,7 +140,9 @@ router.get('/material-center/api/block-groups/delete/:id', async (ctx) => {
|
|||
router.get('/material-center/api/block-groups', async (ctx) => {
|
||||
const result = await mockService.blockGroupService.find(ctx.query)
|
||||
let blockGroup
|
||||
if (result.data.length > 1) {
|
||||
if (result.data.length === 0) {
|
||||
ctx.body = result
|
||||
} else if (result.data.length > 1) {
|
||||
blockGroup = await Promise.all(
|
||||
result.data.map(async (group) => {
|
||||
group.blocks = await Promise.all(
|
||||
|
|
@ -153,7 +155,7 @@ router.get('/material-center/api/block-groups', async (ctx) => {
|
|||
})
|
||||
)
|
||||
ctx.body = getResponseData(blockGroup)
|
||||
} else {
|
||||
} else if (result.data.length === 1) {
|
||||
blockGroup = result.data[0]
|
||||
const blocks = await Promise.all(
|
||||
blockGroup.blocks.map(async (item) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue