@SuppressWarnings("unchecked") public List<MdBarTopic> getHotTopicList(String barId) { try { Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String nowDay = sdf.format(now); Date start = sdf.parse(nowDay.split(" ")[0]+" 00:00:00"); Date end = sdf.parse(nowDay.split(" ")[0]+" 23:59:59"); ArrayList<MdBarTopic> list = new ArrayList<MdBarTopic>(); List<Map> data = this.getNamedQuery("sdBar::getHotTopicList::query", barId, start, end); if(data!=null&&data.size()>0){ for(Map map : data){ MdBarTopic mdBarTopic = new MdBarTopic(); mdBarTopic.setReplyCount(Integer.parseInt(map.get("REPLY_COUNT").toString())); mdBarTopic.setTitle((String) map.get("TITLE")); mdBarTopic.setTopicId((String) map.get("TOPIC_ID")); list.add(mdBarTopic); } } return list; } catch (ParseException e) { e.printStackTrace(); } return null; } sdBar::getHotTopicList::query: oracle SELECT * FROM MD_BAR_TOPIC WHERE BAR_ID = ? AND CRE_TIME > ? AND CRE_TIME < ? and rownum<6 ORDER BY REPLY_COUNT DESC mysql: SELECT * FROM MD_BAR_TOPIC WHERE BAR_ID = ? AND CRE_TIME > ? AND CRE_TIME < ? ORDER BY REPLY_COUNT DESC LIMIT 0,5
|
|