2017-09-03 08:43:13 +08:00
|
|
|
const yapi = require('../yapi.js');
|
|
|
|
const baseModel = require('./base.js');
|
2017-08-18 20:35:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 接口分类
|
|
|
|
*/
|
|
|
|
class interfaceCat extends baseModel {
|
|
|
|
getName() {
|
|
|
|
return 'interface_cat';
|
|
|
|
}
|
|
|
|
|
|
|
|
getSchema() {
|
|
|
|
return {
|
|
|
|
name: { type: String, required: true },
|
|
|
|
uid: { type: Number, required: true },
|
|
|
|
project_id: { type: Number, required: true },
|
|
|
|
desc: String,
|
|
|
|
add_time: Number,
|
|
|
|
up_time: Number
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
save(data) {
|
|
|
|
let m = new this.model(data);
|
|
|
|
return m.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
get(id) {
|
|
|
|
return this.model.findOne({
|
|
|
|
_id: id
|
|
|
|
}).exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
checkRepeat(name) {
|
|
|
|
return this.model.count({
|
|
|
|
name: name
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
list(project_id) {
|
|
|
|
return this.model.find({
|
|
|
|
project_id: project_id
|
|
|
|
}).exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
del(id) {
|
2017-10-18 10:04:16 +08:00
|
|
|
return this.model.remove({
|
2017-08-18 20:35:31 +08:00
|
|
|
_id: id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
delByProjectId(id){
|
2017-10-18 10:04:16 +08:00
|
|
|
return this.model.remove({
|
2017-08-18 20:35:31 +08:00
|
|
|
project_id: id
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
up(id, data) {
|
|
|
|
data.up_time = yapi.commons.time()
|
|
|
|
return this.model.update(
|
|
|
|
{
|
|
|
|
_id: id
|
|
|
|
},
|
|
|
|
data
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = interfaceCat;
|