diff --git a/src/routes/account.ts b/src/routes/account.ts index 01ee242..a7102ac 100644 --- a/src/routes/account.ts +++ b/src/routes/account.ts @@ -47,7 +47,7 @@ router.get('/account/list', async (ctx) => { let pagination = new Pagination(total, ctx.query.cursor || 1, ctx.query.limit || 10) ctx.body = { data: await User.findAll(Object.assign(options, { - attributes: ['id', 'fullname'], + attributes: ['id', 'fullname', 'email'], offset: pagination.start, limit: pagination.limit, order: [ diff --git a/src/routes/repository.ts b/src/routes/repository.ts index 9b26e4d..cf354a3 100644 --- a/src/routes/repository.ts +++ b/src/routes/repository.ts @@ -183,8 +183,10 @@ router.get('/repository/get', async (ctx) => { const tryCache = await RedisService.getCache(CACHE_KEY.REPOSITORY_GET, ctx.query.id) let repository: Repository if (tryCache) { + console.log(`from cache`) repository = JSON.parse(tryCache) } else { + console.log(`from db`) repository = await Repository.findById(ctx.query.id, { attributes: { exclude: [] }, include: [ @@ -195,7 +197,8 @@ router.get('/repository/get', async (ctx) => { QueryInclude.Organization, QueryInclude.RepositoryHierarchy, QueryInclude.Collaborators - ] + ], + order: [[{ model: Module, as: 'modules' }, 'priority', 'asc']] }) 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] } }) } + if (ids && ids.length) { + const mod = await Module.findById(ids[0]) + await RedisService.delCache(CACHE_KEY.REPOSITORY_GET, mod.repositoryId) + } ctx.body = { data: ids.length, } diff --git a/src/service/postman.ts b/src/service/postman.ts index 50681b5..797e8fe 100644 --- a/src/service/postman.ts +++ b/src/service/postman.ts @@ -2,6 +2,7 @@ import { PostmanCollection, Folder, Item } from "../types/postman" import { Repository, Interface, Module, Property } from "../models" import * as url from 'url' 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' @@ -44,6 +45,7 @@ export default class PostmanService { where: { interfaceId, scope: 'response' } }) + const relativeUrl = UrlUtils.getRelative(itf.url) const parseResult = url.parse(itf.url) const itfItem: Item = { name: itf.name, @@ -52,9 +54,8 @@ export default class PostmanService { header: getHeader(requestParams), body: getBody(requestParams), url: { - raw: itf.url, - protocol: parseResult.protocol || 'http', - host: parseResult.hostname ? parseResult.hostname.split('.') : [], + raw: `{{url}}${relativeUrl}`, + host: '{{url}}', port: parseResult.port || '', hash: parseResult.hash, path: [parseResult.path],