yapi/server/controllers/base.js

43 lines
996 B
JavaScript
Raw Normal View History

2017-07-05 17:47:51 +08:00
import yapi from '../yapi.js'
2017-07-10 11:56:53 +08:00
import projectModel from '../models/project.js'
2017-07-05 17:47:51 +08:00
class baseController{
constructor(ctx){
console.log('baseControler init...')
}
getUid(){
return 0
}
getLoginStatus(){
return true
}
2017-07-06 19:21:54 +08:00
getRole(){
return 'admin'
}
2017-07-10 11:56:53 +08:00
async jungeProjectAuth(id){
let model = yapi.getInst(projectModel);
if(this.getRole() === 'admin') return true;
if(!id) return false;
let result = await model.get(id);
if(result.uid === this.getUid()){
return true;
}
return false;
}
async jungeMemberAuth(id, member_uid){
let model = yapi.getInst(projectModel);
if(this.getRole() === 'admin') return true;
if(!id || !member_uid) return false;
let result = await model.checkMemberRepeat(id, member_uid);
if(result > 0){
return true;
}
return false;
}
2017-07-05 17:47:51 +08:00
}
module.exports = baseController