作者主页:夜未央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
package com.june.web.controller.admin;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.june.model.Link;
import com.june.service.LinkService;
@Controller
@RequestMapping("/link")
public class LinkAdminController {
@Resource
private LinkService linkService;
@RequestMapping("/list")
public String list(Model model) {
model.addAttribute("linkList", linkService.getLinkList());
return "link/list";
}
@RequestMapping("/toAdd")
public String toAdd() {
return "link/add";
}
@RequestMapping("/add")
public void add(Link link, Model model) {
int result = linkService.add(link);
model.addAttribute("msg", result > 0 ? "保存成功" : "保存失败");
}
@RequestMapping("/toUpdate")
public String toUpdate(Integer id, Model model) {
model.addAttribute("link", linkService.findById(id));
return "link/update";
}
@RequestMapping("/update")
public void update(Link link,Model model) {
int result = linkService.update(link);
model.addAttribute("msg", result > 0 ? "保存成功" : "保存失败");
}
@RequestMapping("/delete")
public String delete(Integer id) {
linkService.delete(id);
return "redirect:/link/list.do";
}
@RequestMapping("/deletes")
public String deletes(String ids) {
String[] idArr = org.springframework.util.StringUtils.commaDelimitedListToStringArray(ids);
int len = idArr.length;
Integer[] linkIds = new Integer[len];
for (int i = 0; i < len; i++) {
linkIds[i] = Integer.parseInt(idArr[i]);
}
linkService.batchDelete(linkIds);
return "redirect:/link/list.do";
}
}
SysLoginOrOutController
package com.june.web.controller.admin;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.june.service.BloggerService;
import com.june.util.ResponseUtils;
import com.june.util.ShiroUtils;
import lombok.extern.slf4j.Slf4j;
@Controller
@RequestMapping("/admin")
public @Slf4j class SysLoginOrOutController {
@Resource
private BloggerService bloggerService;
@RequestMapping("/{page}")
public String page(@PathVariable String page) {
return page;
}
@RequestMapping("/logout")
public String logout() {
ShiroUtils.logout();
return "login";
}
//登录
@RequestMapping("/userLogin")
public void login(String username, String password, HttpServletResponse response) {
try {
// shiro 登录
Subject subject = SecurityUtils.getSubject();
if (!subject.isAuthenticated()) {
if (log.isDebugEnabled()) {
log.debug("执行 shiro 登录操作...");
}
subject.login(new UsernamePasswordToken(username, ShiroUtils.encryptPassword(password)));
}
} catch (UnknownAccountException | IncorrectCredentialsException e) {
ResponseUtils.writeText(response, "用户名或密码错误");
} catch (Exception e) {
ResponseUtils.writeText(response, "登录失败");
}
}
}
CommentAdminController
package com.june.web.controller.admin;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.june.model.Comment;
import com.june.model.PageBean;
import com.june.service.BlogService;
import com.june.service.CommentService;
import com.june.util.Constants;
import com.june.util.PageUtils;
import com.june.util.ResponseUtils;
import com.june.util.StringUtils;
@Controller
@RequestMapping("/comment")
public class CommentAdminController {
@Resource
private CommentService commentService;
@Resource
private BlogService blogService;
@RequestMapping("/list")
public String list(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = Constants.BACK_PAGE_SIZE + 1 + "") Integer pageSize,
String firstDate, String secondDate, String userName,
Boolean isPass, Model model, HttpServletRequest request) {
Map<String, Object> params = new HashMap<String, Object>(6);
params.put("firstDate", firstDate);
params.put("secondDate", secondDate);
params.put("userName", userName);
params.put("isPass", isPass);
int totalCount = commentService.getCount(params);
PageBean pageBean = new PageBean(totalCount, page, pageSize);
params.put("start", pageBean.getStart());
params.put("size", pageSize);
List<Comment> commentList = commentService.getCommentList(params);
commentList.stream().forEach(comment -> {
String content = comment.getContent();
if (content.length() > 60) {
comment.setContent(content.substring(0,60) + "...");
}
});
model.addAttribute("pagination", pageBean);
StringBuilder param = new StringBuilder(); // 分页查询参数
param.append(StringUtils.isEmpty(firstDate) ? "" : "&firstDate=" + firstDate);
param.append(StringUtils.isEmpty(secondDate) ? "" : "&secondDate=" + secondDate);
param.append(StringUtils.isEmpty(userName) ? "" : "&userName=" + userName);
param.append(isPass == null ? "" : "&isPass=" + isPass);
String pageCode = PageUtils.genPagination(request.getContextPath() + "/comment/list.do",
pageBean, param.toString());
model.addAttribute("pageCode", pageCode);
model.addAttribute("entry", params);
model.addAttribute("commentList", commentList);
return "comment/list";
}
@RequestMapping("/toAdd")
public String toAdd() {
return "comment/add";
}
@RequestMapping("/detail")
public String detail(Integer id,Model model){
model.addAttribute("comment", commentService.findById(id));
return "comment/detail";
}
//评论审核
@RequestMapping("/audit")
public void audit(Comment comment, HttpServletResponse response) {
comment.setReplyDate(new Date());
int result = commentService.audit(comment);
JSONObject jsonObj = new JSONObject();
jsonObj.put("success", result > 0);
ResponseUtils.writeJson(response, jsonObj.toString());
}
@RequestMapping("/delete")
public String delete(Integer id) throws IOException{
commentService.delete(id);
return "redirect:/comment/list.do";
}
@RequestMapping("/deletes")
public String deletes(String ids) {
String[] idArr = org.springframework.util.StringUtils.commaDelimitedListToStringArray(ids);
int len = idArr.length;
Integer[] commentIds = new Integer[len];
for (int i = 0; i < len; i++) {
commentIds[i] = Integer.parseInt(idArr[i]);
}
commentService.batchDelete(commentIds);
return "redirect:/comment/list.do";
}
}
IndexController
package com.june.web.controller.front;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.june.lucene.BlogIndex;
import com.june.model.Blog;
import com.june.model.BlogType;
import com.june.model.PageBean;
import com.june.service.BlogService;
import com.june.service.BlogTypeService;
import com.june.service.BloggerService;
import com.june.service.LinkService;
import com.june.util.Constants;
import com.june.util.PageUtils;
import com.june.util.StringUtils;
/**
* 主页Controller
*/
@Controller
public class IndexController {
@Resource
private BlogService blogService;
@Resource
private BloggerService bloggerService;
@Resource
private BlogTypeService blogTypeService;
@Resource
private LinkService linkService;
@Resource
private BlogIndex blogIndex;
@RequestMapping("/index")
public String index(@RequestParam(defaultValue = "1") Integer page,
Model model, HttpServletRequest request) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(2);
int totalCount = blogService.getCount(map);
int pageSize = Constants.FRONT_PAGE_SIZE;
PageBean pageBean = new PageBean(totalCount, page, pageSize);
map.put("start", pageBean.getStart());
map.put("size", pageSize);
List<Blog> blogList = blogService.getBlogList(map);
// 去除摘要中的html标签,防止浏览器解析
blogList.forEach(blog -> blog.setSummary(StringUtils.escapeHtml(blog.getSummary())));
model.addAttribute("blogList", blogList);
String pageCode = PageUtils.genPagination(request.getContextPath() + "/index.shtml", pageBean, "");
model.addAttribute("pageCode", pageCode);
model.addAttribute("totalCount", totalCount);
model.addAttribute("title", "我的文章");
ServletContext application = request.getServletContext();
List<BlogType> blogTypeList = blogTypeService.getTypeList();
blogTypeList.forEach(blogType -> {
Map<String, Object> paramMap = new HashMap<String, Object>(1);
paramMap.put("typeId", blogType.getTypeId());
blogType.setBlogCount(blogService.getCount(paramMap));
});
application.setAttribute("blogTypeList", blogTypeList);
application.setAttribute("dateRankList", blogService.getByDate());
application.setAttribute("readingRankList", blogService.getTopReading());
application.setAttribute("reviewRankList", blogService.getTopReview());
application.setAttribute("blogger", bloggerService.find());
application.setAttribute("linkList", linkService.getLinkList());
application.setAttribute("pageTitle", Constants.DEFAULT_TITLE);
application.setAttribute("pageKeywords", Constants.DEFAULT_KEYWORDS);
application.setAttribute("description", Constants.DEFAULT_DESCRIPTION);
return "blog/list";
}
@RequestMapping("/{category}")
public String life(@PathVariable String category, @RequestParam(defaultValue = "1") Integer page,
Model model, HttpServletRequest request)
throws Exception {
String typeName = "";
switch (category) {
case Constants.LIFE_CATEGORY_EN:
typeName = Constants.LIFE_CATEGORY; break;
case Constants.NEWS_CATEGORY_EN:
typeName = Constants.NEWS_CATEGORY; break;
default: break;
}
Integer typeId = blogTypeService.getIdByName(typeName);
Map<String, Object> map = new HashMap<String, Object>(3);
map.put("typeId", typeId);
int totalCount = blogService.getCount(map);
int pageSize = Constants.FRONT_PAGE_SIZE;
PageBean pageBean = new PageBean(totalCount, page, pageSize);
pageBean.setTotalCount(totalCount);
map.put("start", pageBean.getStart());
map.put("size", pageSize);
List<Blog> blogList = blogService.getBlogList(map);
// 去除摘要中的html标签,防止浏览器解析
blogList.forEach(blog -> blog.setSummary(StringUtils.escapeHtml(blog.getSummary())));
model.addAttribute("blogList", blogList);
String pageCode = PageUtils.genPagination(request.getContextPath() + "/" + category + ".shtml",
pageBean, "");
model.addAttribute("pageCode", pageCode);
model.addAttribute("totalCount", totalCount);
model.addAttribute("pageTitle", typeName + " - 文章分类 - hayuq的博客");
model.addAttribute("title", typeName);
return "blog/list";
}
/**
* 根据关键词查询博客
* @throws Exception
*/
@RequestMapping("/search")
public String search(@RequestParam(defaultValue = "1") Integer page, String q,
Model model, HttpServletRequest request) throws Exception {
if ("POST".equals(request.getMethod())) { // 判断是否是表单提交,post方式
// 解决表单提交中文乱码
q = new String(q);
}
if(q != null) {
// URL解码,防止特殊字符
q = URLDecoder.decode(q, StandardCharsets.UTF_8.name());
}
// 转义特殊字符,防止lucene报异常
String kwd = QueryParser.escape(q);
List<Blog> blogList = blogIndex.query(kwd);
// 分页显示
int totalCount = blogList.size();
int pageSize = Constants.DEFAULT_PAGE_SIZE;
PageBean pageBean = new PageBean(totalCount, page, pageSize);
int fromIndex = pageBean.getStart();
int toIndex = Math.min(totalCount, fromIndex + pageSize);
model.addAttribute("blogList", blogList.subList(fromIndex, toIndex));
model.addAttribute("resultCount", totalCount);
String pageCode = PageUtils.genPagination(request.getContextPath() + "/search.shtml",
pageBean, StringUtils.isEmpty(q) ? "" : "q=" + q);
model.addAttribute("pageCode", pageCode);
q = StringEscapeUtils.escapeHtml4(q);
model.addAttribute("q", q);
model.addAttribute("pageKeywords", q + "," + Constants.DEFAULT_KEYWORDS);
return "blog/result";
}
}
如果也想学习本系统,下面领取。关注并回复:127ssm