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

📄 channelconfigaction.java

📁 shopping home JSP system
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   ChannelConfigAction.java

package com.keyshop.shop.channel.controller;

import com.keyshop.pub.controller.PubAction;
import com.keyshop.pub.model.PubBean;
import com.keyshop.pub.util.*;
import com.keyshop.pub.util.image.ImageUtil;
import com.keyshop.shop.channel.bo.*;
import com.keyshop.shop.channel.manager.ChannelManager;
import com.keyshop.shop.channel.model.*;
import com.keyshop.shop.channel.util.ChannelConst;
import java.io.File;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;
import org.apache.struts.upload.FormFile;

// Referenced classes of package com.keyshop.shop.channel.controller:
//            ChannelConfigForm

public class ChannelConfigAction extends PubAction
{

    public ChannelConfigAction()
    {
    }

    public void initClassName()
    {
        boClass = "com.keyshop.shop.channel.bo.ChannelBO";
    }


    public ActionForward performEditccconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)form;
        cform.setPageType("edit");
        String configId = request.getParameter("channelCc.configId");
        String channelId = request.getParameter("channelCc.channelId");
        if(StringUtil.isEmpty(configId))
        {
            generalError(request, new Exception(getClass().getName() + "no_config_id"));
            return mapping.findForward("fail");
        }
        try
        {
            ChannelContentBO bo = new ChannelContentBO();
            List list = bo.list("from ChannelContent as cc where cc.configId='" + configId + "' and cc.channelId='" + channelId + "'");
            if(list == null || list.size() <= 0)
                performAddccconfig(mapping, form, request, response);
            else
                cform.setChannelContent((ChannelContent)list.iterator().next());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        return mapping.findForward("addCcConfig");
    }

    public ActionForward performAddadconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        try
        {
            ChannelConfigForm cform = (ChannelConfigForm)form;
            Channel channel = (Channel)cform.getBean();
            cform.setPageType("add");
            String contentType = request.getParameter("contentType");
            ChannelAd ad = cform.getChannelAd();
            ad.clear();
            String channelId = request.getParameter("channelAd.channelId");
            String pageViewKey = request.getParameter("channelAd.pageSearchKey");
            String pagePosition = request.getParameter("channelAd.position");
            String configId = request.getParameter("channelAd.configId");
            if(StringUtil.isEmpty(pagePosition))
                pagePosition = "0";
            ad.setChannelId(channelId);
            ad.setPageSearchKey(pageViewKey);
            ad.setPosition(Integer.parseInt(pagePosition));
            ad.setConfigId(configId);
            return mapping.findForward("addAdConfig");
        }
        catch(Exception e)
        {
            generalError(request, e);
            e.printStackTrace();
            return mapping.findForward("fail");
        }
    }

    public ActionForward performEditadconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)form;
        cform.setPageType("edit");
        String configId = request.getParameter("channelAd.configId");
        String channelId = request.getParameter("channelAd.channelId");
        if(StringUtil.isEmpty(configId))
        {
            generalError(request, new Exception(getClass().getName() + "no_config_id"));
            return mapping.findForward("fail");
        }
        try
        {
            ChannelAdBO bo = new ChannelAdBO();
            List list = bo.list("from ChannelAd as ad where ad.configId='" + configId + "' and ad.channelId='" + channelId + "'");
            if(list == null || list.size() <= 0)
                performAddadconfig(mapping, form, request, response);
            else
                cform.setChannelAd((ChannelAd)list.iterator().next());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        return mapping.findForward("addAdConfig");
    }

    public ActionForward performAddpcconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        try
        {
            ChannelConfigForm cform = (ChannelConfigForm)form;
            cform.setPageType("add");
            String contentType = request.getParameter("contentType");
            ChannelProductCategory pc = cform.getChannelPc();
            pc.clear();
            String channelId = request.getParameter("channelPc.channelId");
            String pageViewKey = request.getParameter("channelPc.pageSearchKey");
            String pagePosition = request.getParameter("channelPc.position");
          
            pc.setConfigId(configId);
            if(!StringUtil.isEmpty(rows))
                pc.setRows(Integer.parseInt(rows));
            return mapping.findForward("addPcConfig");
        }
        catch(Exception e)
        {
            generalError(request, e);
            e.printStackTrace();
            return mapping.findForward("fail");
        }
    }

    public ActionForward performEditpcconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        try
        {
            ChannelConfigForm cform = (ChannelConfigForm)form;
            cform.setPageType("edit");
            String configId = request.getParameter("channelPc.configId");
            String channelId = request.getParameter("channelPc.channelId");
            if(StringUtil.isEmpty(configId))
            {
                generalError(request, new Exception(getClass().getName() + "no_config_id"));
                return mapping.findForward("fail");
            }
     
        }
        catch(Exception e)
        {
            generalError(request, e);
            e.printStackTrace();
            return mapping.findForward("fail");
        }
        return mapping.findForward("addPcConfig");
    }

    public ActionForward performSavepcconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)form;
        updateImage();
        ChannelProductCategory pc = cform.getChannelPc();
        try
        {
            ChannelProductCategoryBO bo = new ChannelProductCategoryBO();
            bo.addBean(pc);
            ChannelManager.channelPcConfigMap.put(pc.getChannelId() + pc.getPageSearchKey() + pc.getPosition(), pc.copy());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        String channelId = pc.getChannelId();
        try
        {
            Channel channel = ChannelManager.getChannel(channelId);
            updateEnableStatus(channel);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        request.setAttribute("save_success", "true");
        return mapping.findForward("addPcConfig");
    }

    private boolean updateCCImage()
    {
        ChannelConfigForm channelForm = (ChannelConfigForm)thisform;
        try
        {
            if(channelForm.getPicData() == null || channelForm.getPicData().getFileData().length <= 0)
                return true;
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            return false;
        }
        shopResource = ResourceBundle.getBundle("resources.shopapplication", new Locale("", ""));
        String fileRoot = shopResource.getString(ChannelConst.ADFILE_PATH_ROOT);
        if(channelForm.getPicData() != null && channelForm.getPicData().getFileSize() > ImageUtil.maxSize)
        {
            super.generalError(httpRequest, new Exception("image_size_too_long"));
            return false;
        }
        if(StringUtil.isEmpty(fileRoot))
        {
            super.generalError(httpRequest, new Exception());
            return false;
        }
        ChannelContent cc = channelForm.getChannelContent();
        String contentType = channelForm.getPicData().getContentType();
        String root = httpRequest.getRealPath(fileRoot + File.separator + "img");
        File rootDirectory = new File(root);
        if(!rootDirectory.exists() || !rootDirectory.isDirectory())
            rootDirectory.mkdirs();
        if(channelForm.getPicData() != null && channelForm.getPicData().getFileSize() > 0)
        {
            String fileName = FileUtil.updateImageFile(root, cc.getNavImage(), channelForm.getPicData());
            cc.setNavImage(fileRoot + File.separator + "img" + File.separator + fileName);
        }
        return true;
    }

    private boolean updateImage()
    {
        ChannelConfigForm channelForm = (ChannelConfigForm)thisform;
        try
        {
            if(channelForm.getPicData() == null || channelForm.getPicData().getFileData().length <= 0)
                return true;
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            return false;
        }
        shopResource = ResourceBundle.getBundle("resources.shopapplication", new Locale("", ""));
        String fileRoot = shopResource.getString(ChannelConst.ADFILE_PATH_ROOT);
        if(channelForm.getPicData() != null && channelForm.getPicData().getFileSize() > ImageUtil.maxSize)
        {
            super.generalError(httpRequest, new Exception("image_size_too_long"));
            return false;
        }
        if(StringUtil.isEmpty(fileRoot))
        {
            super.generalError(httpRequest, new Exception());
            return false;
        }
        ChannelProductCategory pc = channelForm.getChannelPc();
        String contentType = channelForm.getPicData().getContentType();
        String root = httpRequest.getRealPath(fileRoot + File.separator + "img");
        File rootDirectory = new File(root);
        if(!rootDirectory.exists() || !rootDirectory.isDirectory())
            rootDirectory.mkdirs();
        if(channelForm.getPicData() != null && channelForm.getPicData().getFileSize() > 0)
        {
            String fileName = FileUtil.updateImageFile(root, pc.getNavImage(), channelForm.getPicData());
            pc.setNavImage(fileRoot + File.separator + "img" + File.separator + fileName);
        }
        return true;
    }

    public ActionForward performUpdatepcconfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        ChannelConfigForm cform = (ChannelConfigForm)form;
        updateImage();
        ChannelProductCategory pc = cform.getChannelPc();
        try
        {
            ChannelProductCategoryBO bo = new ChannelProductCategoryBO();
            bo.updateBean(pc);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }

⌨️ 快捷键说明

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