AddColumn.java
上传用户:junmaots
上传日期:2022-07-09
资源大小:2450k
文件大小:2k
- /*
- * Created on 2005-12-9
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
- package com.mycompany.servlet;
- import java.io.IOException;
- import java.net.URLEncoder;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.mycompany.news.dto.Column;
- import com.mycompany.news.service.ColumnService;
- /**
- * @author Administrator
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
- public class AddColumn extends HttpServlet {
- protected void service(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
-
- // String channelid = request.getParameter("channelid");
- String parentcolumn = request.getParameter("parentcolumn");
- String columnname= request.getParameter("columnname");
- String columnorder= request.getParameter("columnorder");
- String channelid= request.getParameter("channelid");
- // String topcolumn = request.getParameter("topcolumn");
- // String currentlevel= request.getParameter("currentlevel");
- ColumnService cs = new ColumnService();
-
-
- Column column = new Column();
-
- column.setColumnName(columnname);
- column.setColumnStatus(new Integer(1));
- column.setLeafNode(new Integer(1));
- column.setColumnOrder(Integer.valueOf(columnorder));
- column.setParentColumn(Long.valueOf(parentcolumn));
- System.out.println("channelid = "+channelid);
- column.setChannelId(Long.valueOf(channelid));
-
- if(Long.parseLong(parentcolumn)!=0){
- Column parentColumn = cs.getByID(Long.parseLong(parentcolumn));
- parentColumn.setLeafNode(new Integer(0));
- cs.updateColumn(parentColumn);
- if(parentColumn.getTopColumn().longValue()==0){
- column.setTopColumn(parentColumn.getColumnId());
- }else{
- column.setTopColumn(parentColumn.getTopColumn());
- }
- column.setCurrentLevel(new Integer(parentColumn.getCurrentLevel().intValue()+1));
- }else{
- column.setTopColumn(Long.valueOf("0"));
- column.setCurrentLevel(Integer.valueOf("0"));
- }
- if(cs.addColumn(column))
- response.sendRedirect(request.getContextPath()+"/opsucc.jsp?message="+URLEncoder.encode(cs.getMessage(),"GB2312"));
- else
- response.sendRedirect(request.getContextPath()+"/opfail.jsp?message="+URLEncoder.encode(cs.getMessage(),"GB2312"));
- }
- }