💖💖作者:计算机毕业设计小途 💙💙个人简介:曾长期从事计算机专业培训教学,本人也热爱上课教学,语言擅长Java、微信小程序、Python、Golang、安卓Android等,开发项目包括大数据、深度学习、网站、小程序、安卓、算法。平常会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 深度学习实战项目
@TOC
基于SpringBoot的校园流浪动物救助平台介绍
基于SpringBoot的校园流浪动物救助平台是一个面向高校师生的综合性动物救助管理系统,采用当前主流的B/S架构设计,支持Java+SpringBoot和Python+Django两套技术方案供开发者选择。系统前端采用Vue框架结合ElementUI组件库以及传统HTML技术构建用户界面,后端基于SpringBoot框架整合Spring、SpringMVC、MyBatis等核心技术,数据持久化采用MySQL关系型数据库,可使用IDEA或PyCharm等专业开发工具进行开发。该平台功能模块涵盖系统首页展示、个人中心管理、用户信息维护、宠物分类管理、动物中心信息展示、宠物领养申请处理、救助活动组织发布、活动报名参与、志愿者招募管理、论坛分类设置、交流论坛互动、举报记录处理、系统管理维护、系统公告发布、轮播图管理、在线客服服务以及系统公告分类等十六个核心功能模块。平台旨在为校园流浪动物提供一个集救助、领养、志愿服务、信息交流于一体的综合性服务平台,通过技术手段连接救助者、领养者、志愿者等各方角色,实现校园流浪动物救助工作的信息化、规范化管理,同时为广大师生提供参与动物保护公益活动的便捷渠道。
基于SpringBoot的校园流浪动物救助平台演示视频
基于SpringBoot的校园流浪动物救助平台演示图片
基于SpringBoot的校园流浪动物救助平台代码展示
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.*;
@RestController
@RequestMapping("/animal")
public class AnimalController {
@Autowired
private AnimalService animalService;
@Autowired
private AdoptionService adoptionService;
@Autowired
private ActivityService activityService;
SparkSession spark = SparkSession.builder()
.appName("CampusAnimalRescuePlatform")
.master("local[*]")
.config("spark.sql.adaptive.enabled", "true")
.config("spark.sql.adaptive.coalescePartitions.enabled", "true")
.getOrCreate();
@PostMapping("/addAnimal")
public Result addAnimal(@RequestBody Animal animal) {
if (animal.getName() == null || animal.getName().trim().isEmpty()) {
return Result.error("动物名称不能为空");
}
if (animal.getCategoryId() == null) {
return Result.error("请选择动物分类");
}
if (animal.getAge() <= 0 || animal.getAge() > 30) {
return Result.error("动物年龄必须在1-30岁之间");
}
animal.setCreateTime(new Date());
animal.setStatus("待救助");
animal.setHealthStatus("待检查");
if (animal.getGender() == null) {
animal.setGender("未知");
}
if (animal.getWeight() == null || animal.getWeight() <= 0) {
animal.setWeight(0.0);
}
animal.setRescueLocation(animal.getRescueLocation() != null ? animal.getRescueLocation() : "校园内");
animal.setDescription(animal.getDescription() != null ? animal.getDescription() : "");
animal.setIsAdopted(0);
animal.setAdopterCount(0);
boolean saveResult = animalService.save(animal);
if (saveResult) {
Dataset<Row> animalData = spark.read()
.format("jdbc")
.option("url", "jdbc:mysql://localhost:3306/animal_rescue")
.option("dbtable", "animal")
.option("user", "root")
.option("password", "123456")
.load();
animalData.filter(animalData.col("category_id").equalTo(animal.getCategoryId()))
.groupBy("category_id")
.count()
.show();
return Result.success("动物信息添加成功", animal);
} else {
return Result.error("动物信息添加失败");
}
}
@PostMapping("/applyAdoption")
public Result applyAdoption(@RequestBody AdoptionApplication application) {
if (application.getAnimalId() == null) {
return Result.error("请选择要领养的动物");
}
if (application.getUserId() == null) {
return Result.error("用户信息不能为空");
}
Animal animal = animalService.getById(application.getAnimalId());
if (animal == null) {
return Result.error("动物信息不存在");
}
if (animal.getIsAdopted() == 1) {
return Result.error("该动物已被领养");
}
QueryWrapper<AdoptionApplication> wrapper = new QueryWrapper<>();
wrapper.eq("animal_id", application.getAnimalId())
.eq("user_id", application.getUserId())
.eq("status", "待审核");
if (adoptionService.count(wrapper) > 0) {
return Result.error("您已经申请过领养该动物,请勿重复申请");
}
if (application.getReason() == null || application.getReason().trim().length() < 10) {
return Result.error("领养理由至少需要10个字符");
}
if (application.getContactPhone() == null || !application.getContactPhone().matches("^1[3-9]\\d{9}$")) {
return Result.error("请输入正确的手机号码");
}
application.setCreateTime(new Date());
application.setStatus("待审核");
application.setApplicationDate(new Date());
if (application.getExperience() == null) {
application.setExperience("无");
}
if (application.getLivingCondition() == null) {
application.setLivingCondition("未填写");
}
boolean saveResult = adoptionService.save(application);
if (saveResult) {
animal.setAdopterCount(animal.getAdopterCount() + 1);
animalService.updateById(animal);
Dataset<Row> adoptionData = spark.read()
.format("jdbc")
.option("url", "jdbc:mysql://localhost:3306/animal_rescue")
.option("dbtable", "adoption_application")
.option("user", "root")
.option("password", "123456")
.load();
adoptionData.filter(adoptionData.col("animal_id").equalTo(application.getAnimalId()))
.groupBy("animal_id")
.count()
.show();
return Result.success("领养申请提交成功,等待审核", application);
} else {
return Result.error("领养申请提交失败");
}
}
@PostMapping("/createActivity")
public Result createActivity(@RequestBody RescueActivity activity) {
if (activity.getTitle() == null || activity.getTitle().trim().isEmpty()) {
return Result.error("活动标题不能为空");
}
if (activity.getTitle().length() > 100) {
return Result.error("活动标题长度不能超过100个字符");
}
if (activity.getContent() == null || activity.getContent().trim().length() < 20) {
return Result.error("活动内容至少需要20个字符");
}
if (activity.getStartTime() == null || activity.getEndTime() == null) {
return Result.error("请设置活动开始和结束时间");
}
if (activity.getStartTime().before(new Date())) {
return Result.error("活动开始时间不能早于当前时间");
}
if (activity.getEndTime().before(activity.getStartTime())) {
return Result.error("活动结束时间不能早于开始时间");
}
if (activity.getMaxParticipants() == null || activity.getMaxParticipants() <= 0) {
return Result.error("最大参与人数必须大于0");
}
if (activity.getLocation() == null || activity.getLocation().trim().isEmpty()) {
return Result.error("活动地点不能为空");
}
activity.setCreateTime(new Date());
activity.setStatus("进行中");
activity.setCurrentParticipants(0);
activity.setOrganizerId(activity.getOrganizerId());
if (activity.getActivityType() == null) {
activity.setActivityType("救助活动");
}
if (activity.getRequirements() == null) {
activity.setRequirements("无特殊要求");
}
boolean saveResult = activityService.save(activity);
if (saveResult) {
Dataset<Row> activityData = spark.read()
.format("jdbc")
.option("url", "jdbc:mysql://localhost:3306/animal_rescue")
.option("dbtable", "rescue_activity")
.option("user", "root")
.option("password", "123456")
.load();
activityData.filter(activityData.col("status").equalTo("进行中"))
.groupBy("activity_type")
.count()
.orderBy(activityData.col("count").desc())
.show();
return Result.success("救助活动创建成功", activity);
} else {
return Result.error("救助活动创建失败");
}
}
}
基于SpringBoot的校园流浪动物救助平台文档展示
💖💖作者:计算机毕业设计小途 💙💙个人简介:曾长期从事计算机专业培训教学,本人也热爱上课教学,语言擅长Java、微信小程序、Python、Golang、安卓Android等,开发项目包括大数据、深度学习、网站、小程序、安卓、算法。平常会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 深度学习实战项目