2017-07-05 16:17:58 +08:00
|
|
|
import yapi from '../yapi.js'
|
|
|
|
const projectSchema = {
|
2017-07-05 17:47:51 +08:00
|
|
|
uid: Number,
|
2017-07-05 16:17:58 +08:00
|
|
|
name: String,
|
|
|
|
basepath: String,
|
|
|
|
desc: String,
|
2017-07-05 17:47:51 +08:00
|
|
|
group_id: Number,
|
2017-07-05 16:17:58 +08:00
|
|
|
members: Array,
|
|
|
|
prd_host: String,
|
|
|
|
env: Object,
|
|
|
|
add_time: Number,
|
|
|
|
up_time: Number
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var projectModel = yapi.db('project', projectSchema);
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
save: (data) => {
|
|
|
|
let m = new projectModel(data);
|
|
|
|
return m.save();
|
|
|
|
},
|
|
|
|
checkRepeat: (name, basepath) => {
|
|
|
|
return projectModel.count({
|
|
|
|
project_name: name,
|
|
|
|
basepath: basepath
|
|
|
|
})
|
|
|
|
},
|
|
|
|
list: () => {
|
|
|
|
return projectModel.find().exec()
|
|
|
|
},
|
|
|
|
del: (id) => {
|
|
|
|
return projectModel.deleteOne({
|
|
|
|
_id: id
|
|
|
|
})
|
|
|
|
},
|
|
|
|
up: (id, data) => {
|
|
|
|
data.up_time = yapi.commons.time();
|
|
|
|
return projectModel.update({
|
|
|
|
_id: id,
|
|
|
|
}, data)
|
|
|
|
}
|
|
|
|
}
|