package controller;


import java.awt.image.BufferedImage;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Offer;
import model.Request;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import dao.PlatformDaoImp;
import service.PlatformService;
import utils.VerifyCode;

@Controller
public class PlatformController {

	Calendar c = java.util.Calendar.getInstance(); // yyyy年MM月dd日hh时mm分ss秒
	SimpleDateFormat f = new java.text.SimpleDateFormat("yyyy.MM.dd");

	static Logger log=Logger.getLogger(SellerManagementController.class);
	static{
		log.info("right");
	}
	 
	@Resource(name = "PlatformServiceImp")
	private PlatformService PlatformServiceImp;

	@RequestMapping("/removeExchange")
	public String removeExchange(HttpServletRequest req, String request_id, String user_from) {

		Boolean flag = PlatformServiceImp.removeExchange(request_id, user_from);
		System.out.println("flag: " + flag);
		return "index";
	}

	@RequestMapping("/declineExchange") 
	public String declineExchange(HttpServletRequest req, String request_id, String user_to) {

		Boolean flag = PlatformServiceImp.declineExchange(request_id, user_to);
		System.out.println("flag: " + flag);
		return "index";
	}
	
	@RequestMapping("/removeOffer")  
	public String removeOffer(HttpServletRequest req, String offer_id, String user_id) {

		Boolean flag = PlatformServiceImp.removeOffer(offer_id, user_id);
		System.out.println("flag: " + flag);
		return "index";
	}
	
	
	@RequestMapping("/exitTest")
	public String exit(HttpServletRequest req) {

		req.getSession().removeAttribute("user");

		return "index";
	}

	@RequestMapping("/verifyCodeTest")
	public void verifycode(HttpServletRequest request,
			HttpServletResponse response) throws IOException {

		VerifyCode vc = new VerifyCode();

		BufferedImage image = vc.getImage();// 获取一次性验证码图片

		// 该方法必须在getImage()方法之后来调用
		// System.out.println(vc.getText());//获取图片上的文本
		VerifyCode.output(image, response.getOutputStream());// 把图片写到指定流中

		// 把文本保存到session中，为验证做准备
		request.getSession().setAttribute("vCode", vc.getText());

	}
	
	
	 public List<Request> showLatestTransaction(Integer sellerFrom, Integer sellerTo){
		return new PlatformDaoImp().showLatestTransaction(sellerFrom, sellerTo);
	 }
	 
	 public List<Offer> searchExchange(Integer sellerFrom, Integer sellerTo, Integer pointsFrom, Integer pointsToMin){
		return new PlatformDaoImp().searchExcahnge(sellerFrom, sellerTo, pointsFrom, pointsToMin); 
	 }
	 
	 public List<Offer> showRecommendationList(Integer sellerFrom, Integer sellerTo, Integer pointsFrom, Integer pointsToMin){
		return new PlatformDaoImp().searchExcahnge(sellerFrom, sellerTo, pointsFrom, pointsToMin); 
	 }
}

@@ -2355,16 +2355,60 @@
 %0A%09%7D%0A%09%0A%09%0A
+%09 @RequestMapping(%22/showLatestTransaction%22)%0A
 %09 public
@@ -2444,23 +2444,45 @@
 saction(
-Integer
+HttpServletRequest req,String
  sellerF
@@ -2478,39 +2478,38 @@
 ing sellerFrom, 
-Integer
+String
  sellerTo)%7B%0A%09%09re
@@ -2502,34 +2502,128 @@
 ellerTo)%7B%0A%09%09
-return new
+int from = Integer.valueOf(sellerFrom);%0A%09%09int to = Integer.valueOf(sellerTo);%0A%09%09List%3CRequest%3E requests =
  PlatformDao
@@ -2619,24 +2619,26 @@
 Platform
-Dao
+Service
 Imp
-()
 .showLat
@@ -2656,29 +2656,184 @@
 ion(
-sellerFrom, sellerTo)
+from, to);%0A%09%09for(Request re : requests)%7B%0A%09%09%09System.out.println(re.getRid() + %22 %22 + re.getSellerFrom() + %22 %22 + re.getSellerTo()+ %22 %22 + re.getUpdateTime());%0A%09%09%7D%0A%09%09return requests
 ;%0A%09 

Update PlatformController.java