2017-08-08 19:18:34 +08:00
|
|
|
import yapi from '../yapi.js';
|
|
|
|
import baseModel from './base.js';
|
|
|
|
|
|
|
|
class interfaceCase extends baseModel {
|
|
|
|
getName() {
|
2017-08-09 20:01:51 +08:00
|
|
|
return 'interface_case';
|
2017-08-08 19:18:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
getSchema() {
|
|
|
|
return {
|
|
|
|
casename: { type: String, required: true },
|
|
|
|
uid: { type: Number, required: true },
|
|
|
|
col_id: { type: Number, required: true },
|
2017-08-09 16:16:35 +08:00
|
|
|
index: {type: Number, default:0},
|
2017-08-08 19:18:34 +08:00
|
|
|
project_id: { type: Number, required: true },
|
|
|
|
add_time: Number,
|
|
|
|
up_time: Number,
|
|
|
|
env: { type: String, required: true },
|
2017-08-09 20:01:51 +08:00
|
|
|
domain: {type: String },
|
2017-08-08 19:18:34 +08:00
|
|
|
path: { type: String, required: true },
|
|
|
|
method: { type: String, required: true },
|
|
|
|
req_query: [{
|
|
|
|
name: String, value: String
|
|
|
|
}],
|
|
|
|
req_headers: [{
|
|
|
|
name: String, value: String
|
|
|
|
}],
|
|
|
|
req_body_type: {
|
|
|
|
type: String,
|
|
|
|
enum: ['form', 'json', 'text', 'xml']
|
|
|
|
},
|
|
|
|
res_body_form: [{
|
|
|
|
name: String, value: String
|
|
|
|
}],
|
|
|
|
res_body_other: String
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
save(data) {
|
|
|
|
let m = new this.model(data);
|
|
|
|
return m.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
get(id) {
|
|
|
|
return this.model.findOne({
|
|
|
|
_id: id
|
|
|
|
}).exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
list() {
|
2017-08-09 16:16:35 +08:00
|
|
|
return this.model.find().select("casename uid col_id _id index").exec();
|
2017-08-08 19:18:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
del(id) {
|
|
|
|
return this.model.deleteOne({
|
|
|
|
_id: id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
up(id, data) {
|
|
|
|
data.up_time = yapi.commons.time()
|
|
|
|
return this.model.update(
|
|
|
|
{ _id: id },
|
|
|
|
data
|
|
|
|
);
|
|
|
|
}
|
2017-08-09 20:01:51 +08:00
|
|
|
|
|
|
|
upCaseIndex(id, index){
|
|
|
|
return this.model.update({
|
|
|
|
_id: id
|
|
|
|
},{
|
|
|
|
index: index
|
|
|
|
})
|
|
|
|
}
|
2017-08-08 19:18:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = interfaceCase;
|