基于javaweb+springboot的美食菜谱分享平台系统设计和实现(java+springboot+mysql+ssm)
主要技术实现:spring、 springmvc、 springboot、mybatis 、session、 jquery 、 md5 、bootstarp.js tomcat、拦截器等。
具体主要功能模块如下:
1.用户模块管理:用户登录、用户注册、用户的查询、添加、删除操作、
2.美食分享笔记管理:分享笔记列表的展示、添加、修改、删除操作、
3.美食笔记详情管理:美食笔记详情列表的查看、添加、删除等操作、
4.管理员信息管理:管理员信息的查看、修改、
5.公告信息管理:公告信息的查看、添加、修改、删除操作、
6.用户模块管理:用户列表查询、添加、删除、
7.用户评论模块管理:用户评论查询、添加、删除、
8.注销退出登录管理
给大家截一部分效果图吧
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
public Map<String, Object> ckeditorUpload(@RequestParam("file") MultipartFile file) {
Map<String, Object> resultMap = new HashMap<String, Object>();
Map<String, Object> resultMap1 = new HashMap<String, Object>();
String fileName = file.getOriginalFilename(); // 获取文件名
String suffixName = fileName.substring(fileName.lastIndexOf(".")); // 获取文件的后缀
String newFileName = "";
try {
newFileName = DateUtil.getCurrentDateStr() + suffixName; // 新文件名
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(imageFilePath + newFileName)); // 上传
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
resultMap.put("code", 0);
resultMap1.put("filePath", newFileName);
resultMap.put("data", resultMap1);
return resultMap;
}
}
评论控制器:
/**
* 评论控制器
}
ids = ids.substring(0, ids.length() -1);
user.setArticleIds(ids);
userService.save(user);
return "webLogin";
}
/**
* 退出登录
*
* @param request
* @return
*/
@RequestMapping("/quit")
public String quit(HttpServletRequest request) {
HttpSession session = request.getSession();
session.removeAttribute("user");
}
Map<String, Object> monthMap = (Map<String, Object>) yearMap.get("month");
if (null == monthMap) {
monthMap = new LinkedHashMap<String, Object>();
}
List<Map<String, Object>> monthList = (List<Map<String, Object>>) monthMap.get(map.getMonth());
if (null == monthList) {
monthList = new ArrayList<>();
}
monthMap.remove(map.getMonth());
Map<String, Object> obj = new HashMap<>();
obj.put("create_time", DateUtil.formatDate(map.getPublishDate(), "MM月dd日 hh:mm"));
obj.put("content", map.getContent());
monthList.add(obj);
monthMap.put(map.getMonth(), monthList);
yearMap.remove("month");
yearMap.put("month", monthMap);
jsonMap.remove(map.getYear());
jsonMap.put(map.getYear(), yearMap);
}
@RequestMapping("/timeline")
public class TimelineController {
@Resource
private TimelineService timelineService;
/**
* 查询时光轴
* @param page
* @param pageSize
* @return
*/
@RequestMapping("/list")
public Map<String, Object> list2() {
Map<String, Object> resultMap = new HashMap<>();
List<Timeline> maps = timelineService.list(null, 0, 100);
if (CollectionUtils.isNotEmpty(maps)) {
/**
* 根路径以及其他请求处理
*
*/
@Controller
public class IndexController {
@Value("${imageFilePath}")
private String imageFilePath; // 文件路径
@Resource
private NoticeService noticeService;
@Resource
private UserService userService;
@Resource
/**
* 退出登录
*
* @param request
* @return
*/
@RequestMapping("/quitAdmin")
public String quitAdmin(HttpServletRequest request) {
HttpSession session = request.getSession();
session.removeAttribute("user");
return "login";
}
/**
* 验证登录
*
* @param user
* @param request
* @return
*/
@RequestMapping("/checkLogin")
monthList.add(obj);
monthMap.put(map.getMonth(), monthList);
yearMap.remove("month");
yearMap.put("month", monthMap);
jsonMap.remove(map.getYear());
jsonMap.put(map.getYear(), yearMap);
}
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
for (Map.Entry<String, Object> entry : jsonMap.entrySet()) {
datas.add((Map<String, Object>) entry.getValue());
}
resultMap.put("datas", datas);
resultMap.put("result", 1);
}else {
resultMap.put("data", "还没有时光轴数据!");
public String login() {
return "login";
}
/**
* 前台登录页面
*
* @return
*/
@RequestMapping("/webLogin")
public String webLogin() {
return "webLogin";
}
/**
* 注册
*
* @return
*/
@RequestMapping("/regist")
*
* @return
*/
@RequestMapping("/regist")
public String regist() {
return "regist";
}
/**
* 保存注册信息
*
* @param user
* @return
*/
@RequestMapping("/saveUser")
public String saveUser(User user) {
List<Article> randomArticle = articleService.getRandomArticle(3);
String ids="";
for (int i = 0; i < randomArticle.size(); i++) {
Integer articleId = randomArticle.get(i).getArticleId();
ids+=articleId+",";
}
private NoticeService noticeService;
@Resource
private UserService userService;
@Resource
private ArticleService articleService;
@Resource
private ClassifyService classifyService;
@RequestMapping("/")
public String index(HttpSession session) {
// 查询公告
session.setAttribute("noticeList", noticeService.list(0, 5));
return "index";// 跳转到index.html
@RequestMapping("/save")
public ModelAndView save(User user) {
ModelAndView mav = new ModelAndView();
userService.save(user);
mav.setViewName("/index");
return mav;
}
/**
* 写笔记页面
*
* @param request
* @return
*/
// @RequestMapping("notePage")
// public String notePage(HttpServletRequest request, Model model) {
// User user = (User) request.getSession().getAttribute("user");
// if (user == null) {
// return "webLogin";
// }
// List list = classifyService.findAll();
// model.addAttribute("list", list);
int totalPage = (int) (total % pageSize == 0 ? total / pageSize : total / pageSize + 1);
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("totalPage", totalPage);
resultMap.put("data", commentList);
return resultMap;
}
/**
* 添加评论
* @Title: add
* @param comment 评论实体
* @return 参数说明
* @return Map 返回类型
* @throws
*/
@RequestMapping("/add")
public Map<String, Object> add(Comment comment, HttpSession session) {
User currentUser = (User) session.getAttribute("user");
Map<String, Object> resultMap = new HashMap<String, Object>();
comment.setCommentDate(new Date());
comment.setUser(currentUser);
commentService.add(comment);
if (comment.getArticle() != null) {
}
List<Article> retArt = articleService.findByListId(retIds);
session.setAttribute("noticeList", noticeService.list(0, 5));
mav.addObject("retArt", retArt);
mav.addObject("user", u);
mav.setViewName("/viewCollection");
return mav;
}
/**
* 查看个人关注用户
*
* @return
*/
@RequestMapping("viewFocusUser")
public ModelAndView viewFocusUser(HttpServletRequest request, HttpSession session) {
User user = (User) request.getSession().getAttribute("user");
ModelAndView mav = new ModelAndView();
User u = userService.findById(user.getUserId());
resultMap.put("errorNo", 0);
return resultMap;
}
/**
* 登录页面
*
* @return
*/
@RequestMapping("/login")
public String login() {
return "login";
}
/**
* 前台登录页面
*
* @return
*/
@RequestMapping("/webLogin")
public String webLogin() {
return "webLogin";
}
if (CollectionUtils.isNotEmpty(maps)) {
Map<String, Object> jsonMap = new LinkedHashMap<String, Object>();
for (Timeline map : maps) {
Map<String, Object> yearMap = (Map<String, Object>) jsonMap.get(map.getYear());
if (null == yearMap) {
yearMap = new LinkedHashMap<String, Object>();
yearMap.put("year", map.getYear());
}
Map<String, Object> monthMap = (Map<String, Object>) yearMap.get("month");
if (null == monthMap) {
monthMap = new LinkedHashMap<String, Object>();
}
List<Map<String, Object>> monthList = (List<Map<String, Object>>) monthMap.get(map.getMonth());
if (null == monthList) {
monthList = new ArrayList<>();
}
* @throws
*/
@RequestMapping("/add")
public Map<String, Object> add(Comment comment, HttpSession session) {
User currentUser = (User) session.getAttribute("user");
Map<String, Object> resultMap = new HashMap<String, Object>();
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;
}
}
时光轴控制器:
/**
* 时光轴控制器
}
}
时光轴控制器:
/**
* 时光轴控制器
*
*/
@RestController
@RequestMapping("/timeline")
public class TimelineController {
@Resource
private TimelineService timelineService;
/**
* 查询时光轴
for (Map.Entry<String, Object> entry : jsonMap.entrySet()) {
datas.add((Map<String, Object>) entry.getValue());
}
resultMap.put("datas", datas);
resultMap.put("result", 1);
}else {
resultMap.put("data", "还没有时光轴数据!");
}
return resultMap;
}
}
/**
* 注册
*
* @return
*/
@RequestMapping("/regist")
public String regist() {
return "regist";
}
/**
* 保存注册信息
*
* @param user
* @return
*/
@RequestMapping("/saveUser")
public String saveUser(User user) {
return "/common/index";
}
/**
* 博主信息页面
*
* @return
*/
@RequestMapping("/blogger")
public String blogger() {
return "/blogger/index";
}
/**
* 图片上传处理 @Title: ckeditorUpload @param file 图片文件 @return 参数说明 @return
* 前台登录页面
*
* @return
*/
@RequestMapping("/webLogin")
public String webLogin() {
return "webLogin";
}
/**
* 注册
* 保存注册信息
*
* @param user
* @return
*/
@RequestMapping("/saveUser")
public String saveUser(User user) {
List<Article> randomArticle = articleService.getRandomArticle(3);
String ids="";
for (int i = 0; i < randomArticle.size(); i++) {
Integer articleId = randomArticle.get(i).getArticleId();
ids+=articleId+",";
}
ids = ids.substring(0, ids.length() -1);
user.setArticleIds(ids);
userService.save(user);
return "webLogin";
}
/**
* 退出登录
*
* @param request
* @return
*/
@RequestMapping("/blogger")
public String blogger() {
return "/blogger/index";
}
/**
* 图片上传处理 @Title: ckeditorUpload @param file 图片文件 @return 参数说明 @return
* Map 返回类型 @throws
*/
@ResponseBody
@RequestMapping("/upload")
public Map<String, Object> ckeditorUpload(@RequestParam("file") MultipartFile file) {
Map<String, Object> resultMap = new HashMap<String, Object>();
* @param page
* @param pageSize
* @return
*/
@RequestMapping("/list")
public Map<String, Object> commentList(Comment comment, @RequestParam(value = "page", required = false) Integer page,
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
List<Comment> 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<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("totalPage", totalPage);
List<Comment> 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<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("totalPage", totalPage);
resultMap.put("data", commentList);
return resultMap;
}
/**
* 分页查询评论
* @param page
* @param pageSize
* @return
*/
@RequestMapping("/massageList")
public Map<String, Object> massageList(@RequestParam(value = "page", required = false) Integer page,
return resultMap;
}
}
时光轴控制器:
/**
* 时光轴控制器
*
*/
@RestController
@RequestMapping("/timeline")
public class TimelineController {
@Resource
private TimelineService timelineService;
/**
* 查询时光轴
* @param page
* @param pageSize
* @return
*/
return mav;
}
/**
* 查看个人信息
*
* @return
*/
@RequestMapping("viewPerson")
public ModelAndView viewPerson(HttpServletRequest request) {
User user = (User) request.getSession().getAttribute("user");
ModelAndView mav = new ModelAndView();
User u = userService.findById(user.getUserId());
mav.addObject("user", u);
适用
课程设计,大作业,毕业设计,项目练习,学习演示等