当前位置:   article > 正文

SSM框架基于微信小程序的自习室预约系统的设计与实现_基于微信小程序自习室预约系统

基于微信小程序自习室预约系统

 博主介绍:✌在职Java研发工程师、专注于程序设计、源码分享、技术交流、专注于Java技术领域和毕业设计

项目名称

SSM框架基于微信小程序的自习室预约系统的设计与实现

视频演示

SSM框架基于微信小程序的自习室预约系统的设计与实现_哔哩哔哩_bilibili

系统介绍

随着高等教育不断大众化,招生规模迅速扩大,导致高校自习室资源很难有效的满足读者需求,自习室内大学生占座现象越来越普遍和严重。而自习室的座位资源往往受多种人为因素的影响与制约而得不到合理的分配与使用。

本系统采用 SSM和Uniapp整合来进行开发,系统能够保证数据的安全性,提高可移植性,能够满足用户学习要求。系统共分为管理员,学生两种角色,主要功能:登录注册,学生绑定信息成功后可以查看各个自习室的使用情况,并且对空闲自习室提出使用申请,申请经管理员审核通过后,该学生的小程序会生成一个二维码,个人信息维护;管理员可以查看各个自习室的空闲情况以及对学生提出的自习室试用申请进行审核,学生管理,自习室管理,申请管理等。

环境需要

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/ 登录

运行截图

 用户管理控制层:

  1. package com.houserss.controller;
  2. import javax.servlet.http.HttpSession;
  3. import org.apache.commons.lang3.StringUtils;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RequestMethod;
  8. import org.springframework.web.bind.annotation.RequestParam;
  9. import org.springframework.web.bind.annotation.ResponseBody;
  10. import com.houserss.common.Const;
  11. import com.houserss.common.Const.Role;
  12. import com.houserss.common.ServerResponse;
  13. import com.houserss.pojo.User;
  14. import com.houserss.service.IUserService;
  15. import com.houserss.service.impl.UserServiceImpl;
  16. import com.houserss.util.MD5Util;
  17. import com.houserss.util.TimeUtils;
  18. import com.houserss.vo.DeleteHouseVo;
  19. import com.houserss.vo.PageInfoVo;
  20. /**
  21. * Created by admin
  22. */
  23. @Controller
  24. @RequestMapping("/user/")
  25. public class UserController {
  26. @Autowired
  27. private IUserService iUserService;
  28. /**
  29. * 用户登录
  30. * @param username
  31. * @param password
  32. * @param session
  33. * @return
  34. */
  35. @RequestMapping(value = "login.do",method = RequestMethod.POST)
  36. @ResponseBody
  37. public ServerResponse<User> login(User user,String uvcode, HttpSession session){
  38. String code = (String)session.getAttribute("validationCode");
  39. if(StringUtils.isNotBlank(code)) {
  40. if(!code.equalsIgnoreCase(uvcode)) {
  41. return ServerResponse.createByErrorMessage("验证码不正确");
  42. }
  43. }
  44. ServerResponse<User> response = iUserService.login(user.getUsername(),user.getPassword());
  45. if(response.isSuccess()){
  46. session.setAttribute(Const.CURRENT_USER,response.getData());
  47. }
  48. return response;
  49. }
  50. }

管理员管理控制层:

  1. package com.sxl.controller.admin;
  2. import java.util.List;
  3. import java.util.Map;
  4. import javax.servlet.http.HttpServletRequest;
  5. import org.springframework.http.ResponseEntity;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.ui.Model;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import com.sxl.controller.MyController;
  10. @Controller("adminController")
  11. @RequestMapping(value = "/admin")
  12. public class AdminController extends MyController {
  13. @RequestMapping(value = "/index")
  14. public String frame(Model model, HttpServletRequest request)throws Exception {
  15. return "/admin/index";
  16. }
  17. @RequestMapping(value = "/main")
  18. public String main(Model model, HttpServletRequest request)throws Exception {
  19. return "/admin/main";
  20. }
  21. @RequestMapping(value = "/tj1")
  22. public String tj1(Model model, HttpServletRequest request)throws Exception {
  23. String sql="select DATE_FORMAT(insertDate,'%Y-%m-%d') dates,sum(allPrice) price from t_order order by DATE_FORMAT(insertDate,'%Y-%m-%d') desc";
  24. List<Map> list = db.queryForList(sql);
  25. model.addAttribute("list", list);
  26. System.out.println(list);
  27. return "/admin/tj/tj1";
  28. }
  29. @RequestMapping(value = "/password")
  30. public String password(Model model, HttpServletRequest request)throws Exception {
  31. return "/admin/password";
  32. }
  33. @RequestMapping(value = "/changePassword")
  34. public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {
  35. Map admin = getAdmin(request);
  36. if(oldPassword.equals(admin.get("password").toString())){
  37. String sql="update t_admin set password=? where id=?";
  38. db.update(sql, new Object[]{newPassword,admin.get("id")});
  39. return renderData(true,"1",null);
  40. }else{
  41. return renderData(false,"1",null);
  42. }
  43. }
  44. }

