2017-09-17 13:36:51 +08:00
|
|
|
const yapi = require('yapi.js');
|
|
|
|
const baseModel = require('models/base.js');
|
|
|
|
|
|
|
|
class advMockModel extends baseModel {
|
|
|
|
getName() {
|
|
|
|
return 'adv_mock';
|
|
|
|
}
|
|
|
|
|
|
|
|
getSchema() {
|
|
|
|
return {
|
|
|
|
interface_id: { type: Number, required: true },
|
|
|
|
project_id: {type: Number, required: true},
|
2017-09-20 20:21:58 +08:00
|
|
|
enable: {type: Boolean, default: false},
|
2017-09-17 13:36:51 +08:00
|
|
|
mock_script: String,
|
|
|
|
uid: String,
|
|
|
|
up_time: Number
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
get(interface_id) {
|
|
|
|
|
|
|
|
return this.model.findOne({
|
|
|
|
interface_id: interface_id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
delByInterfaceId(interface_id) {
|
2017-10-18 10:04:16 +08:00
|
|
|
return this.model.remove({
|
2017-09-17 13:36:51 +08:00
|
|
|
interface_id: interface_id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
delByProjectId(project_id){
|
2017-10-18 10:04:16 +08:00
|
|
|
return this.model.remove({
|
2017-09-17 13:36:51 +08:00
|
|
|
project_id: project_id
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
save(data) {
|
|
|
|
data.up_time = yapi.commons.time();
|
|
|
|
let m = new this.model(data);
|
|
|
|
return m.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
up(data) {
|
|
|
|
data.up_time = yapi.commons.time();
|
|
|
|
return this.model.update({
|
|
|
|
interface_id: data.interface_id
|
|
|
|
}, {
|
|
|
|
uid: data.uid,
|
|
|
|
up_time: data.up_time,
|
|
|
|
mock_script: data.mock_script,
|
|
|
|
enable: data.enable
|
|
|
|
}, {
|
|
|
|
upsert: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = advMockModel;
|