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

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

一、项目简述

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

二、项目运行

环境配置: 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 {

  @Resource
  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;
  }

  /**
   * 分页查询用户
   * @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 {

  @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
   */
  @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 {

  @Resource
  private 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;
  }

}

 

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

前端: 1.游客模式(可以观看店家信息) 2.用户登录后可以进行点餐,点餐后可以对菜和店家进行点评进行点评,结账 3.订座 4.个人信息管理 后端: 1.五表权限(员工登录做菜,老板登录观看用户记录和菜铺 管理,订单管理) 2.菜谱管理(增删查改),菜系管理 3.统计菜的点击次数,评价,用户消费总金额,最后一次消费时间 1.用户表:user userId(用户id),userName(用户名),password(密码), createTime(创建时间),lastTime(最后一次登录时间),number 预留号码 2.角色表:role roleId(角色id),roleName(角色名称) 3.权限表:authority 权限id(authorityId),权限名称(authorityId),权限地址(url) 4.用户角色表:user_role 用户id(userId),角色id(roleId) 5.角色权限表:role_authority 角色id(roleId),权限Id(authorityId) 6.消费记录表:record 用户id(userId),用户名称(userName), 消费时间(consumptionTime),消费金额(consumptionMoney) 7.订单表:indent 下单id(indentId),下单用户(userName),下单时间 (indentTime),下单菜谱(menuName) 8.菜谱表:menu 菜谱Id(menuId),菜谱名称(menuName),价格(price),菜系 Id(vegetableId), 图片地址(picture),用户购买量 (userCount),好评数量(good), 一 般数量(general),差 评数量(bad),增加时间(addTime) 9.菜系表:vegetableType 菜系id(vegetableId),菜系名称(vegetableName),增加时间 (addTime) 10.评价表:evaluate 用户id(userId),评价菜谱名(menuName),评价内容 (evaluateContent),评价时间(evaluateTime) 原生态系列,底层代码更好的了解整个项目所需要的哪些细节 具体功能还有很多,就不一一描述了, 希望能帮到大家。
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

beyondwild

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值