修改密码业务逻辑:

  1. package com.sxl.controller.admin;
  2. import java.util.Map;
  3. import javax.servlet.http.HttpServletRequest;
  4. import org.springframework.http.ResponseEntity;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.ui.Model;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import com.sxl.controller.MyController;
  9. @Controller("userController")
  10. @RequestMapping(value = "/user")
  11. public class UserController extends MyController {
  12. @RequestMapping(value = "/index")
  13. public String frame(Model model, HttpServletRequest request)throws Exception {
  14. return "/user/index";
  15. }
  16. @RequestMapping(value = "/main")
  17. public String main(Model model, HttpServletRequest request)throws Exception {
  18. return "/user/main";
  19. }
  20. @RequestMapping(value = "/password")
  21. public String password(Model model, HttpServletRequest request)throws Exception {
  22. return "/user/password";
  23. }
  24. @RequestMapping(value = "/changePassword")
  25. public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {
  26. Map user = getUser(request);
  27. if(oldPassword.equals(user.get("password").toString())){
  28. String sql="update t_user set password=? where id=?";
  29. db.update(sql, new Object[]{newPassword,user.get("id")});
  30. return renderData(true,"1",null);
  31. }else{
  32. return renderData(false,"1",null);
  33. }
  34. }
  35. @RequestMapping(value = "/mine")
  36. public String mine(Model model, HttpServletRequest request)throws Exception {
  37. Map user =getUser(request);Map map = db.queryForMap("select * from t_user where id=?",new Object[]{user.get("id")});model.addAttribute("map", map); return "/user/mine";
  38. }
  39. @RequestMapping(value = "/mineSave")
  40. public ResponseEntity<String> mineSave(Model model,HttpServletRequest request,Long id
  41. ,String username,String password,String name,String gh,String mobile) throws Exception{
  42. int result = 0;
  43. String sql="update t_user set name=?,gh=?,mobile=? where id=?";
  44. result = db.update(sql, new Object[]{name,gh,mobile,id});
  45. if(result==1){
  46. return renderData(true,"操作成功",null);
  47. }else{
  48. return renderData(false,"操作失败",null);
  49. }
  50. }
  51. }

