Java项目:在线美食网站系统(java+SSM+jsp+mysql+maven)

news/2024/5/9 11:39:49/文章来源:https://blog.csdn.net/pastclouds/article/details/118572604

源码获取:博客首页 "资源" 里下载!

一、项目简述

功能:用户的注册登录,美食浏览,美食文化,收藏百 科,趣味问答,食谱等等功能等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等。

用户控制器:

/*** 用户控制器**/
@RestController
@RequestMapping("/admin/user")
public class UserAdminController {@Resourceprivate UserService userService;@Value("${MD5Salt}")private String salt; // md5加密盐/*** 根据ID查找用户* @param userId* @return*/@RequestMapping("/findById")public Map<String, Object> findById(Integer userId) {Map<String, Object> resultMap = new HashMap<String, Object>();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<String, Object> 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<User> userList = userService.list(user, s_bregistrationDate, s_eregistrationDate, page - 1, pageSize);Long total = userService.getCount(user, s_bregistrationDate, s_eregistrationDate);Map<String, Object> resultMap = new HashMap<String, Object>();resultMap.put("errorNo", 0);resultMap.put("data", userList);resultMap.put("total", total);return resultMap;}@RequestMapping("/delete")public Map<String, Object> delete(Integer userId) {Map<String, Object> resultMap = new HashMap<String, Object>();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<String> tempList = Arrays.asList(userIds.split(","));List<String> 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<String> tempList = Arrays.asList(userIds.split(","));List<String> 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<String> tempList = new ArrayList<>();if (userIds != null) {tempList = Arrays.asList(userIds.split(","));}List<String> 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<String> tempList = Arrays.asList(artIds.split(","));List<String> 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<String> tempList = Arrays.asList(artIds.split(","));List<String> lineIdList = new ArrayList<>(tempList);lineIdList.add(artId);String ret = StringUtils.join(lineIdList, ",");user.setArticleIds(ret);userService.save(user);mav.setViewName("redirect:/viewCollection");return mav;}
}

评论控制层:

