基于javaweb+mysql的ssm茶叶售卖商场(java+ssm+jsp+jquery+mysql)(平台、卖家、买家)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM茶叶售卖商场(java+ssm+jsp+jquery+mysql)(平台、卖家、买家)
管理员(后台管理):
admin 123456
卖家
saler1 123456
买家
buyer1 123456
SSM的茶叶商城网站
#项目介绍
该系统主要分为前台和后台两大功能模块,共包含三个角色:卖家、买家和管理员。
具体的系统功能如下:
1.前台功能
前台首页、用户注册、用户登录、新闻公告、茶叶行情、查看茶叶、茶叶详情、加入购物车、加入收藏、购买茶叶、付款结算、添加评论、留言交流、个人中心、我的订单、我的收藏、意见反馈、发布茶叶、我的销售等功能。
2.后台功能
后台系统登陆、用户管理、管理员管理、网站内容管理、茶叶类型管理、茶叶信息管理、购买订单管理、用户评价管理、意见反馈管理、留言交流管理等功能。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
#环境需要
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等版本均可;
#技术栈
后台框架:Spring、SpringMVC、MyBatis
UI界面:JSP、jQuery
数据库:MySQL
public String createBbs() {
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
return "admin/addbbs";
}
// 添加数据
@RequestMapping("addBbs.action")
public String addBbs(Bbs bbs) {
this.bbsService.insertBbs(bbs);
return "redirect:/bbs/createBbs.action";
}
// 通过主键删除数据
@RequestMapping("deleteBbs.action")
public String deleteBbs(String id) {
this.bbsService.deleteBbs(id);
return "redirect:/bbs/getAllBbs.action";
}
// 批量删除数据
@RequestMapping("deleteBbsByIds.action")
public String deleteBbsByIds() {
String[] ids = this.getRequest().getParameterValues("bbsid");
for (String bbsid : ids) {
this.bbsService.deleteBbs(bbsid);
}
return "redirect:/bbs/getAllBbs.action";
}
// 更新数据
@RequestMapping("updateBbs.action")
public String updateBbs(Bbs bbs) {
this.bbsService.updateBbs(bbs);
return "redirect:/bbs/getAllBbs.action";
}
// 显示全部数据
@RequestMapping("getAllBbs.action")
public String getAllBbs(String number) {
List<Bbs> bbsList = this.bbsService.getAllBbs();
PageHelper.getPage(bbsList, "bbs", null, null, 10, number, this.getRequest(), null);
return "admin/listbbs";
}
// 按条件查询数据 (模糊查询)
@RequestMapping("queryBbsByCond.action")
public String queryBbsByCond(String cond, String name, String number) {
Bbs bbs = new Bbs();
if(cond != null){
if ("usersid".equals(cond)) {
bbs.setUsersid(name);
}
if ("title".equals(cond)) {
public String updateGoods(Goods goods) {
this.goodsService.updateGoods(goods);
return "redirect:/goods/getAllGoods.action";
}
// 显示全部数据
@RequestMapping("getAllGoods.action")
public String getAllGoods(String number) {
List<Goods> goodsList = this.goodsService.getAllGoods();
PageHelper.getPage(goodsList, "goods", null, null, 10, number, this.getRequest(), null);
return "admin/listgoods";
}
// 按条件查询数据 (模糊查询)
@RequestMapping("queryGoodsByCond.action")
public String queryGoodsByCond(String cond, String name, String number) {
Goods goods = new Goods();
if(cond != null){
if ("usersid".equals(cond)) {
goods.setUsersid(name);
}
if ("goodsname".equals(cond)) {
goods.setGoodsname(name);
}
if ("image".equals(cond)) {
goods.setImage(name);
}
if ("cateid".equals(cond)) {
goods.setCateid(name);
}
if ("price".equals(cond)) {
goods.setPrice(name);
}
if ("storage".equals(cond)) {
goods.setStorage(name);
}
if ("addtime".equals(cond)) {
goods.setAddtime(name);
}
if ("hits".equals(cond)) {
goods.setHits(name);
}
if ("sellnum".equals(cond)) {
goods.setSellnum(name);
}
if ("contents".equals(cond)) {
goods.setContents(name);
}
}
if ("image".equals(cond)) {
goods.setImage(name);
}
if ("cateid".equals(cond)) {
goods.setCateid(name);
}
if ("price".equals(cond)) {
goods.setPrice(name);
}
if ("storage".equals(cond)) {
goods.setStorage(name);
}
if ("addtime".equals(cond)) {
goods.setAddtime(name);
}
if ("hits".equals(cond)) {
goods.setHits(name);
}
if ("sellnum".equals(cond)) {
goods.setSellnum(name);
}
if ("contents".equals(cond)) {
goods.setContents(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.goodsService.getGoodsByLike(goods), "goods", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/querygoods";
}
// 按主键查询数据
@RequestMapping("getGoodsById.action")
public String getGoodsById(String id) {
// 管理员准备
@RequestMapping("index.action")
public String index() {
return "admin/index";
}
// 管理员登录 1 验证用户名是否存在 2 验证密码是否正确
@RequestMapping("login.action")
public String login() {
String username = this.getRequest().getParameter("username");
String password = this.getRequest().getParameter("password");
Admin adminEntity = new Admin();
adminEntity.setUsername(username);
List<Admin> adminlist = this.adminService.getAdminByCond(adminEntity);
if (adminlist.size() == 0) {
this.getRequest().setAttribute("message", "用户名不存在");
return "redirect:/admin/index.action";
} else {
Admin admin = adminlist.get(0);
if (password.equals(admin.getPassword())) {
this.getSession().setAttribute("adminid", admin.getAdminid());
this.getSession().setAttribute("adminname", admin.getUsername());
this.getSession().setAttribute("realname", admin.getRealname());
} else {
this.getRequest().setAttribute("message", "密码错误");
return "redirect:/admin/index.action";
}
}
return "admin/main";
}
// 管理员准备修改密码
@RequestMapping("prePwd.action")
public String prePwd() {
return "admin/editpwd";
}
// 修改密码
@RequestMapping("editpwd.action")
public String editpwd() {
String adminid = (String) this.getSession().getAttribute("adminid");
String password = this.getRequest().getParameter("password");
stars1++;
}
if ("2".equals(topic.getNum())) {
stars2++;
}
if ("3".equals(topic.getNum())) {
stars3++;
}
if ("4".equals(topic.getNum())) {
stars4++;
}
if ("5".equals(topic.getNum())) {
stars5++;
}
}
count.put(stars5);
count.put(stars4);
count.put(stars3);
count.put(stars2);
count.put(stars1);
JSONObject json = new JSONObject();
json.put("count", count.toString());
json.put("names", names.toString().replaceAll("\"", ""));
System.out.println(json.toString());
return json.toString();
}
}
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/banner" , produces = "text/plain;charset=utf-8")
public class BannerController extends BaseController {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
private BannerService bannerService;
// 准备添加数据
@RequestMapping("createBanner.action")
}
@RequestMapping("preTopic.action")
public String preTopic(String id) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin.action";
}
Orders orders = this.ordersService.getOrdersById(id);
this.getRequest().setAttribute("id", id);
this.getRequest().setAttribute("orders", orders);
return "users/addTopic";
}
@RequestMapping("addTopic.action")
public String addTopic(String id) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin.action";
}
Orders orders = this.ordersService.getOrdersById(id);
orders.setStatus("已评价");
this.ordersService.updateOrders(orders);
Topic topic = new Topic();
topic.setAddtime(VeDate.getStringDateShort());
topic.setUsersid(orders.getUsersid());
topic.setGoodsid(orders.getGoodsid());
topic.setOrdersid(orders.getOrdersid());
topic.setNum(this.getRequest().getParameter("num"));
topic.setContents(this.getRequest().getParameter("contents"));
topic.setOrdersid(id);
this.topicService.insertTopic(topic);
return "redirect:/index/showOrders.action";
}
}
public class PageHelper {
public static void getPage(List<?> list, String name, List<String> nameList, List<String> valueList, int pageSize, String number,
HttpServletRequest request, String method) {
buffer.append(" ");
if ((Integer.parseInt(number) + 1) == 1) {
buffer.append("上一页");
} else {
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
}
buffer.append(" ");
if (maxPage <= (Integer.parseInt(number) + 1)) {
buffer.append("下一页");
} else {
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
}
buffer.append(" ");
if (maxPage <= (Integer.parseInt(number) + 1)) {
buffer.append("尾页");
} else {
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
}
String html = buffer.toString();
request.setAttribute("html", html);
request.setAttribute(name + "List", objList);
}
public static void getUserPage(List<?> list, String name, String actionName, int pageSize, String number, HttpServletRequest request) {
StringBuffer buffer = new StringBuffer();
String path = "";
String action = actionName + ".action";
List<Object> objList = new ArrayList<Object>();
int pageNumber = list.size();
int maxPage = pageNumber;
if (maxPage % pageSize == 0) {
maxPage = maxPage / pageSize;
} else {
maxPage = maxPage / pageSize + 1;
}
if (number == null) {
number = "0";
}
int start = Integer.parseInt(number) * pageSize;
int over = (Integer.parseInt(number) + 1) * pageSize;
int count = pageNumber - over;
if (count <= 0) {
over = pageNumber;
}
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin.action";
}
Orders orders = this.ordersService.getOrdersById(id);
orders.setStatus("已评价");
this.ordersService.updateOrders(orders);
Topic topic = new Topic();
topic.setAddtime(VeDate.getStringDateShort());
topic.setUsersid(orders.getUsersid());
topic.setGoodsid(orders.getGoodsid());
topic.setOrdersid(orders.getOrdersid());
topic.setNum(this.getRequest().getParameter("num"));
topic.setContents(this.getRequest().getParameter("contents"));
topic.setOrdersid(id);
this.topicService.insertTopic(topic);
return "redirect:/index/showOrders.action";
}
}
public class PageHelper {
public static void getPage(List<?> list, String name, List<String> nameList, List<String> valueList, int pageSize, String number,
HttpServletRequest request, String method) {
StringBuffer buffer = new StringBuffer();
String name2 = name.substring(0, 1).toUpperCase() + name.substring(1);
String path = "";
String action = "getAll" + name2 + ".action";
if (method != null) {
action = "query" + name2 + "ByCond.action";
}
List<Object> objList = new ArrayList<Object>();
if (nameList != null && valueList != null) {
for (int i = 0; i < nameList.size(); i++) {
path += "&" + nameList.get(i) + "=" + valueList.get(i);
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin.action";
}
Orders orders = this.ordersService.getOrdersById(id);
this.getRequest().setAttribute("id", id);
this.getRequest().setAttribute("orders", orders);
return "users/addTopic";
}
@RequestMapping("addTopic.action")
public String addTopic(String id) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin.action";
}
Orders orders = this.ordersService.getOrdersById(id);
orders.setStatus("已评价");
this.ordersService.updateOrders(orders);
Topic topic = new Topic();
topic.setAddtime(VeDate.getStringDateShort());
topic.setUsersid(orders.getUsersid());
topic.setGoodsid(orders.getGoodsid());
topic.setOrdersid(orders.getOrdersid());
topic.setNum(this.getRequest().getParameter("num"));
topic.setContents(this.getRequest().getParameter("contents"));
topic.setOrdersid(id);
this.topicService.insertTopic(topic);
return "redirect:/index/showOrders.action";
}
}
public class PageHelper {
public static void getPage(List<?> list, String name, List<String> nameList, List<String> valueList, int pageSize, String number,
HttpServletRequest request, String method) {
StringBuffer buffer = new StringBuffer();
String name2 = name.substring(0, 1).toUpperCase() + name.substring(1);
String path = "";
String action = "getAll" + name2 + ".action";
if (method != null) {
action = "query" + name2 + "ByCond.action";
}
List<Object> objList = new ArrayList<Object>();
if (nameList != null && valueList != null) {
for (int i = 0; i < nameList.size(); i++) {
path += "&" + nameList.get(i) + "=" + valueList.get(i);
}
// 添加数据
@RequestMapping("addComplains.action")
public String addComplains(Complains complains) {
this.complainsService.insertComplains(complains);
return "redirect:/complains/createComplains.action";
}
// 通过主键删除数据
@RequestMapping("deleteComplains.action")
public String deleteComplains(String id) {
this.complainsService.deleteComplains(id);
return "redirect:/complains/getAllComplains.action";
}
// 批量删除数据
@RequestMapping("deleteComplainsByIds.action")
public String deleteComplainsByIds() {
String[] ids = this.getRequest().getParameterValues("complainsid");
for (String complainsid : ids) {
this.complainsService.deleteComplains(complainsid);
}
return "redirect:/complains/getAllComplains.action";
}
// 更新数据
@RequestMapping("updateComplains.action")
public String updateComplains(Complains complains) {
this.complainsService.updateComplains(complains);
return "redirect:/complains/getAllComplains.action";
}
// 更新状态
@RequestMapping("status.action")
public String status(String id) {
String status = "";
Complains complains = this.complainsService.getComplainsById(id);
if (status.equals(complains.getStatus())) {
status = "";
}
complains.setStatus(status);
// 准备添加数据
@RequestMapping("createTopic.action")
public String createTopic() {
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
List<Orders> ordersList = this.ordersService.getAllOrders();
this.getRequest().setAttribute("ordersList", ordersList);
List<Goods> goodsList = this.goodsService.getAllGoods();
this.getRequest().setAttribute("goodsList", goodsList);
return "admin/addtopic";
}
// 添加数据
@RequestMapping("addTopic.action")
public String addTopic(Topic topic) {
this.topicService.insertTopic(topic);
return "redirect:/topic/createTopic.action";
}
// 通过主键删除数据
@RequestMapping("deleteTopic.action")
public String deleteTopic(String id) {
this.topicService.deleteTopic(id);
return "redirect:/topic/getAllTopic.action";
}
// 批量删除数据
@RequestMapping("deleteTopicByIds.action")
public String deleteTopicByIds() {
String[] ids = this.getRequest().getParameterValues("topicid");
for (String topicid : ids) {
this.topicService.deleteTopic(topicid);
}
return "redirect:/topic/getAllTopic.action";
}
// 更新数据
@RequestMapping("updateTopic.action")
public String updateTopic(Topic topic) {
this.topicService.updateTopic(topic);
return "redirect:/topic/getAllTopic.action";
}
// 显示全部数据
@RequestMapping("getAllTopic.action")
}
if ("addtime".equals(cond)) {
goods.setAddtime(name);
}
if ("hits".equals(cond)) {
goods.setHits(name);
}
if ("sellnum".equals(cond)) {
goods.setSellnum(name);
}
if ("contents".equals(cond)) {
goods.setContents(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.goodsService.getGoodsByLike(goods), "goods", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/querygoods";
}
// 按主键查询数据
@RequestMapping("getGoodsById.action")
public String getGoodsById(String id) {
Goods goods = this.goodsService.getGoodsById(id);
this.getRequest().setAttribute("goods", goods);
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
List<Cate> cateList = this.cateService.getAllCate();
this.getRequest().setAttribute("cateList", cateList);
return "admin/editgoods";
}
}
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
private CateService cateService;
// 准备添加数据
@RequestMapping("createCate.action")
public String createCate() {
return "admin/addcate";
}
// 添加数据
@RequestMapping("addCate.action")
public String addCate(Cate cate) {
this.cateService.insertCate(cate);
return "redirect:/cate/createCate.action";
}
// 通过主键删除数据
@RequestMapping("deleteCate.action")
public String deleteCate(String id) {
this.cateService.deleteCate(id);
return "redirect:/cate/getAllCate.action";
}
// 批量删除数据
@RequestMapping("deleteCateByIds.action")
public String deleteCateByIds() {
String[] ids = this.getRequest().getParameterValues("cateid");
for (String cateid : ids) {
this.cateService.deleteCate(cateid);
}
return "redirect:/cate/getAllCate.action";
}
// 更新数据
@RequestMapping("updateCate.action")
public String updateCate(Cate cate) {
this.cateService.updateCate(cate);
return "redirect:/cate/getAllCate.action";
}
// 显示全部数据
@RequestMapping("getAllCate.action")
public String getAllCate(String number) {
List<Cate> cateList = this.cateService.getAllCate();
PageHelper.getPage(cateList, "cate", null, null, 10, number, this.getRequest(), null);
return "admin/listcate";
}
}
if ("num".equals(cond)) {
cart.setNum(name);
}
if ("addtime".equals(cond)) {
cart.setAddtime(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.cartService.getCartByLike(cart), "cart", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/querycart";
}
// 按主键查询数据
@RequestMapping("getCartById.action")
public String getCartById(String id) {
Cart cart = this.cartService.getCartById(id);
this.getRequest().setAttribute("cart", cart);
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
List<Goods> goodsList = this.goodsService.getAllGoods();
this.getRequest().setAttribute("goodsList", goodsList);
return "admin/editcart";
}
}
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin.action";
}
Orders orders = this.ordersService.getOrdersById(id);
this.getRequest().setAttribute("id", id);
this.getRequest().setAttribute("orders", orders);
return "users/addTopic";
}
@RequestMapping("addTopic.action")
public String addTopic(String id) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin.action";
}
Orders orders = this.ordersService.getOrdersById(id);
orders.setStatus("已评价");
this.ordersService.updateOrders(orders);
Topic topic = new Topic();
topic.setAddtime(VeDate.getStringDateShort());
topic.setUsersid(orders.getUsersid());
topic.setGoodsid(orders.getGoodsid());
topic.setOrdersid(orders.getOrdersid());
topic.setNum(this.getRequest().getParameter("num"));
topic.setContents(this.getRequest().getParameter("contents"));
topic.setOrdersid(id);
this.topicService.insertTopic(topic);
return "redirect:/index/showOrders.action";
}
}
public class PageHelper {
//定义为控制器
@Controller
// 设置路径
@RequestMapping("/index")
public class IndexController extends BaseController {
@Autowired
private UsersService usersService;
@Autowired
private BannerService bannerService;
@Autowired
private ArticleService articleService;
@Autowired
private CateService cateService;
@Autowired
private GoodsService goodsService;
@Autowired
private CartService cartService;
@Autowired
private FavService favService;
@Autowired
private OrdersService ordersService;
@Autowired
// 按条件查询数据 (模糊查询)
@RequestMapping("queryCartByCond.action")
public String queryCartByCond(String cond, String name, String number) {
Cart cart = new Cart();
if(cond != null){
if ("usersid".equals(cond)) {
cart.setUsersid(name);
}
if ("goodsid".equals(cond)) {
cart.setGoodsid(name);
}
if ("price".equals(cond)) {
cart.setPrice(name);
}
if ("num".equals(cond)) {
cart.setNum(name);
}
if ("addtime".equals(cond)) {
cart.setAddtime(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.cartService.getCartByLike(cart), "cart", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/querycart";
}
// 按主键查询数据
@RequestMapping("getCartById.action")
public String getCartById(String id) {
Cart cart = this.cartService.getCartById(id);
this.getRequest().setAttribute("cart", cart);
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
List<Goods> goodsList = this.goodsService.getAllGoods();
this.getRequest().setAttribute("goodsList", goodsList);
return "admin/editcart";
}
}
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/banner" , produces = "text/plain;charset=utf-8")
public class BannerController extends BaseController {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
private BannerService bannerService;
// 准备添加数据
@RequestMapping("createBanner.action")
public String createBanner() {
return "admin/addbanner";
}
// 添加数据
@RequestMapping("addBanner.action")
public String addBanner(Banner banner) {
banner.setAddtime(VeDate.getStringDateShort());
this.bannerService.insertBanner(banner);
return "redirect:/banner/createBanner.action";
}
// 通过主键删除数据
@RequestMapping("deleteBanner.action")
public String deleteBanner(String id) {
this.bannerService.deleteBanner(id);
return "redirect:/banner/getAllBanner.action";
}
// 批量删除数据
@RequestMapping("deleteBannerByIds.action")
public String deleteBannerByIds() {
String[] ids = this.getRequest().getParameterValues("bannerid");
for (String bannerid : ids) {
this.bannerService.deleteBanner(bannerid);
}
return "redirect:/banner/getAllBanner.action";
}
// 更新数据