Java项目:SSM场地预订管理系统

news2024/11/15 9:41:44

作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

本项目分为前后台,前台为普通用户登录,后台为管理员登录;

用户角色包含以下功能:

按分类查看场地,用户登录,查看网站公告,按分类查看器材,查看商品详情,加入购物车,提交订单,查看订单,修改个人信息等功能。

管理员角色包含以下功能:

管理员登录,管理员信息管理,用户信息管理,新闻公告信息管理,实体类型信息管理,场地信息管理,器材信息管理,评价信息管理等功能。

环境需要

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版本;

6.是否Maven项目:否;

技术栈

1. 后端:Spring+SpringMVC+Mybatis

2. 前端:JSP+CSS+JavaScript+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
用户账号/密码: user/123456

管理员账号/密码:admin/admin

运行截图

前台界面

后台界面

相关代码

OrdersAction

package com.action;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.entity.Orders;
import com.service.OrdersService;
import com.entity.Users;
import com.service.UsersService;
import com.util.PageHelper;
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/orders" , produces = "text/plain;charset=utf-8")
public class OrdersAction extends BaseAction {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
@Resource
private OrdersService ordersService;
@Autowired
@Resource
private UsersService usersService;

// 准备添加数据
@RequestMapping("createOrders.action")
public String createOrders() {
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
return "admin/addorders";
}
// 添加数据
@RequestMapping("addOrders.action")
public String addOrders(Orders orders) {
this.ordersService.insertOrders(orders);
return "redirect:/orders/createOrders.action";
}

// 通过主键删除数据
@RequestMapping("deleteOrders.action")
public String deleteOrders(String id) {
this.ordersService.deleteOrders(id);
return "redirect:/orders/getAllOrders.action";
}

// 批量删除数据
@RequestMapping("deleteOrdersByIds.action")
public String deleteOrdersByIds() {
String[] ids = this.getRequest().getParameterValues("ordersid");
for (String ordersid : ids) {
this.ordersService.deleteOrders(ordersid);
}
return "redirect:/orders/getAllOrders.action";
}

// 更新数据
@RequestMapping("updateOrders.action")
public String updateOrders(Orders orders) {
this.ordersService.updateOrders(orders);
return "redirect:/orders/getAllOrders.action";
}
// 显示全部数据
@RequestMapping("getAllOrders.action")
public String getAllOrders(String number) {
List<Orders> ordersList = this.ordersService.getAllOrders();
PageHelper.getPage(ordersList, "orders", null, null, 10, number, this.getRequest(), null);
return "admin/listorders";
}

// 按条件查询数据 (模糊查询)
@RequestMapping("queryOrdersByCond.action")
public String queryOrdersByCond(String cond, String name, String number) {
Orders orders = new Orders();
if(cond != null){
if ("ordercode".equals(cond)) {
orders.setOrdercode(name);
}
if ("username".equals(cond)) {
orders.setUsername(name);
}
if ("total".equals(cond)) {
orders.setTotal(name);
}
if ("status".equals(cond)) {
orders.setStatus(name);
}
if ("addtime".equals(cond)) {
orders.setAddtime(name);
}
}

List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.ordersService.getOrdersByLike(orders), "orders", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/queryorders";
}

// 按主键查询数据
@RequestMapping("getOrdersById.action")
public String getOrdersById(String id ) {
Orders orders = this.ordersService.getOrdersById(id);
this.getRequest().setAttribute("orders", orders);
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
return "admin/editorders";
}

public OrdersService getOrdersService() { return ordersService; }

public void setOrdersService(OrdersService ordersService) { this.ordersService = ordersService; }

}

JiancaiAction

package com.action;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.entity.Jiancai;
import com.service.JiancaiService;
import com.entity.Cate;
import com.service.CateService;
import com.util.PageHelper;

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/jiancai", produces = "text/plain;charset=utf-8")
public class JiancaiAction extends BaseAction {
	// 注入Service 由于标签的存在 所以不需要getter setter
	@Autowired
	@Resource
	private JiancaiService jiancaiService;
	@Autowired
	@Resource
	private CateService cateService;

	// 准备添加数据
	@RequestMapping("createJiancai.action")
	public String createJiancai() {
		List<Cate> cateList = this.cateService.getAllCate();
		this.getRequest().setAttribute("cateList", cateList);
		return "admin/addjiancai";
	}

