基于javaweb+mysql的springboot家政服务网站系统设计和实现(java+springboot+ssm+mysql+jsp+maven)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot家政服务网站系统设计和实现(java+springboot+ssm+mysql+jsp+maven)
一、项目简述
本系统主要实现的功能有: 项目功能较多,包括用户的注册登录,家政0员务的查看, 分类,预订,以及支付,订单信息的查看,后台管理员的 人员管理,服务类别管理,订单分配,数据统计,家政维 护等等功能。
二、项目运行
1运行环境:
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持) 项目技术: Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven
buffer.append((Integer.parseInt(number) + 1));
buffer.append("页 ");
if ((Integer.parseInt(number) + 1) == 1) {
buffer.append("首页");
} else {
buffer.append("<a href=\"index/" + action + "?number=0" + path + "\">首页</a>");
}
buffer.append(" ");
if ((Integer.parseInt(number) + 1) == 1) {
buffer.append("上一页");
} else {
buffer.append("<a href=\"index/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
}
buffer.append(" ");
if (maxPage <= (Integer.parseInt(number) + 1)) {
buffer.append("下一页");
} else {
buffer.append("<a href=\"index/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
}
buffer.append(" ");
if (maxPage <= (Integer.parseInt(number) + 1)) {
buffer.append("尾页");
} else {
buffer.append("<a href=\"index/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
}
String html = buffer.toString();
request.setAttribute("html", html);
request.setAttribute(name + "List", objList);
}
}
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/admin", produces = "text/plain;charset=utf-8")
public class AdminController extends BaseController {
// 注入Service 由于标签的存在 所以不需要getter setter
if (!targetFile.exists()) {
targetFile.mkdirs();
}
// 保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
model.addAttribute("imageFileName", fileName);
return "saveimage";
}
@RequestMapping(value = "/files")
public String files(@RequestParam(value = "image", required = false) MultipartFile file, HttpServletRequest request, ModelMap model) {
String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/";
String fileName = file.getOriginalFilename();
int i = fileName.lastIndexOf(".");
String name = String.valueOf(VeDate.getStringDatex());
String type = fileName.substring(i + 1);
fileName = name + "." + type;
File targetFile = new File(path, fileName);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
// 保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
model.addAttribute("imageFileName", fileName);
return "savefile";
}
}
//package com.interceptor;
//
if ("birthday".equals(cond)) {
users.setBirthday(name);
}
if ("contact".equals(cond)) {
users.setContact(name);
}
if ("regdate".equals(cond)) {
users.setRegdate(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.usersService.getUsersByLike(users), "users", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/queryusers";
}
// 按主键查询数据
@RequestMapping("/getUsersById")
public String getUsersById(String id) {
Users users = this.usersService.getUsersById(id);
this.getRequest().setAttribute("users", users);
return "admin/editusers";
}
public UsersService getUsersService() {
return usersService;
}
public void setUsersService(UsersService usersService) {
this.usersService = usersService;
}
}
String userid = (String) this.getSession().getAttribute("userid");
this.getSession().setAttribute("users", this.usersService.getUsersById(userid));
return "users/userinfo";
}
@RequestMapping("/personal")
public String personal(Users users) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
this.usersService.updateUsers(users);
return "redirect:/index/userinfo";
}
// 添加产品到购物车
@RequestMapping("/addcart")
public String addcart() {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
String userid = (String) this.getSession().getAttribute("userid");
Users users=usersService.getUsersById(userid);
Goods goods=goodsService.find(getRequest().getParameter("goodsid"));
Cart cart = new Cart();
cart.setAddtime(VeDate.getStringDateShort());
cart.setGoodsid(getRequest().getParameter("goodsid"));
cart.setPrice(getRequest().getParameter("price"));
cart.setUsersid(userid);
cart.setImage(goods.getImage());
cart.setUsername(goods.getGoodsname());
cart.setUsername(users.getUsername());
this.cartService.insertCart(cart);
return "redirect:/index/cart";
}
// 查看购物车
@RequestMapping("/cart")
public String cart() {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
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";
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/users", produces = "text/plain;charset=utf-8")
public class UsersController extends BaseController {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
@Resource
private UsersService usersService;
// 准备添加数据
@RequestMapping("/createUsers")
public String createUsers() {
return "admin/addusers";
}
// 添加数据
@RequestMapping("/addUsers")
public String addUsers(Users users) {
this.usersService.insertUsers(users);
return "redirect:/users/createUsers";
}
// 通过主键删除数据
@RequestMapping("/deleteUsers")
public String deleteUsers(String id) {
this.usersService.deleteUsers(id);
return "redirect:/users/getAllUsers";
}
// 批量删除数据
@RequestMapping("/deleteUsersByIds")
public String deleteUsersByIds() {
String[] ids = this.getRequest().getParameterValues("usersid");
Object obj = list.get(i);
objList.add(obj);
}
buffer.append(" 共为");
buffer.append(maxPage);
buffer.append("页 共有");
buffer.append(pageNumber);
buffer.append("条 当前为第");
buffer.append((Integer.parseInt(number) + 1));
buffer.append("页 ");
if ((Integer.parseInt(number) + 1) == 1) {
buffer.append("首页");
} else {
buffer.append("<a href=\"index/" + action + "?number=0" + path + "\">首页</a>");
}
buffer.append(" ");
if ((Integer.parseInt(number) + 1) == 1) {
buffer.append("上一页");
} else {
buffer.append("<a href=\"index/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
}
buffer.append(" ");
if (maxPage <= (Integer.parseInt(number) + 1)) {
buffer.append("下一页");
} else {
buffer.append("<a href=\"index/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
}
buffer.append(" ");
if (maxPage <= (Integer.parseInt(number) + 1)) {
buffer.append("尾页");
} else {
buffer.append("<a href=\"index/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
}
String html = buffer.toString();
request.setAttribute("html", html);
request.setAttribute(name + "List", objList);
}
}
if ("jiguan".equals(cond)) {
employ.setJiguan(name);
}
if ("minzu".equals(cond)) {
employ.setMinzu(name);
}
if ("workdate".equals(cond)) {
employ.setWorkdate(name);
}
if ("contact".equals(cond)) {
employ.setContact(name);
}
if ("memo".equals(cond)) {
employ.setMemo(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.employService.getEmployByLike(employ), "employ", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/queryemploy";
}
// 按主键查询数据
@RequestMapping("/getEmployById")
public String getEmployById(String id) {
Employ employ = this.employService.getEmployById(id);
this.getRequest().setAttribute("employ", employ);
return "admin/editemploy";
}
public EmployService getEmployService() {
return employService;
}
public void setEmployService(EmployService employService) {
this.employService = employService;
}
}
model.addAttribute("imageFileName", fileName);
return "saveimage";
}
@RequestMapping(value = "/files")
public String files(@RequestParam(value = "image", required = false) MultipartFile file, HttpServletRequest request, ModelMap model) {
String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/";
String fileName = file.getOriginalFilename();
int i = fileName.lastIndexOf(".");
String name = String.valueOf(VeDate.getStringDatex());
String type = fileName.substring(i + 1);
fileName = name + "." + type;
File targetFile = new File(path, fileName);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
// 保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
model.addAttribute("imageFileName", fileName);
return "savefile";
}
}
//package com.interceptor;
//
//
//
//@Component
//public class LoginInterceptor implements HandlerInterceptor {
// @Autowired
// private UsersService usersService;
// @Override
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// HttpSession session = request.getSession();
// String userid= (String) session.getAttribute("userid");
}
html = buffer.toString();
this.getRequest().setAttribute("html", html);
this.getRequest().setAttribute("goodsList", goodsList);
return "users/list";
}
// 全部产品
@RequestMapping("/all")
public String all(String number) {
int pageSize = 10;
this.front();
List<Goods> goodsList = new ArrayList<Goods>();
List<Goods> tempList = this.goodsService.getAllGoods();
int pageNumber = tempList.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;
}
for (int i = start; i < over; i++) {
Goods x = tempList.get(i);
goodsList.add(x);
}
String html = "";
StringBuffer buffer = new StringBuffer();
buffer.append(" 共为");
buffer.append(maxPage);
buffer.append("页 共有");
buffer.append(pageNumber);
buffer.append("条 当前为第");
buffer.append((Integer.parseInt(number) + 1));
buffer.append("页 ");
if ((Integer.parseInt(number) + 1) == 1) {
buffer.append("首页");
} else {
buffer.append("<a href=\"index/all?number=0\">首页</a>");
}
buffer.append(" ");
JSONObject json = new JSONObject();
json.put("count", count.toString());
json.put("names", name.toString().replaceAll("\"", ""));
return json.toString();
}
@RequestMapping("/chartBar")
@ResponseBody
public String chartBar() throws JSONException {
JSONArray name = new JSONArray();
JSONArray count = new JSONArray();
List<Cate> cateList = this.cateService.getAllCate();
for (Cate cate : cateList) {
name.put(cate.getCatename());
int sum1 = 0;
int sum2 = 0;
int sum3 = 0;
int sum4 = 0;
int sum5 = 0;
Topic t = new Topic();
t.setCateid(cate.getCateid());
List<Topic> list = this.topicService.getTopicBar(t);
for (Topic x : list) {
if (Integer.parseInt(x.getNum()) == 1) {
sum1++;
}
if (Integer.parseInt(x.getNum()) == 2) {
sum2++;
}
if (Integer.parseInt(x.getNum()) == 3) {
sum3++;
}
if (Integer.parseInt(x.getNum()) == 4) {
sum4++;
}
if (Integer.parseInt(x.getNum()) == 5) {
sum5++;
}
}
String sum = "" + sum1 + ";" + sum2 + ";" + sum3 + ";" + sum4 + ";" + sum5;
System.out.println(sum);
count.put(sum);
}
JSONObject json = new JSONObject();
json.put("count", count.toString().replaceAll("\"", ""));
}
// 按条件查询数据 (模糊查询)
@RequestMapping("/queryAllotByCond")
public String queryAllotByCond(String cond, String name, String number) {
Allot allot = new Allot();
if (cond != null) {
if ("ordersid".equals(cond)) {
allot.setOrdersid(name);
}
if ("employid".equals(cond)) {
allot.setEmployid(name);
}
if ("addtime".equals(cond)) {
allot.setAddtime(name);
}
if ("status".equals(cond)) {
allot.setStatus(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.allotService.getAllotByLike(allot), "allot", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/queryallot";
}
// 按主键查询数据
@RequestMapping("/getAllotById")
public String getAllotById(String id) {
Allot allot = this.allotService.getAllotById(id);
this.getRequest().setAttribute("allot", allot);
List<Orders> ordersList = this.ordersService.getAllOrders();
this.getRequest().setAttribute("ordersList", ordersList);
List<Employ> employList = this.employService.getAllEmploy();
this.getRequest().setAttribute("employList", employList);
return "admin/editallot";
}
public AllotService getAllotService() {
return allotService;
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";
} 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";
} else {
this.getSession().setAttribute("message", "密码错误");
return "redirect:/index/preLogin";
}
}
}
// 准备注册
@RequestMapping("/preReg")
public String preReg() {
this.front();
return "users/register";
}
// 用户注册
@RequestMapping("/register")
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";
}
return "users/login";
}
// 退出登录
}
html = buffer.toString();
this.getRequest().setAttribute("html", html);
this.getRequest().setAttribute("ordersList", ordersList);
return "users/orderlist";
}
// 准备付款
@RequestMapping("/prePay")
public String prePay(String id) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
this.getRequest().setAttribute("id", id);
Orders order=ordersService.getOrdersById(id);
this.getRequest().setAttribute("order",order);
System.out.println(order);
System.out.println(order.getTotal()+"==========");
return "users/pay";
}
// 付款
@RequestMapping("/pay")
public String pay(String id) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
String oid=getRequest().getParameter("id");
Orders orders = this.ordersService.getOrdersById(oid);
orders.setStatus("已付款");
this.ordersService.updateOrders(orders);
return "redirect:/index/showOrders";
}
// 确认收货
@RequestMapping("/preTopic")
public String preTopic(String id) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
Items items = new Items();
items.setOrdercode(orders.getOrdercode());
List<Items> itemsList = this.itemsService.getItemsByCond(items);
this.getRequest().setAttribute("detailsList", itemsList);
this.getRequest().setAttribute("orders", orders);
return "users/addTopic";
}
@RequestMapping("/deleteEmployByIds")
public String deleteEmployByIds() {
String[] ids = this.getRequest().getParameterValues("employid");
for (String employid : ids) {
this.employService.deleteEmploy(employid);
}
return "redirect:/employ/getAllEmploy";
}
// 更新数据
@RequestMapping("/updateEmploy")
public String updateEmploy(Employ employ) {
this.employService.updateEmploy(employ);
return "redirect:/employ/getAllEmploy";
}
// 显示全部数据
@RequestMapping("/getAllEmploy")
public String getAllEmploy(String number) {
List<Employ> employList = this.employService.getAllEmploy();
PageHelper.getPage(employList, "employ", null, null, 10, number, this.getRequest(), null);
return "admin/listemploy";
}
// 按条件查询数据 (模糊查询)
@RequestMapping("/queryEmployByCond")
public String queryEmployByCond(String cond, String name, String number) {
Employ employ = new Employ();
if (cond != null) {
if ("realname".equals(cond)) {
employ.setRealname(name);
}
if ("sex".equals(cond)) {
employ.setSex(name);
}
if ("birthday".equals(cond)) {
employ.setBirthday(name);
}
if ("idcard".equals(cond)) {
employ.setIdcard(name);
}
if ("jiguan".equals(cond)) {
employ.setJiguan(name);
}
if ("minzu".equals(cond)) {
employ.setMinzu(name);
}
if ("workdate".equals(cond)) {
employ.setWorkdate(name);
}
//用户个人中心
@RequestMapping("/usercenter")
public String usercenter() {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
return "users/usercenter";
}
@RequestMapping("/userinfo")
public String userinfo() {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
String userid = (String) this.getSession().getAttribute("userid");
this.getSession().setAttribute("users", this.usersService.getUsersById(userid));
return "users/userinfo";
}
@RequestMapping("/personal")
public String personal(Users users) {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
this.usersService.updateUsers(users);
return "redirect:/index/userinfo";
}
// 添加产品到购物车
@RequestMapping("/addcart")
public String addcart() {
this.front();
if (this.getSession().getAttribute("userid") == null) {
return "redirect:/index/preLogin";
}
String userid = (String) this.getSession().getAttribute("userid");
private OrdersService ordersService;
@Autowired
@Resource
private EmployService employService;
// 准备添加数据
@RequestMapping("/createAllot")
public String createAllot() {
Orders orders = new Orders();
orders.setStatus("已付款");
List<Orders> ordersList = this.ordersService.getOrdersByCond(orders);
this.getRequest().setAttribute("ordersList", ordersList);
List<Employ> employList = this.employService.getAllEmploy();
this.getRequest().setAttribute("employList", employList);
return "admin/addallot";
}
// 添加数据
@RequestMapping("/addAllot")
public String addAllot(Allot allot) {
allot.setAddtime(VeDate.getStringDateShort());
allot.setStatus("进行中");
this.allotService.insertAllot(allot);
Orders orders = this.ordersService.getOrdersById(allot.getOrdersid());
orders.setStatus("进行中");
this.ordersService.updateOrders(orders);
return "redirect:/allot/createAllot";
}
// 通过主键删除数据
@RequestMapping("/deleteAllot")
public String deleteAllot(String id) {
this.allotService.deleteAllot(id);
return "redirect:/allot/getAllAllot";
}
// 批量删除数据
@RequestMapping("/deleteAllotByIds")
public String deleteAllotByIds() {
String[] ids = this.getRequest().getParameterValues("allotid");
for (String allotid : ids) {
this.allotService.deleteAllot(allotid);
}
return "redirect:/allot/getAllAllot";
}
return "redirect:/topic/getAllTopic";
}
// 显示全部数据
@RequestMapping("/getAllTopic")
public String getAllTopic(String number) {
List<Topic> topicList = this.topicService.getAllTopic();
PageHelper.getPage(topicList, "topic", null, null, 10, number, this.getRequest(), null);
return "admin/listtopic";
}
// 按条件查询数据 (模糊查询)
@RequestMapping("/queryTopicByCond")
public String queryTopicByCond(String cond, String name, String number) {
Topic topic = new Topic();
if (cond != null) {
if ("usersid".equals(cond)) {
topic.setUsersid(name);
}
if ("ordersid".equals(cond)) {
topic.setOrdersid(name);
}
if ("goodsid".equals(cond)) {
topic.setGoodsid(name);
}
if ("num".equals(cond)) {
topic.setNum(name);
}
if ("contents".equals(cond)) {
topic.setContents(name);
}
if ("addtime".equals(cond)) {
topic.setAddtime(name);
}
if ("status".equals(cond)) {
topic.setStatus(name);
}
if ("reps".equals(cond)) {
topic.setReps(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.topicService.getTopicByLike(topic), "topic", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/querytopic";
}
// 按主键查询数据