9月17日 微服务架构 周一

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/helloworld_1996/article/details/82750660
package com.hao.controller;

import java.util.List;
import java.util.Map;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hao.dto.Car;
import com.hao.service.ICarService;
import com.hao.util.ExcelUtils;

@Controller
public class CarController {

	@Autowired
	private ICarService iCarService;
	@RequestMapping("list")
	public String list(HttpServletRequest request){
		List<Map<String, Object>> cList = iCarService.findCarList();
		request.setAttribute("cList", cList);
		return "list";
	}
	@RequestMapping("toUpd")
	public String toUpd(Integer carid,HttpServletRequest request){
		Car c = iCarService.getCarById(carid);
		System.out.println(c);
		request.setAttribute("c", c);

		return "update";
	}
	@RequestMapping("toAdd")
	public String toAdd(){
		return "add";
	}
	@RequestMapping("update")
	public String update(Car car){
		iCarService.update(car);
		return "redirect:list.do";
	}
	@RequestMapping("add")
	public String add(Car car){
		iCarService.add(car);
		return "redirect:list.do";
	}
	@RequestMapping("del")
	public String del(Integer carid){
		iCarService.del(carid);
		return "redirect:list.do";
	}
	@RequestMapping("toExport")
	public void toExport(HttpServletResponse response){
		List<Car> cList = iCarService.exportList();
		String[] columnNames = {"编号","销售日期","车型","销售金额","销售员姓名","电话","销售员提成"};
		String[] columns = {"carid","cardate","cartype","carprice","salname","salphone","salup"};
		ExcelUtils.exportExcel(response, cList, columnNames, columns, "销售报表", "salTable");
	}
}

即使是聪明绝顶的人,也不可长期与蠢货厮混,否则又多了一票蠢货。
《素履之往》
——木心

猜你喜欢

转载自blog.csdn.net/helloworld_1996/article/details/82750660
今日推荐