	// 添加数据
	@RequestMapping("addJiancai.action")
	public String addJiancai(Jiancai jiancai) {
		jiancai.setHits("0");
		jiancai.setSellnum("0");
		this.jiancaiService.insertJiancai(jiancai);
		return "redirect:/jiancai/createJiancai.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteJiancai.action")
	public String deleteJiancai(String id) {
		this.jiancaiService.deleteJiancai(id);
		return "redirect:/jiancai/getAllJiancai.action";
	}

	// 批量删除数据
	@RequestMapping("deleteJiancaiByIds.action")
	public String deleteJiancaiByIds() {
		String[] ids = this.getRequest().getParameterValues("jiancaiid");
		for (String jiancaiid : ids) {
			this.jiancaiService.deleteJiancai(jiancaiid);
		}
		return "redirect:/jiancai/getAllJiancai.action";
	}

	// 更新数据
	@RequestMapping("updateJiancai.action")
	public String updateJiancai(Jiancai jiancai) {
		this.jiancaiService.updateJiancai(jiancai);
		return "redirect:/jiancai/getAllJiancai.action";
	}

	// 显示全部数据
	@RequestMapping("getAllJiancai.action")
	public String getAllJiancai(String number) {
		List<Jiancai> jiancaiList = this.jiancaiService.getAllJiancai();
		PageHelper.getPage(jiancaiList, "jiancai", null, null, 10, number, this.getRequest(), null);
		return "admin/listjiancai";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryJiancaiByCond.action")
	public String queryJiancaiByCond(String cond, String name, String number) {
		Jiancai jiancai = new Jiancai();
		if (cond != null) {
			if ("jiancainame".equals(cond)) {
				jiancai.setJiancainame(name);
			}
			if ("image".equals(cond)) {
				jiancai.setImage(name);
			}
			if ("cateid".equals(cond)) {
				jiancai.setCatename(name);
			}
			if ("price".equals(cond)) {
				jiancai.setPrice(name);
			}
			if ("recommend".equals(cond)) {
				jiancai.setRecommend(name);
			}
			if ("thestart".equals(cond)) {
				jiancai.setThestart(name);
			}
			if ("theend".equals(cond)) {
				jiancai.setTheend(name);
			}
			if ("hits".equals(cond)) {
				jiancai.setHits(name);
			}
			if ("sellnum".equals(cond)) {
				jiancai.setSellnum(name);
			}
			if ("contents".equals(cond)) {
				jiancai.setContents(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.jiancaiService.getJiancaiByLike(jiancai), "jiancai", nameList, valueList, 10, number, this.getRequest(), "query");
		name = null;
		cond = null;
		return "admin/queryjiancai";
	}

	// 按主键查询数据
	@RequestMapping("getJiancaiById.action")
	public String getJiancaiById(String id) {
		Jiancai jiancai = this.jiancaiService.getJiancaiById(id);
		this.getRequest().setAttribute("jiancai", jiancai);
		List<Cate> cateList = this.cateService.getAllCate();
		this.getRequest().setAttribute("cateList", cateList);
		return "admin/editjiancai";
	}

	public JiancaiService getJiancaiService() {
		return jiancaiService;
	}

	public void setJiancaiService(JiancaiService jiancaiService) {
		this.jiancaiService = jiancaiService;
	}

}

IndexAction

package com.action;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

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

import com.entity.Article;
import com.entity.Cart;
import com.entity.Cate;
import com.entity.City;
import com.entity.Details;
import com.entity.Jiancai;
import com.entity.Orders;
import com.entity.Topic;
import com.entity.Users;
import com.service.ArticleService;
import com.service.CartService;
import com.service.CateService;
import com.service.PeihuoService;
import com.service.CityService;
import com.service.DetailsService;
import com.service.JiancaiService;
import com.service.OrdersService;
import com.service.TopicService;
import com.service.UsersService;
import com.util.VeDate;

//定义为控制器
@Controller
// 设置路径
@RequestMapping("/index")
public class IndexAction extends BaseAction {

	@Autowired
	@Resource
	private UsersService usersService;
	@Autowired
	@Resource
	private ArticleService articleService;
	@Autowired
	@Resource
	private CateService cateService;
	@Autowired
	@Resource
	private CityService cityService;
	@Autowired
	@Resource
	private PeihuoService peihuoService;
	@Autowired
	@Resource
	private JiancaiService jiancaiService;
	@Autowired
	@Resource
	private CartService cartService;
	@Autowired
	@Resource
	private OrdersService ordersService;
	@Autowired
	@Resource
	private DetailsService detailsService;
	@Autowired
	@Resource
	private TopicService topicService;

	// 公共方法 提供公共查询数据
	private void front() {
		this.getRequest().setAttribute("title", "优品场地网-力作中国最大的场地网站");
		List<Cate> cateList = this.cateService.getAllCate();
		this.getRequest().setAttribute("cateList", cateList);
		List<Jiancai> hotList = this.jiancaiService.getJiancaiByHot();
		Collections.shuffle(hotList);
		this.getRequest().setAttribute("hotList", hotList);
	}

	// 首页显示
		@RequestMapping("index.action")
		public String index() {
			this.front();
			List<Cate> cateList = this.cateService.getCateFront();
			List<Cate> frontList = new ArrayList<Cate>();
			for (Cate cate : cateList) {
				List<Jiancai> flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
				cate.setFlimList(flimList);
				frontList.add(cate);
			}
			this.getRequest().setAttribute("frontList", frontList);
			return "users/index";
		}
		
		// 首页显示
		@RequestMapping("network.action")
		public String network() {
			this.front();
			List<Cate> cateList = this.cateService.getCateFront();
			List<Cate> frontList = new ArrayList<Cate>();
			for (Cate cate : cateList) {
				List<Jiancai> flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
				cate.setFlimList(flimList);
				frontList.add(cate);
			}
			this.getRequest().setAttribute("frontList", frontList);
			return "users/network";
		}

	// 公告
	@RequestMapping("article.action")
	public String article(String number) {
		this.front();
		List<Article> articleList = new ArrayList<Article>();
		List<Article> tempList = this.articleService.getAllArticle();
		int pageNumber = tempList.size();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Article x = tempList.get(i);
			articleList.add(x);
		}
		String html = "";
		StringBuffer buffer = new StringBuffer();
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"index/article.action?number=0\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"index/article.action?number=" + (maxPage - 1) + "\">尾页</a>");
		}
		html = buffer.toString();
		this.getRequest().setAttribute("html", html);
		this.getRequest().setAttribute("articleList", articleList);
		return "users/article";
	}

