fix #265 && post man issue

pull/275/head
Bosn 7 years ago
parent 110c8dcfce
commit eae07f1e47

@ -47,7 +47,7 @@ router.get('/account/list', async (ctx) => {
let pagination = new Pagination(total, ctx.query.cursor || 1, ctx.query.limit || 10) let pagination = new Pagination(total, ctx.query.cursor || 1, ctx.query.limit || 10)
ctx.body = { ctx.body = {
data: await User.findAll(Object.assign(options, { data: await User.findAll(Object.assign(options, {
attributes: ['id', 'fullname'], attributes: ['id', 'fullname', 'email'],
offset: pagination.start, offset: pagination.start,
limit: pagination.limit, limit: pagination.limit,
order: [ order: [

@ -183,8 +183,10 @@ router.get('/repository/get', async (ctx) => {
const tryCache = await RedisService.getCache(CACHE_KEY.REPOSITORY_GET, ctx.query.id) const tryCache = await RedisService.getCache(CACHE_KEY.REPOSITORY_GET, ctx.query.id)
let repository: Repository let repository: Repository
if (tryCache) { if (tryCache) {
console.log(`from cache`)
repository = JSON.parse(tryCache) repository = JSON.parse(tryCache)
} else { } else {
console.log(`from db`)
repository = await Repository.findById(ctx.query.id, { repository = await Repository.findById(ctx.query.id, {
attributes: { exclude: [] }, attributes: { exclude: [] },
include: [ include: [
@ -195,7 +197,8 @@ router.get('/repository/get', async (ctx) => {
QueryInclude.Organization, QueryInclude.Organization,
QueryInclude.RepositoryHierarchy, QueryInclude.RepositoryHierarchy,
QueryInclude.Collaborators QueryInclude.Collaborators
] ],
order: [[{ model: Module, as: 'modules' }, 'priority', 'asc']]
}) })
await RedisService.setCache(CACHE_KEY.REPOSITORY_GET, JSON.stringify(repository), ctx.query.id) await RedisService.setCache(CACHE_KEY.REPOSITORY_GET, JSON.stringify(repository), ctx.query.id)
} }
@ -451,6 +454,10 @@ router.post('/module/sort', async (ctx) => {
where: { id: ids[index] } where: { id: ids[index] }
}) })
} }
if (ids && ids.length) {
const mod = await Module.findById(ids[0])
await RedisService.delCache(CACHE_KEY.REPOSITORY_GET, mod.repositoryId)
}
ctx.body = { ctx.body = {
data: ids.length, data: ids.length,
} }

@ -2,6 +2,7 @@ import { PostmanCollection, Folder, Item } from "../types/postman"
import { Repository, Interface, Module, Property } from "../models" import { Repository, Interface, Module, Property } from "../models"
import * as url from 'url' import * as url from 'url'
import { REQUEST_PARAMS_TYPE } from "../models/bo/property"; import { REQUEST_PARAMS_TYPE } from "../models/bo/property";
import UrlUtils from "../routes/utils/url"
const SCHEMA_V_2_1_0 = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json' const SCHEMA_V_2_1_0 = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json'
@ -44,6 +45,7 @@ export default class PostmanService {
where: { interfaceId, scope: 'response' } where: { interfaceId, scope: 'response' }
}) })
const relativeUrl = UrlUtils.getRelative(itf.url)
const parseResult = url.parse(itf.url) const parseResult = url.parse(itf.url)
const itfItem: Item = { const itfItem: Item = {
name: itf.name, name: itf.name,
@ -52,9 +54,8 @@ export default class PostmanService {
header: getHeader(requestParams), header: getHeader(requestParams),
body: getBody(requestParams), body: getBody(requestParams),
url: { url: {
raw: itf.url, raw: `{{url}}${relativeUrl}`,
protocol: parseResult.protocol || 'http', host: '{{url}}',
host: parseResult.hostname ? parseResult.hostname.split('.') : [],
port: parseResult.port || '', port: parseResult.port || '',
hash: parseResult.hash, hash: parseResult.hash,
path: [parseResult.path], path: [parseResult.path],

Loading…
Cancel
Save