目录
前言
一、技术栈
二、系统功能介绍
三、核心代码
1、登录模块
2、文件上传模块
3、代码封装
宠物领养救助平台采用B/S架构,数据库是MySQL。网站的搭建与开发采用了先进的java进行编写,使用了springboot框架。该系统从两个对象:由管理员和用户来对系统进行设计构建。主要功能包括:个人信息修改,对用户、宠物类别、宠物招领、领养申请、宠物认领、宠物论坛等功能进行管理。本系统在一般宠物领养救助平台的基础上增加了首页推送最新信息的功能,方便用户快速浏览,是一个高效的、动态的、交互友好的宠物领养救助平台。
本系统在设计过程中,很好地发挥了该开发方式的优势,让实现代码有了良好的可读性,而且使代码的更新和维护更加的方便,操作简单,对以后的维护减少了很多麻烦。系统的顺利开发和实现,对于宠物领养救助这一方面提供巨大的便利服务,无论是管理员还是用户,都带来了极大的便利,方便大众,为社会的进步与发展提供了一些动力。
末尾获取源码
Spring Boot+JS+ jQuery+Ajax...
当游客打开系统的网址后,首先看到的就是首页界面。在这里,游客能够看到宠物领养救助平台的导航条显示首页、宠物招领、宠物认领、 宠物论坛、宠物资讯、后台管理、在线反馈、个人中心等,系统首页界面如图5-1所示:
当用户进入系统进行相关操作前必须进行注册、登录,用户注册、用户登录界面如图5-2所示:
用户点击宠物招领,在宠物招领页面的输入栏中填写宠物名称、宠物类别、宠物性别,进行查询,还可以查看宠物名称、宠物类别、宠物性别、图片、年龄、性情、爱好、身体状况、状态,并且进行领养申请、评论等操作,如图5-3所示:
用户点击宠物认领,在宠物认领页面的输入栏中填写宠物名称、宠物类别、性别、丢失地址,进行查询,还可以查看宠物名称、宠物类别、封面、性别、丢失时间、丢失地址、发布日期、用户账号、用户姓名、用户电话,并且进行收藏、评论等操作,如图5-4所示:
用户通过宠物论坛填写标题、类型、内容,进行发布帖子,与其他用户可以在下方发表评论,可依关键字搜索帖子,如图5-5所示:
在个人中心页面可以更新个人详细信息,还可以对我的发布、我的收藏进行详细操作,如图5-6所示:
管理员登录,在登录页面正确输入用户名和密码、角色后,进入操作系统进行操作;如图5-7所示。
管理员进入系统主页面,主要功能包括对系统首页、个人中心、用户管理、宠物类别管理、宠物招领管理、领养申请管理、宠物认领管理、宠物论坛、系统管理等进行操作。管理员主页面如图5-8所示:
管理员点击用户管理,在用户管理页面中输入用户账号、用户姓名、性别、用户电话、头像等信息,进行查询、新增或删除用户信息等操作。如图5-9所示:
管理员点击宠物类别管理,在宠物类别管理页面中输入宠物类别等信息,进行查询、新增或删除宠物类别等操作。如图5-10所示:
管理员点击宠物招领管理,在宠物招领管理页面中对宠物名称、宠物类别、宠物性别、图片、年龄、性情、爱好、身体状况、状态等信息,进行查询、新增或删除宠物招领等操作。如图5-11所示:
管理员点击领养申请管理,在领养申请管理页面中对申请编号、用户账号、用户姓名、用户电话、宠物名称、宠物类别、宠物性别、图片、领养时间、领养附件、审核回复、审核状态、审核等信息,进行查询、新增或删除领养申请等操作。如图5-12所示:
管理员点击宠物认领管理,在宠物认领管理页面中对宠物名称、宠物类别、封面、性别、丢失时间、丢失地址、发布日期、用户账号、用户姓名、用户电话等信息,进行查询、新增或删除宠物认领等操作。如图5-13所示:
用户点击后台管理,然后页面跳转到系统主页面,主要包括对系统首页、个人中心、领养申请管理、宠物认领管理等进行操作。用户主页面如图5-14所示:
package com.controller;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
@RequestMapping("users")
@RestController
public class UserController{
@Autowired
private UserService userService;
@Autowired
private TokenService tokenService;
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
return R.ok().put("token", token);
}
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody UserEntity user){
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
userService.update(user,null);
return R.ok("密码已重置为:123456");
}
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page);
}
@RequestMapping("/list")
public R list( UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
ew.allEq(MPUtil.allEQMapPre( user, "user"));
return R.ok().put("data", userService.selectListView(ew));
}
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
@PostMapping("/save")
public R save(@RequestBody UserEntity user){
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
@RequestMapping("/update")
public R update(@RequestBody UserEntity user){
userService.updateById(user);
return R.ok();
}
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
userService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
package com.controller;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
@Autowired
private ConfigService configService;
@RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
if (file.isEmpty()) {
throw new EIException("上传文件不能为空");
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
}
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(upload.getAbsolutePath()+"/"+fileName);
file.transferTo(dest);
FileUtils.copyFile(dest, new File("C:UsersDesktopjiadianspringbootl7ownsrcmainresourcesstaticupload"+"/"+fileName));
if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
} else {
configEntity.setValue(fileName);
}
configService.insertOrUpdate(configEntity);
}
return R.ok().put("file", fileName);
}
@IgnoreAuth
@RequestMapping("/download")
public ResponseEntity<byte[]> download(@RequestParam String fileName) {
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
}
File file = new File(upload.getAbsolutePath()+"/"+fileName);
if(file.exists()){
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", fileName);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
}
} catch (IOException e) {
e.printStackTrace();
}
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
package com.utils;
import java.util.HashMap;
import java.util.Map;
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
public R() {
put("code", 0);
}
public static R error() {
return error(500, "未知异常,请联系管理员");
}
public static R error(String msg) {
return error(500, msg);
}
public static R error(int code, String msg) {
R r = new R();
r.put("code", code);
r.put("msg", msg);
return r;
}
public static R ok(String msg) {
R r = new R();
r.put("msg", msg);
return r;
}
public static R ok(Map<String, Object> map) {
R r = new R();
r.putAll(map);
return r;
}
public static R ok() {
return new R();
}
public R put(String key, Object value) {
super.put(key, value);
return this;
}
}
相关知识
【精选】基于spring boot+vue的宠物管理系统(源码+定制+开发)Spring Boot宠物管理系统、Vue宠物管理平台、Spring Boot宠物平台设计、智能宠物管理平台开发
基于Spring Boot的宠物领养系统(毕设)
基于Spring Boot的宠物咖啡馆平台的设计与实现
[含文档+PPT+源码等]精品基于springboot实现的原生Andriod宠物救助领养app
构建便捷高效的宠物医疗预约服务平台:基于Spring Boot的实现本文介绍了基于Spring Boot的宠物医疗预约服
构建便捷高效的宠物医疗预约服务平台:基于Spring Boot的实现
基于SpringBoot+Vue的宠物领养管理系统
基于spring boot+vue的流浪宠物领养救助管理系统
(计算机毕设)基于Vue和Spring Boot的宠物救助网站设计与实现
Springboot计算机毕业设计宠物领养平台f2308
网址: 基于Spring Boot的宠物领养救助平台 https://m.mcbbbk.com/newsview558986.html
上一篇: 仙境中养宠物指南 |
下一篇: 桌面萌宠2024官方下载 |