package com.iamberry.wechat.handles.wx;

import java.io.IOException;

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

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.iamberry.wechat.tools.NameUtils;

@Controller
@RequestMapping("/wechat/activity")
public class LuckDrawWechatHandler {
	/**
	 * 跳转抽奖页面
	 * 2016年9月28日
	 * @param req
	 * @param res
	 */
	@RequestMapping("/go_luck_draw")
	public void toLuckDraw(HttpServletRequest req,HttpServletResponse res){
		String url = "/WEB-INF/views/wechat/zhuanpan.html";
		toPage(req, res, url);
	}
	
	/**
	 * 跳转中奖纪录页面
	 * 2016年9月28日
	 * @param req
	 * @param res
	 */
	@RequestMapping("/go_prize_log")
	public void toPrizeLog(HttpServletRequest req,HttpServletResponse res){
		String url = NameUtils.WECHAT_GO_PRIZE_LOG;
		toPage(req, res, url);
	}
	
	/**
	 * 分享抽奖页面
	 * 2016年9月29日
	 * @param req
	 * @param res
	 */
	@RequestMapping("/share_luck_draw")
	public void toShareLuckDraw(HttpServletRequest req,HttpServletResponse res){
		String url = NameUtils.WECHAT_GO_LUCK_DRAW;
		toPage(req, res, url);
	}
	/**
	 * 转发请求
	 * @param req
	 * @param res
	 * @param url
	 */
	private void toPage(HttpServletRequest req,HttpServletResponse res,String url){
		try {
			req.getRequestDispatcher(url).forward(req,res);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
