package controller; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import pojo.Comments; import service.CommentsService; @Controller public class CommentsController { @Resource public CommentsService commentsService; //评论请求 @RequestMapping("/commentsMan.html") public String commentsMan() { return "admin/comments_table"; } //获取所有的评论 @RequestMapping("/comments/getAllComments.html") public void getAllComments(@RequestParam(value="rows",required=false)Integer rows, @RequestParam(value="page",required=false)Integer page, HttpServletRequest request, @RequestParam(value="commentsName",required=false)String commentsName, @RequestParam(value="commentsProName",required=false)String commentsProName, HttpServletResponse response ) throws Exception { response.setCharacterEncoding("utf-8"); //传入map Map<String,Object> map = new HashMap<String,Object>(); List<Comments> list = commentsService.getAllComments((page-1)*rows,rows,commentsName,commentsProName); map.put("total", commentsService.getAllCommentsTotal(commentsName,commentsProName)); map.put("rows", list); String jsonString = tools.JSONTools.JSONMap(map); PrintWriter out = response.getWriter(); out.write(jsonString); out.flush(); out.close(); } //评论的删除 @RequestMapping("/deleteComments.html") public void deleteStudent(HttpServletRequest request,@RequestParam(value="pks",required=false)String pks[], HttpServletResponse response) throws Exception{ //这里判断一下,传来的数组是空的,则返回删除错误,不为空则遍历开始删除 response.setCharacterEncoding("utf-8"); String data ="删除失败"; if(pks.length!=0){ int numSuccess =0; int numFail=0; for (String commentsId : pks) { boolean delete = commentsService.deleteComments(commentsId); if(delete) { numSuccess+=1; }else { numFail+=1; } } data="您选择了"+pks.length+"条数据。"+"删除成功:"+numSuccess+"条"+",失败:"+numFail; } PrintWriter out = response.getWriter(); out.write(data); out.flush(); out.close(); } }

微信网友_7134912998903808 LV15
2024年8月29日
jskdbf LV7
2022年6月11日
lilong007 LV23
2021年12月22日
success1011 LV8
2021年12月15日
双方各何必呢 LV13
2021年12月10日
桐姥爷无敌呀 LV4
2021年11月15日
dxadsaf LV6
2021年10月7日
15167672991 LV6
2021年6月29日
凉筱123 LV2
2021年5月29日
xiaoxiexie LV13
2021年4月26日

talete LV3
2月14日
ma406805131 LV19
2024年12月18日
微信网友_7134912998903808 LV15
2024年8月29日
try8023 LV19
2024年6月7日
1134116035
2024年2月28日
暂无贡献等级
heshao LV2
2024年2月7日
PSSDZH LV3
2023年12月26日
zhaozhiqi LV5
2023年10月10日
yeyuuu LV6
2023年5月18日
箜canasd LV5
2023年4月3日