标签:
@RequestMapping("/sendHistory")
public ModelAndView sendrhistory(HttpServletRequest req, HttpServletResponse rep, @RequestParam int p) throws Exception {
System.out.println("start...");
String a=req.getParameter("status");
ModelAndView modelAndView = new ModelAndView("send_history");
Map<String, Object> map = dbUtilsTemplate.findFirst("select count(*) from message where user_id=‘" + getLoginUser().getId() + "‘");
Map<String, Object> map1 = dbUtilsTemplate.findFirst("select count(*) from message where user_id=‘" + getLoginUser().getId() + "‘ and status=‘DELIVERED‘");
int count = Integer.parseInt(map.get("count(*)").toString());
int numbers=Integer.parseInt(map1.get("count(*)").toString());;
String sql="";
sql = "select country_code ,phone_number ,content ,b.dic_value status, send_time ,receive_time from message a," + "statusdic b where user_id=‘" + getLoginUser().getId() + "‘" + " and a.api_name=b.api_name and a.status=b.dic_key order by send_time desc limit " + getPageStart(10, count, p) + ",10 ";
//条件查询
if(req.getParameter("status")!=null&&req.getParameter("status").equals("b"))
{
sql = "select country_code ,phone_number ,content ,b.dic_value status, send_time ,receive_time from message a,"
+ "statusdic b where user_id=‘" + getLoginUser().getId() + "‘" +"and a.status=‘DELIVERED‘"+
" and a.api_name=b.api_name and a.status=b.dic_key and phone_number like ‘%" + req.getParameter("phone_number")
+ "%‘ order by send_time desc limit " + getPageStart(10, count, p) + ",10 " ;
System.out.println(sql);
}
if(req.getParameter("status")!=null&&req.getParameter("status").equals("c")){
sql = "select country_code ,phone_number ,content ,b.dic_value status, send_time ,receive_time from message a,"
+ "statusdic b where user_id=‘" + getLoginUser().getId() + "‘" +"and status=‘0‘"+
" and a.api_name=b.api_name and a.status=b.dic_key and phone_number like ‘%" + req.getParameter("phone_number")
+ "%‘ order by send_time desc limit " + getPageStart(10, count, p) + ",10 " ;
}
if(req.getParameter("status")!=null&&req.getParameter("status").equals("a")){
sql = "select country_code ,phone_number ,content ,b.dic_value status, send_time ,receive_time from message a,"
+ "statusdic b where user_id=‘" + getLoginUser().getId() + "‘" +
" and a.api_name=b.api_name and a.status=b.dic_key and phone_number like ‘%" + req.getParameter("phone_number")
+ "%‘ order by send_time desc limit " + getPageStart(10, count, p) + ",10 " ;
}
System.out.println(sql);
List<Message> list = dbUtilsTemplate.find(Message.class, sql);
modelAndView.addObject("numbers", numbers);
modelAndView.addObject("list", list);
modelAndView.addObject("status", a);
modelAndView.addObject("phone", req.getParameter("phone_number"));
return modelAndView;
}
标签:
原文地址:http://www.cnblogs.com/jessi/p/4758381.html