一、项目简述
功能:用户的注册登录,美食浏览,美食文化,收藏百 科,趣味问答,食谱等等功能等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
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
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;
}
/**
private 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;
}
}
}
评论控制层:
/**
* 评论Controller层
*
*/
@RestController
@RequestMapping("/admin/comment")
public class CommentAdminController {
@Resource
private CommentService commentService;
@Resource
private UserService userService;
@Resource
private ReplyService replyService;
@Resource
private ArticleService articleService;
/**
* 分页查询评论
* @Title: list
* @param comment 评论实体
* @param commentDates 时间段 (搜索用到)
@RestController
@RequestMapping("/admin/comment")
public class CommentAdminController {
@Resource
private CommentService commentService;
@Resource
private UserService userService;
@Resource
private ReplyService replyService;
@Resource
private ArticleService articleService;
/**
* 分页查询评论
* @Title: list
* @param comment 评论实体
* @param commentDates 时间段 (搜索用到)
* @param page 当前页
* @param limit 每页记录数
* @param trueName 昵称
* @return 参数说明
* @return Map<String,Object> 返回类型
* @throws
*/
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;
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("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);
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(","));
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;
}