const system=require("../../system");
const Dao=require("../dao.base");
class RoleDao extends Dao{
  constructor(){
    super(Dao.getModelName(RoleDao));
  }
  async findOne(paramappid,t){
    var app=  await this.model.findOne({where:{appid:paramappid}},{transaction:t});
    return app;
  }
  async preUpdate(u){
    return u;
  }
  async update(obj){
    var obj2=await this.preUpdate(obj);
    await this.model.update(obj2,{where:{id:obj2.id}});
    var role=await this.model.findOne({where:{id:obj2.id}});
    return role;
  }
  async preCreate(u){
    return u;
  }
  async create(u,t){
      var self=this;
      var u2= await this.preCreate(u);
      if(t){
         var role= await this.model.create(u2,{transaction: t});
         return role;
      }else{
        var role= await this.model.create(u2);
        return role;
      }
  }
}
module.exports=RoleDao;
