const system = require("../../../system");
const Dao = require("../../dao.base");
class UserDao extends Dao {
  constructor() {
    super(Dao.getModelName(UserDao));
  }


  /**
   * 条件查询
   * @param {} params 
   */
  async findUserBySaasId(params){
    let sql = [];
    sql.push('select ucid,ucname,uctype,saas_id,isEnabled from uc_user where 1 = 1');
    if(params.ucid){
      sql.push("AND ucid = :ucid");
    }
    if(params.ucname){
      sql.push("AND ucname = :ucname");
    }
    if(params.uctype){
      sql.push("AND uctype = :uctype");
    }
    if(params.saas_id){
      sql.push("AND saas_id = :saas_id");
    }
    if(params.isEnabled){
      sql.push("AND saas_id = :isEnabled");
    }
    
    sql.push(`AND (deleted_at > NOW() or deleted_at is null)`);
    return await this.customQuery(sql.join(" "), params);
  }
}
module.exports = UserDao;