最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java畢業(yè)設(shè)計實戰(zhàn)之生活旅行分享平臺的實現(xiàn)

 更新時間:2022年02月05日 12:49:19   作者:qq_1334611189  
這是一個使用了java+Springboot+JPA+Jsp+Html+js+Ajax+maven+mysql開發(fā)的生活旅行分享平臺,是一個畢業(yè)設(shè)計的實戰(zhàn)練習(xí),具有分享發(fā)布平臺該有的所有功能,感興趣的朋友快來看看吧

一、項目運行

環(huán)境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

項目技術(shù):

Springboot+ SpringMVC + JPA+ Jsp + Html+ JavaScript + JQuery + Ajax + maven等等

評論業(yè)務(wù)控制器:

/**
 * 評論控制器
 * @author yy
 *
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
 
  @Resource
  private CommentService commentService;
 
  @Resource
  private ArticleService articleService;
 
  @Resource
  private ReplyService replyService;
 
  /**
   * 分頁查詢評論
   * @param comment
   * @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);
    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();
    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  參數(shù)說明
   * @return Map<String,Object>    返回類型
   * @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;
  }
 
}

回復(fù)業(yè)務(wù)控制器:

/**
 * 回復(fù)控制器
 * @author yy
 *
 */
@RestController
@RequestMapping("/reply")
public class ReplyController {
 
  @Resource
  private ReplyService replyService;
 
  /**
   * 獲取回復(fù)
   * @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;
  }
 
  /**
   * 添加回復(fù)
   * @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;
  }
 
}

管理員業(yè)務(wù)控制器:

/**
 * 管理員控制器
 * @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
  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) {
        mav.addObject("errorInfo", "用戶名或者密碼錯誤!");
        mav.setViewName("/login");
      } else {
        session.setAttribute("adminUser", resultUser);
        // 統(tǒng)計用戶總數(shù)
        Long userCount = userService.getCount();
        // 統(tǒng)計今天注冊
        Long userRegCount = userService.getTodayRegistCount(new User(), "1", "1");
        // 統(tǒng)計今日登錄
        Long userLogCount = userService.getCount(new User(), "1", "1");
        // 統(tǒng)計筆記總數(shù)
        Long artCount = articleService.getCount();
        // 統(tǒng)計筆記分類
        Long classCount = classifyService.getCount();
 
        session.setAttribute("userCount", userCount);
        session.setAttribute("userRegCount", userRegCount);
        session.setAttribute("userLogCount", userLogCount);
        session.setAttribute("artCount", artCount);
        session.setAttribute("classCount", classCount);
 
        mav.addObject("success", true);
        mav.setViewName("/admin/index");
      }
    } catch (Exception e) { // 用戶名密碼錯誤
      e.printStackTrace();
      mav.addObject("admin", admin);
      mav.addObject("errorInfo", "用戶名或者密碼錯誤!");
      mav.setViewName("/login");
    }
    return mav;
  }
 
  /**
   * 查看個人信息
   * 
   * @return
   */
  @RequestMapping("viewPerson")
  public ModelAndView viewPerson(HttpServletRequest request) {
    Admin admin = (Admin) request.getSession().getAttribute("adminUser");
    ModelAndView mav = new ModelAndView();
    Admin u = adminService.findById(admin.getAdminId());
    mav.addObject("user", u);
    mav.setViewName("/admin/adminViewPerson");
    return mav;
  }
 
  /**
   * 保存用戶信息
   * 
   * @param user
   * @return
   */
  @RequestMapping("/save")
  public ModelAndView save(Admin user) {
    ModelAndView mav = new ModelAndView();
    adminService.save(user);
    mav.setViewName("/admin/index");
    return mav;
  }
}

用戶業(yè)務(wù)控制器:

/**
 * 用戶控制器
 *
 */
@RestController
@RequestMapping("/admin/user")
public class UserAdminController {
 
  @Resource
  private UserService userService;
 
  @Value("${MD5Salt}")
  private String salt; // md5加密鹽
 
