/** * 更新状态 * * @author wei.luo * @createTime 2012-4-8 * @param request * @param response * @return */ @RequestMapping(value = "/updateStatus") public String updateStatus(HttpServletRequest request, HttpServletResponse response) { String type = request.getParameter("type"); if (StringUtils.isBlank(type)) { type = String.valueOf(request.getAttribute("type")); if (StringUtils.isBlank(type)) { return this.gotoCurrentPage(request, response); } } String id = request.getParameter("id"); if (StringUtils.isBlank(id)) { type = String.valueOf(request.getAttribute("id")); if (StringUtils.isBlank(id)) { return this.gotoCurrentPage(request, response); } } News news = this.newsService.findById(Integer.parseInt(id)); if (null != news) { if (null != type && "true".equals(type)) { // 将状态修改为下线 news.setStatus("下线"); this.newsService.alter(news); } if (null != type && "false".equals(type)) { // 将状态修改为上线 news.setStatus("上线"); this.newsService.alter(news); } } return this.gotoCurrentPage(request, response); }
/** * 更改排序 * * @author wei.luo * @createTime 2012-4-29 * @param request * @param response * @return */ @RequestMapping(value = "/changeOrder") public String changeOrder(HttpServletRequest request, HttpServletResponse response) { String id = request.getParameter("id"); String type = request.getParameter("type"); News news = (News) this.newsService.findById(Integer.parseInt(id)); int order = 0; if (news.getOrders() != null) { order = news.getOrders(); } if (null != type && type.equals("up")) { // 上升一名 即排名-1 news.setOrders(this.newsService.changeOrder(order - 1, order)); } else { // 下降一名 news.setOrders(this.newsService.changeOrder(order + 1, order)); } this.newsService.alter(news); return gotoCurrentPage(request, response); }