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

  async findUserByRoleId(params){
    let sql = [];
    sql.push(`SELECT c.ucid,c.ucname,c.uctype,c.saas_id,c.isEnabled,c.created_at,c.updated_at,c.deleted_at
    FROM uc_role a INNER JOIN uc_user_role b ON a.id = b.role_id INNER JOIN uc_user c ON b.user_id = c.id
    WHERE 1=1 and ( c.deleted_at is null or c.deleted_at > NOW() ) `);
    if(params.id){
      sql.push("AND a.id = :id");
    }
    return await this.customQuery(sql.join(" "), params);
  }
}
module.exports = RoleDao;