怎么用Java实现校园跑腿管理系统
发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,这篇文章主要介绍"怎么用Java实现校园跑腿管理系统",在日常操作中,相信很多人在怎么用Java实现校园跑腿管理系统问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"怎么用
千家信息网最后更新 2025年02月01日怎么用Java实现校园跑腿管理系统
这篇文章主要介绍"怎么用Java实现校园跑腿管理系统",在日常操作中,相信很多人在怎么用Java实现校园跑腿管理系统问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"怎么用Java实现校园跑腿管理系统"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
前端使用的是vue+elementui,这款系统只适合学习巩固SpringBoot+VUE,后面还要在这上面加校园公告、校园零食等功能,后期代码我也会持续更新上去。系统分为管理员和学生、学生是管理员后台添加的两种角色。
运行环境:
后端 jdk1.8、maven3.5/3.6 mysql5.7 idea/eclipse
前端 idea vue-cli node.js 搭建vue环境 webpack3.6.0指定版本
管理员控制层:
@Controller@RequestMapping(value = "admin")public class AdminController { private final UserService userService; private final GoodService goodService; private final TypeService typeService; private final OrderService orderService; @Autowired public AdminController(UserService userService, GoodService goodService, TypeService typeService, OrderService orderService) { this.userService = userService; this.goodService = goodService; this.typeService = typeService; this.orderService = orderService; } @RequestMapping(value = "/adminLogin", method = RequestMethod.GET) public String getAdminLogin(){ return "admin/adminLogin"; } @RequestMapping(value = "/adminLogin", method = RequestMethod.POST) public String postAdminLogin(ModelMap model, @RequestParam(value = "email", required = false) String email, @RequestParam(value = "password", required = false) String password, HttpSession session) { User admin = userService.getUserByEmail(email); String message; if (admin != null){ String mdsPass = DigestUtils.md5DigestAsHex((password + admin.getCode()).getBytes());// if (!mdsPass .equals(admin.getPassword())){// message = "用户密码错误!";// } if (!password .equals(admin.getPassword())){ message = "用户密码错误!"; } else if (admin.getRoleId() != 101){ message = "用户没有权限访问!"; } else { session.setAttribute("admin",admin); return "redirect:/admin/adminPage"; } } else { message = "用户不存在!"; } model.addAttribute("message", message); return "admin/adminLogin"; } @RequestMapping(value = "/adminLogout", method = RequestMethod.GET) public String adminLogout(@RequestParam(required = false, defaultValue = "false" )String adminLogout, HttpSession session){ if (adminLogout.equals("true")){ session.removeAttribute("admin"); }// adminLogout = "false"; return "redirect:/"; } @RequestMapping(value = "/adminPage", method = RequestMethod.GET) public String getAdminPage(ModelMap model, HttpSession session){ User admin = (User) session.getAttribute("admin"); if (admin == null){ return "redirect:/admin/adminLogin"; } ListgoodList = goodService.getAllGoodList(); for (Good good : goodList) { good.setGoodUser(userService.getUserById(good.getUserId())); good.setGoodSecondType(typeService.getSecondTypeById(good.getSecondTypeId())); } List userList = userService.getAllUser(); List firstTypeList = typeService.getAllFirstType(); List orderList = orderService.getOrderList(); model.addAttribute("goodList", goodList); model.addAttribute("userList", userList); model.addAttribute("firstTypeList", firstTypeList); model.addAttribute("orderList", orderList); return "admin/adminPage"; } @RequestMapping(value = "/user/update/status/{statusId}&{userId}", method = RequestMethod.GET) public ResponseEntity updateUserStatus(@PathVariable Integer statusId, @PathVariable Integer userId){ Boolean success = userService.updateUserStatus(statusId, userId); if (success){ List userList = userService.getAllUser(); return ResponseEntity.ok(userList); } return ResponseEntity.ok(success); } @RequestMapping(value = "/user/delete/{userId}", method = RequestMethod.GET) public ResponseEntity deleteUser(@PathVariable Integer userId){ Boolean success = userService.deleteUser(userId); if (success){ List userList = userService.getAllUser(); return ResponseEntity.ok(userList); } return ResponseEntity.ok(success); } }
用户控制层:
@Controller@RequestMapping(value = "user")public class UserController { private final GoodService goodService; private final OrderService orderService; private final ReviewService reviewService; private final UserService userService; private final CollectService collectService; @Autowired public UserController(GoodService goodService, OrderService orderService, ReviewService reviewService, UserService userService, CollectService collectService) { this.goodService = goodService; this.orderService = orderService; this.reviewService = reviewService; this.userService = userService; this.collectService = collectService; } @RequestMapping(value = "userProfile", method = RequestMethod.GET) public String getMyProfile(ModelMap model, HttpSession session) { User user = (User) session.getAttribute("user"); if (user == null) { return "redirect:/"; } Listcollects = collectService .getCollectByUserId(user.getId()); for (Collect collect : collects) { collect.setGood(goodService.getGoodById(collect.getGoodId())); } List goods = goodService.getGoodByUserId(user.getId()); List orders = orderService.getOrderByCustomerId(user.getId()); List reviews = reviewService.gerReviewByToUserId(user.getId()); List replies = reviewService.gerReplyByToUserId(user.getId()); List sellGoods = orderService.getOrderBySellerId(user.getId()); model.addAttribute("collects", collects); model.addAttribute("goods", goods); model.addAttribute("orders", orders); model.addAttribute("reviews", reviews); model.addAttribute("replies", replies); model.addAttribute("sellGoods", sellGoods); return "user/userProfile"; } @RequestMapping(value = "/review", method = RequestMethod.GET) public String getReviewInfo(@RequestParam(required = false) Integer goodId, @RequestParam(required = false) Integer reviewId) { System.out.println("reviewId" + reviewId); if (reviewId != null) { System.out.println("reviewId" + reviewId); if (reviewService.updateReviewStatus(1, reviewId) == 1) { return "redirect:/goods/goodInfo?goodId=" + goodId; } } return "redirect:/user/userProfile"; } @RequestMapping(value = "/reply", method = RequestMethod.GET) public String getReplyInfo( @RequestParam(required = false) Integer reviewId, @RequestParam(required = false) Integer replyId) { if (replyId != null) { if (reviewService.updateReplyStatus(1, replyId) == 1) { Integer goodId = reviewService.getGoodIdByReviewId(reviewId); return "redirect:/goods/goodInfo?goodId=" + goodId; } } return "redirect:/user/userProfile"; } @RequestMapping(value = "/userEdit", method = RequestMethod.GET) public String getUserEdit(ModelMap model, @RequestParam(value = "userId", required = false) Integer userId, HttpSession session) { User sessionUser = (User) session.getAttribute("user"); if (sessionUser == null) { return "redirect:/"; } User user = userService.getUserById(userId); List sellGoods = orderService.getOrderBySellerId(user.getId()); List reviews = reviewService.gerReviewByToUserId(user.getId()); List replies = reviewService.gerReplyByToUserId(user.getId()); model.addAttribute("user", user); model.addAttribute("sellGoods", sellGoods); model.addAttribute("reviews", reviews); model.addAttribute("replies", replies); return "user/userEdit"; } @RequestMapping(value = "/userEdit", method = RequestMethod.POST) public String postUserEdit(ModelMap model, @Valid User user, HttpSession session, @RequestParam(value = "photo", required = false) MultipartFile photo) throws IOException { String status; Boolean insertSuccess; User sessionUser = (User) session.getAttribute("user"); user.setId(sessionUser.getId()); InfoCheck infoCheck = new InfoCheck(); if (!infoCheck.isMobile(user.getMobile())) { status = "请输入正确的手机号!"; } else if (!infoCheck.isEmail(user.getEmail())) { status = "请输入正确的邮箱!"; } else if (userService.getUserByMobile(user.getMobile()).getId() != user .getId()) { System.out.println(userService.getUserByMobile(user.getMobile()) .getId() + " " + user.getId()); status = "此手机号码已使用!"; } else if (userService.getUserByEmail(user.getEmail()).getId() != user .getId()) { status = "此邮箱已使用!"; } else { if (!photo.isEmpty()) { RandomString randomString = new RandomString(); FileCheck fileCheck = new FileCheck(); String filePath = "/statics/image/photos/" + user.getId(); String pathRoot = fileCheck.checkGoodFolderExist(filePath); String fileName = user.getId() + randomString.getRandomString(10); String contentType = photo.getContentType(); String imageName = contentType.substring(contentType .indexOf("/") + 1); String name = fileName + "." + imageName; photo.transferTo(new File(pathRoot + name)); String photoUrl = filePath + "/" + name; user.setPhotoUrl(photoUrl); } else { String photoUrl = userService.getUserById(user.getId()) .getPhotoUrl(); user.setPhotoUrl(photoUrl); } insertSuccess = userService.updateUser(user); if (insertSuccess) { session.removeAttribute("user"); session.setAttribute("user", user); return "redirect:/user/userProfile"; } else { status = "修改失败!"; model.addAttribute("user", user); model.addAttribute("status", status); return "user/userEdit"; } } System.out.println(user.getMobile()); System.out.println(status); model.addAttribute("user", user); model.addAttribute("status", status); return "user/userEdit"; } @RequestMapping(value = "/password/edit", method = RequestMethod.POST) public ResponseEntity editPassword(@RequestBody Password password) { User user = userService.getUserById(password.getUserId()); String oldPass = DigestUtils .md5DigestAsHex((password.getOldPassword() + user.getCode()) .getBytes()); if (oldPass.equals(user.getPassword())) { RandomString randomString = new RandomString(); String code = (randomString.getRandomString(5)); String md5Pass = DigestUtils.md5DigestAsHex((password .getNewPassword() + code).getBytes()); Boolean success = userService.updatePassword(md5Pass, code, password.getUserId()); if (success) { return ResponseEntity.ok(true); } else { return ResponseEntity.ok("密码修改失败!"); } } else { return ResponseEntity.ok("原密码输入不正确!"); } } }
类型控制层:
@Controller@RequestMapping("type")public class TypeController { private final TypeService typeService; private final GoodService goodService; @Autowired public TypeController(TypeService typeService, GoodService goodService) { this.typeService = typeService; this.goodService = goodService; } @RequestMapping(value = "/secondType/{firstTypeId}", method = RequestMethod.GET) public ResponseEntity getSecondTypeId(@PathVariable Integer firstTypeId) { ListsecondTypes = typeService .getSecondTypeByFirstTypeId(firstTypeId); if (secondTypes == null) { return ResponseEntity.ok("isNull"); } return ResponseEntity.ok(secondTypes); } @RequestMapping(value = "/secondType/delete/{secondTypeId}", method = RequestMethod.GET) public ResponseEntity deleteSecondType(@PathVariable Integer secondTypeId) { Boolean success = goodService.getGoodsAdminByType(secondTypeId) .isEmpty(); System.out.println(goodService.getGoodsAdminByType(secondTypeId)); if (success) { Integer thisFirstTypeId = typeService.getSecondTypeById( secondTypeId).getFirstTypeId(); success = typeService.deleteSecondType(secondTypeId); if (success) { List secondTypeList = typeService .getSecondTypeByFirstTypeId(thisFirstTypeId); if (secondTypeList == null) { return ResponseEntity.ok("isNull"); } return ResponseEntity.ok(secondTypeList); } } return ResponseEntity.ok(success); } @RequestMapping(value = "/firstType/delete/{firstTypeId}", method = RequestMethod.GET) public ResponseEntity deleteFirstType(@PathVariable Integer firstTypeId) { Boolean success = typeService.getSecondTypeByFirstTypeId(firstTypeId) .isEmpty(); if (success) { success = typeService.deleteFirstType(firstTypeId); if (success) { List firstTypeList = typeService.getAllFirstType(); if (firstTypeList == null) { return ResponseEntity.ok("isNull"); } return ResponseEntity.ok(firstTypeList); } } return ResponseEntity.ok(success); } @RequestMapping(value = "/secondType/create", method = RequestMethod.POST) public ResponseEntity createSecondType(@RequestBody SecondType secondType) { Integer thisFirstTypeId = secondType.getFirstTypeId(); Boolean success = typeService.createSecondType(secondType); if (success) { List secondTypeList = typeService .getSecondTypeByFirstTypeId(thisFirstTypeId); return ResponseEntity.ok(secondTypeList); } return ResponseEntity.ok(success); } @RequestMapping(value = "/firstType/create", method = RequestMethod.POST) public ResponseEntity createSecondType(@RequestBody FirstType firstType) { Boolean success = typeService.createFirstType(firstType); if (success) { List firstTypeList = typeService.getAllFirstType(); return ResponseEntity.ok(firstTypeList); } return ResponseEntity.ok(success); }}
到此,关于"怎么用Java实现校园跑腿管理系统"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
管理
校园
系统
用户
学习
管理系统
密码
管理员
控制
输入
前端
学生
手机
更多
环境
邮箱
错误
帮助
实用
接下来
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
cisco网络安全
招银软件开发能干几年
lumion连接服务器失败
连接orale数据库
阴阳师连接不到服务器
医院怎么开展网络安全
软件开发师的形象
关于网络技术的高频词
软件开发一个项目做半年
广州的网络安全问题
四川软件开发外包平台
吃鸡怎么选服务器
大学学生网络安全守则心得体会
网络安全周天津主会场
c 模拟登陆并获取数据库
崇明区数据软件开发常见问题
红豆工业互联网公司软件开发
红桥区项目网络技术售后服务
sql数据库收缩对业务
成都的网络安全公司
优客帮软件开发
秦皇岛聚点网络技术
数据库sql的软件
网络安全股奇虎360
网络安全劳动育人
网络安全自查情况报告工作措施
一图软件开发流程
不同的数据库两表同步数据
以色列网络安全知识
网络技术专利数量排名