文章目录
- 宠物管理系统
- 一、项目演示
- 二、项目介绍
- 三、19000字论文参考
- 四、部分功能截图
- 五、部分代码展示
- 六、底部获取项目源码和万字论文参考(9.9¥带走)
宠物管理系统
一、项目演示
宠物管理系统
二、项目介绍
基于springboot+vue的前后端分离宠物管理系统
角色:用户、管理员
1、用户的主要功能:
首页:展示公告列表,宠物科普,介绍流浪宠物,热门活动
注册、登录、宠物领养、宠物救助、丢失宠物查看、宠物论坛
2、管理员的主要功能:
用户管理、申请领养管理、评论管理、流浪动物救助、动物走失管理、救助站管理、帖子管理、捐赠管理、公告管理、科普文章管理、活动管理等
语言:java
前端技术:Vue、 ELementUI、echarts
后端技术:SpringBoot、Mybatis-Plus
数据库:MySQL
三、19000字论文参考
四、部分功能截图
五、部分代码展示
package com.rabbiter.pet.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelWriter;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletOutputStream;
import java.net.URLEncoder;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.pet.entity.Animal;
import com.rabbiter.pet.service.IAnimalService;
import com.rabbiter.pet.entity.Applcation;
import com.rabbiter.pet.service.IApplcationService;
import com.rabbiter.pet.utils.TokenUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rabbiter.pet.common.Result;
import org.springframework.web.multipart.MultipartFile;
import com.rabbiter.pet.entity.User;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author
* @since 2023-04-02
*/
@RestController
@RequestMapping("/applcation")
public class ApplcationController {
@Resource
private IApplcationService applcationService;
@Resource
private IAnimalService animalService;
private final String now = DateUtil.now();
// 新增或者更新
@PostMapping
public Result save(@RequestBody Applcation applcation) {
applcationService.saveOrUpdate(applcation);
return Result.success();
}
@PostMapping("/state/{id}/{state}")
public Result state(@PathVariable Integer id, @PathVariable String state) {
Applcation applcation = applcationService.getById(id);
applcation.setState(state);
QueryWrapper<Applcation> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("animal_id", applcation.getAnimalId());
List<Applcation> list = applcationService.list(queryWrapper);
for (Applcation app : list) {
app.setState("审核不通过");
applcationService.updateById(app);
}
applcationService.updateById(applcation);
Animal animal = animalService.getById(applcation.getAnimalId());
animal.setIsAdopt("是");
animal.setAdopt("不可领养");
animalService.updateById(animal);
return Result.success();
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Integer id) {
applcationService.removeById(id);
return Result.success();
}
@PostMapping("/del/batch")
public Result deleteBatch(@RequestBody List<Integer> ids) {
applcationService.removeByIds(ids);
return Result.success();
}
@GetMapping
public Result findAll() {
return Result.success(applcationService.list());
}
@GetMapping("/{id}")
public Result findOne(@PathVariable Integer id) {
return Result.success(applcationService.getById(id));
}
@GetMapping("/my")
public Result my() {
List<Animal> animals = animalService.list();
QueryWrapper<Applcation> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("id");
User currentUser = TokenUtils.getCurrentUser();
if (currentUser == null) {
return Result.success(new ArrayList<>());
}
queryWrapper.eq("user_id", currentUser.getId());
List<Applcation> applcations = applcationService.list(queryWrapper);
for (Applcation record : applcations) {
animals.stream().filter(animal -> animal.getId().equals(record.getAnimalId())).findFirst().ifPresent(record::setAnimal);
}
return Result.success(applcations);
}
@GetMapping("/page")
public Result findPage(@RequestParam(defaultValue = "") String name,
@RequestParam Integer pageNum,
@RequestParam Integer pageSize) {
List<Animal> animals = animalService.list();
QueryWrapper<Applcation> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("id");
if (!"".equals(name)) {
queryWrapper.like("name", name);
}
Page<Applcation> page = applcationService.page(new Page<>(pageNum, pageSize), queryWrapper);
for (Applcation record : page.getRecords()) {
animals.stream().filter(animal -> animal.getId().equals(record.getAnimalId())).findFirst().ifPresent(record::setAnimal);
}
return Result.success(page);
}
}
package com.rabbiter.pet.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelWriter;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletOutputStream;
import java.net.URLEncoder;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.pet.entity.User;
import com.rabbiter.pet.service.IUserService;
import com.rabbiter.pet.utils.TokenUtils;
import com.rabbiter.pet.entity.Comment;
import com.rabbiter.pet.service.ICommentService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rabbiter.pet.common.Result;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author
* @since 2023-03-19
*/
@RestController
@RequestMapping("/comment")
public class CommentController {
@Resource
private ICommentService commentService;
@Resource
private IUserService userService;
// 新增或者更新
@PostMapping
public Result save(@RequestBody Comment comment) {
comment.setUser(TokenUtils.getCurrentUser().getNickname());
comment.setTime(DateUtil.now());
commentService.saveOrUpdate(comment);
return Result.success();
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Integer id) {
commentService.removeById(id);
return Result.success();
}
@PostMapping("/del/batch")
public Result deleteBatch(@RequestBody List<Integer> ids) {
commentService.removeByIds(ids);
return Result.success();
}
@GetMapping
public Result findAll() {
return Result.success(commentService.list());
}
@GetMapping("/article/{type}/{articleId}")
public Result findAll(@PathVariable Integer type, @PathVariable Integer articleId) {
QueryWrapper<Comment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("article_id", articleId);
queryWrapper.eq("type", type);
List<Comment> list = commentService.list(queryWrapper);
List<Comment> res = new ArrayList<>();
for (Comment comment : list) {
User one = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getNickname, comment.getUser()));
if (one != null) {
comment.setAvatar(one.getAvatarUrl()); // 设置头像
}
if (comment.getPid() == null) {
res.add(comment);
List<Comment> children = list.stream().filter(c -> comment.getId().equals(c.getPid())).collect(Collectors.toList());
comment.setChildren(children);
}
}
return Result.success(res);
}
@GetMapping("/{id}")
public Result findOne(@PathVariable Integer id) {
return Result.success(commentService.getById(id));
}
@GetMapping("/page")
public Result findPage(@RequestParam(defaultValue = "") String name,
@RequestParam Integer pageNum,
@RequestParam Integer pageSize) {
QueryWrapper<Comment> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("id");
if (!"".equals(name)) {
queryWrapper.like("name", name);
}
return Result.success(commentService.page(new Page<>(pageNum, pageSize), queryWrapper));
}
}
package com.rabbiter.pet.controller;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.pet.common.Result;
import com.rabbiter.pet.entity.Files;
import com.rabbiter.pet.mapper.FileMapper;
import com.rabbiter.pet.utils.PathUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
/**
* 文件上传相关接口
*/
@RestController
@RequestMapping("/file")
public class FileController {
@Value("${server.port}")
private String serverPort;
@Resource
private FileMapper fileMapper;
/**
* 文件上传接口
* @param file 前端传递过来的文件
* @return
* @throws IOException
*/
@PostMapping("/upload")
public String upload(@RequestParam MultipartFile file) throws IOException {
String originalFilename = file.getOriginalFilename();
String type = FileUtil.extName(originalFilename);
long size = file.getSize();
// 定义一个文件唯一的标识码
String fileUUID = IdUtil.fastSimpleUUID() + StrUtil.DOT + type;
File uploadFile = new File(PathUtils.getClassLoadRootPath() + "/files/" + fileUUID);
// 判断配置的文件目录是否存在,若不存在则创建一个新的文件目录
File parentFile = uploadFile.getParentFile();
if(!parentFile.exists()) {
parentFile.mkdirs();
}
String url;
// 获取文件的md5
String md5 = SecureUtil.md5(file.getInputStream());
// 从数据库查询是否存在相同的记录
Files dbFiles = getFileByMd5(md5);
if (dbFiles != null) {
url = dbFiles.getUrl();
} else {
// 上传文件到磁盘
file.transferTo(uploadFile);
// 数据库若不存在重复文件,则不删除刚才上传的文件
url = "/file/" + fileUUID;
}
// 存储数据库
Files saveFile = new Files();
saveFile.setName(originalFilename);
saveFile.setType(type);
saveFile.setSize(size/1024); // 单位 kb
saveFile.setUrl(url);
saveFile.setMd5(md5);
fileMapper.insert(saveFile);
return url;
}
/**
* 文件下载接口 http://localhost:9090/file/{fileUUID}
* @param fileUUID
* @param response
* @throws IOException
*/
@GetMapping("/{fileUUID}")
public void download(@PathVariable String fileUUID, HttpServletResponse response) throws IOException {
// 根据文件的唯一标识码获取文件
File uploadFile = new File(PathUtils.getClassLoadRootPath() + "/files/" + fileUUID);
// 设置输出流的格式
ServletOutputStream os = response.getOutputStream();
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileUUID, "UTF-8"));
response.setContentType("application/octet-stream");
// 读取文件的字节流
try {
os.write(FileUtil.readBytes(uploadFile));
} catch (Exception e) {
System.err.println("文件下载失败,文件不存在");
}
os.flush();
os.close();
}
/**
* 通过文件的md5查询文件
* @param md5
* @return
*/
private Files getFileByMd5(String md5) {
// 查询文件的md5是否存在
QueryWrapper<Files> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("md5", md5);
List<Files> filesList = fileMapper.selectList(queryWrapper);
return filesList.size() == 0 ? null : filesList.get(0);
}
@PostMapping("/update")
public Result update(@RequestBody Files files) {
return Result.success(fileMapper.updateById(files));
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Integer id) {
Files files = fileMapper.selectById(id);
files.setIsDelete(true);
fileMapper.updateById(files);
return Result.success();
}
@PostMapping("/del/batch")
public Result deleteBatch(@RequestBody List<Integer> ids) {
// select * from sys_file where id in (id,id,id...)
QueryWrapper<Files> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", ids);
List<Files> files = fileMapper.selectList(queryWrapper);
for (Files file : files) {
file.setIsDelete(true);
fileMapper.updateById(file);
}
return Result.success();
}
/**
* 分页查询接口
* @param pageNum
* @param pageSize
* @param name
* @return
*/
@GetMapping("/page")
public Result findPage(@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(defaultValue = "") String name) {
QueryWrapper<Files> queryWrapper = new QueryWrapper<>();
// 查询未删除的记录
queryWrapper.eq("is_delete", false);
queryWrapper.orderByDesc("id");
if (!"".equals(name)) {
queryWrapper.like("name", name);
}
return Result.success(fileMapper.selectPage(new Page<>(pageNum, pageSize), queryWrapper));
}
}
六、底部获取项目源码和万字论文参考(9.9¥带走)
有问题,或者需要协助调试运行项目的也可以