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

📄 channelconfigaction.java

📁 shopping home JSP system
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        String channelId = pc.getChannelId();
        try
        {
            Channel channel = ChannelManager.getChannel(channelId);
            updateEnableStatus(channel);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        ChannelManager.channelPcConfigMap.put(channelId + pc.getPageSearchKey() + pc.getPosition(), pc.copy());
        request.setAttribute("update_success", "true");
        return mapping.findForward("addPcConfig");
    }

    public ActionForward performSaveadconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)form;
        ChannelAd ad = cform.getChannelAd();
        try
        {
            ChannelAdBO bo = new ChannelAdBO();
            bo.addBean(ad);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        String channelId = ad.getChannelId();
        try
        {
            Channel channel = ChannelManager.getChannel(channelId);
            updateEnableStatus(channel);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        ChannelManager.channelAdConfigMap.put(ad.getChannelId() + ad.getPageSearchKey() + ad.getPosition(), ad.copy());
        request.setAttribute("save_success", "true");
        return mapping.findForward("addAdConfig");
    }

    public ActionForward performSaveccconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)form;
        updateCCImage();
        ChannelContent cc = cform.getChannelContent();
        try
        {
            ChannelContentBO bo = new ChannelContentBO();
            bo.addBean(cc);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        ChannelManager.channelCcConfigMap.put(cc.getChannelId() + cc.getPageSearchKey() + cc.getPosition(), cc.copy());
        request.setAttribute("save_success", "true");
        return mapping.findForward("addCcConfig");
    }

    public ActionForward performUpdateccconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)form;
        updateCCImage();
        ChannelContent cc = cform.getChannelContent();
        try
        {
            ChannelContentBO bo = new ChannelContentBO();
            bo.updateBean(cc);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        ChannelManager.channelCcConfigMap.put(cc.getChannelId() + cc.getPageSearchKey() + cc.getPosition(), cc.copy());
        request.setAttribute("update_success", "true");
        return mapping.findForward("addCcConfig");
    }

    public ActionForward performUpdateadconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)form;
        ChannelAd ad = cform.getChannelAd();
        try
        {
            ChannelAdBO bo = new ChannelAdBO();
            bo.updateBean(ad);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        String channelId = ad.getChannelId();
        try
        {
            Channel channel = ChannelManager.getChannel(channelId);
            ChannelManager.channelAdConfigMap.put(ad.getChannelId() + ad.getPageSearchKey() + ad.getPosition(), ad.copy());
            updateEnableStatus(channel);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        request.setAttribute("update_success", "true");
        return mapping.findForward("addAdConfig");
    }

    public ActionForward performRemoveadconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelAd ad = null;
        try
        {
            String channelId = request.getParameter("bean.id");
            String configId = request.getParameter("configId");
            ChannelAdBO bo = new ChannelAdBO();
            String deleteSql = "from ChannelAd c where c.channelId='" + channelId + "' and c.configId='" + configId + "'";
            List list = bo.list(deleteSql);
            if(list != null && list.size() > 0)
                ad = (ChannelAd)list.get(0);
            if(ad != null)
            {
                bo.deleteById(ad.getId());
                ChannelManager.channelAdConfigMap.remove(ad.getChannelId() + ad.getPageSearchKey() + ad.getPosition());
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        ChannelManager.channelAdConfigMap.remove(ad.getChannelId() + ad.getPageSearchKey() + ad.getPosition());
        request.setAttribute("remove_success", "true");
        return performList(mapping, form, request, response);
    }

    public ActionForward performRemoveccconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelContent cc = null;
        try
        {
            String channelId = request.getParameter("bean.id");
            String configId = request.getParameter("configId");
            ChannelContentBO bo = new ChannelContentBO();
            String deleteSql = "from ChannelContent c where c.channelId='" + channelId + "' and c.configId='" + configId + "'";
            List list = bo.list(deleteSql);
            if(list != null && list.size() > 0)
                cc = (ChannelContent)list.get(0);
            if(cc != null)
            {
                ChannelManager.channelCcConfigMap.remove(cc.getChannelId() + cc.getPageSearchKey() + cc.getPosition());
                bo.deleteById(cc.getId());
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        request.setAttribute("remove_success", "true");
        return performList(mapping, form, request, response);
    }

    public ActionForward performRemovepcconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        try
        {
            String channelId = request.getParameter("bean.id");
            String configId = request.getParameter("configId");
            ChannelProductCategoryBO bo = new ChannelProductCategoryBO();
            ChannelProductCategory channelProductCategory = null;
            String sql = " from ChannelProductCategory c where c.channelId='" + channelId + "' and c.configId='" + configId + "'";
            List list = bo.list(sql);
            if(list != null && list.size() > 0)
                channelProductCategory = (ChannelProductCategory)list.get(0);
            if(channelProductCategory != null)
                bo.deleteById(channelProductCategory.getId());
            ChannelManager.channelPcConfigMap.remove(channelProductCategory.getChannelId() + channelProductCategory.getPageSearchKey() + channelProductCategory.getPosition());
            request.setAttribute("remove_success", "true");
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        return performList(mapping, form, request, response);
    }

    public void updateEnableStatus(Channel channel)
    {
        if(channel == null && StringUtil.isEmpty(channel.getId()))
            return;
        try
        {
            if(!channel.isEnableStatus())
            {
                ChannelBO bo = new ChannelBO();
                if(ChannelManager.isChannelEnable(channel.getId(), channel.getJspModelId()) && !channel.isEnableStatus())
                {
                    channel.setEnableStatus(true);
                    bo.updateBean(channel);
                }
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }

    public ActionForward performSave(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        return super.performSave(mapping, form, request, response);
    }

    public ActionForward performList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)thisform;
        Channel bean = (Channel)cform.getBean();
        if("true".equals(request.getParameter("init")))
            cform.clear();
        try
        {
            String channelId = bean.getId();
            if(StringUtil.isEmpty(channelId))
                channelId = request.getParameter("bean.id");
            if(StringUtil.isEmpty(channelId))
            {
                generalError(request, new Exception(getClass().getName() + "no_channel_id"));
                return mapping.findForward("fail");
            }
            Channel channel = ChannelManager.getChannel(channelId);
            if(channel == null)
            {
                generalError(request, new Exception(getClass().getName() + "no_channel_id"));
                return mapping.findForward("fail");
            }
            bean = channel;
            String modelId = bean.getJspModelId();
            String contentType = cform.getContentType();
            List channelAds = ChannelManager.getChannelAds(channelId);
            cform.setChannelAdList(channelAds);
            List channelPcs = ChannelManager.getChannelProductCategorys(channelId);
            cform.setChannelPrdouctCategoryList(channelPcs);
            List channelCcs = ChannelManager.getChannelCcs(channelId);
            cform.setChannelContentList(channelCcs);
            if(!StringUtil.isEmpty(modelId))
            {
                List configs = ChannelManager.getChannelJspModelConfigs(modelId, contentType, cform.getContentName());
                if(configs != null && configs.size() > 0)
                    setConfigStatus(configs, channelAds, channelPcs, channelCcs);
                Pager page = new Pager(40);
                page.setTotalRow(configs.size());
                request.setAttribute("pager", page);
                request.setAttribute("searchresult", configs);
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            generalError(request, new Exception(getClass().getName() + "no_channel_id"));
            return mapping.findForward("fail");
        }
        return mapping.findForward("list");
    }

 

    protected String getSelectSQL()
    {
        return "";
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        try
        {
            actionType = request.getParameter("actionType");
            if(!StringUtil.isEmpty(actionType) && !actionType.equalsIgnoreCase("add") && !actionType.equalsIgnoreCase("list") && !actionType.equalsIgnoreCase("edit") && !actionType.equalsIgnoreCase("update") && !actionType.equalsIgnoreCase("save"))
                actionType.equalsIgnoreCase("remove");
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        return super.execute(mapping, form, request, response);
    }

    protected boolean isObjectExisted(PubBean bean)
    {
        return false;
    }
}

⌨️ 快捷键说明

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