这期内容当中小编将会给大家带来有关Java如何实现家政服务平台系统,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
一、项目简述
功能包括: 家政服务网站系统,用户注册,登录,分为家政人员,普 通用户,以及最高管理员,包括家政分类查询,展示,线 上预约服务,家政申请,评论,留言沟通・,联系家政服 务,家政人员的认证,职业认证,以及后台的维护等等功能。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + maven等等。
用户信息控制层:
//定义为控制器@Controller// 设置路径@RequestMapping(value = "/users", produces = "text/plain;charset=utf-8")public class UsersController extends BaseController {// 注入Service 由于标签的存在 所以不需要getter setter@Autowired@Resourceprivate 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");for (String usersid : ids) {this.usersService.deleteUsers(usersid);}return "redirect:/users/getAllUsers";} // 更新数据@RequestMapping("/updateUsers")public String updateUsers(Users users) {this.usersService.updateUsers(users);return "redirect:/users/getAllUsers";} // 显示全部数据@RequestMapping("/getAllUsers")public String getAllUsers(String number) {List<Users> usersList = this.usersService.getAllUsers();PageHelper.getPage(usersList, "users", null, null, 10, number, this.getRequest(), null);return "admin/listusers";} // 按条件查询数据 (模糊查询)@RequestMapping("/queryUsersByCond")public String queryUsersByCond(String cond, String name, String number) {Users users = new Users();if (cond != null) {if ("username".equals(cond)) {users.setUsername(name);}if ("password".equals(cond)) {users.setPassword(name);}if ("realname".equals(cond)) {users.setRealname(name);}if ("sex".equals(cond)) {users.setSex(name);}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;} }
标签增删改查:
//定义为控制器@Controller// 设置路径@RequestMapping(value = "/topic", produces = "text/plain;charset=utf-8")public class TopicController extends BaseController {// 注入Service 由于标签的存在 所以不需要getter setter@Autowired@Resourceprivate TopicService topicService;@Autowired@Resourceprivate UsersService usersService;@Autowired@Resourceprivate OrdersService ordersService;@Autowired@Resourceprivate GoodsService goodsService; // 准备添加数据@RequestMapping("/createTopic")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")public String addTopic(Topic topic) {topic.setUsersid("");topic.setOrdersid("");topic.setGoodsid("");topic.setNum("");topic.setAddtime(VeDate.getStringDateShort());topic.setStatus("");this.topicService.insertTopic(topic);return "redirect:/topic/createTopic";} // 通过主键删除数据@RequestMapping("/deleteTopic")public String deleteTopic(String id) {this.topicService.deleteTopic(id);return "redirect:/topic/getAllTopic";} // 批量删除数据@RequestMapping("/deleteTopicByIds")public String deleteTopicByIds() {String[] ids = this.getRequest().getParameterValues("topicid");for (String topicid : ids) {this.topicService.deleteTopic(topicid);}return "redirect:/topic/getAllTopic";} // 更新数据@RequestMapping("/updateTopic")public String updateTopic(Topic topic) {this.topicService.updateTopic(topic);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";} // 按主键查询数据@RequestMapping("/getTopicById")public String getTopicById(String id) {Topic topic = this.topicService.getTopicById(id);this.getRequest().setAttribute("topic", topic);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/edittopic";} public TopicService getTopicService() {return topicService;} public void setTopicService(TopicService topicService) {this.topicService = topicService;} }
订单控制层:
//定义为控制器@Controller// 设置路径@RequestMapping(value = "/orders", produces = "text/plain;charset=utf-8")public class OrdersController extends BaseController {// 注入Service 由于标签的存在 所以不需要getter setter@Autowired@Resourceprivate OrdersService ordersService;@Autowired@Resourceprivate UsersService usersService; // 准备添加数据@RequestMapping("/createOrders")public String createOrders() {List<Users> usersList = this.usersService.getAllUsers();this.getRequest().setAttribute("usersList", usersList);return "admin/addorders";} // 添加数据@RequestMapping("/addOrders")public String addOrders(Orders orders) {this.ordersService.insertOrders(orders);return "redirect:/orders/createOrders";} // 通过主键删除数据@RequestMapping("/deleteOrders")public String deleteOrders(String id) {this.ordersService.deleteOrders(id);return "redirect:/orders/getAllOrders";} // 批量删除数据@RequestMapping("/deleteOrdersByIds")public String deleteOrdersByIds() {String[] ids = this.getRequest().getParameterValues("ordersid");for (String ordersid : ids) {this.ordersService.deleteOrders(ordersid);}return "redirect:/orders/getAllOrders";} // 更新数据@RequestMapping("/updateOrders")public String updateOrders(Orders orders) {this.ordersService.updateOrders(orders);return "redirect:/orders/getAllOrders";} // 显示全部数据@RequestMapping("/getAllOrders")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")public String queryOrdersByCond(String cond, String name, String number) {Orders orders = new Orders();if (cond != null) {if ("ordercode".equals(cond)) {orders.setOrdercode(name);}if ("usersid".equals(cond)) {orders.setUsersid(name);}if ("total".equals(cond)) {orders.setTotal(name);}if ("addtime".equals(cond)) {orders.setAddtime(name);}if ("status".equals(cond)) {orders.setStatus(name);}if ("address".equals(cond)) {orders.setAddress(name);}if ("contact".equals(cond)) {orders.setContact(name);}if ("workdate".equals(cond)) {orders.setWorkdate(name);}if ("worktime".equals(cond)) {orders.setWorktime(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")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;} }
数据图表控制层:
//定义为控制器@Controller// 设置路径@RequestMapping(value = "/chart", produces = "text/plain;charset=utf-8")public class ChartController extends BaseController {@Autowired@Resourceprivate OrdersService ordersService;@Autowired@Resourceprivate CateService cateService;@Autowired@Resourceprivate GoodsService goodsService;@Autowired@Resourceprivate TopicService topicService; @RequestMapping("/chartline")@ResponseBodypublic String chartline() throws JSONException {String start = this.getRequest().getParameter("start");String end = this.getRequest().getParameter("end");long days = VeDate.getDays(end, start) + 1;JSONArray count = new JSONArray();JSONArray day = new JSONArray(); // 存放名称for (int i = 0; i < days; i++) {String nxtDay = VeDate.getNextDay(start, "" + i);double total = 0;Orders orders = new Orders();orders.setAddtime(nxtDay);List<Orders> list = this.ordersService.getOrdersByCond(orders);for (Orders b : list) {total += Double.parseDouble(b.getTotal());}count.put(total);day.put(nxtDay);}JSONObject json = new JSONObject();json.put("count", count.toString());json.put("days", day.toString().replaceAll("\"", ""));return json.toString();} @RequestMapping("/chartpie")@ResponseBodypublic String chartpie() throws JSONException {JSONArray count = new JSONArray();JSONArray name = new JSONArray(); // 存放名称List<Goods> goodsList = this.goodsService.getAllGoods();for (Goods goods : goodsList) {name.put(goods.getGoodsname());count.put(Integer.parseInt(goods.getSellnum()));}JSONObject json = new JSONObject();json.put("count", count.toString());json.put("names", name.toString().replaceAll("\"", ""));return json.toString();} @RequestMapping("/chartBar")@ResponseBodypublic 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("\"", ""));json.put("names", name.toString().replaceAll("\"", ""));return json.toString();}}
上述就是小编为大家分享的Java如何实现家政服务平台系统了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注编程网行业资讯频道。