예제 #1
0
 public static void initMap() {
   NSimpleHibernateDao nSimpleHibernateDao = SpringContextHolder.getBean("NSimpleHibernateDao");
   String hql = "from BaseDataList where typeuuid='emot'";
   List<BaseDataList> list =
       (List<BaseDataList>) nSimpleHibernateDao.getHibernateTemplate().find(hql);
   map.clear();
   for (BaseDataList o : list) {
     String url =
         ProjectProperties.getProperty(
             "share_url_getEmot", "http://kd.wenjienet.com/px-rest/i/emoji/");
     map.put(o.getDatavalue(), url + o.getDescription());
   }
 }
예제 #2
0
  /**
   * 获取上传地址,每次调用缓存延长24小时
   *
   * @param uuid
   * @return
   * @throws IOException
   */
  public static String getUploadFilePath(String uuid) {
    Jedis jedis = getJedis();
    Response<String> pathResponse;
    try {
      String key = CacheConstants.Redis_String_PhotoPath + uuid;

      // if(true)return jedis.get(key);
      Pipeline p = jedis.pipelined();
      pathResponse = p.get(key);
      p.expire(key, CacheConstants.Redis_String_PhotoPath_Expire);
      p.sync();
      p.close();
      //		    List<Object> results = p.syncAndReturnAll();
      String path = pathResponse.get();
      if (path != null) return path;
      List list =
          nSimpleHibernateDao
              .createSqlQuery("select path from fp_photo_item where uuid='" + uuid + "'")
              .list();

      if (list != null && list.size() > 0) {
        path = (String) list.get(0);
        setUploadFilePath(uuid, path);
      } else { // 防止暴力查数据库
        setUploadFilePath(uuid, "");
      }
      return path;
    } catch (Exception e) {
      //// e.printStackTrace();
      throw e;
    } finally {
      if (jedis != null) jedis.close();
    }
  }