fix: col list bug

This commit is contained in:
sean 2017-08-14 16:30:30 +08:00
parent 01ea9897fe
commit 5c91366f3a
9 changed files with 54 additions and 24 deletions

View File

@ -1,9 +1,11 @@
var ace = require('brace'),
Mock = require('mockjs')
require('brace/mode/json');
require('brace/mode/javascript');
require('brace/theme/xcode');
require("brace/ext/language_tools.js");
require("brace/snippets/json.js")
require("brace/snippets/javascript.js");
var json5 = require('json5');
var langTools = ace.acequire("ace/ext/language_tools"),
editor,
@ -70,7 +72,7 @@ function run(options) {
editor = ace.edit(container)
editor.$blockScrolling = Infinity;
editor.getSession().setMode('ace/mode/json');
editor.getSession().setMode('ace/mode/javascript');
editor.setTheme('ace/theme/xcode');
editor.setOptions({
enableBasicAutocompletion: true,
@ -85,7 +87,7 @@ function run(options) {
if (typeof data === 'string') {
editor.setValue(data);
} else if (typeof data === 'object') {
editor.setValue(JSON.stringify(data, null, " "))
editor.setValue(json5.stringify(data, null, " "))
}
},
editor: editor
@ -122,7 +124,8 @@ function run(options) {
function handleJson(json) {
var curData = mockEditor.curData;
try {
var obj = JSON.parse(json);
var obj = json5.parse(json);
curData.text = json;
curData.format = true;
curData.jsonData = obj;
curData.mockData = Mock.mock(obj);

View File

@ -52,6 +52,7 @@
"gulp-babel": "^6.1.2",
"gulp-watch": "^4.3.11",
"json2html": "0.0.8",
"json5": "^0.5.1",
"jsoneditor": "^5.9.3",
"jsonwebtoken": "^7.4.1",
"koa": "^2.0.0",

View File

@ -23,8 +23,7 @@ class interfaceColController extends baseController{
async list(ctx){
try {
let id = ctx.query.project_id;
let inst = this.colModel(interfaceColModel);
let result = await inst.list(id);
let result = await this.colModel.list(id);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);

View File

@ -33,7 +33,7 @@ class interfaceModel extends baseModel {
}],
req_body_type: {
type: String,
enum: ['form', 'json', 'text', 'xml']
enum: ['form', 'json', 'text', 'file']
},
req_body_form: [{
name: String, value: String, value_type: { type: String, enum: ['text', 'file'] }, desc: String, required: {
@ -42,12 +42,26 @@ class interfaceModel extends baseModel {
default: "1"
}
}],
req_body_json_doc: [{
json_path: String, desc: String,required:{
type:String,
enum: ["1", "0"],
default: "1"
}
}],
req_body_other: String,
res_body_type: {
type: String,
enum: ['json', 'text', 'xml']
},
res_body: String
res_body: String,
res_body_json_doc: [{
json_path: String, desc: String,required:{
type:String,
enum: ["1", "0"],
default: "1"
}
}]
};
}

View File

@ -60,7 +60,7 @@ class projectModel extends baseModel {
list(group_id, auth) {
let params = {group_id: group_id}
if(!auth) params.project_type = 'public';
return this.model.find(params).sort({ _id: -1 }).exec();
return this.model.find(params).select("_id uid name basepath desc group_id project_type protocol prd_host env add_time up_time").sort({ _id: -1 }).exec();
}
listWithPaging(group_id, page, limit) {

View File

@ -75,36 +75,35 @@ var interfaceColController = function (_baseController) {
key: 'list',
value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
var id, inst, result;
var id, result;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
id = ctx.query.project_id;
inst = this.colModel(_interfaceCol2.default);
_context.next = 5;
return inst.list(id);
_context.next = 4;
return this.colModel.list(id);
case 5:
case 4:
result = _context.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context.next = 12;
_context.next = 11;
break;
case 9:
_context.prev = 9;
case 8:
_context.prev = 8;
_context.t0 = _context['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
case 12:
case 11:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[0, 9]]);
}, _callee, this, [[0, 8]]);
}));
function list(_x) {

View File

@ -72,7 +72,7 @@ var interfaceModel = function (_baseModel) {
}],
req_body_type: {
type: String,
enum: ['form', 'json', 'text', 'xml']
enum: ['form', 'json', 'text', 'file']
},
req_body_form: [{
name: String, value: String, value_type: { type: String, enum: ['text', 'file'] }, desc: String, required: {
@ -81,12 +81,26 @@ var interfaceModel = function (_baseModel) {
default: "1"
}
}],
req_body_json_doc: [{
json_path: String, desc: String, required: {
type: String,
enum: ["1", "0"],
default: "1"
}
}],
req_body_other: String,
res_body_type: {
type: String,
enum: ['json', 'text', 'xml']
},
res_body: String
res_body: String,
res_body_json_doc: [{
json_path: String, desc: String, required: {
type: String,
enum: ["1", "0"],
default: "1"
}
}]
};
}
}, {

View File

@ -101,7 +101,7 @@ var projectModel = function (_baseModel) {
value: function list(group_id, auth) {
var params = { group_id: group_id };
if (!auth) params.project_type = 'public';
return this.model.find(params).sort({ _id: -1 }).exec();
return this.model.find(params).select("_id uid name basepath desc group_id project_type protocol prd_host env add_time up_time").sort({ _id: -1 }).exec();
}
}, {
key: 'listWithPaging',

View File

@ -18,7 +18,7 @@
<script src="/lib/snippets-json.js"></script>
<script src="/lib/ext-language.tools.js"></script>
<script src="/lib/mode-json-1.2.8.js"></script>
<!-- <script src="https://qsso.corp.qunar.com/lib/qsso-auth.js"></script> -->
<script src="https://qsso.corp.qunar.com/lib/qsso-auth.js"></script>