const system=require("../../../system");
const Dao=require("../../dao.base");
class BusinesstypeDao extends Dao{
  constructor(){
    super(Dao.getModelName(BusinesstypeDao));
  }
  async refQuery(qobj) {
    var w = qobj.refwhere ? qobj.refwhere : {};
    w["p_id"] = 0;
    if (qobj.levelinfo) {
      w[qobj.levelinfo.levelfield] = qobj.levelinfo.level;
    }
    if (qobj.parentinfo) {
      w[qobj.parentinfo.parentfield] = qobj.parentinfo.parentcode;
    }
    //如果需要控制数据权限
    if (qobj.datapriv) {
      w["id"] = { [this.db.Op.in]: qobj.datapriv };
    }
    if (qobj.likestr) {
      w[qobj.fields[0]] = { [this.db.Op.like]: "%" + qobj.likestr + "%" };
      return this.model.findAll({ where: w, attributes: qobj.fields });
    } else {
      return this.model.findAll({ where: w, attributes: qobj.fields });
    }
  }
}
module.exports=BusinesstypeDao;