通用管理模块:

  1. package com.sxl.controller;
  2. import java.nio.charset.Charset;
  3. import java.util.Locale;
  4. import java.util.ResourceBundle;
  5. import javax.servlet.http.HttpServletRequest;
  6. import org.apache.commons.lang.StringUtils;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.http.HttpHeaders;
  9. import org.springframework.http.HttpStatus;
  10. import org.springframework.http.MediaType;
  11. import org.springframework.http.ResponseEntity;
  12. import com.sxl.util.JacksonJsonUtil;
  13. import com.sxl.util.StringUtil;
  14. import com.sxl.util.SystemProperties;
  15. public class BaseController {
  16. public static final Long EXPIRES_IN = 1000 * 3600 * 24 * 1L;// 1
  17. @Autowired
  18. private SystemProperties systemProperties;
  19. /**
  20. * 获得配置文件内容
  21. */
  22. public String getConfig(String key) {
  23. return systemProperties.getProperties(key);
  24. }
  25. /**
  26. * 返回服务器地址 like http://192.168.1.1:8441/UUBean/
  27. */
  28. public String getHostUrl(HttpServletRequest request) {
  29. String hostName = request.getServerName();
  30. Integer hostPort = request.getServerPort();
  31. String path = request.getContextPath();
  32. if (hostPort == 80) {
  33. return "http://" + hostName + path + "/";
  34. } else {
  35. return "http://" + hostName + ":" + hostPort + path + "/";
  36. }
  37. }
  38. /***
  39. * 获取当前的website路径 String
  40. */
  41. public static String getWebSite(HttpServletRequest request) {
  42. String returnUrl = request.getScheme() + "://"
  43. + request.getServerName();
  44. if (request.getServerPort() != 80) {
  45. returnUrl += ":" + request.getServerPort();
  46. }
  47. returnUrl += request.getContextPath();
  48. return returnUrl;
  49. }
  50. /**
  51. * 初始化HTTP头.
  52. *
  53. * @return HttpHeaders
  54. */
  55. public HttpHeaders initHttpHeaders() {
  56. HttpHeaders headers = new HttpHeaders();
  57. MediaType mediaType = new MediaType("text", "html",
  58. Charset.forName("utf-8"));
  59. headers.setContentType(mediaType);
  60. return headers;
  61. }
  62. /**
  63. * 返回 信息数据
  64. *
  65. * @param status
  66. * @param msg
  67. * @return
  68. */
  69. public ResponseEntity<String> renderMsg(Boolean status, String msg) {
  70. if (StringUtils.isEmpty(msg)) {
  71. msg = "";
  72. }
  73. String str = "{\"status\":\"" + status + "\",\"msg\":\"" + msg + "\"}";
  74. ResponseEntity<String> responseEntity = new ResponseEntity<String>(str,
  75. initHttpHeaders(), HttpStatus.OK);
  76. return responseEntity;
  77. }
  78. /**
  79. * 返回obj数据
  80. *
  81. * @param status
  82. * @param msg
  83. * @param obj
  84. * @return
  85. */
  86. public ResponseEntity<String> renderData(Boolean status, String msg,
  87. Object obj) {
  88. if (StringUtils.isEmpty(msg)) {
  89. msg = "";
  90. }
  91. StringBuffer sb = new StringBuffer();
  92. sb.append("{");
  93. sb.append("\"status\":\"" + status + "\",\"msg\":\"" + msg + "\",");
  94. sb.append("\"data\":" + JacksonJsonUtil.toJson(obj) + "");
  95. sb.append("}");
  96. ResponseEntity<String> responseEntity = new ResponseEntity<String>(
  97. sb.toString(), initHttpHeaders(), HttpStatus.OK);
  98. return responseEntity;
  99. }
  100. /***
  101. * 获取IP(如果是多级代理,则得到的是一串IP值)
  102. */
  103. public static String getIpAddr(HttpServletRequest request) {
  104. String ip = request.getHeader("x-forwarded-for");
  105. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  106. ip = request.getHeader("Proxy-Client-IP");
  107. }
  108. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  109. ip = request.getHeader("WL-Proxy-Client-IP");
  110. }
  111. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  112. ip = request.getRemoteAddr();
  113. }
  114. if (ip != null && ip.length() > 0) {
  115. String[] ips = ip.split(",");
  116. for (int i = 0; i < ips.length; i++) {
  117. if (!"unknown".equalsIgnoreCase(ips[i])) {
  118. ip = ips[i];
  119. break;
  120. }
  121. }
  122. }
  123. return ip;
  124. }
  125. /**
  126. * 国际化获得语言内容
  127. *
  128. * @param key
  129. * 语言key
  130. * @param args
  131. * @param argsSplit
  132. * @param defaultMessage
  133. * @param locale
  134. * @return
  135. */
  136. public static String getLanguage(String key, String args, String argsSplit,
  137. String defaultMessage, String locale) {
  138. String language = "zh";
  139. String contry = "cn";
  140. String returnValue = defaultMessage;
  141. if (!StringUtil.isEmpty(locale)) {
  142. try {
  143. String[] localeArray = locale.split("_");
  144. language = localeArray[0];
  145. contry = localeArray[1];
  146. } catch (Exception e) {
  147. }
  148. }
  149. try {
  150. ResourceBundle resource = ResourceBundle.getBundle("lang.resource",
  151. new Locale(language, contry));
  152. returnValue = resource.getString(key);
  153. if (!StringUtil.isEmpty(args)) {
  154. String[] argsArray = args.split(argsSplit);
  155. for (int i = 0; i < argsArray.length; i++) {
  156. returnValue = returnValue.replace("{" + i + "}",
  157. argsArray[i]);
  158. }
  159. }
  160. } catch (Exception e) {
  161. }
  162. return returnValue;
  163. }
  164. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/241750
推荐阅读
相关标签
  

闽ICP备14008679号