Package com.lgx8.gateway.servlet

Source Code of com.lgx8.gateway.servlet.GatewayHotScreen

package com.lgx8.gateway.servlet;

import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.lgx8.gateway.service.IGatewayService;
import com.lgx8.gateway.util.GatewayConstants;
import com.lgx8.gateway.vo.ProductVO;
import com.lgx8.management.entities.News;

import freemarker.template.Template;
import freemarker.template.TemplateException;

/**
* Servlet implementation class GatewayHotScreen
*/
public class GatewayHotScreen extends GatewayBaseServlet {
  private static final long serialVersionUID = 1L;

  /**
     * @see GatewayBaseServlet#GatewayBaseServlet()
     */
    public GatewayHotScreen() {
        super();
        // TODO Auto-generated constructor stub
    }

  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Map<Object, Object> root = new HashMap<Object, Object>();
    root.putAll(super.root);
   
    Template temp = getConfiguration().getTemplate("hotscreen.ftl");
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
   
    //热门商品
    List<ProductVO> productVOs1 = gatewayService.initGatewayInfo(GatewayConstants.CID_RMSP);
   
    if(productVOs1 != null && productVOs1.size() != 0)
    {
      root.put("productVOs1", productVOs1);
    }
   

    //热兑换
    List<ProductVO> productVOs2 = gatewayService.initGatewayInfo(GatewayConstants.CID_SZRTHB);
   
    if(productVOs2 != null && productVOs2.size() != 0)
    {
      root.put("productVOs2", productVOs2);
    }
   
    List<News> listNews1 = gatewayService.findByType("1");
   
    root.put("listNews1", listNews1);
   
    List<News> listNews2 = gatewayService.findByType("2");
   
    root.put("listNews2", listNews2);
   
    List<News> listNews3 = gatewayService.findByType("3");
   
    root.put("listNews3", listNews3);
   
    /* 将模板和数据模型合并 */
    Writer out = response.getWriter();
    try {
      temp.process(root, out);
    } catch (TemplateException e) {
      e.printStackTrace();
    }
    out.flush();
  }

}
TOP

Related Classes of com.lgx8.gateway.servlet.GatewayHotScreen

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.