基于java+springboot+layui的流浪动物交流信息平台设计实现
🍅 作者主頁:Java李楊勇?
🍅 簡介:Java領域優質創作者🏆、【java李楊勇】公號作者? ?簡歷模板、學習資料、面試題庫【關注我,都給你】
🍅文末獲取源碼聯系和送書🍅
前言介紹:
? ? ? ? ? 漫步校園中,偶爾會看到幾只貓,或是晃做在小道上,或是蜷作一團躺在花壇邊上,就像是無家可歸的可憐的孩子,真叫人心疼!其實,它們就是一些被人遺棄的流浪寵物。 流浪寵物是指無主、長期在野外生存的寵物。與野貓(狗)不同,流浪寵物特指那些曾被人們收養過,后來因為某些原因、被拋棄的寵物。某些原因,可能是因為主人的喬遷,可能是經濟跟不上,也可能只是主人不喜歡了,就遺棄了。事實上,在全國社會各地,還有許許多多同他們一樣遭遇被遺棄的命運的可憐的貓兒狗兒。 校園里的這些貓兒,算是比較幸運的,因為經常有好心的同學會給它們喂一些吃的,它們還不至于餓死。另外的那些流浪寵物,不僅失去了溫暖的家,失去了主人的關愛,就連基本的餐餉都成了問題。
在現在貓狗等小動物自被馴化以來,作為人類的伙伴,他們也有自己的理智與情感,我們應該給予充分的尊重和關懷。但是隨著社會經濟的發展,貓狗等小動物數量日益增多、部分人們的嫌棄和遺棄,流浪動物越來越多。這就需要社會機構或者熱心人士關懷和救助這些流浪動物。在社會網絡化的背景下,推進人與動物和諧共處符合時代特點。而我們開發一個自愿救助流浪動物網站能夠為一些機構和愛心人士提供平臺,讓小寵物們能更好的找到主人使它們也更容易的生存下去。同時,也可以為一些不愿意繼續養寵物的主人提供轉讓服務。提高人們的動物保護意識,動物也是大自然的一員人們應該保護它們,倡導愛護動物的社會風氣,促進人與動物更和諧的相處。因此,本課題的研究符合時代現狀,將為營造一個人與自然動物生命體和諧共處的良好社會環境走出一小步。
技術工具:
開發工具:IDEA 2021.3、navicat for mysql 、postman。
開發語言:java、jdk1.8、mysql5。
硬件環境:Windows 10操作系統、Google瀏覽器等。
主要技術:springboot、mybatis-plus、layui、mysql等
模塊設計:
1.用戶模塊管理:用戶登錄、用戶注冊、用戶的查詢、刪除操作、
2.流浪動物首頁管理:首頁列表的展示、添加、修改、刪除操作、
3.流浪動物信息詳情管理:流浪動物信息詳情列表的查看、添加、刪除等操作、
4.管理員信息管理:管理員信息的查看、修改、
5.公告信息管理:公告信息的查看、添加、修改、刪除操作、
6.用戶模塊管理:用戶列表查詢、添加、刪除、、
7.用戶評論模塊管理:用戶評論查詢、添加、刪除、
8.注銷退出登錄管理
系統架構:
功能截圖:
用戶登錄注冊:
?前端首頁:
分類查看:
詳情查看:
評論回復信息:這里用戶頭像替換成自己本地路徑即可顯示
收藏領養管理:
我的個人信息:
我的領養收藏:
發布流浪交流信息:
我的發布:
后端管理:
后端首頁:
用戶管理:
類型管理:
詳情管理:
評論回復管理:
通知公告等:
代碼實現:
用戶登錄:
/*** 根路徑以及其他請求處理* * @author admin**/ @Controller public class IndexController {@Value("${imageFilePath}")private String imageFilePath; // 文件路徑@Resourceprivate NoticeService noticeService;@Resourceprivate UserService userService;@Resourceprivate ArticleService articleService;@Resourceprivate ClassifyService classifyService;@RequestMapping("/")public String index(HttpSession session) {// 查詢公告session.setAttribute("noticeList", noticeService.list(0, 5));return "index";// 跳轉到index.html}/*** 登錄頁面* * @return*/@RequestMapping("/login")public String login() {return "login";}/*** 前臺登錄頁面* * @return*/@RequestMapping("/webLogin")public String webLogin() {return "webLogin";}/*** 注冊* * @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+","; // } // ids = ids.substring(0, ids.length() -1); // user.setArticleIds(ids);user.setRegistrationDate(new Date());userService.save(user);return "webLogin";}/*** 退出登錄* * @param request* @return*/@RequestMapping("/quit")public String quit(HttpServletRequest request) {HttpSession session = request.getSession();session.removeAttribute("user");return "index";}/*** 退出登錄* * @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")public ModelAndView checkLogin(User user, HttpServletRequest request) {ModelAndView mav = new ModelAndView();HttpSession session = request.getSession();User u = userService.findByUsernameAndPassword(user.getUsername(), user.getPassword());if (u == null) {mav.addObject("user", user);mav.addObject("errorInfo", "用戶名或者密碼錯誤!");mav.setViewName("webLogin");} else {u.setLatelyLoginTime(new Date());userService.save(u);session.setAttribute("user", u);mav.addObject("username", u.getUsername());mav.addObject("user", u);mav.addObject("success", true);mav.setViewName("/index");}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);mav.setViewName("/viewPerson");return mav;}/*** 查看個人收藏夾* * @return*/@RequestMapping("viewCollection")public ModelAndView viewCollection(HttpServletRequest request, HttpSession session) {User user = (User) request.getSession().getAttribute("user");ModelAndView mav = new ModelAndView();User u = userService.findById(user.getUserId());String artIds = u.getArticleIds();List<String> result = new ArrayList<>();if (StringUtils.isNotBlank(artIds)) {result = Arrays.asList(StringUtils.split(artIds, ","));}List<Integer> retIds = new ArrayList<>();for (String temp : result) {retIds.add(Integer.valueOf(temp).intValue());}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());String userIds = u.getUserIds();List<String> result = new ArrayList<>();if (StringUtils.isNotBlank(userIds)) {result = Arrays.asList(StringUtils.split(userIds, ","));}List<Integer> retIds = new ArrayList<>();for (String temp : result) {retIds.add(Integer.valueOf(temp).intValue());}List<User> retArt = userService.findByListId(retIds);session.setAttribute("noticeList", noticeService.list(0, 5));mav.addObject("retArt", retArt);mav.addObject("user", u);mav.setViewName("/viewFocusUser");return mav;}/*** 保存用戶信息* * @param user* @return*/@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<Classify> list = classifyService.findAll();// model.addAttribute("list", list);// return "one";// }@RequestMapping("notePage")public ModelAndView notePage(HttpServletRequest request) {ModelAndView mav = new ModelAndView();User user = (User) request.getSession().getAttribute("user");if (user == null) {mav.setViewName("/webLogin");return mav;}List<Classify> list = classifyService.findAll();mav.addObject("list", list);mav.setViewName("/one");return mav;}/*** 保存筆記* * @param article* @param request* @return*/@RequestMapping("addNote")public ModelAndView addNote(Article article, HttpServletRequest request) {ModelAndView mav = new ModelAndView();// 獲取當前用戶信息User user = (User) request.getSession().getAttribute("user");article.setUserId(user.getUserId());article.setPublishDate(new Date());article.setClick(0);article.setCommentNum(0);article.setContentNoTag(StringUtil.Html2Text(article.getContent()));articleService.save(article);mav.setViewName("/index");return mav;}@RequestMapping("saveNote")public ModelAndView saveNote(Article article, HttpServletRequest request) {ModelAndView mav = new ModelAndView();Article a = articleService.findById(article.getArticleId());article.setPublishDate(a.getPublishDate());// 獲取當前用戶信息articleService.save(article);mav.setViewName("/index");return mav;}/*** 查看筆記* * @return*/@RequestMapping("viewNote")public String viewNote(HttpSession session) {session.setAttribute("noticeList", noticeService.list(0, 5));return "mylist";}@RequestMapping("/delete/{id}")public String delete(@PathVariable(value = "id") String id) throws Exception {articleService.delete(Integer.parseInt(id));return "mylist";}/*** 查看個人筆記加載數據列表* * @param article* @param publishDates* @param page* @param pageSize* @return*/@RequestMapping("/mylist")public Map<String, Object> list(Article article,@RequestParam(value = "publishDates", required = false) String publishDates,@RequestParam(value = "page", required = false) Integer page,@RequestParam(value = "pageSize", required = false) Integer pageSize, HttpServletRequest request) {Map<String, Object> resultMap = new HashMap<String, Object>();// User user = (User) request.getSession().getAttribute("user");// article.setUserId(user.getUserId());String s_bPublishDate = null; // 開始時間String s_ePublishDate = null; // 結束時間if (StringUtil.isNotEmpty(publishDates)) {String[] strs = publishDates.split(" - "); // 拆分時間段s_bPublishDate = strs[0];s_ePublishDate = strs[1];}Long total = articleService.getCount(article, s_bPublishDate, s_ePublishDate);int totalPage = (int) (total % pageSize == 0 ? total / pageSize : total / pageSize + 1); // 總頁數resultMap.put("totalPage", totalPage);resultMap.put("errorNo", 0);resultMap.put("data", articleService.list(article, s_bPublishDate, s_ePublishDate, page - 1, pageSize));resultMap.put("total", total);return resultMap;}/*** 后臺默認首頁* * @return*/@RequestMapping("/index")public String root() {return "/common/index";}/*** 博主信息頁面* * @return*/@RequestMapping("/blogger")public String blogger() {return "/blogger/index";}/*** 圖片上傳處理 @Title: ckeditorUpload @param file 圖片文件 @return 參數說明 @return* Map<String,Object> 返回類型 @throws*/@ResponseBody@RequestMapping("/upload")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 blocke.printStackTrace();}resultMap.put("code", 0);resultMap1.put("filePath", newFileName);resultMap.put("data", resultMap1);return resultMap;}}全局yml:
server: port: 80servlet:context-path: /spring: datasource: driver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://localhost:3306/baby_mobile?characterEncoding=utf8&useSSL=falseusername: rootpassword: 123456jpa:hibernate:ddl-auto: updateshow-sql: truethymeleaf:cache: false數據庫設計:
表t_admin
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | admin_id | int | 10 | 0 | N | Y |
| 2 | head_portrait | varchar | 200 | 0 | Y | N |
| 3 | password | varchar | 200 | 0 | Y | N |
| 4 | phone | varchar | 200 | 0 | Y | N |
| 5 | sex | varchar | 50 | 0 | Y | N |
| 6 | signature | varchar | 500 | 0 | Y | N |
| 7 | true_name | varchar | 200 | 0 | Y | N |
| 8 | user_name | varchar | 200 | 0 | Y | N |
表t_article
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | article_id | int | 10 | 0 | N | Y |
| 2 | author | varchar | 200 | 0 | N | N |
| 3 | click | int | 10 | 0 | Y | N |
| 4 | comment_num | int | 10 | 0 | Y | N |
| 5 | content | text | 65535 | 0 | Y | N |
| 6 | image_name | varchar | 255 | 0 | Y | N |
| 7 | is_original | int | 10 | 0 | Y | N |
| 8 | is_top | int | 10 | 0 | Y | N |
| 9 | publish_date | datetime | 19 | 0 | Y | N |
| 10 | title | varchar | 200 | 0 | N | N |
| 11 | classify_id | int | 10 | 0 | Y | N |
| 12 | user_id | int | 10 | 0 | Y | N |
表t_blogger
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | blogger_id | int | 10 | 0 | N | Y |
| 2 | head_portrait | varchar | 200 | 0 | Y | N |
| 3 | motto | varchar | 500 | 0 | Y | N |
| 4 | nick_name | varchar | 200 | 0 | Y | N |
| 5 | site | varchar | 200 | 0 | Y | N |
| 6 | signature | varchar | 500 | 0 | Y | N |
表t_classify
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | classify_id | int | 10 | 0 | N | Y |
| 2 | classify_name | varchar | 200 | 0 | N | N |
表t_comment
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | comment_id | int | 10 | 0 | N | Y |
| 2 | comment_date | datetime | 19 | 0 | Y | N |
| 3 | content | varchar | 500 | 0 | Y | N |
| 4 | article_id | int | 10 | 0 | Y | N |
| 5 | user_id | int | 10 | 0 | Y | N |
表t_link
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | link_id | int | 10 | 0 | N | Y |
| 2 | link_email | varchar | 200 | 0 | Y | N |
| 3 | link_name | varchar | 200 | 0 | Y | N |
| 4 | link_url | varchar | 200 | 0 | Y | N |
| 5 | order_num | int | 10 | 0 | Y | N |
表t_notice
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | notice_id | int | 10 | 0 | N | Y |
| 2 | grade | int | 10 | 0 | Y | N |
| 3 | content | varchar | 500 | 0 | Y | N |
| 4 | publish_date | datetime | 19 | 0 | Y | N |
表t_reply
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | reply_id | int | 10 | 0 | N | Y |
| 2 | content | varchar | 500 | 0 | Y | N |
| 3 | reply_date | datetime | 19 | 0 | Y | N |
| 4 | comment_id | int | 10 | 0 | Y | N |
| 5 | user_id | int | 10 | 0 | Y | N |
表t_timeline
| 編號 | 名稱 | 數據類型 | 長度 | 小數位 | 允許空值 | 主鍵 |
| 1 | timeline_id | int | 10 | 0 | N | Y |
| 2 | content | varchar | 200 | 0 | Y | N |
| 3 | publish_date | datetime | 19 | 0 | Y | N |
| 4 | month | varchar | 200 | 0 | Y | N |
| 5 | year | varchar | 200 | 0 | Y | N |
源碼獲取:
?大家點贊、收藏、關注、評論啦 、查看👇🏻👇🏻👇🏻微信公眾號獲取聯系方式👇🏻👇🏻👇🏻
打卡 文章 更新?136/? 365天
?精彩專欄推薦訂閱:在下方專欄👇🏻👇🏻👇🏻👇🏻
Java項目精品實戰案例《100套》
web前端期末大作業網頁實戰《100套》
🥇 評論區抽粉絲送書啦
💌 歡迎大家在評論區提出意見和建議! (抽三位幸運兒送書,實物圖如下)💌
內容簡介
本書從Vue.js框架技術的基礎概念出發,逐步深入Vue.js進階實戰,并在最后配合一個網站項目和一個后臺系統開發實戰案例,重點介紹了使用Vue.js+axios+ElementUI+wangEditor進行前端開發和使用組件進行Vue單頁面網頁復用,讓讀者不但可以系統地學習Vue.js前端開發框架的相關知識,而且還能對業務邏輯的分析思路、實際應用開發有更為深入的理解。
本書語言平實,用詞詼諧,案例豐富,實用性強,特別適合剛入社會的職場新人、Vue.js框架的初級讀者和進階讀者閱讀,也適合希望從后臺開發轉型做前端的程序員等其他編程愛好者閱讀。另外,本書也適合作為相關培訓機構的教材使用。
京東自營購買鏈接
《Vue.js框架與Web前端開發從入門到精通》(舒志強)【摘要 書評 試讀】- 京東圖書
當當自營購買鏈接
《Vue.js框架與Web前端開發從入門到精通》(舒志強)【簡介_書評_在線閱讀】 - 當當圖書
大家點贊關注,三天后也就是 1月13日 從👇🏻👇🏻👇🏻評論區👇🏻👇🏻👇🏻留言的同學中抽取三位送書
如果中獎了聯系不上則視為放棄,可以從👇🏻👇🏻👇🏻下方卡片👇🏻👇🏻👇🏻里找到作者的聯系方式,每周都會送6~9本書,后面送書力度還會加大,一年送幾百上千本不是問題,
總結
以上是生活随笔為你收集整理的基于java+springboot+layui的流浪动物交流信息平台设计实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于java SSM springboo
- 下一篇: mysql 正则替换 换行,MySQL中