赞
踩
基于javaweb+mysql的springboot校园物流快递管理系统(java+maven+thymeleaf+html+springboot+layui+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot校园物流快递管理系统(java+maven+thymeleaf+html+springboot+layui+mysql)
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @PostMapping("/updateUserInfo") public String updateUserInfo(User user, HttpSession session) { User userInfo = (User) session.getAttribute("user"); Integer id = userInfo.getId(); user.setId(id); userService.updateById(user); return "redirect:/toUserInfo"; } @GetMapping("/findByName") @ResponseBody public void findName(String name, HttpSession session, HttpServletResponse response) throws IOException { User nowUser = (User) session.getAttribute("user"); Integer id = nowUser.getId(); response.setContentType("application/json;charset=utf-8"); QueryWrapper<User> wrapper = new QueryWrapper<User>().eq("name", name).ne("id", id); User userInfo = userService.getOne(wrapper); Map<String, Object> map = new HashMap<>(); if (userInfo != null) { map.put("nameExit", true); map.put("msg", "用户名已存在"); } else { map.put("nameExit", false); map.put("msg", "正确"); } //将map转为json,并且传递给客户端 String s = JSON.toJSONString(map); PrintWriter writer = response.getWriter(); writer.write(s); writer.close(); } @RequestMapping("/uploadAvatar") public String uploadAvatar(@RequestParam("file") MultipartFile file, HttpSession session) { String filename = file.getOriginalFilename();
postService.updatePostStatusTo2(id, new Date()); return "redirect:/toAdminSend"; } //用户管理 @GetMapping("/toAdminUser") public String toAdminUser(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, HttpSession session, Model model, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { PageHelper.startPage(pageNum, 6); List<User> userList = userService.list(); PageInfo<User> pageInfo = new PageInfo<>(userList); model.addAttribute("userList", userList); model.addAttribute("pageInfo", pageInfo); return "adminUser"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @GetMapping("/adminUserTo1/{id}") public String adminUserTo1(@PathVariable Integer id, HttpSession session) { User user = userService.getById(id); user.setRole(1); userService.updateById(user); User userInfo = (User) session.getAttribute("user"); if (id == userInfo.getId()) { session.setAttribute("user", user); return "index"; } return "redirect:/toAdminUser"; } @GetMapping("/adminUserTo0/{id}") public String adminUserTo0(@PathVariable Integer id) { User user = userService.getById(id); user.setRole(0); userService.updateById(user); return "redirect:/toAdminUser"; } }
UserService userService; //寄件管理 @GetMapping("/toAdminSend") public String toAdminSend(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, HttpSession session, Model model, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { PageHelper.startPage(pageNum, 6); List<Post> postList = postService.findAllPost(); PageInfo<Post> pageInfo = new PageInfo<>(postList); model.addAttribute("postList", postList); model.addAttribute("pageInfo", pageInfo); List<Category> categoryList = categoryService.list(); model.addAttribute("categoryList", categoryList); return "adminSend"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @GetMapping("adminSendPost/{id}") public String adminSendPost(@PathVariable Integer id) { postService.updatePostStatusTo1(id, new Date()); return "redirect:/toAdminSend"; } @PostMapping("/searchPost") public String searchPost(Post post, @RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, Model model) { PageHelper.startPage(pageNum, 6); List<Post> postList = postService.findPostBySearch(post); PageInfo<Post> pageInfo = new PageInfo<>(postList); List<Category> categoryList = categoryService.list(); model.addAttribute("categoryList", categoryList); model.addAttribute("postList", postList); model.addAttribute("pageInfo", pageInfo); return "adminSend"; } //收件管理 @GetMapping("adminPickUpPost/{id}") public String adminPickUpPost(@PathVariable Integer id, Model model) { Post post = postService.findById(id); model.addAttribute("post", post); QueryWrapper<Position> status0 = new QueryWrapper<Position>().eq("status", 0); List<Position> positionList = positionService.list(status0); model.addAttribute("positionList", positionList); return "adminPickUp"; }
@Autowired UserService userService; @GetMapping("/toLogin") public String toLogin(){ return "login"; } @PostMapping("/userLogin") public String login(@RequestParam String username, @RequestParam String password, HttpSession session, RedirectAttributes attributes) { QueryWrapper<User> wrapper = new QueryWrapper<User>().eq("username", username).eq("password", password); User user = userService.getOne(wrapper); if (user != null){ session.setAttribute("user",user); return "redirect:/index"; }else { attributes.addFlashAttribute("message","用户名或密码错误"); return "redirect:/toLogin"; } } @GetMapping("/toRegister") public String toRegister() { return "register"; } @PostMapping("/register") public String register(User user) { user.setCreateTime(new Date()); userService.save(user); return "redirect:/toLogin"; } @GetMapping("/findUsername") @ResponseBody public void findUsername(String username, HttpServletResponse response) throws IOException { response.setContentType("application/json;charset=utf-8"); QueryWrapper<User> wrapper = new QueryWrapper<User>().eq("username", username); User userInfo = userService.getOne(wrapper); Map<String, Object> map = new HashMap<>(); if (userInfo != null) { map.put("userExit", true); map.put("msg", "用户名已存在"); } else { map.put("userExit", false); map.put("msg", "正确"); } //将map转为json,并且传递给客户端
/** */ @Controller public class SendController { @Autowired PostService postService; @GetMapping("/toSend") public String toSend(HttpSession session, RedirectAttributes attributes){ User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { return "send"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @PostMapping("/sendPost") public String sendPost(Post post,HttpSession session){ User user = (User) session.getAttribute("user"); post.setUserId(user.getId()); post.setCreateTime(new Date()); post.setUpdateTime(new Date()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String format = dateFormat.format(new Date()); String num = format.concat(String.valueOf(user.getId())); String postNum = num.concat("2"); post.setNum(postNum); postService.save(post); return "redirect:/toUserSend"; } @PostMapping("/updatePost") public String updatePost(Post post){ post.setUpdateTime(new Date()); postService.updateById(post); return "redirect:/toUserSend"; } }
/** */ @Controller public class adminController { @Autowired PostService postService; @Autowired CategoryService categoryService; @Autowired PositionService positionService; @Autowired OrdersService ordersService; @Autowired UserService userService; //寄件管理 @GetMapping("/toAdminSend") public String toAdminSend(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, HttpSession session, Model model, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { PageHelper.startPage(pageNum, 6); List<Post> postList = postService.findAllPost(); PageInfo<Post> pageInfo = new PageInfo<>(postList); model.addAttribute("postList", postList); model.addAttribute("pageInfo", pageInfo); List<Category> categoryList = categoryService.list(); model.addAttribute("categoryList", categoryList); return "adminSend"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @GetMapping("adminSendPost/{id}") public String adminSendPost(@PathVariable Integer id) { postService.updatePostStatusTo1(id, new Date()); return "redirect:/toAdminSend"; } @PostMapping("/searchPost")
/** */ @Controller public class PickUpController { @Autowired OrdersService ordersService; @Autowired PositionService positionService; @Autowired PostService postService; @GetMapping("/toPickUp") public String toPickUp(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, Model model, HttpSession session, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { PageHelper.startPage(pageNum, 6); List<Orders> ordersList = ordersService.findByUserId(userInfo.getId()); PageInfo<Orders> pageInfo = new PageInfo<>(ordersList); model.addAttribute("ordersList",ordersList); model.addAttribute("pageInfo",pageInfo); return "pickUp"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @GetMapping("/pickUpOrders/{id}") public String pickUpOrders(@PathVariable Integer id){ ordersService.updateOrdersStatusTo1(id,new Date()); Orders orders = ordersService.findById(id); //柜子状态变为0 Position position = positionService.getById(orders.getPositionId()); position.setStatus(0); positionService.updateById(position); //post状态变为3 Post post = postService.findByNum(orders.getNum()); postService.updatePostStatusTo3(post.getId(), new Date()); return "redirect:/toPickUp"; } @GetMapping("/pickUpOrders2/{id}") public String pickUpOrders2(@PathVariable Integer id){ ordersService.updateOrdersStatusTo1(id,new Date());
@Autowired private AliyunOssUtil aliyunOssUtil; //个人信息 @GetMapping("/toUserInfo") public String toUserInfo(HttpSession session, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { Integer id = userInfo.getId(); User user = userService.getById(id); //更新 session.setAttribute("user", user); return "userInfo"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @PostMapping("/updateUserInfo") public String updateUserInfo(User user, HttpSession session) { User userInfo = (User) session.getAttribute("user"); Integer id = userInfo.getId(); user.setId(id); userService.updateById(user); return "redirect:/toUserInfo"; } @GetMapping("/findByName") @ResponseBody public void findName(String name, HttpSession session, HttpServletResponse response) throws IOException { User nowUser = (User) session.getAttribute("user"); Integer id = nowUser.getId(); response.setContentType("application/json;charset=utf-8"); QueryWrapper<User> wrapper = new QueryWrapper<User>().eq("name", name).ne("id", id); User userInfo = userService.getOne(wrapper); Map<String, Object> map = new HashMap<>(); if (userInfo != null) { map.put("nameExit", true); map.put("msg", "用户名已存在"); } else { map.put("nameExit", false); map.put("msg", "正确"); } //将map转为json,并且传递给客户端 String s = JSON.toJSONString(map); PrintWriter writer = response.getWriter(); writer.write(s); writer.close(); }
public String adminSendPost(@PathVariable Integer id) { postService.updatePostStatusTo1(id, new Date()); return "redirect:/toAdminSend"; } @PostMapping("/searchPost") public String searchPost(Post post, @RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, Model model) { PageHelper.startPage(pageNum, 6); List<Post> postList = postService.findPostBySearch(post); PageInfo<Post> pageInfo = new PageInfo<>(postList); List<Category> categoryList = categoryService.list(); model.addAttribute("categoryList", categoryList); model.addAttribute("postList", postList); model.addAttribute("pageInfo", pageInfo); return "adminSend"; } //收件管理 @GetMapping("adminPickUpPost/{id}") public String adminPickUpPost(@PathVariable Integer id, Model model) { Post post = postService.findById(id); model.addAttribute("post", post); QueryWrapper<Position> status0 = new QueryWrapper<Position>().eq("status", 0); List<Position> positionList = positionService.list(status0); model.addAttribute("positionList", positionList); return "adminPickUp"; } // @GetMapping("/toAdminPickUp") // public String toAdminPickUp(Model model, RedirectAttributes attributes, HttpSession session) { // User userInfo = (User) session.getAttribute("user"); // if (userInfo != null) { // QueryWrapper<Position> status0 = new QueryWrapper<Position>().eq("status", 0); // List<Position> positionList = positionService.list(status0); // model.addAttribute("positionList", positionList); // return "adminPickUp"; // } else { // attributes.addFlashAttribute("message", "权限不足,请先登录"); // return "redirect:/toLogin"; // } // }
} } @GetMapping("toPostDetail/{id}") public String toPostDetail(@PathVariable Integer id, Model model) { Post post = postService.findById(id); model.addAttribute("post",post); return "send3"; } @GetMapping("toUpdatePost/{id}") public String toUpdatePost(@PathVariable Integer id, Model model) { Post post = postService.findById(id); model.addAttribute("post",post); return "send2"; } @GetMapping("deletePost/{id}") public String deletePost(@PathVariable Integer id) { postService.removeById(id); return "redirect:/toUserSend"; } } /** */ @Controller public class LoginController { @Autowired
orders.setUserId(user.getId()); orders.setSendName(sendName); orders.setPositionId(positionId); orders.setCreateTime(new Date()); orders.setUpdateTime(new Date()); orders.setNum(num); ordersService.save(orders); //柜子状态变为1 Position position = positionService.getById(positionId); position.setStatus(1); positionService.updateById(position); //post状态变为2 postService.updatePostStatusTo2(id, new Date()); return "redirect:/toAdminSend"; } //用户管理 @GetMapping("/toAdminUser") public String toAdminUser(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, HttpSession session, Model model, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { PageHelper.startPage(pageNum, 6); List<User> userList = userService.list(); PageInfo<User> pageInfo = new PageInfo<>(userList); model.addAttribute("userList", userList); model.addAttribute("pageInfo", pageInfo); return "adminUser"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @GetMapping("/adminUserTo1/{id}") public String adminUserTo1(@PathVariable Integer id, HttpSession session) { User user = userService.getById(id); user.setRole(1); userService.updateById(user); User userInfo = (User) session.getAttribute("user"); if (id == userInfo.getId()) { session.setAttribute("user", user); return "index"; } return "redirect:/toAdminUser"; }
*/ @Controller public class UserController { @Autowired UserService userService; @Autowired PostService postService; @Autowired OrdersService ordersService; @Autowired private AliyunOssUtil aliyunOssUtil; //个人信息 @GetMapping("/toUserInfo") public String toUserInfo(HttpSession session, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { Integer id = userInfo.getId(); User user = userService.getById(id); //更新 session.setAttribute("user", user); return "userInfo"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @PostMapping("/updateUserInfo") public String updateUserInfo(User user, HttpSession session) { User userInfo = (User) session.getAttribute("user"); Integer id = userInfo.getId(); user.setId(id); userService.updateById(user); return "redirect:/toUserInfo"; } @GetMapping("/findByName") @ResponseBody public void findName(String name, HttpSession session, HttpServletResponse response) throws IOException { User nowUser = (User) session.getAttribute("user");
postService.removeById(id); return "redirect:/toUserSend"; } } /** */ @Controller public class LoginController { @Autowired UserService userService; @GetMapping("/toLogin") public String toLogin(){ return "login"; } @PostMapping("/userLogin") public String login(@RequestParam String username, @RequestParam String password, HttpSession session, RedirectAttributes attributes) { QueryWrapper<User> wrapper = new QueryWrapper<User>().eq("username", username).eq("password", password); User user = userService.getOne(wrapper); if (user != null){ session.setAttribute("user",user); return "redirect:/index"; }else { attributes.addFlashAttribute("message","用户名或密码错误");
/** */ @Controller public class adminController { @Autowired PostService postService; @Autowired CategoryService categoryService; @Autowired PositionService positionService; @Autowired OrdersService ordersService; @Autowired UserService userService; //寄件管理 @GetMapping("/toAdminSend") public String toAdminSend(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, HttpSession session, Model model, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { PageHelper.startPage(pageNum, 6); List<Post> postList = postService.findAllPost(); PageInfo<Post> pageInfo = new PageInfo<>(postList); model.addAttribute("postList", postList); model.addAttribute("pageInfo", pageInfo); List<Category> categoryList = categoryService.list(); model.addAttribute("categoryList", categoryList); return "adminSend"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @GetMapping("adminSendPost/{id}") public String adminSendPost(@PathVariable Integer id) { postService.updatePostStatusTo1(id, new Date());
if (!"".equals(filename.trim())) { File newFile = new File(filename); FileOutputStream outputStream = new FileOutputStream(newFile); outputStream.write(file.getBytes()); outputStream.close(); file.transferTo(newFile); //返回图片的URL String url = aliyunOssUtil.upLoad(newFile); User userInfo = (User) session.getAttribute("user"); userInfo.setAvatar(url); userService.saveOrUpdate(userInfo); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return "redirect:/toUserInfo"; } //我收到的 @GetMapping("/toUserPickUp") public String toUserPickUp(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, HttpSession session, Model model, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { PageHelper.startPage(pageNum, 6); List<Orders> ordersList = ordersService.findAllByUserId(userInfo.getId()); PageInfo<Orders> pageInfo = new PageInfo<>(ordersList); model.addAttribute("ordersList", ordersList); model.addAttribute("pageInfo", pageInfo); return "userPickUp"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } //我寄出的 @GetMapping("/toUserSend") public String toUserSend(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, HttpSession session, Model model, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { PageHelper.startPage(pageNum, 6); List<Post> postList = postService.findByUserId(userInfo.getId()); PageInfo<Post> pageInfo = new PageInfo<>(postList); model.addAttribute("postList", postList); model.addAttribute("pageInfo", pageInfo); return "userSend"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; }
} @GetMapping("/pickUpOrders/{id}") public String pickUpOrders(@PathVariable Integer id){ ordersService.updateOrdersStatusTo1(id,new Date()); Orders orders = ordersService.findById(id); //柜子状态变为0 Position position = positionService.getById(orders.getPositionId()); position.setStatus(0); positionService.updateById(position); //post状态变为3 Post post = postService.findByNum(orders.getNum()); postService.updatePostStatusTo3(post.getId(), new Date()); return "redirect:/toPickUp"; } @GetMapping("/pickUpOrders2/{id}") public String pickUpOrders2(@PathVariable Integer id){ ordersService.updateOrdersStatusTo1(id,new Date()); //柜子状态变为0 Orders orders = ordersService.findById(id); Position position = positionService.getById(orders.getPositionId()); position.setStatus(0); positionService.updateById(position); return "redirect:/toUserPickUp"; } } /** */
/** */ @Controller public class UserController { @Autowired UserService userService; @Autowired PostService postService; @Autowired OrdersService ordersService; @Autowired private AliyunOssUtil aliyunOssUtil; //个人信息 @GetMapping("/toUserInfo") public String toUserInfo(HttpSession session, RedirectAttributes attributes) { User userInfo = (User) session.getAttribute("user"); if (userInfo != null) { Integer id = userInfo.getId(); User user = userService.getById(id); //更新 session.setAttribute("user", user); return "userInfo"; } else { attributes.addFlashAttribute("message", "权限不足,请先登录"); return "redirect:/toLogin"; } } @PostMapping("/updateUserInfo") public String updateUserInfo(User user, HttpSession session) { User userInfo = (User) session.getAttribute("user"); Integer id = userInfo.getId(); user.setId(id); userService.updateById(user); return "redirect:/toUserInfo";
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。