  /**
   * 根據(jù)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; // 結(jié)束時間
    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;
  }
 
  /**
   * 取消關(guān)注
   * @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");// 當(dāng)前登錄用戶
 
    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;
  }
 
  /**
   * 關(guān)注用戶
   * @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");// 當(dāng)前登錄用戶
 
    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");// 當(dāng)前登錄用戶
 
    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");// 當(dāng)前登錄用戶
 
    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");// 當(dāng)前登錄用戶
 
    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;
  }
}

到此這篇關(guān)于Java畢業(yè)設(shè)計實戰(zhàn)之生活旅行分享平臺的實現(xiàn)的文章就介紹到這了,更多相關(guān)Java 生活旅行分享平臺內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 詳解SpringBoot依賴注入和使用配置文件

    詳解SpringBoot依賴注入和使用配置文件

    這篇文章主要介紹了SpringBoot依賴注入和使用配置文件的相關(guān)知識,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2024-01-01
  • Java多線程中的互斥鎖解析

    Java多線程中的互斥鎖解析

    這篇文章主要介紹了Java多線程中的互斥鎖解析,Java語言中,引入了對象互斥鎖的概念,來保證共享數(shù)據(jù)操作的完整性,每個對象都對應(yīng)于一個可稱為互斥鎖的標(biāo)記,這個標(biāo)記用來保證在任一時刻,只能有一個線程訪問該對象,需要的朋友可以參考下
    2023-09-09
  • tk-mybatis整合springBoot使用兩個數(shù)據(jù)源的方法

    tk-mybatis整合springBoot使用兩個數(shù)據(jù)源的方法

    單純的使用mybaits進(jìn)行多數(shù)據(jù)配置網(wǎng)上資料很多,但是關(guān)于tk-mybaits多數(shù)據(jù)源配置沒有相關(guān)材料,本文就詳細(xì)的介紹一下如何使用,感興趣的可以了解一下
    2021-12-12
  • java sqlserver text 類型字段讀取方法

    java sqlserver text 類型字段讀取方法

    有這樣一個需求,需要將原本存儲在數(shù)據(jù)庫中的文檔轉(zhuǎn)存至文件系統(tǒng)中,于是寫了一個簡單的程序完成此功能
    2012-11-11
  • Java 判斷線程池所有任務(wù)是否執(zhí)行完畢的操作

    Java 判斷線程池所有任務(wù)是否執(zhí)行完畢的操作

    這篇文章主要介紹了Java 判斷線程池所有任務(wù)是否執(zhí)行完畢的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08
  • 解析mybatis-plus中的resultMap簡單使用

    解析mybatis-plus中的resultMap簡單使用

    mybatis-plus也只是聽過,可是終究沒有使用過。于是自己花幾天晚上的時間研究mybatis-plus的使用。這篇文章主要介紹了mybatis-plus的resultMap簡單使用,需要的朋友可以參考下
    2021-11-11
  • SpringCloud集成zookeeper實現(xiàn)服務(wù)注冊并訪問功能

    SpringCloud集成zookeeper實現(xiàn)服務(wù)注冊并訪問功能

    zookeeper和eureka一樣,是用于充當(dāng)服務(wù)注冊功能服務(wù)器的一個springcloud插件,這篇文章主要介紹了SpringCloud集成zookeeper實現(xiàn)服務(wù)注冊并訪問,需要的朋友可以參考下
    2022-06-06
  • 詳解SpringBoot如何創(chuàng)建自定義Starter

    詳解SpringBoot如何創(chuàng)建自定義Starter

    Spring Boot的自動配置機制為開發(fā)人員提供了一種輕松集成和配置各種功能的便捷方式,本文將深入探討在Spring Boot中如何創(chuàng)建自定義Starter,為構(gòu)建模塊化且易維護(hù)的應(yīng)用提供有力的支持,需要的朋友可以參考下
    2024-02-02
  • 高內(nèi)聚低耦合原則_動力節(jié)點Java學(xué)院整理

    高內(nèi)聚低耦合原則_動力節(jié)點Java學(xué)院整理

    耦合度就是某模塊(類)與其它模塊(類)之間的關(guān)聯(lián)、感知和依賴的程度,是衡量代碼獨立性的一個指標(biāo),也是軟件工程設(shè)計及編碼質(zhì)量評價的一個標(biāo)準(zhǔn)
    2017-08-08
  • springboot中將日志信息存儲在catalina.base中過程解析

    springboot中將日志信息存儲在catalina.base中過程解析

    這篇文章主要介紹了springboot中將日志信息存儲在catalina.base中過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-09-09

最新評論

石首市| 平南县| 武川县| 沿河| 夏津县| 山丹县| 五原县| 缙云县| 吴堡县| 霸州市| 阿城市| 金门县| 周口市| 商丘市| 石渠县| 大邑县| 昭觉县| 西昌市| 个旧市| 阜平县| 宁夏| 汨罗市| 南雄市| 永定县| 庆元县| 黔南| 遵义市| 湘乡市| 潼南县| 佛冈县| 南丰县| 松阳县| 孟村| 钟祥市| 平定县| 香格里拉县| 吉隆县| 绥阳县| 梅河口市| 通州区| 兰溪市|