赞
踩
该项目 两种角色 用户、管理员:
用户主要功能有:待收列表,收件列表,寄件功能,寄件列表,个人信息修改;
管理员主要功能有:相比于用户多了 物流管理,用户管理;
jdk8+mysql5.7+IntelliJ IDEA+maven
SpringBoot+MybatisPlus+Thymeleaf+jquery+layui
登录
注册
寄件
寄件列表
待收件
收件列表
个人信息
物流管理
用户管理
代码结构
/** * @author GXY */ @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") 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"; // } // } @PostMapping("/adminPickUpOrders") public String adminPickUpOrders(@RequestParam String num, @RequestParam String name, @RequestParam String sendName, @RequestParam Integer id, @RequestParam Integer positionId,RedirectAttributes attributes) { QueryWrapper<User> userName = new QueryWrapper<User>().eq("name", name); try { User user = userService.getOne(userName); if (user==null) { attributes.addFlashAttribute("message", "收件人有误,请注册后邮寄"); } Orders orders = new Orders(); orders.setUserId(user.getId()); orders.setSendName(sendName); orders.setPositionId(positionId); orders.setCreateTime(new Date()); orders.setUpdateTime(new Date()); orders.setNum(num); ordersService.save(orders); }catch (NullPointerException e) { e.printStackTrace(); } //柜子状态变为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"; } @GetMapping("/adminUserTo0/{id}") public String adminUserTo0(@PathVariable Integer id) { User user = userService.getById(id); user.setRole(0); userService.updateById(user); return "redirect:/toAdminUser"; } }
/** * @author GXY */ @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()); //柜子状态变为0 Orders orders = ordersService.findById(id); Position position = positionService.getById(orders.getPositionId()); position.setStatus(0); positionService.updateById(position); return "redirect:/toUserPickUp"; } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。