Map<String, Object> jsonMap = new HashMap<String, Object>();
String params = request().getParameter("data");
String userId=CJSON.getUserId(params);
long pageNum=Convert.strToLong(CJSON.getData(params,"pageNum"), 1);
try {
List<Map<String, Object>> replyMyList= appMessageService.getReplyMy(userId,pageNum);
//查看资讯回复
List<Map<String, Object>> replyMyConsultList= appMessageService.getReplyMyConsult(userId,pageNum);
jsonMap.put("replyMyConsultList", replyMyConsultList);
jsonMap.put("replyMyList", replyMyList);
jsonMap.put("code","-1");
jsonMap.put("msg","查询成功");
CJSON.printObject(true, jsonMap);
} catch (Exception e) {
e.printStackTrace();
jsonMap.put("code", "0");
jsonMap.put("msg", "未知异常");
JSONUtils.printObject(CJSON.setRetData(false, jsonMap));
log.error(e);
}
return null;
}
//service
public List<Map<String, Object>> getReplyMyConsult(String userId, long pageNum) throws SQLException, DataException {
List<Map<String, Object>>list = null;
Connection conn = null;
try {
conn = MySQL.getConnection();
list = appMessageDao.getReplyMyConsult(conn, userId, pageNum);
} catch (SQLException e) {
conn.rollback();
log.error(e);
e.printStackTrace();
throw e;
}finally{
if(conn != null){
conn.close();
}
}
return list;
}
//dao
public List<Map<String, Object>> getReplyMyConsult(Connection conn, String userId, long pageNum) throws SQLException, DataException {
StringBuffer sql = new StringBuffer();
sql.append("select reply.id,mr.msg as message ,date_format(mr.create_time,'%m-%d %H:%i') as create_time,admin.nickName,admin.img as imgUrl ");
sql.append(" from xyd_p_reply reply ");
sql.append(" LEFT JOIN xyd_information mm on reply.preemption_id=mm.id ");
sql.append(" LEFT JOIN xyd_p_reply mr on mr.parentId=reply.id ");
sql.append(" LEFT JOIN t_admin ad on reply.creator=ad.id ");
sql.append(" LEFT JOIN t_admin admin on mr.creator=admin.id ");
sql.append("where mr.parentId in (select id from xyd_p_reply where creator='"+userId+"')");
// sql.append(" LIMIT " + (pageNum-1) * IConstant.STAR_MESSAGE_LIMIT_NUM + "," + IConstant.STAR_MESSAGE_LIMIT_NUM);
DataSet dataSet = MySQL.executeQuery(conn, sql.toString());
dataSet.tables.get(0).rows.genRowsMap();
return dataSet.tables.get(0).rows.rowsMap;
}
//struts2别忘了配XML。注意拦截方法