基于javaweb+mysql的ssm二手汽车商城管理系统(java+jsp+bootstrap+ssm+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM二手汽车商城管理系统(java+jsp+bootstrap+ssm+mysql)
项目介绍
本项目共分为管理员、用户、店员三种角色: 管理员角色包含以下功能: 管理员登录,在售车辆管理,品牌管理,品牌分类管理,推荐车辆,订单管理,销量统计等功能。
用户角色包含以下功能: 用户登录,用户角色首页,购物商城,查看购物车,订单管理,个人信息修改,关于我们等功能。
店员角色包含以下功能: 添加删除修改二手车,订单管理,销量统计,个人信息修改等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7/8.0版本均可; 6.是否Maven项目:否;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+JavaScript+jQuery+BootStrap
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中DB.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
@Autowired
private CarService carService;
@Autowired
private ShopCartService shopCartService;
@Autowired
private BrandService brandService;
//提交订单页面
@RequestMapping("/addOrderInit")
public String addOrderInit(ShopCart shopCart, Map<String, Object> map,HttpSession session){
Login login = (Login) session.getAttribute("loginSession");
if(login == null){
return "redirect:/loginInitAction";
}else if( !login.getLogin_permission().equals("user")){
return "redirect:/loginInitAction";
}
Car car = carService.queryOnlineCarById(shopCart.getShopCart_car_id()).get(0);
Person preson = personService.queryPersonById(shopCart.getShopCart_person_id());
map.put("personInfo", preson);
map.put("carInfo", car);
//从购物车付款,成功后删除购物车中的记录!!!
if(shopCart.getShopCart_id() != null){
shopCartService.deleteById(shopCart.getShopCart_id());
}
return "user/order/order_add";
}
//下单(生成订单,未支付,跳转到支付页面)
@RequestMapping("/addOrder")
public String addOrder(Order order, Map<String, Object> map){
String id = orderService.addOrder(order);
map.put("order_id", id);
return "user/order/order_pay";
}
//跳转到支付页面(用于待付款列表的使用)
@RequestMapping("/orderToPay")
public String orderToPay(String order_id, Map<String, Object> map){
map.put("order_id", order_id);
return "user/order/order_pay";
}
//用户取消订单(删除!)
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "all");
map.put("notReceiveOrder", orderList);
return "admin/orderManage/order_notReceive";
}
//根据id查询为收货订单
@RequestMapping("/queryNotReceiveById")
public String queryNotReceiveById(Map<String, Object> map, String order_id, String currentpage){
List<Order> orderList = orderService.querySendOrderById(order_id);
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("notReceiveOrder", orderList);
map.put("queryString", order_id);
return "admin/orderManage/order_notReceive";
}
//历史订单列表
@RequestMapping("/orderHistoryList")
public String orderHistoryList(Map<String, Object> map, String currentpage){
List<Order> orderList = orderService.queryAllReceiveOrder();
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "all");
map.put("HistoryOrder", orderList);
return "admin/orderManage/order_history";
}
//根据id查询历史订单
public String orderDetails(Map<String, Object> map, String order_id){
Order order = orderService.queryOrderById(order_id).get(0);
map.put("detailsOrder", order);
return "admin/orderManage/order_details";
}
//根据id查询未发货订单
@RequestMapping("/queryNotSendById")
public String queryNotSendById(Map<String, Object> map, String order_id, String currentpage){
List<Order> orderList = orderService.queryPayOrderById(order_id);
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("notSendOrder", orderList);
map.put("queryString", order_id);
return "admin/orderManage/order_notSend";
}
//已经发货未收货订单
@RequestMapping("/orderNotReceiveList")
public String orderNotReceiveList(Map<String, Object> map, String currentpage){
List<Order> orderList = orderService.queryAllSendOrder();
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "all");
map.put("notReceiveOrder", orderList);
return "admin/orderManage/order_notReceive";
}
//根据id查询为收货订单
@RequestMapping("/queryNotReceiveById")
public String queryNotReceiveById(Map<String, Object> map, String order_id, String currentpage){
List<Order> orderList = orderService.querySendOrderById(order_id);
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("brandList",brandService.queryAllBrand());
return "shop/carManage/car_update_downShelf";
}
//保存修改后的下架汽车
@RequestMapping(value="/saveDownShelfCar", method=RequestMethod.POST)
public String saveDownShelfCar(@RequestParam("imgSrc")MultipartFile mf, Map<String, Object> map, Car car) throws IOException{
if(mf.getSize() != 0){
InputStream is = mf.getInputStream();
File target = new File(Constants.IMAGEPATH + mf.getOriginalFilename());
OutputStream os = null;
try{
os = new FileOutputStream(target, true);
int templeng = 0;
byte[] tempbyte = new byte[4096];
while((templeng = is.read(tempbyte)) != -1){
os.write(tempbyte, 0, templeng);
os.flush();
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
is.close();
os.close();
}catch (IOException e) {
e.printStackTrace();
}
}
File deleteFile = new File(Constants.IMAGEPATH + car.getCar_img());
if (deleteFile.exists() && !car.getCar_img().equals("demo.jpg")){
//deleteFile.delete();
}
car.setCar_img(mf.getOriginalFilename());
}
carService.saveCar(car);
return "redirect:/shop/queryAllDownShelfCar";
}
//根据编号查询下架车辆信息
@RequestMapping("/queryDownShelfCarById")
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > onlineCarList.size() ? onlineCarList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
onlineCarList = onlineCarList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("carOnlineList", onlineCarList);
map.put("queryString", car_id);
return "shop/carManage/car_online_list";
}
//添加车辆初始化界面
@RequestMapping("/addCarInit")
public String addCarInit(Map<String, Object> map){
map.put("BrandList", brandService.queryAllBrand());
return "shop/carManage/car_add";
}
//添加车辆
@RequestMapping(value="/addCar", method=RequestMethod.POST)
public String addCar(@RequestParam("imgSrc")MultipartFile mf, Car car) throws IOException{
if(mf.getSize() != 0){ //上传的图片不为空
InputStream is = mf.getInputStream();
File target = new File(Constants.IMAGEPATH + mf.getOriginalFilename());
OutputStream os = null;
try{
os = new FileOutputStream(target, true);
int templeng = 0;
byte[] tempbyte = new byte[4096];
while((templeng = is.read(tempbyte)) != -1){
os.write(tempbyte, 0, templeng);
os.flush();
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
is.close();
os.close();
}catch (IOException e) {
e.printStackTrace();
}
}
car.setCar_img(mf.getOriginalFilename());
}else{ //用户上传图片为空
car.setCar_img("demo.jpg");
}
public class ShopOrderManageAction {
@Autowired
private OrderService orderService;
@Autowired
private PageService pageService;
//未发货订单列表
@RequestMapping("/orderNotSendList")
public String orderNotSendList(Map<String, Object> map, HttpSession session,String currentpage){
Login login = (Login) session.getAttribute("shoploginSession");
if(login == null || !login.getLogin_permission().equals("shop")){
return "redirect:/loginInitAction";
}
List<Order> orderList = orderService.shopQueryAllPayOrder(login.getLogin_id());
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "all");
map.put("notSendOrder", orderList);
return "shop/orderManage/order_notSend";
}
//将订单发货,然后返回未发货订单列表
@RequestMapping("/sendOrderById")
public String sendOrderById(String order_id){
orderService.sendOrderById(order_id);
return "redirect:/shopOrderManage/orderNotSendList";
}
//订单信息详情
@RequestMapping("/orderDetails")
public String orderDetails(Map<String, Object> map, String order_id){
Order order = orderService.queryOrderById(order_id).get(0);
map.put("detailsOrder", order);
return "shop/orderManage/order_details";
}
//根据id查询未发货订单
int templeng = 0;
byte[] tempbyte = new byte[4096];
while((templeng = is.read(tempbyte)) != -1){
os.write(tempbyte, 0, templeng);
os.flush();
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
is.close();
os.close();
}catch (IOException e) {
e.printStackTrace();
}
}
File deleteFile = new File(Constants.IMAGEPATH + car.getCar_img());
if (deleteFile.exists() && !car.getCar_img().equals("demo.jpg")){
//deleteFile.delete();
}
car.setCar_img(mf.getOriginalFilename());
}
carService.saveCar(car);
return "redirect:/shop/queryAllOnlineCar";
}
//根据车辆将汽车下架
@RequestMapping("/carDownShelf")
public String carDownShelf(String car_id){
String operaDeleteId = carService.queryOnlineCarByIdOrName(car_id).get(0).getCar_shop_id();
carService.carDownShelf(car_id, operaDeleteId);
return "redirect:/shop/queryAllOnlineCar";
}
//下架车辆列表
@RequestMapping("/queryAllDownShelfCar")
public String queryAllDownShelfCar(Map<String, Object> map, HttpSession session, String currentpage){
Login login = (Login) session.getAttribute("shoploginSession");
if(login == null || !login.getLogin_permission().equals("shop")){
return "redirect:/loginInitAction";
}
@Controller
public class LoginAction {
@Autowired
private LoginService loginService;
@Autowired
private PersonService personService;
//登录初始化页面
@RequestMapping("/loginInitAction")
public String loginInitAction(){
return "login";
}
//注册
@RequestMapping("/register")
public String register(String passwd, String username, String tel, String login_permession, Map<String, Object> map, HttpSession session){
if(personService.textTelExist(tel)){
map.put("registerTelError", "对不起,您输入的手机号码已经被注册过了。");
return "login";
}
String newId = loginService.getNewId();
loginService.addLogin(passwd, newId, login_permession);
personService.addPerson(username, newId, tel);
Login loginInfo = loginService.getRegisterLoginEntity();
if(loginInfo.getLogin_permission().equals("shop")){
session.setAttribute("shoploginSession", loginInfo);
session.setAttribute("shoploginSession_name", username);
return "/shop/index";
}else{
session.setAttribute("loginSession", loginInfo);
}
//将订单发货,然后返回未发货订单列表
@RequestMapping("/sendOrderById")
public String sendOrderById(String order_id){
orderService.sendOrderById(order_id);
return "redirect:/adminOrderManage/orderNotSendList";
}
//订单信息详情
@RequestMapping("/orderDetails")
public String orderDetails(Map<String, Object> map, String order_id){
Order order = orderService.queryOrderById(order_id).get(0);
map.put("detailsOrder", order);
return "admin/orderManage/order_details";
}
//根据id查询未发货订单
@RequestMapping("/queryNotSendById")
public String queryNotSendById(Map<String, Object> map, String order_id, String currentpage){
List<Order> orderList = orderService.queryPayOrderById(order_id);
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("notSendOrder", orderList);
map.put("queryString", order_id);
return "admin/orderManage/order_notSend";
}
//已经发货未收货订单
@RequestMapping("/orderNotReceiveList")
public String orderNotReceiveList(Map<String, Object> map, String currentpage){
List<Order> orderList = orderService.queryAllSendOrder();
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "all");
map.put("notReceiveOrder", orderList);
return "admin/orderManage/order_notReceive";
}
//根据id查询为收货订单
@RequestMapping("/queryNotReceiveById")
public String queryNotReceiveById(Map<String, Object> map, String order_id, String currentpage){
List<Order> orderList = orderService.querySendOrderById(order_id);
//初始化用户更新页面
@RequestMapping("/updateInfoInit")
public String updateInfoInit(HttpSession session, Map<String, Object> map){
Login login = (Login) session.getAttribute("loginSession");
if(login == null){
return "redirect:/loginInitAction";
}else if( !login.getLogin_permission().equals("user")){
return "redirect:/loginInitAction";
}
Person person = personService.queryPersonById(login.getLogin_id());
map.put("updatePersonInfo", person);
return "user/userInfo/updateInfo";
}
//保存用户修改后的个人信息
@RequestMapping("/saveUpdatePersonInfo")
public String saveUpdatePersonInfo(Person person, Map<String, Object> map){
personService.saveUpdatePersonInfo(person);
return "redirect:/user/updateInfoInit";
}
//利用ajax确定修改后的电话号码没有被注册
@RequestMapping("/ajaxTextTelExist")
public void ajaxGetStu_name(HttpServletRequest request, HttpServletResponse response, String person_tel) throws UnsupportedEncodingException{
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
boolean boolTel = personService.textTelExist(person_tel);
String json = new Gson().toJson(boolTel);
try {
response.getWriter().print(json);
} catch (IOException e) {
e.printStackTrace();
}
}
//修改用户的密码
@RequestMapping("/changePassword")
public String changePassword(String oldPwd, String newPwd, Map<String, Object> map, HttpSession session){
Login login = (Login) session.getAttribute("loginSession");
if(login == null){
return "redirect:/loginInitAction";
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "all");
map.put("HistoryOrder", orderList);
return "admin/orderManage/order_history";
}
//根据id查询历史订单
@RequestMapping("/queryHistoryById")
public String queryHistoryById(Map<String, Object> map, String order_id, String currentpage){
List<Order> orderList = orderService.queryReceiveOrderById(order_id);
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("HistoryOrder", orderList);
map.put("queryString", order_id);
return "admin/orderManage/order_history";
}
//用户已经删除订单(回收站订单)
@RequestMapping("/orderDeleteList")
public String orderDeleteList(Map<String, Object> map, String currentpage){
List<Order> orderList = orderService.queryAllDeleteOrder();
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "all");
map.put("DeleteOrderList", orderList);
return "admin/orderManage/order_delete";
}
map.put("queryKind", "all");
map.put("carOnlineList", onlineCarList);
return "shop/carManage/car_online_list";
}
//根据id查询在售车辆
@RequestMapping("/queryOnlineCarById")
public String queryOnlineCarById(Map<String, Object> map, String car_id, String shop_id, String currentpage){
List<Car> onlineCarList = null;
if(car_id == null || car_id.equals("")){
onlineCarList = carService.shopQueryAllOnlineCar(shop_id);
}else{
onlineCarList = carService.shopQueryOnlineCarByIdOrName(car_id, shop_id);
}
Page page = pageService.pageToCar(onlineCarList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > onlineCarList.size() ? onlineCarList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
onlineCarList = onlineCarList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("carOnlineList", onlineCarList);
map.put("queryString", car_id);
return "shop/carManage/car_online_list";
}
//添加车辆初始化界面
@RequestMapping("/addCarInit")
public String addCarInit(Map<String, Object> map){
map.put("BrandList", brandService.queryAllBrand());
return "shop/carManage/car_add";
}
//添加车辆
@RequestMapping(value="/addCar", method=RequestMethod.POST)
public String addCar(@RequestParam("imgSrc")MultipartFile mf, Car car) throws IOException{
if(mf.getSize() != 0){ //上传的图片不为空
InputStream is = mf.getInputStream();
File target = new File(Constants.IMAGEPATH + mf.getOriginalFilename());
OutputStream os = null;
try{
os = new FileOutputStream(target, true);
int templeng = 0;
public String deleteById(String shopCart_id){
shopCartService.deleteById(shopCart_id);
return "redirect:/shopCart/shopCartList";
}
}
@Controller
@RequestMapping("/adminClassifyManage")
public class PriceManageAction {
@Autowired
private PriceService priceService;
//获取全部的分类价格(排序好的)
@RequestMapping("/getAllPrice")
public String getAllPrice(Map<String, Object> map){
map.put("PriceClassifyList", priceService.getAllPrice());
return "admin/classifyManage/classify_price";
}
//添加价格分类区间
@RequestMapping("/addPrice")
public String addPrice(int price_classify_num){
System.out.println("===========");
priceService.addPrice(price_classify_num);
return "redirect:/adminClassifyManage/getAllPrice";
}
//根据id删除某个价格区间
@RequestMapping("/deletePrice")
public String deletePrice(String price_classify_id){
public String queryAllOnlineCar(Map<String, Object> map, String currentpage){
List<Car> onlineCarList = carService.queryAllOnlineCar();
Page page = pageService.pageToCar(onlineCarList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > onlineCarList.size() ? onlineCarList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
onlineCarList = onlineCarList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "all");
map.put("carOnlineList", onlineCarList );
return "admin/carManage/car_online_list";
}
//根据id查询在售车辆
@RequestMapping("/queryOnlineCarById")
public String queryOnlineCarById(Map<String, Object> map, String car_id, String currentpage){
List<Car> onlineCarList = null;
if(car_id == null || car_id.equals("")){
onlineCarList = carService.queryAllOnlineCar();
}else{
onlineCarList = carService.queryOnlineCarByIdOrName(car_id);
}
Page page = pageService.pageToCar(onlineCarList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > onlineCarList.size() ? onlineCarList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
onlineCarList = onlineCarList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("carOnlineList", onlineCarList);
map.put("queryString", car_id);
return "admin/carManage/car_online_list";
}
// //根据id查询在售车辆
// @RequestMapping("/addCarInit")
// public String addCarInit(Map<String, Object> map){
// map.put("BrandList", brandService.queryAllBrand());
// return "admin/carManage/car_add";
// }
//
// //添加车辆
// @RequestMapping("/addCar")
// public String addCar(Car car){
// carService.addCar(car);
// return "redirect:/admin/queryAllOnlineCar";
// }
//查看单个车辆详情
@RequestMapping("/carDetail")
public String carDetails(Map<String, Object> map, String car_id){
List<Car> list = carService.queryOnlineCarById(car_id);
map.put("queryKind", "all");
map.put("DeleteOrderList", orderList);
return "admin/orderManage/order_delete";
}
//根据id查询回收站的订单
@RequestMapping("/queryDeleteById")
public String queryDeleteById(Map<String, Object> map, String order_id, String currentpage){
List<Order> orderList = orderService.queryDeleteOrderById(order_id);
Page page = pageService.pageToOrder(orderList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > orderList.size() ? orderList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
orderList = orderList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("queryKind", "idOrName");
map.put("DeleteOrderList", orderList);
map.put("queryString", order_id);
return "admin/orderManage/order_delete";
}
//根据id彻底删除回收站的订单
@RequestMapping("/orderDeleteById")
public String orderDeleteById(String order_id){
orderService.orderDeleteById(order_id);
return "redirect:/adminOrderManage/orderDeleteList";
}
}
@Autowired
private ShopCartService shopCartService;
@Autowired
private PageService pageService;
//导航栏的搜索框
@RequestMapping("/navQueryIdOrName")
public String navQueryIdOrName(Map<String, Object> map, String car_name){
List<Car> onlineCarList = carService.queryOnlineCarByIdOrName(car_name);
map.put("onlineCarList", onlineCarList);
map.put("brandList", brandService.queryBeQueryBrand());
map.put("priceList",priceService.getAllPrice());
map.put("recommandList", carService.queryAllRecommandCar());
return "user/shop/shopIndex";
}
//初始化商店界面
@RequestMapping("/shopInit")
public String shopInit(Map<String, Object> map, String currentpage){
List<Car> onlineCarList = carService.queryAllOnlineCar();
Page page = pageService.pageToCar(onlineCarList.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > onlineCarList.size() ? onlineCarList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
onlineCarList = onlineCarList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
map.put("page", page);
map.put("onlineCarList", onlineCarList);
map.put("brandList", brandService.queryBeQueryBrand());
map.put("priceList",priceService.getAllPrice());
map.put("recommandList", carService.queryAllRecommandCar());
return "user/shop/shopIndex";
}
//多添加查询商品
@RequestMapping("/queryCarByClassifys")
public String queryCarByClassifys(String brand_id, String price_low, String price_high, String time_start, String time_end, Map<String, Object> map){
if(time_start == null || time_start.equals("不限制")) time_start = "1000-01-01 00:00:01";
if(time_end == null || time_end.equals("不限制")) time_end = "5000-01-01 00:00:01";
ShopQuery shopQuery = new ShopQuery(Integer.parseInt(price_low), Integer.parseInt(price_high), brand_id, time_start, time_end);
@Controller
public class LoginAction {
@Autowired
private LoginService loginService;
@Autowired
private PersonService personService;
//登录初始化页面
@RequestMapping("/loginInitAction")
public String loginInitAction(){
return "login";
}
//注册
@RequestMapping("/register")
public String register(String passwd, String username, String tel, String login_permession, Map<String, Object> map, HttpSession session){
if(personService.textTelExist(tel)){
map.put("registerTelError", "对不起,您输入的手机号码已经被注册过了。");
return "login";
}
String newId = loginService.getNewId();
loginService.addLogin(passwd, newId, login_permession);
personService.addPerson(username, newId, tel);
Login loginInfo = loginService.getRegisterLoginEntity();
if(loginInfo.getLogin_permission().equals("shop")){
session.setAttribute("shoploginSession", loginInfo);
session.setAttribute("shoploginSession_name", username);
return "/shop/index";
}else{
if(mf.getSize() != 0){
InputStream is = mf.getInputStream();
File target = new File(Constants.IMAGEPATH + mf.getOriginalFilename());
OutputStream os = null;
try{
os = new FileOutputStream(target, true);
int templeng = 0;
byte[] tempbyte = new byte[4096];
while((templeng = is.read(tempbyte)) != -1){
os.write(tempbyte, 0, templeng);
os.flush();
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
is.close();
os.close();
}catch (IOException e) {
e.printStackTrace();
}
}
File deleteFile = new File(Constants.IMAGEPATH + car.getCar_img());
if (deleteFile.exists() && !car.getCar_img().equals("demo.jpg")){
//deleteFile.delete();
}
car.setCar_img(mf.getOriginalFilename());
}
carService.saveCar(car);
return "redirect:/admin/queryAllDownShelfCar";
}
//根据编号查询下架车辆信息
@RequestMapping("/queryDownShelfCarById")
public String queryDownShelfCarById(Map<String, Object> map, String car_id, String currentpage){
List<Car> list = null;
if(car_id == null || car_id.equals("")){
list = carService.queryAllDownShelfCar();
}else{
list = carService.queryDownShelfCarByIdOrName(car_id);
}
Page page = pageService.pageToCar(list.size(), currentpage);
int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > list.size() ? list.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();