	// 阅读公告
	@RequestMapping("read.action")
	public String read(String id) {
		this.front();
		Article article = this.articleService.getArticleById(id);
		article.setHits("" + (Integer.parseInt(article.getHits()) + 1));
		this.articleService.updateArticle(article);
		this.getRequest().setAttribute("article", article);
		return "users/read";
	}

	// 准备登录
	@RequestMapping("preLogin.action")
	public String prelogin() {
		this.front();
		return "users/login";
	}

	// 用户登录
	@RequestMapping("login.action")
	public String login() {
		this.front();
		String username = this.getRequest().getParameter("username");
		String password = this.getRequest().getParameter("password");
		Users u = new Users();
		u.setUsername(username);
		List<Users> usersList = this.usersService.getUsersByCond(u);
		if (usersList.size() == 0) {
			this.getSession().setAttribute("message", "用户名不存在");
			return "redirect:/index/preLogin.action";
		} else {
			Users users = usersList.get(0);
			if (password.equals(users.getPassword())) {
				this.getSession().setAttribute("userid", users.getUsersid());
				this.getSession().setAttribute("username", users.getUsername());
				this.getSession().setAttribute("users", users);
				return "redirect:/index/index.action";
			} else {
				this.getSession().setAttribute("message", "密码错误");
				return "redirect:/index/preLogin.action";
			}
		}
	}

	// 准备注册
	@RequestMapping("preReg.action")
	public String preReg() {
		this.front();
		return "users/register";
	}

	// 用户注册
	@RequestMapping("register.action")
	public String register(Users users) {
		this.front();
		Users u = new Users();
		u.setUsername(users.getUsername());
		List<Users> usersList = this.usersService.getUsersByCond(u);
		if (usersList.size() == 0) {
			users.setRegdate(VeDate.getStringDateShort());
			this.usersService.insertUsers(users);
		} else {
			this.getSession().setAttribute("message", "用户名已存在");
			return "redirect:/index/preReg.action";
		}

		return "redirect:/index/preLogin.action";
	}

