SortAction.java
上传用户:yunfeng252
上传日期:2022-07-23
资源大小:12403k
文件大小:4k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package org.yufeng.struts.action;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.servlet.http.HttpServletResponse;
  5. import javax.servlet.http.HttpSession;
  6. import org.apache.struts.action.ActionForm;
  7. import org.apache.struts.action.ActionForward;
  8. import org.apache.struts.action.ActionMapping;
  9. import org.yufeng.domains.Article;
  10. import org.yufeng.domains.Assort;
  11. import org.yufeng.domains.Sort;
  12. import org.yufeng.service.ISortServiceDao;
  13. import org.yufeng.utils.Tools;
  14. public class SortAction extends BaseAction {
  15. public ActionForward soas_show(ActionMapping mapping, ActionForm form,
  16. HttpServletRequest request, HttpServletResponse response) {
  17. HttpSession session = request.getSession();
  18. ISortServiceDao sortService = (ISortServiceDao)this.getSortService();
  19. List sort_list = sortService.browseSort();
  20. Sort sort = null;
  21. for(int i=0;i<sort_list.size();i++){
  22. sort = (Sort)sort_list.get(i);
  23. sort.setAssort_list(this.getAssortService().browseAllAssortById(sort.getSo_id()));
  24. }
  25. session.setAttribute("sort_list", sort_list);
  26. return mapping.findForward("sort_show");
  27. }
  28. public ActionForward toSoAs_edit(ActionMapping mapping, ActionForm form,
  29. HttpServletRequest request, HttpServletResponse response) {
  30. HttpSession session = request.getSession();
  31. String so_id = request.getParameter("so_id");
  32. String as_id = request.getParameter("as_id");
  33. if(so_id!=null){
  34. Sort sort = this.getSortService().loadSort(Integer.parseInt(so_id));
  35. session.setAttribute("so_name", sort.getSo_name());
  36. session.removeAttribute("as_name");
  37. }else if(as_id!=null){
  38. Assort assort = this.getAssortService().loadAssort(Integer.parseInt(as_id));
  39. session.setAttribute("as_name", assort.getAs_name());
  40. session.removeAttribute("so_name");
  41. }
  42. return new ActionForward("/sort.do?method=soas_show");
  43. }
  44. public ActionForward soas_edit(ActionMapping mapping, ActionForm form,
  45. HttpServletRequest request, HttpServletResponse response) {
  46. HttpSession session = request.getSession();
  47. String so_name = request.getParameter("so_name");
  48. String as_name = request.getParameter("as_name");
  49. String edit_name = request.getParameter("edit_name");
  50. if(!"".equals(so_name)){
  51. this.getSortService().updateSort(so_name, edit_name);
  52. session.removeAttribute("so_name");
  53. }else if(!"".equals(as_name)){
  54. this.getAssortService().updateSort(as_name, edit_name);
  55. session.removeAttribute("as_name");
  56. }
  57. return new ActionForward("/sort.do?method=soas_show");
  58. }
  59. public ActionForward soas_add(ActionMapping mapping, ActionForm form,
  60. HttpServletRequest request, HttpServletResponse response) {
  61. HttpSession session = request.getSession();
  62. String so_addname = request.getParameter("so_addname");
  63. String as_addname = request.getParameter("as_addname");
  64. if(!"".equals(so_addname)){
  65. Sort sort = new Sort();
  66. sort.setSo_name(so_addname);
  67. sort.setSo_createTime(Tools.getData());
  68. sort.setSo_count(0);
  69. this.getSortService().addSort(sort);
  70. }if(!"".equals(as_addname)){
  71. Assort assort = new Assort();
  72. assort.setAs_name(as_addname);
  73. assort.setAs_sort_id(Integer.parseInt(request.getParameter("so_addid")));
  74. assort.setAs_createTime(Tools.getData());
  75. assort.setAs_count(0);
  76. this.getAssortService().addAssort(assort);
  77. }
  78. return new ActionForward("/sort.do?method=soas_show");
  79. }
  80. public ActionForward soas_dele(ActionMapping mapping, ActionForm form,
  81. HttpServletRequest request, HttpServletResponse response) {
  82. String so_id = request.getParameter("so_id");
  83. String as_id = request.getParameter("as_id");
  84. if(null!=so_id){
  85. Sort sort = new Sort();
  86. sort.setSo_id(Integer.parseInt(so_id));
  87. this.getSortService().delSort(sort);
  88. }else if(null!=as_id){
  89. Assort assort = new Assort();
  90. assort.setAs_id(Integer.parseInt(as_id));
  91. this.getAssortService().delAssort(assort);
  92. }
  93. return new ActionForward("/sort.do?method=soas_show");
  94. }
  95. public ActionForward soas_deleall(ActionMapping mapping, ActionForm form,
  96. HttpServletRequest request, HttpServletResponse response) {
  97. String[] dele_id = request.getParameterValues("dele_id");
  98. getAssortService().delAllAssort(dele_id);
  99. return new ActionForward("/sort.do?method=soas_show");
  100. }
  101. }