예제 #1
0
파일: Agency.java 프로젝트: norain2050/sp2p
  /**
   * 合作机构标,机构列表
   *
   * @param error 信息值
   * @return List<Agency>
   */
  public static List<Agency> queryAgencys(ErrorInfo error) {
    error.clear();

    List<t_agencies> tagencies = null;
    List<Agency> agencys = new ArrayList<Agency>();

    String hql =
        "select new t_agencies(id, name) from t_agencies where is_use =? order by time desc";

    try {
      tagencies = t_agencies.find(hql, Constants.ENABLE).fetch();
    } catch (Exception e) {
      e.printStackTrace();
      Logger.error("合作机构->布合作机构标,机构列表:" + e.getMessage());
      error.msg = error.FRIEND_INFO + "加载合作机构失败!";

      return null;
    }

    if (null == tagencies) {
      return agencys;
    }

    Agency agency = null;

    for (t_agencies tagency : tagencies) {
      agency = new Agency();

      agency._id = tagency.id;
      agency.name = tagency.name;

      agencys.add(agency);
    }

    error.code = 0;

    return agencys;
  }