	// 退出登录
	@RequestMapping("exit.action")
	public String exit() {
		this.front();
		this.getSession().removeAttribute("userid");
		this.getSession().removeAttribute("username");
		this.getSession().removeAttribute("users");
		return "index";
	}

	// 准备修改密码
	@RequestMapping("prePwd.action")
	public String prePwd() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		return "users/editpwd";
	}

	// 修改密码
	@RequestMapping("editpwd.action")
	public String editpwd() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		String password = this.getRequest().getParameter("password");
		String repassword = this.getRequest().getParameter("repassword");
		Users users = this.usersService.getUsersById(userid);
		if (password.equals(users.getPassword())) {
			users.setPassword(repassword);
			this.usersService.updateUsers(users);
		} else {
			this.getSession().setAttribute("message", "旧密码错误");
			return "redirect:/index/prePwd.action";
		}
		return "redirect:/index/prePwd.action";
	}

	@RequestMapping("usercenter.action")
	public String usercenter() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		return "users/usercenter";
	}

	@RequestMapping("userinfo.action")
	public String userinfo() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		this.getSession().setAttribute("users", this.usersService.getUsersById(userid));
		return "users/userinfo";
	}

	@RequestMapping("personal.action")
	public String personal(Users users) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		this.usersService.updateUsers(users);
		return "redirect:/index/userinfo.action";
	}

	// 添加产品到购物车
	@RequestMapping("addcart.action")
	public String addcart() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Cart cart = new Cart();
		cart.setJiancaiid(getRequest().getParameter("goodsid"));
		cart.setNum(getRequest().getParameter("num"));
		cart.setPrice(getRequest().getParameter("price"));
		cart.setUsersid(userid);
		this.cartService.insertCart(cart);
		return "redirect:/index/cart.action";
	}

	// 查看购物车
	@RequestMapping("cart.action")
	public String cart() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Cart cart = new Cart();
		cart.setUsersid(userid);
		List<Cart> cartList = this.cartService.getCartByCond(cart);
		this.getRequest().setAttribute("cartList", cartList);
		return "users/cart";
	}

	// 删除购物车中的产品
	@RequestMapping("deletecart.action")
	public String deletecart(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		this.cartService.deleteCart(id);
		return "redirect:/index/cart.action";
	}

	// 准备结算
	@RequestMapping("preCheckout.action")
	public String preCheckout() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Cart cart = new Cart();
		cart.setUsersid(userid);
		List<Cart> cartList = this.cartService.getCartByCond(cart);
		if (cartList.size() == 0) {
			this.getRequest().setAttribute("message", "请选购场地");
			return "redirect:/index/cart.action";
		}
		List<City> cityList = this.cityService.getAllCity();
		this.getRequest().setAttribute("cityList", cityList);
		return "users/checkout";
	}

	// 结算
	@RequestMapping("checkout.action")
	public String checkout() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Cart cart1 = new Cart();
		cart1.setUsersid(userid);
		List<Cart> cartList = this.cartService.getCartByCond(cart1);
		if (cartList.size() == 0) {
			this.getRequest().setAttribute("message", "请选购场地");
			return "redirect:/index/cart.action";
		} else {
			// 获取一个1200-9999的随机数 防止同时提交
			String ordercode = "PD" + VeDate.getStringDatex();
			double total = 0;
			for (Cart cart : cartList) {
				Details details = new Details();
				details.setDetailsid(VeDate.getStringDatex() + (Math.random() * 9 + 1) * 1200);
				details.setJiancaiid(cart.getJiancaiid());
				details.setNum(cart.getNum());
				details.setOrdercode(ordercode);
				details.setPrice(cart.getPrice());
				details.setPeihuoid(this.getRequest().getParameter("peihuoid"));
				details.setCityid(this.getRequest().getParameter("cityid"));
				details.setViewdate(this.getRequest().getParameter("viewdate"));
				this.detailsService.insertDetails(details);
				Jiancai goods = this.jiancaiService.getJiancaiById(cart.getJiancaiid());
				goods.setSellnum("" + (Integer.parseInt(goods.getSellnum()) + Integer.parseInt(cart.getNum())));
				this.jiancaiService.updateJiancai(goods);
				total += Double.parseDouble(cart.getPrice()) * Double.parseDouble(cart.getNum());
				this.cartService.deleteCart(cart.getCartid());
			}
			Orders orders = new Orders();
			orders.setAddtime(VeDate.getStringDateShort());
			orders.setOrdercode(ordercode);
			orders.setStatus("未付款");
			orders.setTotal("" + total);
			orders.setUsersid(userid);
			this.ordersService.insertOrders(orders);
		}
		return "redirect:/index/showOrders.action";
	}

	// 查看订购
	@RequestMapping("showOrders.action")
	public String showOrders(String number) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Orders orders = new Orders();
		orders.setUsersid(userid);
		List<Orders> ordersList = new ArrayList<Orders>();
		List<Orders> tempList = this.ordersService.getOrdersByCond(orders);
		int pageNumber = tempList.size();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Orders o = tempList.get(i);
			ordersList.add(o);
		}
		String html = "";
		StringBuffer buffer = new StringBuffer();
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"index/showOrders.action?number=0\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"index/showOrders.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"index/showOrders.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"index/showOrders.action?number=" + (maxPage - 1) + "\">尾页</a>");
		}
		html = buffer.toString();
		this.getRequest().setAttribute("html", html);
		this.getRequest().setAttribute("ordersList", ordersList);
		return "users/orderlist";
	}

	// 准备付款
	@RequestMapping("prePay.action")
	public String prePay(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		this.getRequest().setAttribute("id", id);
		return "users/pay";
	}

	// 付款
	@RequestMapping("pay.action")
	public String pay(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
		orders.setStatus("已付款");
		this.ordersService.updateOrders(orders);
		return "redirect:/index/showOrders.action";
	}

	// 确认收货
	@RequestMapping("over.action")
	public String over(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
		orders.setStatus("已收货");
		this.ordersService.updateOrders(orders);
		return "redirect:/index/showOrders.action";
	}

	// 取消订单
	@RequestMapping("cancel.action")
	public String cancel(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
		orders.setStatus("已取消");
		this.ordersService.updateOrders(orders);
		return "redirect:/index/showOrders.action";
	}

	// 订单明细
	@RequestMapping("orderdetail.action")
	public String orderdetail(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		Details details = new Details();
		details.setOrdercode(id);
		List<Details> detailsList = this.detailsService.getDetailsByCond(details);
		this.getRequest().setAttribute("detailsList", detailsList);
		return "users/orderdetail";
	}

	// 按分类查询
	@RequestMapping("cate.action")
	public String cate(String id, String number) {
		this.front();
		Jiancai goods = new Jiancai();
		goods.setCateid(id);
		List<Jiancai> flimList = new ArrayList<Jiancai>();
		List<Jiancai> tempList = this.jiancaiService.getJiancaiByCond(goods);
		int pageNumber = tempList.size();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Jiancai x = tempList.get(i);
			flimList.add(x);
		}
		String html = "";
		StringBuffer buffer = new StringBuffer();
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"index/cate.action?number=0&id=\" + id+ \"\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"index/cate.action?number=" + (Integer.parseInt(number) - 1) + "&id=\" + id+ \"\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"index/cate.action?number=" + (Integer.parseInt(number) + 1) + "&id=\" + id+ \"\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"index/cate.action?number=" + (maxPage - 1) + "&id=\" + id+ \"\">尾页</a>");
		}
		html = buffer.toString();
		this.getRequest().setAttribute("html", html);
		this.getRequest().setAttribute("flimList", flimList);
		return "users/list";
	}

	// 推荐产品
		@RequestMapping("recommend.action")
		public String recommend(String number) {
			this.front();
			Jiancai goods = new Jiancai();
			goods.setRecommend("是");
			List<Jiancai> flimList = new ArrayList<Jiancai>();
			List<Jiancai> tempList = this.jiancaiService.getJiancaiByCond(goods);
			int pageNumber = tempList.size();
			int maxPage = pageNumber;
			if (maxPage % 12 == 0) {
				maxPage = maxPage / 12;
			} else {
				maxPage = maxPage / 12 + 1;
			}
			if (number == null) {
				number = "0";
			}
			int start = Integer.parseInt(number) * 12;
			int over = (Integer.parseInt(number) + 1) * 12;
			int count = pageNumber - over;
			if (count <= 0) {
				over = pageNumber;
			}
			for (int i = start; i < over; i++) {
				Jiancai x = tempList.get(i);
				flimList.add(x);
			}
			String html = "";
			StringBuffer buffer = new StringBuffer();
			buffer.append("&nbsp;&nbsp;共为");
			buffer.append(maxPage);
			buffer.append("页&nbsp; 共有");
			buffer.append(pageNumber);
			buffer.append("条&nbsp; 当前为第");
			buffer.append((Integer.parseInt(number) + 1));
			buffer.append("页 &nbsp;");
			if ((Integer.parseInt(number) + 1) == 1) {
				buffer.append("首页");
			} else {
				buffer.append("<a href=\"index/recommend.action?number=0\">首页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if ((Integer.parseInt(number) + 1) == 1) {
				buffer.append("上一页");
			} else {
				buffer.append("<a href=\"index/recommend.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if (maxPage <= (Integer.parseInt(number) + 1)) {
				buffer.append("下一页");
			} else {
				buffer.append("<a href=\"index/recommend.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if (maxPage <= (Integer.parseInt(number) + 1)) {
				buffer.append("尾页");
			} else {
				buffer.append("<a href=\"index/recommend.action?number=" + (maxPage - 1) + "\">尾页</a>");
			}
			html = buffer.toString();
			this.getRequest().setAttribute("html", html);
			this.getRequest().setAttribute("flimList", flimList);
			return "users/list";
		}
		
		// 推荐产品
		@RequestMapping("hot.action")
		public String getHost(String number) {
			this.front();
			Jiancai goods = new Jiancai();
			goods.setRecommend("是");
			List<Jiancai> flimList = new ArrayList<Jiancai>();
			List<Jiancai> tempList = this.jiancaiService.getJiancaiByHot();
			int pageNumber = tempList.size();
			int maxPage = pageNumber;
			if (maxPage % 12 == 0) {
				maxPage = maxPage / 12;
			} else {
				maxPage = maxPage / 12 + 1;
			}
			if (number == null) {
				number = "0";
			}
			int start = Integer.parseInt(number) * 12;
			int over = (Integer.parseInt(number) + 1) * 12;
			int count = pageNumber - over;
			if (count <= 0) {
				over = pageNumber;
			}
			for (int i = start; i < over; i++) {
				Jiancai x = tempList.get(i);
				flimList.add(x);
			}
			String html = "";
			StringBuffer buffer = new StringBuffer();
			buffer.append("&nbsp;&nbsp;共为");
			buffer.append(maxPage);
			buffer.append("页&nbsp; 共有");
			buffer.append(pageNumber);
			buffer.append("条&nbsp; 当前为第");
			buffer.append((Integer.parseInt(number) + 1));
			buffer.append("页 &nbsp;");
			if ((Integer.parseInt(number) + 1) == 1) {
				buffer.append("首页");
			} else {
				buffer.append("<a href=\"index/hot.action?number=0\">首页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if ((Integer.parseInt(number) + 1) == 1) {
				buffer.append("上一页");
			} else {
				buffer.append("<a href=\"index/hot.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if (maxPage <= (Integer.parseInt(number) + 1)) {
				buffer.append("下一页");
			} else {
				buffer.append("<a href=\"index/hot.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if (maxPage <= (Integer.parseInt(number) + 1)) {
				buffer.append("尾页");
			} else {
				buffer.append("<a href=\"index/hot.action?number=" + (maxPage - 1) + "\">尾页</a>");
			}
			html = buffer.toString();
			this.getRequest().setAttribute("html", html);
			this.getRequest().setAttribute("flimList", flimList);
			return "users/list";
		}

	// 全部产品
	@RequestMapping("all.action")
	public String all(String number) {
		this.front();
		List<Jiancai> flimList = new ArrayList<Jiancai>();
		List<Jiancai> tempList = this.jiancaiService.getAllJiancai();
		int pageNumber = tempList.size();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Jiancai x = tempList.get(i);
			flimList.add(x);
		}
		String html = "";
		StringBuffer buffer = new StringBuffer();
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"index/all.action?number=0\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"index/all.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"index/all.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"index/all.action?number=" + (maxPage - 1) + "\">尾页</a>");
		}
		html = buffer.toString();
		this.getRequest().setAttribute("html", html);
		this.getRequest().setAttribute("flimList", flimList);
		return "users/list";
	}

	// 查询场地
	@RequestMapping("query.action")
	public String query(String name) {
		this.front();
		Jiancai goods = new Jiancai();
		goods.setJiancainame(name);
		List<Jiancai> flimList = this.jiancaiService.getJiancaiByLike(goods);
		this.getRequest().setAttribute("flimList", flimList);
		return "users/list";
	}

	// 场地详情
	@RequestMapping("detail.action")
	public String detail(String id) {
		this.front();
		Jiancai goods = this.jiancaiService.getJiancaiById(id);
		goods.setHits("" + (Integer.parseInt(goods.getHits()) + 1));
		this.jiancaiService.updateJiancai(goods);
		this.getRequest().setAttribute("goods", goods);
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Topic topic = new Topic();
		topic.setJiancaiid(id);
		List<Topic> topicList = this.topicService.getTopicByCond(topic);
		this.getRequest().setAttribute("topicList", topicList);
		this.getRequest().setAttribute("tnum", topicList.size());
		return "users/detail";
	}

	@RequestMapping("addTopic.action")
	public String addTopic(Topic topic) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		topic.setAddtime(VeDate.getStringDateShort());
		topic.setContents(this.getRequest().getParameter("contents"));
		topic.setJiancaiid(this.getRequest().getParameter("goodsid"));
		topic.setNum(this.getRequest().getParameter("num"));
		topic.setUsersid(userid);
		this.topicService.insertTopic(topic);
		return "redirect:/index/detail.action?id=" + topic.getJiancaiid();
	}

}

如果也想学习本系统,下面领取。关注并回复:089ssm  

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/61660.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【车载开发系列】UDS诊断---通信控制($0x28)

【车载开发系列】UDS诊断—通信控制&#xff08;$0x28&#xff09; UDS诊断---通信控制&#xff08;$0x28&#xff09;【车载开发系列】UDS诊断---通信控制&#xff08;$0x28&#xff09;一.概念定义二.实现原理三.应用场景四.子功能五.报文格式1&#xff09;请求报文2&#xf…

自动导入指定文件夹内的文献到 Endnote 中

简介 最近正着手写一篇综述文章&#xff0c;来整体把握下自己研究领域的历史、方法、最新进展与趋势。由于需要对相关文献进行搜集、阅读和分类。庄小编使用 EndNote 来进行管理文献。 在使用较长时间后&#xff0c;整理了几个超级好用的小技巧。比如&#xff1a;自动导入指定…

pikachu靶场-upload-速通

upload-速通client checkMIME typegetimagesizeclient check 最简单的&#xff0c;先上传一张含有一句话木马的图片&#xff0c;抓包修改图片后缀为php&#xff0c;放包发送就行 访问并确认该上传文件是否以php形式解析 蚁剑直连&#xff1a; MIME type 后端php检查上传文…

基于MSER的高速公路交通标志提取matlab仿真

目录 1.算法描述 2.仿真效果预览 3.MATLAB核心程序 4.完整MATLAB 1.算法描述 自然场景下的文本检测是自然场景图像信息提取的基础,在车牌识别、实时翻译、图像检索等领域具有广泛的应用价值及研究意义。基于连通区域的方法是自然场景文本检测中最为常见的方法,其中最大稳定…

[附源码]Python计算机毕业设计SSM街舞公司管理系统(程序+LW)

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

Java Script 内置对象(三) --------- Array 对象

判断是否为数组有两种方式&#xff0c;instanceof 和 Array.isArray( 参数 )&#xff0c;两者判断方法均为如果是数组则返回 true&#xff0c;不是数组则返回 **false&#xff0c;**其中第二个方法为H5新增加的方法 var arr[]; var obj{}; console.log(arr instanceof Arra…

微服务入门案例

boot与cloud版本 springboot:提供了快速开发微服务的能力 springcloud提供了微服务治理的能力&#xff08;服务注册与发现、服务降级、限流、熔断、网关、负载均衡、配置中心...&#xff09;&#xff0c;为微服务开发提供了全家桶服务 springboot的版本查看地址&#xff1a;Spr…

云原生之Docker简介和环境准备

Docker简介一、主机环境二、Docker 安装三、Docker简介3.1、Docker解决的问题3.2、Docker技术边界3.3、Docker带来的改变3.4、Docker和虚拟机的区别3.5、Docker 架构图3.6、直观感受client请求server总结后言一、主机环境 &#xff08;1&#xff09;ubuntu-20.04.4-live-serve…

【torch.utils.data】 Dataset和Dataloader的解读和使用

文章目录torch.utils.data前言DatasetDataloader实践参考torch.utils.data 前言 Pytorch中的 torch.utils.data 提供了两个抽象类&#xff1a;Dataset 和 Dataloader。Dataset 允许你自定义自己的数据集&#xff0c;用来存储样本及其对应的标签。而 Dataloader 则是在 Datase…

LTspice XVII > Transformer 变压器仿真

目录 第①步设置 第②步设置 第③步设置 第④步设置 输出结果 最近在看“无线电基础电路实作修订版 [&#xff08;美&#xff09;西尔弗 著] 2014年版”这本书&#xff0c;打算好好修炼下无线电方面的基础知识&#xff0c;让自己更加牛逼一些&#xff0c;工作中偶尔可以装…

指标与标签的区别?

概述 在公司数据建设过程中&#xff0c;经常会使用和提到指标和标签&#xff0c;但是很多小伙伴对于两者的区别确不能讲清楚。实际上标签与指标一样&#xff0c;是理解数据的两种方式&#xff0c;在赋能业务上&#xff0c;两者同样重要。接下来将结合自身的理解&#xff0c;从…

Java项目:SSM共享汽车租赁平台

作者主页&#xff1a;源码空间站2022 简介&#xff1a;Java领域优质创作者、Java项目、学习资料、技术互助 文末获取源码 项目介绍 本项目分为前后台&#xff0c;前台为普通用户登录&#xff0c;后台为管理员登录&#xff1b; 管理员角色包含以下功能&#xff1a; 管理员登录…

ElementUI组件-日期时间控件设置禁用日期

ElementUI组件-日期时间控件禁用指定日期 主要属性 查看官网&#xff0c;可以看到有个叫做picker-options的组件属性&#xff0c;没错&#xff0c;就是借助他来完成禁用指定日期的操作&#xff0c;如下 该属性值传入的是一个对象&#xff0c;对于时间选择器、日期选择器、日…

[阶段4 企业开发进阶] 3. 消息队列--RabbitMQ

文章目录1 消息队列1.1 MQ的概念基本介绍使用原因MQ分类如何选择1.2 RabbitMQRabbitMQ核心工作原理安装教程1 消息队列 1.1 MQ的概念 基本介绍 MQ本质是个队列&#xff0c;FIFO 先入先出&#xff0c;只不过队列中存放的内容是 message 而已是一种跨进程的通信机制&#xff0…

[附源码]计算机毕业设计校刊投稿系统Springboot程序

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

Py之removebg:removebg的简介、安装、使用方法之详细攻略

Py之removebg&#xff1a;removebg的简介、安装、使用方法之详细攻略 目录 removebg的简介 1、官网注册获取APIKey removebg的安装 removebg的使用方法 1、直接调用并实现抠图 2、更多案例 removebg的简介 Remove Image Background&#xff0c;是一款不用PS就完成抠图的强…

每日挠头算法题(十五)螺旋矩阵II

“强大方能侠义” ------持续更新Blue Bridge杯入门系列算法实例-------- 如果你也喜欢Java和算法&#xff0c;欢迎订阅专栏共同学习交流&#xff01; 你的点赞、关注、评论、是我创作的动力&#xff01; -------希望我的文章对你有所帮助-------- 前言&#xff1a;最近可能…

【Python自学笔记】报错No module Named Wandb

【Python自学笔记】已经装了wandb&#xff0c;还报错No module Named Wandb 方法1.重启cmd和jupyter notebook 直接把窗口和cmd页面全关了&#xff0c;重新打开&#xff0c;再次运行安装和启动代码&#xff1a; !pip install wandbimport wandb wandb.init(project"你自…

【Matlab】一、解常微分方程ODE

文章目录求解常微分方程 ODE&#xff08;1&#xff09;求解解析解&#xff08;2&#xff09;求解数值解求解常微分方程 ODE ​ 在matlab中&#xff0c;我们可以求解常微分方程的解析解&#xff0c;和数值解&#xff0c;一般使用dsolve来求解常微分方程的解析解&#xff0c;使用…

jsp 上传文件及实体信息,ajax post 请求(formdata)报错400<======>前后端代码示例

Content-Type最常见的几种类型&#xff1a; 通常&#xff0c;没有声明&#xff0c;默认application/x-www-form-urlencoded application/x-www-form-urlencoded form表单默认的数据格式&#xff0c;提交的数据形式 key1val1&key2val2&#xff08;参数少&#xff09; mu…