• Java项目:SSM物流快递管理系统


    作者主页:夜未央5788

     简介: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版本;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:HTML+CSS+JavaScript+jsp

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
    3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

    4. 运行项目,输入localhost:8080/ 登录

    运行截图

     

     

     

     

     

     

     

     

    相关代码

    LinkAdminController

    1. package com.june.web.controller.admin;
    2. import javax.annotation.Resource;
    3. import org.springframework.stereotype.Controller;
    4. import org.springframework.ui.Model;
    5. import org.springframework.web.bind.annotation.RequestMapping;
    6. import com.june.model.Link;
    7. import com.june.service.LinkService;
    8. @Controller
    9. @RequestMapping("/link")
    10. public class LinkAdminController {
    11. @Resource
    12. private LinkService linkService;
    13. @RequestMapping("/list")
    14. public String list(Model model) {
    15. model.addAttribute("linkList", linkService.getLinkList());
    16. return "link/list";
    17. }
    18. @RequestMapping("/toAdd")
    19. public String toAdd() {
    20. return "link/add";
    21. }
    22. @RequestMapping("/add")
    23. public void add(Link link, Model model) {
    24. int result = linkService.add(link);
    25. model.addAttribute("msg", result > 0 ? "保存成功" : "保存失败");
    26. }
    27. @RequestMapping("/toUpdate")
    28. public String toUpdate(Integer id, Model model) {
    29. model.addAttribute("link", linkService.findById(id));
    30. return "link/update";
    31. }
    32. @RequestMapping("/update")
    33. public void update(Link link,Model model) {
    34. int result = linkService.update(link);
    35. model.addAttribute("msg", result > 0 ? "保存成功" : "保存失败");
    36. }
    37. @RequestMapping("/delete")
    38. public String delete(Integer id) {
    39. linkService.delete(id);
    40. return "redirect:/link/list.do";
    41. }
    42. @RequestMapping("/deletes")
    43. public String deletes(String ids) {
    44. String[] idArr = org.springframework.util.StringUtils.commaDelimitedListToStringArray(ids);
    45. int len = idArr.length;
    46. Integer[] linkIds = new Integer[len];
    47. for (int i = 0; i < len; i++) {
    48. linkIds[i] = Integer.parseInt(idArr[i]);
    49. }
    50. linkService.batchDelete(linkIds);
    51. return "redirect:/link/list.do";
    52. }
    53. }

    SysLoginOrOutController

    1. package com.june.web.controller.admin;
    2. import javax.annotation.Resource;
    3. import javax.servlet.http.HttpServletResponse;
    4. import org.apache.shiro.SecurityUtils;
    5. import org.apache.shiro.authc.IncorrectCredentialsException;
    6. import org.apache.shiro.authc.UnknownAccountException;
    7. import org.apache.shiro.authc.UsernamePasswordToken;
    8. import org.apache.shiro.subject.Subject;
    9. import org.springframework.stereotype.Controller;
    10. import org.springframework.web.bind.annotation.PathVariable;
    11. import org.springframework.web.bind.annotation.RequestMapping;
    12. import com.june.service.BloggerService;
    13. import com.june.util.ResponseUtils;
    14. import com.june.util.ShiroUtils;
    15. import lombok.extern.slf4j.Slf4j;
    16. @Controller
    17. @RequestMapping("/admin")
    18. public @Slf4j class SysLoginOrOutController {
    19. @Resource
    20. private BloggerService bloggerService;
    21. @RequestMapping("/{page}")
    22. public String page(@PathVariable String page) {
    23. return page;
    24. }
    25. @RequestMapping("/logout")
    26. public String logout() {
    27. ShiroUtils.logout();
    28. return "login";
    29. }
    30. //登录
    31. @RequestMapping("/userLogin")
    32. public void login(String username, String password, HttpServletResponse response) {
    33. try {
    34. // shiro 登录
    35. Subject subject = SecurityUtils.getSubject();
    36. if (!subject.isAuthenticated()) {
    37. if (log.isDebugEnabled()) {
    38. log.debug("执行 shiro 登录操作...");
    39. }
    40. subject.login(new UsernamePasswordToken(username, ShiroUtils.encryptPassword(password)));
    41. }
    42. } catch (UnknownAccountException | IncorrectCredentialsException e) {
    43. ResponseUtils.writeText(response, "用户名或密码错误");
    44. } catch (Exception e) {
    45. ResponseUtils.writeText(response, "登录失败");
    46. }
    47. }
    48. }

    CommentAdminController

    1. package com.june.web.controller.admin;
    2. import java.io.IOException;
    3. import java.util.Date;
    4. import java.util.HashMap;
    5. import java.util.List;
    6. import java.util.Map;
    7. import javax.annotation.Resource;
    8. import javax.servlet.http.HttpServletRequest;
    9. import javax.servlet.http.HttpServletResponse;
    10. import org.json.JSONObject;
    11. import org.springframework.stereotype.Controller;
    12. import org.springframework.ui.Model;
    13. import org.springframework.web.bind.annotation.RequestMapping;
    14. import org.springframework.web.bind.annotation.RequestParam;
    15. import com.june.model.Comment;
    16. import com.june.model.PageBean;
    17. import com.june.service.BlogService;
    18. import com.june.service.CommentService;
    19. import com.june.util.Constants;
    20. import com.june.util.PageUtils;
    21. import com.june.util.ResponseUtils;
    22. import com.june.util.StringUtils;
    23. @Controller
    24. @RequestMapping("/comment")
    25. public class CommentAdminController {
    26. @Resource
    27. private CommentService commentService;
    28. @Resource
    29. private BlogService blogService;
    30. @RequestMapping("/list")
    31. public String list(@RequestParam(defaultValue = "1") Integer page,
    32. @RequestParam(defaultValue = Constants.BACK_PAGE_SIZE + 1 + "") Integer pageSize,
    33. String firstDate, String secondDate, String userName,
    34. Boolean isPass, Model model, HttpServletRequest request) {
    35. Map params = new HashMap(6);
    36. params.put("firstDate", firstDate);
    37. params.put("secondDate", secondDate);
    38. params.put("userName", userName);
    39. params.put("isPass", isPass);
    40. int totalCount = commentService.getCount(params);
    41. PageBean pageBean = new PageBean(totalCount, page, pageSize);
    42. params.put("start", pageBean.getStart());
    43. params.put("size", pageSize);
    44. List commentList = commentService.getCommentList(params);
    45. commentList.stream().forEach(comment -> {
    46. String content = comment.getContent();
    47. if (content.length() > 60) {
    48. comment.setContent(content.substring(0,60) + "...");
    49. }
    50. });
    51. model.addAttribute("pagination", pageBean);
    52. StringBuilder param = new StringBuilder(); // 分页查询参数
    53. param.append(StringUtils.isEmpty(firstDate) ? "" : "&firstDate=" + firstDate);
    54. param.append(StringUtils.isEmpty(secondDate) ? "" : "&secondDate=" + secondDate);
    55. param.append(StringUtils.isEmpty(userName) ? "" : "&userName=" + userName);
    56. param.append(isPass == null ? "" : "&isPass=" + isPass);
    57. String pageCode = PageUtils.genPagination(request.getContextPath() + "/comment/list.do",
    58. pageBean, param.toString());
    59. model.addAttribute("pageCode", pageCode);
    60. model.addAttribute("entry", params);
    61. model.addAttribute("commentList", commentList);
    62. return "comment/list";
    63. }
    64. @RequestMapping("/toAdd")
    65. public String toAdd() {
    66. return "comment/add";
    67. }
    68. @RequestMapping("/detail")
    69. public String detail(Integer id,Model model){
    70. model.addAttribute("comment", commentService.findById(id));
    71. return "comment/detail";
    72. }
    73. //评论审核
    74. @RequestMapping("/audit")
    75. public void audit(Comment comment, HttpServletResponse response) {
    76. comment.setReplyDate(new Date());
    77. int result = commentService.audit(comment);
    78. JSONObject jsonObj = new JSONObject();
    79. jsonObj.put("success", result > 0);
    80. ResponseUtils.writeJson(response, jsonObj.toString());
    81. }
    82. @RequestMapping("/delete")
    83. public String delete(Integer id) throws IOException{
    84. commentService.delete(id);
    85. return "redirect:/comment/list.do";
    86. }
    87. @RequestMapping("/deletes")
    88. public String deletes(String ids) {
    89. String[] idArr = org.springframework.util.StringUtils.commaDelimitedListToStringArray(ids);
    90. int len = idArr.length;
    91. Integer[] commentIds = new Integer[len];
    92. for (int i = 0; i < len; i++) {
    93. commentIds[i] = Integer.parseInt(idArr[i]);
    94. }
    95. commentService.batchDelete(commentIds);
    96. return "redirect:/comment/list.do";
    97. }
    98. }

    IndexController

    1. package com.june.web.controller.front;
    2. import java.net.URLDecoder;
    3. import java.nio.charset.StandardCharsets;
    4. import java.util.HashMap;
    5. import java.util.List;
    6. import java.util.Map;
    7. import javax.annotation.Resource;
    8. import javax.servlet.ServletContext;
    9. import javax.servlet.http.HttpServletRequest;
    10. import org.apache.commons.lang3.StringEscapeUtils;
    11. import org.apache.lucene.queryparser.classic.QueryParser;
    12. import org.springframework.stereotype.Controller;
    13. import org.springframework.ui.Model;
    14. import org.springframework.web.bind.annotation.PathVariable;
    15. import org.springframework.web.bind.annotation.RequestMapping;
    16. import org.springframework.web.bind.annotation.RequestParam;
    17. import com.june.lucene.BlogIndex;
    18. import com.june.model.Blog;
    19. import com.june.model.BlogType;
    20. import com.june.model.PageBean;
    21. import com.june.service.BlogService;
    22. import com.june.service.BlogTypeService;
    23. import com.june.service.BloggerService;
    24. import com.june.service.LinkService;
    25. import com.june.util.Constants;
    26. import com.june.util.PageUtils;
    27. import com.june.util.StringUtils;
    28. /**
    29. * 主页Controller
    30. */
    31. @Controller
    32. public class IndexController {
    33. @Resource
    34. private BlogService blogService;
    35. @Resource
    36. private BloggerService bloggerService;
    37. @Resource
    38. private BlogTypeService blogTypeService;
    39. @Resource
    40. private LinkService linkService;
    41. @Resource
    42. private BlogIndex blogIndex;
    43. @RequestMapping("/index")
    44. public String index(@RequestParam(defaultValue = "1") Integer page,
    45. Model model, HttpServletRequest request) throws Exception {
    46. Map map = new HashMap(2);
    47. int totalCount = blogService.getCount(map);
    48. int pageSize = Constants.FRONT_PAGE_SIZE;
    49. PageBean pageBean = new PageBean(totalCount, page, pageSize);
    50. map.put("start", pageBean.getStart());
    51. map.put("size", pageSize);
    52. List blogList = blogService.getBlogList(map);
    53. // 去除摘要中的html标签,防止浏览器解析
    54. blogList.forEach(blog -> blog.setSummary(StringUtils.escapeHtml(blog.getSummary())));
    55. model.addAttribute("blogList", blogList);
    56. String pageCode = PageUtils.genPagination(request.getContextPath() + "/index.shtml", pageBean, "");
    57. model.addAttribute("pageCode", pageCode);
    58. model.addAttribute("totalCount", totalCount);
    59. model.addAttribute("title", "我的文章");
    60. ServletContext application = request.getServletContext();
    61. List blogTypeList = blogTypeService.getTypeList();
    62. blogTypeList.forEach(blogType -> {
    63. Map paramMap = new HashMap(1);
    64. paramMap.put("typeId", blogType.getTypeId());
    65. blogType.setBlogCount(blogService.getCount(paramMap));
    66. });
    67. application.setAttribute("blogTypeList", blogTypeList);
    68. application.setAttribute("dateRankList", blogService.getByDate());
    69. application.setAttribute("readingRankList", blogService.getTopReading());
    70. application.setAttribute("reviewRankList", blogService.getTopReview());
    71. application.setAttribute("blogger", bloggerService.find());
    72. application.setAttribute("linkList", linkService.getLinkList());
    73. application.setAttribute("pageTitle", Constants.DEFAULT_TITLE);
    74. application.setAttribute("pageKeywords", Constants.DEFAULT_KEYWORDS);
    75. application.setAttribute("description", Constants.DEFAULT_DESCRIPTION);
    76. return "blog/list";
    77. }
    78. @RequestMapping("/{category}")
    79. public String life(@PathVariable String category, @RequestParam(defaultValue = "1") Integer page,
    80. Model model, HttpServletRequest request)
    81. throws Exception {
    82. String typeName = "";
    83. switch (category) {
    84. case Constants.LIFE_CATEGORY_EN:
    85. typeName = Constants.LIFE_CATEGORY; break;
    86. case Constants.NEWS_CATEGORY_EN:
    87. typeName = Constants.NEWS_CATEGORY; break;
    88. default: break;
    89. }
    90. Integer typeId = blogTypeService.getIdByName(typeName);
    91. Map map = new HashMap(3);
    92. map.put("typeId", typeId);
    93. int totalCount = blogService.getCount(map);
    94. int pageSize = Constants.FRONT_PAGE_SIZE;
    95. PageBean pageBean = new PageBean(totalCount, page, pageSize);
    96. pageBean.setTotalCount(totalCount);
    97. map.put("start", pageBean.getStart());
    98. map.put("size", pageSize);
    99. List blogList = blogService.getBlogList(map);
    100. // 去除摘要中的html标签,防止浏览器解析
    101. blogList.forEach(blog -> blog.setSummary(StringUtils.escapeHtml(blog.getSummary())));
    102. model.addAttribute("blogList", blogList);
    103. String pageCode = PageUtils.genPagination(request.getContextPath() + "/" + category + ".shtml",
    104. pageBean, "");
    105. model.addAttribute("pageCode", pageCode);
    106. model.addAttribute("totalCount", totalCount);
    107. model.addAttribute("pageTitle", typeName + " - 文章分类 - hayuq的博客");
    108. model.addAttribute("title", typeName);
    109. return "blog/list";
    110. }
    111. /**
    112. * 根据关键词查询博客
    113. * @throws Exception
    114. */
    115. @RequestMapping("/search")
    116. public String search(@RequestParam(defaultValue = "1") Integer page, String q,
    117. Model model, HttpServletRequest request) throws Exception {
    118. if ("POST".equals(request.getMethod())) { // 判断是否是表单提交,post方式
    119. // 解决表单提交中文乱码
    120. q = new String(q);
    121. }
    122. if(q != null) {
    123. // URL解码,防止特殊字符
    124. q = URLDecoder.decode(q, StandardCharsets.UTF_8.name());
    125. }
    126. // 转义特殊字符,防止lucene报异常
    127. String kwd = QueryParser.escape(q);
    128. List blogList = blogIndex.query(kwd);
    129. // 分页显示
    130. int totalCount = blogList.size();
    131. int pageSize = Constants.DEFAULT_PAGE_SIZE;
    132. PageBean pageBean = new PageBean(totalCount, page, pageSize);
    133. int fromIndex = pageBean.getStart();
    134. int toIndex = Math.min(totalCount, fromIndex + pageSize);
    135. model.addAttribute("blogList", blogList.subList(fromIndex, toIndex));
    136. model.addAttribute("resultCount", totalCount);
    137. String pageCode = PageUtils.genPagination(request.getContextPath() + "/search.shtml",
    138. pageBean, StringUtils.isEmpty(q) ? "" : "q=" + q);
    139. model.addAttribute("pageCode", pageCode);
    140. q = StringEscapeUtils.escapeHtml4(q);
    141. model.addAttribute("q", q);
    142. model.addAttribute("pageKeywords", q + "," + Constants.DEFAULT_KEYWORDS);
    143. return "blog/result";
    144. }
    145. }

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

  • 相关阅读:
    MyBatis的使用
    C++笔记
    MySQL第一弹
    1695. 删除子数组的最大得分-哈希表+双指针
    【web开发】1、flask入门和html开发
    2020美亚个人赛复盘
    A* 算法实现与解析
    C++Primer第五版 第十四章习题答案(1~5)
    crontab 实现秒级定时任务的执行(学习笔记)
    echarts 饼图 环形图 lable添加下划线
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126553777