/*** 评论Controller层**/
@RestController
@RequestMapping("/admin/comment")
public class CommentAdminController {@Resourceprivate CommentService commentService;@Resourceprivate UserService userService;@Resourceprivate ReplyService replyService;@Resourceprivate ArticleService articleService;/*** 分页查询评论* @Title: list  * @param comment  评论实体* @param commentDates  时间段 (搜索用到)* @param page  当前页* @param limit  每页记录数* @param trueName  昵称* @return  参数说明 * @return Map<String,Object>    返回类型 * @throws*/@RequestMapping("/list")public Map<String, Object> list(Comment comment,@RequestParam(value = "commentDates", required = false) String commentDates,@RequestParam(value = "page", required = false) Integer page,@RequestParam(value = "pageSize", required = false) Integer pageSize,@RequestParam(value = "nickname", required = false) String nickname) {String s_bCommentDate = null; // 开始时间String s_eCommentDate = null; // 结束时间if (StringUtil.isNotEmpty(commentDates)) {String[] strs = commentDates.split(" - "); // 拆分时间段s_bCommentDate = strs[0];s_eCommentDate = strs[1];}Integer userId = null;Map<String, Object> resultMap = new HashMap<String, Object>();if (StringUtil.isNotEmpty(nickname)) {User user = userService.findByTrueName(nickname);if (user != null) {userId = user.getUserId();}if (userId == null) {resultMap.put("errorInfo", "用户昵称不存在,没有评论!");} else {resultMap.put("errorNo", 0);}} else {resultMap.put("errorNo", 0);}List<Comment> commentList = commentService.list(comment, s_bCommentDate, s_eCommentDate, page - 1, pageSize,userId);Long total = commentService.getCount(comment, s_bCommentDate, s_eCommentDate, userId);resultMap.put("data", commentList);resultMap.put("total", total);return resultMap;}/*** 删除评论* @param ids* @return*/@RequestMapping("/delete")public Map<String, Object> delete(@RequestParam(value = "commentId") String ids) {String[] idsStr = ids.split(","); // 拆分ids字符串Map<String, Object> resultMap = new HashMap<String, Object>();for (int i = 0; i < idsStr.length; i++) {Integer articleId = commentService.getArticleId(Integer.parseInt(idsStr[i]));commentService.delete(Integer.parseInt(idsStr[i]));if (articleId != null) {articleService.reduceComment(articleId);}}resultMap.put("errorNo", 0);resultMap.put("data", 1);return resultMap;}}

回复控制器:

/*** 回复控制器**/
@RestController
@RequestMapping("/reply")
public class ReplyController {@Resourceprivate ReplyService replyService;/*** 获取回复* @param reply* @return*/@RequestMapping("/list")public Map<String, Object> replyList(Reply reply) {List<Reply> replyList = replyService.list(reply);Map<String, Object> resultMap = new HashMap<String, Object>();resultMap.put("data", replyList);return resultMap;}/*** 添加回复* @param reply* @return*/@RequestMapping("/add")public Map<String, Object> add(Reply reply, HttpSession session) {User currentUser = (User) session.getAttribute("user");Map<String, Object> resultMap = new HashMap<String, Object>();reply.setReplyDate(new Date());reply.setUser(currentUser);replyService.add(reply);resultMap.put("reply", reply);resultMap.put("success", true);return resultMap;}}

源码获取:博客首页 "资源" 里下载!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_700678.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

关于大型网站技术演进的思考(五)--存储的瓶颈(5)

上文里我遗留了两个问题&#xff0c;一个问题是数据库做了水平拆分以后&#xff0c;如果我们对主键的设计采取一种均匀分布的策略&#xff0c;那么它对于被水平拆分出的表后续的查询操作将有何种影响&#xff0c;第二个问题就是水平拆分的扩容问题。这两个问题在深入下去&#…

5个在线调试代码的网站

对于编程开发的人来说&#xff0c;有个快速测试代码的地方是非常方便重要的&#xff0c;这里&#xff0c;我们收集了5个很好用的在线调试网站。 1.codepad 是一款简单的在线 IDE 编辑器服务&#xff0c;你只需要把代码粘贴进去就可以编译运行了&#xff0c;连工程也不需要新建&…

[转载]从100PV到1亿级PV网站架构演变

首页最新文章在线课程业界开发IT技术设计创业IT职场投稿更多 - 导航条 -首页最新文章在线课程业界开发- Web前端- Python- Android- iOS- Java- C/C- PHP- Ruby- GoIT技术- Linux- UNIX- MySQL- NoSQL- 数据库- Git- 算法- 测试- 信息安全- Vim设计- 网页设计- UI设计- 交互设计…

1h2g云服务器做网站,云服务器1h2g

云服务器1h2g 内容精选换一换IP地址组是多个IP地址的集合&#xff0c;可被安全组规则引用&#xff0c;可统一管理具有相同安全要求或需要频繁修改的IP地址。通过使用IP地址组&#xff0c;可有效应对需要重复多次编辑安全组规则的场景&#xff0c;方便管理。您需要先创建一个IP地…

VS2013自带的Browser Link功能引发浏览localhost网站时不停的轮询

浏览localhost网站时候不管你打开那个页面它都会不停的轮询。据悉这是VS2013自带的Browser Link功能&#xff0c;里面用到SignalR机制什么是Browser Link功能&#xff0c;什么是SignalR机制大家可以没事去百度了解一下。Browser Link功能讲解地址&#xff1a;http://www.cxyclu…

method=post 怎么让查看源代码看不到_网站文档不能复制怎么办?教你3个小妙招,1分钟轻松化解...

不知道大家平常在查找资料时&#xff0c;碰到网页资料不能下载时&#xff0c;是怎么样进行处理的。那么笔者今天就来分享我查找不能复制文档时&#xff0c;所用的3个小妙招&#xff0c;帮助轻松化解&#xff0c;一起来看看吧。1、保存网页当我们遇到一个不能直接复制的文档&…

自定义html托管,10分钟搞定“傻瓜式”的静态网站搭建托管之旅

原文发布于微信公众号&#xff1a;腾讯云存储(关注有惊喜)静态网站&#xff1a;有别于动态网站&#xff0c;它就是只包含静态内容(如图片、音频、视频、HTML、CSS、JS)的网站&#xff0c;不依赖服务器端动态渲染页面。那么静态网站托管应该如何使用呢&#xff1f;今天就和大家分…

idea运行jsp显示源码_基于jsp+mysql+Spring+mybatis的SSM在线个人PC电脑商城平台网站系统...

运行环境: 最好是java jdk 1.8&#xff0c;我们在这个平台上运行的。其他版本理论上也可以。IDE环境&#xff1a; Eclipse,Myeclipse,IDEA都可以tomcat环境&#xff1a; Tomcat 7.x,8.x,9.x版本均可硬件环境&#xff1a; windows 7/8/10 1G内存以上主要功能说明&#xff1a; 管…

埃森哲java开发怎么样_花费2亿,耗时2年,网站还没建完,咨询公司埃森哲被告上法庭!...

本文作者&#xff1a;靠谱的小灶君全文共3158字&#xff0c;预计阅读8分钟耗费2个多亿&#xff0c;耗时2年多连一个可用的网站都无法交付想要完工?那就再交1000万美元美国汽车租赁公司赫兹(Hertz)一怒之下将知名咨询公司埃森哲告上法庭*Hertz 诉讼部分截图“坑爹啊&#xff0c…

网站收录工具(php导航自动收录源码)_网站如何快速收录,网站不收录怎么办?...

经常有朋友说怎么快速收录&#xff0c;网站不收录怎么收录&#xff1f;&#xff1f;其实&#xff0c;网站不包括一般的新网站数量&#xff0c;没有SEO基础&#xff0c;SEO了解合作伙伴经常会遇到问题&#xff0c;甚至很多人会告诉你&#xff0c;不包括网站引流&#xff0c;导致…

编写纳新网站后端的相关知识总结

使用HSSFWorkbook导出数据库中的数据 导入Apache POI Maven jar包 <!-- Apache POI --> <dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.6</version> </dependency>在控制层编…

qq浏览器网页翻译_科研利器 | NCBI网站影响因子与网页翻译插件安装指南

小编说在平时的科研工作中&#xff0c;善用各类工具能帮助我们提升科研效率&#xff0c;而浏览器的插件与各类软件相比&#xff0c;更加便捷、并且不会占用电脑内存。今天推荐两款浏览器增强插件&#xff0c;提高效率妥妥的~Scholarscope1、进入官网https://www.scholarscope.c…

c语言可视化_这些算法可视化网站助你轻松学算法

前言无疑&#xff0c;数据结构与算法学习最大的难点之一就是如何在脑中形象化其抽象的逻辑步骤。而图像在很多时候能够大大帮助我们理解其对应的抽象化的东西&#xff0c;而如果这个图像还是我们自己一点点画出来的&#xff0c;那么无疑这个印象是最深刻的了。没错&#xff0c;…

网站信息统计的简单实现过程

作者&#xff1a; pcskySQL语句如下&#xff1a; SELECT DD.SumHits, AA.CountArt, CC.WeekUpdate, BB.RegUserNumFROM(SELECT COUNT(newsid) AS CountArt FROM article) AA,(SELECT COUNT(id) AS RegUserNum FROM Admin) BB,(SELECT COUNT(newsid) AS WeekUpdate FROM(articl…

艾宾浩斯计划表自动生成网站_施工进度计划表横道图,自动出图超方便,建议收藏...

横道图&#xff0c;是一种非常实用的图表类型。施工进度计划的制定在工程项目里是很重要的&#xff0c;这可以大大提高施工单位的管理水平&#xff0c;是项目施工必备。作为一个在工地摸爬滚打好几年的人来说&#xff0c;这些更是不可或缺的。几年下来&#xff0c;也整理了好多…

emoji 乱码_这个自制emoji的网站,让你成为永远不输的斗图王者

作为表情界的元老级人物&#xff0c;不管是苹果官网输入法、微信官方表情还是各个主流输入法里&#xff0c;我们都可以从里面找到大量 emoji 表情。然鹅……就算这么多表情&#xff0c;小帮每次发 emoji 时还有有些选择困难。因为翻遍所有表情&#xff0c;都没法找到合适的啊&a…

服务器怎么设置网站写入权限,如何设置服务器写入权限设置方法

如何设置服务器写入权限设置方法 内容精选换一换将用户组添加至企业项目中&#xff0c;并为其设置一定的权限策略&#xff0c;该用户组中的用户即可拥有策略定义的对该企业项目中资源的使用权限。本小节指导您如何为企业项目添加用户组并授权。分辨率低的情况下单击页面右上方的…

mvc的宿舍管理系统源码 基于jsp_[源码和文档分享]基于JSP的MVC框架实现的图书推荐系统展示平台网站...

推荐系统是目前互联网中最常见的一种智能产品形式。由于网络中信息量的快速增长以及图书出版行业出版量的攀升&#xff0c;人们需要一种办法&#xff0c;来解决信息过载的问题。此外&#xff0c;用户访问网络是为了获取信息&#xff0c;但并不是所有的访问都有很强的目的性&…

给网站管理员的建议:创建可利用的、可抓取的网站

转载自 谷歌中文网站管理员博客 发表者 T.V. Raman&#xff0c;研究学者 原文&#xff1a; Webmaster tips for creating accessible, crawlable sites 发表于&#xff1a;2008年4月14日 上午10:47 Hubbell和我正在我们位于加州的家中度假。欢迎您随时 阅读在此之前我为网站管…

高并发高流量网站架构

Web2.0的兴起&#xff0c;掀起了互联网新一轮的网络创业大潮。以用户为导向的新网站建设概念&#xff0c;细分了网站功能和用户群&#xff0c;不仅成功的造就了一大批新生的网站&#xff0c;也极大的方便了上网的人们。但Web2.0以用户为导向的理念&#xff0c;使得新生的网站有…