⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contentaction.java

📁 采用JAVA开发
💻 JAVA
字号:
package com.gctech.sms.voice.web;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import org.apache.log4j.Logger;
import com.gctech.sms.voice.*;
import com.gctech.sms.voice.dao.*;
import com.gctech.sms.voice.common.*;


public class ContentAction extends Action
{
  VoiceFacade  f = new VoiceFacade();
  static Logger logger = Logger.getLogger(LoginAction.class);
  public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
  {
    /**@todo: complete the business logic here, this is just a skeleton.*/
    CatalogActionForm form = (CatalogActionForm) actionForm;
    logger.debug(form.getBigType()+":"+form.getSmallType());
    //查询用户上传类型
    if(form.getBigType().intValue()==0)
    {
      return queryUserVoice(actionMapping,form,httpServletRequest,httpServletResponse);
    }
    //公司自有类型
    else
    {
        return queryJFDVoice(actionMapping,form,httpServletRequest,httpServletResponse);
    }

  }

  private ActionForward queryUserVoice(ActionMapping actionMapping, CatalogActionForm form, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
  {
    try
   {
     Integer bType = form.getBigType();
     Integer sType = form.getSmallType();
     String offset = httpServletRequest.getParameter("pager.offset");
      int startIndex = 0;
      int endIndex=0;
      HttpSession session = httpServletRequest.getSession();
      if(offset==null)
      {
        int size = 0;
        size = f.getVoiceSizeByUser();
        session.setAttribute("resultSize",new Integer(size));
        startIndex = 1;
        endIndex = Consts.MAX_PAGE_ITEMS;
        if(endIndex > size) endIndex = size;
        VoiceValueObject[] vos = null;
        vos = f.getVoiceByUser(startIndex,endIndex);
        httpServletRequest.setAttribute("result",vos);
        httpServletRequest.setAttribute("bType",bType);
        httpServletRequest.setAttribute("sType",sType);
        return actionMapping.findForward("detailPage");

      }
      else
      {
        startIndex = (new Integer(offset)).intValue() + 1;
        int size = ((Integer)session.getAttribute("resultSize")).intValue();
        endIndex = startIndex + Consts.MAX_PAGE_ITEMS;
        if(endIndex > size)endIndex = size;
        VoiceValueObject[] vos = f.getVoiceByUser(startIndex,endIndex);
        httpServletRequest.setAttribute("result",vos);
        httpServletRequest.setAttribute("bType",bType);
        httpServletRequest.setAttribute("sType",sType);
        return actionMapping.findForward("detailPage");
      }


   }
   catch(Exception ex)
   {
     logger.info(ex.getMessage());
     return actionMapping.findForward("error");
   }

  }

  private ActionForward queryJFDVoice(ActionMapping actionMapping, CatalogActionForm form, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
 {
   try
   {
     Integer bType = form.getBigType();
     Integer sType = form.getSmallType();
     String offset = httpServletRequest.getParameter("pager.offset");
     logger.debug("offset:"+offset);
     logger.debug("sType:"+form.getSmallType());
     logger.debug("bType:"+form.getBigType());
      int startIndex = 0;
      int endIndex=0;
      HttpSession session = httpServletRequest.getSession();
      if(offset==null)
      {
        int size = 0;
        if(sType.intValue()==0)
        {
          if(bType.intValue()==-1)
          {
            size = f.getVoiceSizeByBigCatalog(null);
          }
          else
          {
           size = f.getVoiceSizeByBigCatalog(bType);
          }

        }
        else
        {
            size = f.getVoiceSizeBySmallCatalog(sType);
        }
        session.setAttribute("resultSize",new Integer(size));
        startIndex = 1;
        endIndex = Consts.MAX_PAGE_ITEMS;
        if(endIndex > size) endIndex = size;
        VoiceValueObject[] vos = null;
        if(sType.intValue() == 0)
        {
          if(bType.intValue()==-1)
          {
            vos = f.getVoiceByBigCatalog(null,startIndex,endIndex);
          }
          else
          {
           vos = f.getVoiceByBigCatalog(bType,startIndex,endIndex);
          }


        }
        else
        {
            vos = f.getVoiceBySmallCatalog(sType,startIndex,endIndex);
        }
        httpServletRequest.setAttribute("result",vos);

        httpServletRequest.setAttribute("bType",bType);
        httpServletRequest.setAttribute("sType",sType);
        return actionMapping.findForward("detailPage");

      }
      else
      {
        startIndex = (new Integer(offset)).intValue() + 1;
        int size = ((Integer)session.getAttribute("resultSize")).intValue();
        endIndex = startIndex + Consts.MAX_PAGE_ITEMS;
        if(endIndex > size)endIndex = size;
        VoiceValueObject[] vos = null;
        if(sType.intValue() == 0)
        {
          if(bType.intValue()==-1)
          {
            vos = f.getVoiceByBigCatalog(null,startIndex,endIndex);
          }
          else
          {
              vos = f.getVoiceByBigCatalog(bType,startIndex,endIndex);
          }

        }
        else
        {
             vos = f.getVoiceBySmallCatalog(sType,startIndex,endIndex);
        }
        httpServletRequest.setAttribute("result",vos);
        httpServletRequest.setAttribute("bType",bType);
        httpServletRequest.setAttribute("sType",sType);
        return actionMapping.findForward("detailPage");
      }


   }
   catch(Exception ex)
   {
     logger.info(ex.getMessage());
     return actionMapping.findForward("error");
   }

 }




}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -