Java怎么实现生活旅行分享平台
发表于:2024-11-24 作者:千家信息网编辑
千家信息网最后更新 2024年11月24日,这篇"Java怎么实现生活旅行分享平台"文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇"
千家信息网最后更新 2024年11月24日Java怎么实现生活旅行分享平台
这篇"Java怎么实现生活旅行分享平台"文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇"Java怎么实现生活旅行分享平台"文章吧。
一、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
Springboot+ SpringMVC + JPA+ Jsp + Html+ JavaScript + JQuery + Ajax + maven等等
评论业务控制器:
/** * 评论控制器 * @author yy * */@RestController@RequestMapping("/comment")public class CommentController { @Resource private CommentService commentService; @Resource private ArticleService articleService; @Resource private ReplyService replyService; /** * 分页查询评论 * @param comment * @param page * @param pageSize * @return */ @RequestMapping("/list") public MapcommentList(Comment comment, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "pageSize", required = false) Integer pageSize) { List commentList = commentService.list(comment, null, null, page - 1, pageSize, null); Long total = commentService.getCount(comment, null, null, null); int totalPage = (int) (total % pageSize == 0 ? total / pageSize : total / pageSize + 1); Map resultMap = new HashMap (); resultMap.put("totalPage", totalPage); resultMap.put("data", commentList); return resultMap; } /** * 分页查询评论 * @param page * @param pageSize * @return */ @RequestMapping("/massageList") public Map massageList(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "pageSize", required = false) Integer pageSize) { List commentList = commentService.massageList(page - 1, pageSize); Long total = commentService.getCount2(); int totalPage = (int) (total % pageSize == 0 ? total / pageSize : total / pageSize + 1); Map resultMap = new HashMap (); resultMap.put("totalPage", totalPage); resultMap.put("data", commentList); return resultMap; } /** * 添加评论 * @Title: add * @param comment 评论实体 * @return 参数说明 * @return Map 返回类型 * @throws */ @RequestMapping("/add") public Map add(Comment comment, HttpSession session) { User currentUser = (User) session.getAttribute("user"); Map resultMap = new HashMap (); comment.setCommentDate(new Date()); comment.setUser(currentUser); commentService.add(comment); if (comment.getArticle() != null) { articleService.increaseComment(comment.getArticle().getArticleId()); } resultMap.put("comment", comment); resultMap.put("success", true); return resultMap; } }
回复业务控制器:
/** * 回复控制器 * @author yy * */@RestController@RequestMapping("/reply")public class ReplyController { @Resource private ReplyService replyService; /** * 获取回复 * @param reply * @return */ @RequestMapping("/list") public MapreplyList(Reply reply) { List replyList = replyService.list(reply); Map resultMap = new HashMap (); resultMap.put("data", replyList); return resultMap; } /** * 添加回复 * @param reply * @return */ @RequestMapping("/add") public Map add(Reply reply, HttpSession session) { User currentUser = (User) session.getAttribute("user"); Map resultMap = new HashMap (); reply.setReplyDate(new Date()); reply.setUser(currentUser); replyService.add(reply); resultMap.put("reply", reply); resultMap.put("success", true); return resultMap; } }
管理员业务控制器:
/** * 管理员控制器 * @author yy * */@RestController@RequestMapping("/admin")public class AdminController { @Value("${MD5Salt}") private String salt; // md5加密盐 @Resource private AdminService adminService; @Resource private UserService userService; @Resource private ArticleService articleService; @Resource private ClassifyService classifyService; /** * 后台管理员登录验证 * @param admin * @param request * @return */ @RequestMapping("/login") public ModelAndView login(Admin admin, HttpServletRequest request) { ModelAndView mav = new ModelAndView(); HttpSession session = request.getSession(); try { Admin resultUser = adminService.findByUserNameAndPassword(admin.getUserName(), admin.getPassword()); if (resultUser == null) { mav.addObject("errorInfo", "用户名或者密码错误!"); mav.setViewName("/login"); } else { session.setAttribute("adminUser", resultUser); // 统计用户总数 Long userCount = userService.getCount(); // 统计今天注册 Long userRegCount = userService.getTodayRegistCount(new User(), "1", "1"); // 统计今日登录 Long userLogCount = userService.getCount(new User(), "1", "1"); // 统计笔记总数 Long artCount = articleService.getCount(); // 统计笔记分类 Long classCount = classifyService.getCount(); session.setAttribute("userCount", userCount); session.setAttribute("userRegCount", userRegCount); session.setAttribute("userLogCount", userLogCount); session.setAttribute("artCount", artCount); session.setAttribute("classCount", classCount); mav.addObject("success", true); mav.setViewName("/admin/index"); } } catch (Exception e) { // 用户名密码错误 e.printStackTrace(); mav.addObject("admin", admin); mav.addObject("errorInfo", "用户名或者密码错误!"); mav.setViewName("/login"); } return mav; } /** * 查看个人信息 * * @return */ @RequestMapping("viewPerson") public ModelAndView viewPerson(HttpServletRequest request) { Admin admin = (Admin) request.getSession().getAttribute("adminUser"); ModelAndView mav = new ModelAndView(); Admin u = adminService.findById(admin.getAdminId()); mav.addObject("user", u); mav.setViewName("/admin/adminViewPerson"); return mav; } /** * 保存用户信息 * * @param user * @return */ @RequestMapping("/save") public ModelAndView save(Admin user) { ModelAndView mav = new ModelAndView(); adminService.save(user); mav.setViewName("/admin/index"); return mav; }}
用户业务控制器:
/** * 用户控制器 * */@RestController@RequestMapping("/admin/user")public class UserAdminController { @Resource private UserService userService; @Value("${MD5Salt}") private String salt; // md5加密盐 /** * 根据ID查找用户 * @param userId * @return */ @RequestMapping("/findById") public MapfindById(Integer userId) { Map resultMap = new HashMap (); User user = userService.findById(userId); resultMap.put("errorNo", 0); resultMap.put("data", user); return resultMap; } /** * 分页查询用户 * @param user * @param registrationDates * @param page * @param limit * @return */ @RequestMapping("/list") public Map list(User user, @RequestParam(value = "latelyLoginTimes", required = false) String latelyLoginTimes, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "pageSize", required = false) Integer pageSize) { String s_bregistrationDate = null; // 开始时间 String s_eregistrationDate = null; // 结束时间 if (StringUtil.isNotEmpty(latelyLoginTimes)) { String[] strs = latelyLoginTimes.split(" - "); // 拆分时间段 s_bregistrationDate = strs[0]; s_eregistrationDate = strs[1]; } List userList = userService.list(user, s_bregistrationDate, s_eregistrationDate, page - 1, pageSize); Long total = userService.getCount(user, s_bregistrationDate, s_eregistrationDate); Map resultMap = new HashMap (); resultMap.put("errorNo", 0); resultMap.put("data", userList); resultMap.put("total", total); return resultMap; } @RequestMapping("/delete") public Map delete(Integer userId) { Map resultMap = new HashMap (); userService.delete(userId); resultMap.put("errorNo", 0); return resultMap; } /** * 取消关注 * @param request * @param userId * @return */ @RequestMapping("/removeFocusUser") public ModelAndView removeFocusUser(HttpServletRequest request, String userId) { ModelAndView mav = new ModelAndView(); User user = (User) request.getSession().getAttribute("user");// 当前登录用户 String userIds = user.getUserIds(); List tempList = Arrays.asList(userIds.split(",")); List lineIdList = new ArrayList<>(tempList); lineIdList.remove(userId); String ret = StringUtils.join(lineIdList, ","); user.setUserIds(ret); userService.save(user); mav.setViewName("redirect:/viewFocusUser"); return mav; } /** * 关注用户 * @param request * @param userId * @return */ @RequestMapping("/addFocusUser") public ModelAndView addFocusUser(HttpServletRequest request, String userId) { ModelAndView mav = new ModelAndView(); User user = (User) request.getSession().getAttribute("user");// 当前登录用户 String userIds = user.getUserIds(); List tempList = Arrays.asList(userIds.split(",")); List lineIdList = new ArrayList<>(tempList); lineIdList.add(userId); String ret = StringUtils.join(lineIdList, ","); user.setUserIds(ret); userService.save(user); mav.setViewName("redirect:/viewFocusUser"); return mav; } @RequestMapping("/addFocusUser/{userId}") public ModelAndView addFocusUser(@PathVariable(value = "userId", required = false) Integer userId, HttpSession session) { ModelAndView mav = new ModelAndView(); User user = (User) session.getAttribute("user");// 当前登录用户 String userIds = user.getUserIds(); List tempList = new ArrayList<>(); if (userIds != null) { tempList = Arrays.asList(userIds.split(",")); } List lineIdList = new ArrayList<>(tempList); lineIdList.add(userId.toString()); String ret = StringUtils.join(lineIdList, ","); user.setUserIds(ret); userService.save(user); mav.setViewName("redirect:/viewFocusUser"); return mav; } /** * 取消收藏 * @param request * @param userId * @return */ @RequestMapping("/removeCollection") public ModelAndView removeCollection(HttpServletRequest request, String artId) { ModelAndView mav = new ModelAndView(); User user = (User) request.getSession().getAttribute("user");// 当前登录用户 String artIds = user.getArticleIds(); List tempList = Arrays.asList(artIds.split(",")); List lineIdList = new ArrayList<>(tempList); lineIdList.remove(artId); String ret = StringUtils.join(lineIdList, ","); user.setArticleIds(ret); userService.save(user); mav.setViewName("redirect:/viewCollection"); return mav; } /** * 收藏 * @param request * @param userId * @return */ @RequestMapping("/addCollection") public ModelAndView addCollection(HttpServletRequest request, String artId) { ModelAndView mav = new ModelAndView(); User user = (User) request.getSession().getAttribute("user");// 当前登录用户 String artIds = user.getArticleIds(); List tempList = Arrays.asList(artIds.split(",")); List lineIdList = new ArrayList<>(tempList); lineIdList.add(artId); String ret = StringUtils.join(lineIdList, ","); user.setArticleIds(ret); userService.save(user); mav.setViewName("redirect:/viewCollection"); return mav; }}
以上就是关于"Java怎么实现生活旅行分享平台"这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注行业资讯频道。
用户
控制器
控制
登录
评论
内容
统计
业务
平台
旅行
生活
密码
时间
用户名
管理员
错误
查询
管理
信息
总数
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
服务器内存是啥意思
燃烧的远征奥金斧服务器怎么样
ih数据库免费点数
同花顺软件开发需要多少钱
吴江区正规软件开发口碑推荐
服务器主机买来干什么
北京网络安全产业园
.网络安全应急指挥平台建设
近三年中国数据库大会
南理工数据库基础试卷
梦幻西游2新开服务器
衡阳真友软件开发有限公司
软件开发人员职业分析
阿里云服务器装虚拟机
战地2042哪个服务器延迟低
职教网络安全
hp二手服务器
新罗区通透陪网络技术服务部
网络安全英文缩写
数控机床维护保养数据库
ios软件开发环境
数据库技术与大数据关系
关于军队网络安全ppt课件
后台服务器问题
mysql数据库恢复数据
数据库bak文件应用什么打开
苹果怎么完全清除数据库
甲骨文服务器最新注册教程
服务器管理口ip怎么改
耕地质量等级评定数据库