const system=require("../../../system");
const Dao=require("../../dao.base");
class ProductpriceDao extends Dao{
  constructor(){
    super(Dao.getModelName(ProductpriceDao));
  }
  extraWhere(obj,w,qc,linkAttrs){
    if(obj.bizpath && obj.bizpath!=""){
      if(obj.bizpath.indexOf("platformprice")>0){//说明是租户查询自己创建的应用
         w["company_id"]= obj.company_id;
      }
    }
    if(linkAttrs.length>0){
      var search=obj.search;
      var lnkKey=linkAttrs[0];
      var strq="$"+lnkKey.replace("~",".")+"$";
      w[strq]= {[this.db.Op.like]:"%"+search[lnkKey]+"%"};
    }
    return w;
 }
  extraModelFilter(){
    //return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
    return {"key":"include","value":[
      {model:this.db.models.pricestrategy,attributes:["id","optionunion"]},
      {model:this.db.models.product,attributes:["id","name"]}]};
  }
}
module.exports=ProductpriceDao;
    // var u=new UserDao();
    // var roledao=system.getObject("db.roleDao");
    // (async ()=>{
    //   var users=await u.model.findAll({where:{app_id:1}});
    //   var role=await roledao.model.findOne({where:{code:"guest"}});
    //   console.log(role);
    //   for(var i=0;i<users.length;i++){
    //     await users[i].setRoles([role]);
    //     console.log(i);
    //   }
    //
    // })();
