SortAction.java
上传用户:yunfeng252
上传日期:2022-07-23
资源大小:12403k
文件大小:4k
- package org.yufeng.struts.action;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.yufeng.domains.Article;
- import org.yufeng.domains.Assort;
- import org.yufeng.domains.Sort;
- import org.yufeng.service.ISortServiceDao;
- import org.yufeng.utils.Tools;
- public class SortAction extends BaseAction {
- public ActionForward soas_show(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- ISortServiceDao sortService = (ISortServiceDao)this.getSortService();
- List sort_list = sortService.browseSort();
- Sort sort = null;
- for(int i=0;i<sort_list.size();i++){
- sort = (Sort)sort_list.get(i);
- sort.setAssort_list(this.getAssortService().browseAllAssortById(sort.getSo_id()));
- }
- session.setAttribute("sort_list", sort_list);
- return mapping.findForward("sort_show");
- }
-
- public ActionForward toSoAs_edit(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- String so_id = request.getParameter("so_id");
- String as_id = request.getParameter("as_id");
- if(so_id!=null){
- Sort sort = this.getSortService().loadSort(Integer.parseInt(so_id));
- session.setAttribute("so_name", sort.getSo_name());
- session.removeAttribute("as_name");
- }else if(as_id!=null){
- Assort assort = this.getAssortService().loadAssort(Integer.parseInt(as_id));
- session.setAttribute("as_name", assort.getAs_name());
- session.removeAttribute("so_name");
- }
- return new ActionForward("/sort.do?method=soas_show");
- }
- public ActionForward soas_edit(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- String so_name = request.getParameter("so_name");
- String as_name = request.getParameter("as_name");
- String edit_name = request.getParameter("edit_name");
- if(!"".equals(so_name)){
- this.getSortService().updateSort(so_name, edit_name);
- session.removeAttribute("so_name");
- }else if(!"".equals(as_name)){
- this.getAssortService().updateSort(as_name, edit_name);
- session.removeAttribute("as_name");
- }
- return new ActionForward("/sort.do?method=soas_show");
- }
- public ActionForward soas_add(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- String so_addname = request.getParameter("so_addname");
- String as_addname = request.getParameter("as_addname");
- if(!"".equals(so_addname)){
- Sort sort = new Sort();
- sort.setSo_name(so_addname);
- sort.setSo_createTime(Tools.getData());
- sort.setSo_count(0);
- this.getSortService().addSort(sort);
- }if(!"".equals(as_addname)){
- Assort assort = new Assort();
- assort.setAs_name(as_addname);
- assort.setAs_sort_id(Integer.parseInt(request.getParameter("so_addid")));
- assort.setAs_createTime(Tools.getData());
- assort.setAs_count(0);
- this.getAssortService().addAssort(assort);
- }
- return new ActionForward("/sort.do?method=soas_show");
- }
-
- public ActionForward soas_dele(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- String so_id = request.getParameter("so_id");
- String as_id = request.getParameter("as_id");
- if(null!=so_id){
- Sort sort = new Sort();
- sort.setSo_id(Integer.parseInt(so_id));
- this.getSortService().delSort(sort);
- }else if(null!=as_id){
- Assort assort = new Assort();
- assort.setAs_id(Integer.parseInt(as_id));
- this.getAssortService().delAssort(assort);
- }
- return new ActionForward("/sort.do?method=soas_show");
- }
-
- public ActionForward soas_deleall(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- String[] dele_id = request.getParameterValues("dele_id");
- getAssortService().delAllAssort(dele_id);
- return new ActionForward("/sort.do?method=soas_show");
- }
- }