mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
|
import yapi from '../yapi.js';
|
||
|
import baseModel from './base.js';
|
||
|
|
||
|
class interfaceCase extends baseModel {
|
||
|
getName() {
|
||
|
return 'interface_col';
|
||
|
}
|
||
|
|
||
|
getSchema() {
|
||
|
return {
|
||
|
casename: { type: String, required: true },
|
||
|
uid: { type: Number, required: true },
|
||
|
col_id: { type: Number, required: true },
|
||
|
project_id: { type: Number, required: true },
|
||
|
add_time: Number,
|
||
|
up_time: Number,
|
||
|
env: { type: String, required: true },
|
||
|
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() {
|
||
|
return this.model.find().exec();
|
||
|
}
|
||
|
|
||
|
del(id) {
|
||
|
return this.model.deleteOne({
|
||
|
_id: id
|
||
|
});
|
||
|
}
|
||
|
|
||
|
up(id, data) {
|
||
|
data.up_time = yapi.commons.time()
|
||
|
return this.model.update(
|
||
|
{ _id: id },
|
||
|
data
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = interfaceCase;
|