const system=require("../../system");
const ServiceBase=require("../sve.base");
class DataauthService extends ServiceBase{
  constructor(){
     super(ServiceBase.getDaoName(DataauthService));
  }
  async saveauth(obj){
    //先按照uid,modelname,检查是否存在，不存在创建，存在更新
    var oldauth= await this.dao.findOne({user_id:obj.user_id,modelname:obj.modelname});
    if(!oldauth){
      return this.dao.create(obj);
    }else{
      obj.id=oldauth.id;
      return this.dao.update(obj);
    }
  }
  
}
module.exports=DataauthService;
