基于javaweb+springboot的生活旅行分享平台(java+Springboot+JPA+Jsp+Html+js+Ajax+maven+mysql)

一、项目运行

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

项目技术:
Springboot+ SpringMVC + JPA+ Jsp + Html+ JavaScript + JQuery + Ajax + maven等等请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

   * @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;
  }
}
评论业务控制器:
/**
 * 评论控制器
 * @author yy
    mav.setViewName("redirect:/viewCollection");
    return mav;
  }
}
评论业务控制器:
/**
 * 评论控制器
 * @author yy
 *
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
  @Resource
  private CommentService commentService;
  @Resource
  private ArticleService articleService;
  @Resource
  private ReplyService replyService;
  /**
  @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) {
/**
 * 管理员控制器
 * @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
    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
    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,
                                         @RequestParam(value = "pageSize", required = false) Integer pageSize) {
    List<Comment> commentList = commentService.massageList(page - 1, pageSize);
    Long total = commentService.getCount2();
      @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);
用户业务控制器:
/**
 * 用户控制器
 *
 */
@RestController
@RequestMapping("/admin/user")
public class UserAdminController {
  @Resource
  private UserService userService;
  @Value("${MD5Salt}")
  private String salt; // md5加密盐
  /**
   * 根据ID查找用户
   * @param userId
   * @return
   */
  @RequestMapping("/findById")
 *
 */
@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;
  }
    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 Map<String, Object> replyList(Reply reply) {
    List<Reply> replyList = replyService.list(reply);
    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("data", replyList);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值