SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)

哈喽,大家好!我是阿瞒,今天给大家带来的一个《流浪猫狗领养救助管理系统》,制作时间花费了....嗯....大概两周的时间吧,如果喜欢可以点赞、收藏、关注三连,也可以评论私信啥的哦,我看见了就会第一时间回复的。

 

话不多说咱们直接开整吧,冲啊!!!冲啊!!!冲啊!!!

开发技术及开发工具

开发工具采用Idea【前后端代码的编写】、Navicat Premium 15【Mysql数据库的连接】

前端采用Vue、ElementUI

后端采用SpringBoot、Mybatis

数据库采用Mysql

记得以上的技术所需要的环境都得装好哟,这里就不跟大家说怎么去装了,百度就ok了

然后这个毕业设计是没有进行前后端分离的哦

系统结构图

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第1张图片

内置功能

1.登录功能

2.系统管理:用户管理、角色管理、菜单管理、个人信息管理

3.救助站管理:救助站信息

4.领养管理:待领养信息、领养信息

5.养宠攻略管理:攻略信息

6.交流消息管理:消息信息
7.捐赠支出管理:捐赠支出信息

PS:角色一开始分为管理员与普通用户,大家可以根据自己的喜好来添加角色和角色的权限

系统演示图

先上一个处理跨域请求的类吧,否则前端请求不到后端接口地址哦,因为是不同域、不同端口的,这里我的项目是单体的所以其实这个跨域问题也不用解决,贴出来让大家注意一下,以后做前后端分离的系统的话就要处理这些东西了

package com.user.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 解决跨域问题
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*")
                .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
                .allowCredentials(true)
                .maxAge(3600)
                .allowedHeaders("*");
    }
}

附上整个项目的springboot配置文件

#控制台日志输出
logging:
    level:
        com:
            user:
                '*': debug

server:
    #设置端口号
    port: 1234
spring:
    #设置数据源mysql数据库的连接驱动、连接地址、数据库密码、数据库用户名
    datasource:
        driver-class-name: com.mysql.cj.jdbc.Driver
        password: 123456
        url: jdbc:mysql://localhost:3306/animal_rescue?serverTimezone=UTC
        username: root
    #啥玩意模板,有点忘了
    thymeleaf:
        prefix: classpath:/templates/
        suffix: .html

1.登录功能(小猫猫是不是很可爱呢...嘻嘻嘻)

2.系统管理:用户管理、角色管理、菜单管理、个人信息管理

PS:用户管理本来还想通过soket来实现一个聊天的子系统,想了想没啥这玩意也没做过就搁置了,哈哈哈,主要还是太懒了

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第2张图片

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第3张图片

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第4张图片

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第5张图片

 User的Controller展现层

CONTROLLER层

  • 控制层,实现对Get和Post的相应
  • 用于前后端交互,service层和前端通过Controller层进行数据交互

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.controller;

import com.user.model.User;
import com.user.service.IUserService;
import com.user.utils.Result;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    IUserService iUserService;
    //用户登录
    @GetMapping("{fullname}/{password}")
    public Result tologin(@PathVariable String fullname,@PathVariable String password){
        return iUserService.u(fullname, password);
    }
    //查寻所有用户以及其角色信息
    @GetMapping("/info")
    public Result getUserInfo(){
        return new Result(true,iUserService.selectUserByRoleId());
    }
    //删除用户
    @DeleteMapping("{userid}")
    public Result delUser(@PathVariable String userid){
        return new Result(iUserService.delUser(userid));
    }
    //新增用户
    @PostMapping
    public Result addUser(@RequestBody User user){
        boolean flag = iUserService.addUser(user);
        return new Result(flag, flag ? "添加成功^_^" : "因已有重复账号,添加失败-_-!");
    }
    //根据编号查询用户
    @GetMapping("/selectUserById/{userid}")
    public Result selectUserById(@PathVariable(name = "userid") String userid){
        return new Result(true,iUserService.selectUserById(userid));
    }
    //修改用户
    @PutMapping
    public Result updateUserById(@RequestBody User user){
        boolean flag = iUserService.updateUserById(user);
        return new Result(flag, flag ? "修改成功^_^" : "因已有重复账号,修改失败-_-!");
    }

}

 User功能的Service接口层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service;

import com.user.model.User;
import com.user.utils.Result;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IUserService {
    //登录
    Result u(String fullname, String password);
    //查询用户与之对应的角色
    List selectUserByRoleId();
    //根据id删除用户
    Boolean delUser(String userid);
    //新增用户
    Boolean addUser(User user);
    //根据id查询用户
    User selectUserById(String userid);
    //根据id修改用户信息
    Boolean updateUserById(User user);
}

 User功能的Service接口的Impl实现层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service.impl;

import com.user.dao.RoleDao;
import com.user.dao.UserDao;
import com.user.model.Role;
import com.user.model.User;
import com.user.service.IUserService;
import com.user.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.UUID;

@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    UserDao userDao;
    @Autowired
    RoleDao roleDao;
    //登录
    @Override
    public Result u(String fullname, String password) {
        User user =userDao.u(fullname,password);

        if(StringUtils.isEmpty(user)){
            return new Result(false);
        }else {
            user.setRole(roleDao.r(user.getUserid()));
            return new Result(true,user);
        }
    }
    //查询用户与之对应的角色
    @Override
    public List selectUserByRoleId() {
        List user = userDao.getUser();
        for (User u: user) {
            Role r = roleDao.r(u.getUserid());
            if(!StringUtils.isEmpty(r)){
                u.setRoleName(r.getRolename());
            }
        }
        return user;
    }
    //根据id删除用户
    @Override
    public Boolean delUser(String userid) {
        userDao.delUserRole(userid);
        return userDao.delUser(userid)>0;
    }
    //新增用户
    @Override
    public Boolean addUser(User user) {
        List list = userDao.getUser();
        for (User u: list) {
            if(u.getFullname().equals(user.getFullname())){
                return false;
            }
        }
        String uuid = UUID.randomUUID().toString().replaceAll("-","");
        //设置新增用户编号自增1
        user.setUserid(uuid);
        //新增用户角色
        userDao.addUserRole(user);
        return userDao.addUser(user)>0;
    }
    //根据id查询用户
    @Override
    public User selectUserById(String userid) {
        User user = userDao.selectUserById(userid);
        Role r = roleDao.r(user.getUserid());
        user.setRoleName(r.getRolename());
        user.setBackup(r.getRoleid());
        return user;
    }
    //根据id修改用户信息
    @Override
    public Boolean updateUserById(User user) {
        List list = userDao.getUser();
        for (User u: list) {
            if(u.getFullname().equals(user.getFullname())){
                if(u.getFullname().equals(user.getBackup3())){
                    //如果当前用户账号等于数据库里的账号
                }else{
                    return false;
                }
            }
        }


        //修改根据角色编号修改用户角色
        roleDao.updateRoleUser(user.getBackup(),user.getUserid());
        return userDao.updateUserById(user)>0;
    }
}

 User功能的Dao数据持久化层

DAO层

  • 数据持久层,用于存放sql语句,在SpringBoot中用注解来为每一个方法注入sql语句
  • 又称为mapper层

这一层请注意,我用的是mybatis的注解sql,并没有在mapper的xml里使用sql语句哦

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.dao;

import com.user.model.User;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface UserDao {
    //登录验证
    @Select("select * from user where fullname = #{fullname} and password = #{password}")
    User u(String fullname,String password);
    //查询所有用户
    @Select("select * from user")
    List getUser();
    //根据id删除用户
    @Delete("DELETE from user where userid=#{userid}")
    Integer delUser(String userid);
    //根据id删除用户对应的角色
    @Delete("DELETE from userrole where userid=#{userid}")
    Integer delUserRole(String userid);
    //新增用户
    @Insert("insert into user (userid,fullname,password)\n" +
            "value\n" +
            "(#{userid},#{fullname},#{password})")
    Integer addUser(User user);
    //查询所有用户
    @Select("select * from user order by userid DESC limit 1;")
    User selectUserCount();
    //新增用户角色
    @Insert("insert into userrole (roleid,userid)\n" +
            "value\n" +
            "(#{backup},#{userid})")
    Integer addUserRole(User user);
    //根据id查询用户
    @Select("select * from user where userid = #{userid}")
    User selectUserById(String userid);
    //根据id修改用户账号密码
    @Update("UPDATE user SET " +
            "fullname = #{fullname}, " +
            "password = #{password},  " +
            "username = #{username}," +
            "identity = #{identity}," +
            "sex = #{sex}," +
            "age = #{age}," +
            "area = #{area}," +
            "address = #{address}," +
            "phone = #{phone}\n" +
            "WHERE userid = #{userid}")
    Integer updateUserById(User user);
}

 User功能的Model实体层

MODEL层

  • model层,又称:数据访问层
  • 一张表对应一个实体类

这一层的类,我用的是mybatis-plus的maven插件自动生成数据库对应的字段以及表的实体类

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * 

* *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) public class User implements Serializable { private static final long serialVersionUID = 1L; /** * 用户编号 */ private String userid; /** * 用户账号 */ private String fullname; /** * 用户密码 */ private String password; /** * 用户姓名 */ private String username; /** * 用户身份证 */ private String identity; /** * 用户性别(0女,1男) */ private String sex; /** * 用户年龄 */ private String age; /** * 用户所在地区 */ private String area; /** * 用户具体地址 */ private String address; /** * 用户手机号 */ private String phone; /** * 备用1 */ private String backup; /** * 备用2 */ private String backup2; /** * 备用3 */ private String backup3; /** * 用户_角色 */ private Role role; /** * 角色名称 */ private String roleName; }

3.救助站管理:救助站信息

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第6张图片

 救助站的Controller展现层

CONTROLLER层

  • 控制层,实现对Get和Post的相应
  • 用于前后端交互,service层和前端通过Controller层进行数据交互

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.controller;


import com.user.model.Station;
import com.user.service.IStationService;
import com.user.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 

* 救助站表 前端控制器 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @RestController @RequestMapping("/station") public class StationController { @Autowired IStationService iStationService; //查询所有救助站信息 @GetMapping("/list") public Result getStationAll(){ return new Result(true,iStationService.getStationAll()); } //根据编号查询救助站信息 @GetMapping("/getStationOne/{staId}") public Result getStationOne(@PathVariable String staId){ return new Result(true,iStationService.getStationOne(staId)); } //删除救助站 @DeleteMapping("{staId}") public Result delStation(@PathVariable String staId){ String[] sta = staId.split(","); for (String id : sta){ iStationService.delStation(id); } return new Result(true); } //新增救助站 @PostMapping("/addStation") public Result addStation(@RequestBody Station station){ boolean flag = iStationService.addStation(station); return new Result(flag, flag ? "添加成功^_^" : "添加失败-_-!"); } //根据救助站名称、容量、地区、地址模糊查询 @PostMapping("/selectStationByCriteria") public Result selectStationByCriteria(@RequestBody Station station){ return new Result(true,iStationService.selectStationByCriteria(station)); } //修改救助站 @PostMapping("/udpateStation") public Result updateStationById(@RequestBody Station station){ boolean flag = iStationService.updateStationById(station); return new Result(flag, flag ? "修改成功^_^" : "修改失败-_-!"); } }

救助站功能的Service接口层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service;

import com.user.model.Role;
import com.user.model.Station;
import com.user.model.User;
import com.user.utils.Result;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IStationService {
    //查询所有救助站信息
    List getStationAll();
    //根据编号查询救助站信息
    Station getStationOne(String staId);
    //根据id删除救助站
    Boolean delStation(String staId);
    //新增救助站
    Boolean addStation(Station station);
    //模糊查询救助站
    List selectStationByCriteria(Station station);
    //根据编号修改救助站
    Boolean updateStationById(Station station);
}

救助站功能的Service接口的Impl实现层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service.impl;

import com.user.dao.StationDao;
import com.user.model.Menu;
import com.user.model.Station;
import com.user.service.IStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class StationServiceImpl implements IStationService {
    @Autowired
    StationDao stationDao;

    //查询所有救助站信息
    @Override
    public List getStationAll() {
        List station = stationDao.getStationAll();
        return station;
    }
    //根据编号查询救助站信息
    @Override
    public Station getStationOne(String staId) {
        return stationDao.getStationOne(staId);
    }
    //根据id删除救助站
    @Override
    public Boolean delStation(String staId) {
        return stationDao.delStation(staId)>0;
    }
    //新增救助站
    @Override
    public Boolean addStation(Station station) {
        return stationDao.addStation(station)>0;
    }
    //模糊查询救助站
    @Override
    public List selectStationByCriteria(Station station) {
        //名称
        //容量
        //地区
        //地址
        List sta = stationDao.selectStationByCriteria(station);
        return sta;
    }
    //根据编号修改救助站
    @Override
    public Boolean updateStationById(Station station) {
        return stationDao.updateStationById(station)>0;
    }
}

 救助站功能的Dao数据持久化层

DAO层

  • 数据持久层,用于存放sql语句,在SpringBoot中用注解来为每一个方法注入sql语句
  • 又称为mapper层

这一层请注意,我用的是mybatis的注解sql,并没有在mapper的xml里使用sql语句哦

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.dao;

import com.user.model.Menu;
import com.user.model.Role;
import com.user.model.Station;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StationDao {
    //查询所有救助站信息
    @Select("select * from station")
    List getStationAll();
    //根据编号查询救助站信息
    @Select("select * from station where sta_id = #{staId}")
    Station getStationOne(String staId);

    //根据id删除救助站
    @Delete("delete from station where sta_id = #{staId}")
    Integer delStation(String staId);

    //新增救助站
    @Insert("insert into `station`(sta_name,capacity,set_time,area,address,phone)\n" +
            "values" +
            "(#{staName},#{capacity},#{setTime},#{area},#{address},#{phone})")
    Integer addStation(Station station);
    //模糊查询救助站
    @Select({""})
    List selectStationByCriteria(Station station);
    //根据编号修改救助站
    @Update("    update station\n" +
            "    set sta_name = #{staName},\n" +
            "      capacity = #{capacity},\n" +
            "      set_time = #{setTime},\n" +
            "      area = #{area},\n" +
            "      address = #{address},\n" +
            "      phone = #{phone},\n" +
            "      backup = #{backup},\n" +
            "      backup2 = #{backup2},\n" +
            "      backup3 = #{backup3}\n" +
            "    where sta_id = #{staId}")
    Integer updateStationById(Station station);
}

 救助站功能的Model实体层

MODEL层

  • model层,又称:数据访问层
  • 一张表对应一个实体类

这一层的类,我用的是mybatis-plus的maven插件自动生成数据库对应的字段以及表的实体类

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.sql.Date;
import java.time.LocalDateTime;

/**
 * 

* 救助站表 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @Data public class Station implements Serializable { private static final long serialVersionUID = 1L; /** * 救助站编号 */ @TableId(value = "sta_id", type = IdType.AUTO) private Integer staId; /** * 救助站名称 */ private String staName; /** * 救助站容量 */ private String capacity; /** * 救助站成立时间 */ @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") private Date setTime; /** * 救助站所在地区 */ private String area; /** * 救助站具体地址 */ private String address; /** * 救助站联系方式 */ private String phone; /** * 备用列1 */ private String backup; /** * 备用列1 */ private String backup2; /** * 备用列3 */ private String backup3; }

4.领养管理:待领养信息、领养信息

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第7张图片

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第8张图片

   领养管理Controller展现层

CONTROLLER层

  • 控制层,实现对Get和Post的相应
  • 用于前后端交互,service层和前端通过Controller层进行数据交互

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.controller;


import com.user.model.Adopt;
import com.user.service.IAdoptService;
import com.user.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 

* 领养信息表 前端控制器 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @RestController @RequestMapping("/adopt") public class AdoptController { @Autowired IAdoptService iAdoptService; //查询所有宠物领养信息信息 @GetMapping("/list") public Result getAdoptAll(){ return new Result(true,iAdoptService.getAdoptAll()); } //根据编号查询宠物领养信息信息 @GetMapping("/getAdoptOne/{adId}") public Result getAdoptOne(@PathVariable String adId){ return new Result(true,iAdoptService.getAdoptOne(adId)); } //删除宠物领养信息 @DeleteMapping("{adId}") public Result delAdopt(@PathVariable String adId){ String[] sta = adId.split(","); for (String id : sta){ iAdoptService.delAdopt(id); } return new Result(true); } //根据宠物领养信息模糊查询 @PostMapping("/selectAdoptByCriteria") public Result selectAdoptByCriteria(@RequestBody Adopt adopt){ System.out.println(adopt.getAn().getAnName()); System.out.println(adopt.getUser().getUsername()); return new Result(true,iAdoptService.selectAdoptByCriteria(adopt)); } //修改宠物领养信息 @PutMapping public Result updateAdoptById(@RequestBody Adopt adopt){ boolean flag = iAdoptService.updateAdoptById(adopt); return new Result(flag, flag ? "修改成功^_^" : "修改失败-_-!"); } }

领养管理功能的Service接口层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service;

import com.user.model.Adopt;

import java.util.List;

public interface IAdoptService {
    //查询所有宠物领养信息信息
    List getAdoptAll();
    //根据编号查询宠物领养信息信息
    Adopt getAdoptOne(String anId);
    //根据id删除宠物领养信息
    Boolean delAdopt(String anId);
    //模糊查询宠物领养信息
    List selectAdoptByCriteria(Adopt Adopt);
    //根据编号修改宠物领养信息
    Boolean updateAdoptById(Adopt Adopt);
}

 领养管理功能的Service接口的Impl实现层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service.impl;

import com.user.dao.AdoptDao;
import com.user.dao.AnimalDao;
import com.user.model.Adopt;
import com.user.model.Animal;
import com.user.service.IAdoptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AodptServiceImpl implements IAdoptService {
    @Autowired
    AdoptDao adoptDao;
    @Autowired
    AnimalDao animalDao;

    //查询所有动物信息
    @Override
    public List getAdoptAll() {
        List ado = adoptDao.getAdoptAll();
        return ado;
    }
    //根据编号查询动物信息
    @Override
    public Adopt getAdoptOne(String adId) {
        return adoptDao.getAdoptOne(adId);
    }
    //根据id删除动物
    @Override
    public Boolean delAdopt(String adId) {
        return adoptDao.delAdopt(adId)>0;
    }
    //模糊查询动物
    @Override
    public List selectAdoptByCriteria(Adopt adopt) {
        List sta = adoptDao.selectAdoptByCriteria(adopt);
        return sta;
    }
    //根据编号修改动物领养信息
    @Override
    public Boolean updateAdoptById(Adopt adopt) {
        //如果当前状态为驳回或者为待领养那么修改宠物的状态
        if ("0".equals(adopt.getAdoptStatus())){
            Animal a = new Animal();
            a.setAnId(Integer.valueOf(adopt.getAnId()));
            a.setState("1");
            animalDao.updateAnimalStateById(a);
        }
        return adoptDao.updateAdoptById(adopt)>0;
    }
}

 领养管理功能的Dao数据持久化层

DAO层

  • 数据持久层,用于存放sql语句,在SpringBoot中用注解来为每一个方法注入sql语句
  • 又称为mapper层

这一层请注意,我用的是mybatis的注解sql,并没有在mapper的xml里使用sql语句哦

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.dao;

import com.user.model.Adopt;
import com.user.model.Animal;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdoptDao {
    //查询所有领养宠物信息
    @Select("select * from adopt")
    List getAdoptAll();
    //根据编号查询领养宠物信息
    @Select("select a.ad_id,a.remarks,a.adopt_time,a.adopt_status,\n" +
            "adopt_status as adoptStatus,a.an_id,\n" +
            "b.an_id as banId,an_name as anName,\n" +
            "c.userid as cuserId,fullname\n" +
            "from adopt as a \n" +
            "INNER JOIN animal as b on a.an_id = b.an_id \n" +
            "INNER JOIN `user` as c on a.userid = c.userid\n" +
            "where ad_id = #{adId}")
    @ResultMap(value = "adoptMap")
    Adopt getAdoptOne(String adId);

    //根据id删除领养宠物
    @Delete("delete from adopt where ad_id = #{adId}")
    Integer delAdopt(String adId);

    //模糊查询领养宠物
    @Select({""})
    @Results(id="adoptMap",value={
            @Result(id=true,column = "ad_id",property = "adId"),
            @Result(column = "remarks",property = "remarks"),
            @Result(column = "adopt_time",property = "adoptTime"),
            @Result(column = "adoptStatus",property = "adoptStatus"),
            @Result(column = "banId",property = "anId"),
            @Result(column = "cuserId",property = "userid"),
            @Result(column = "anName",property = "backup"),
            //宠物信息
            @Result(column = "banId",property = "an.anId"),
            @Result(column = "anName",property = "an.anName"),
            //用户信息
            @Result(column = "cuserId",property = "user.userid"),
            @Result(column = "fullname",property = "user.username")
    })
    List selectAdoptByCriteria(Adopt Adopt);

    //新增宠物领养信息
    @Insert("insert into `adopt`(userid,an_id,adopt_time,remarks,adopt_status)\n" +
            "values\n" +
            "(#{userid},#{anId},#{adoptTime},#{remarks},'2')")
    Integer addAdopt(Adopt Adopt);

    //根据编号修改领养宠物
    @Update("    update adopt\n" +
            "    set userid = #{userid},\n" +
            "      an_id = #{anId},\n" +
            "      adopt_time = #{adoptTime},\n" +
            "      remarks = #{remarks},\n" +
            "      adopt_status = #{adoptStatus},\n" +
            "      backup = #{backup},\n" +
            "      backup2 = #{backup2},\n" +
            "      backup3 = #{backup3}\n" +
            "    where ad_id = #{adId}")
    Integer updateAdoptById(Adopt Adopt);
}

  领养管理功能的Model实体层

MODEL层

  • model层,又称:数据访问层
  • 一张表对应一个实体类

这一层的类,我用的是mybatis-plus的maven插件自动生成数据库对应的字段以及表的实体类

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 

* 领养信息表 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) public class Adopt implements Serializable { private static final long serialVersionUID = 1L; /** * 动物编号 */ @TableId(value = "ad_id", type = IdType.AUTO) private Integer adId; /** * 领养人编号 */ private String userid; /** * 被领养猫狗编号 */ private String anId; /** * 领养时间 */ @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") private Date adoptTime; /** * 物种(0猫,1狗) */ private String remarks; /** * 审核状态(0驳回,1通过,2待审核) */ private String adoptStatus; /** * 备用列1 */ private String backup; /** * 备用列1 */ private String backup2; /** * 备用列3 */ private String backup3; /** * 宠物信息 */ private Animal an; /** * 用户信息 */ private User user; }

5.养宠攻略管理:攻略信息

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第9张图片

 养宠攻略管理Controller展现层

CONTROLLER层

  • 控制层,实现对Get和Post的相应
  • 用于前后端交互,service层和前端通过Controller层进行数据交互

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.controller;


import com.user.model.Strategy;
import com.user.service.IStrategyService;
import com.user.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 

* 攻略表 前端控制器 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @RestController @RequestMapping("/strategy") public class StrategyController { @Autowired IStrategyService iStrategyService; //查询所有攻略信息 @GetMapping("/list") public Result getStrategyAll(){ return new Result(true,iStrategyService.getStrategyAll()); } //根据编号查询攻略信息 @GetMapping("/getStrategyOne/{strId}") public Result getStrategyOne(@PathVariable String strId){ return new Result(true,iStrategyService.getStrategyOne(strId)); } //删除攻略 @DeleteMapping("{strId}") public Result delStrategy(@PathVariable String strId){ String[] sta = strId.split(","); for (String id : sta){ iStrategyService.delStrategy(id); } return new Result(true); } //新增攻略 @PostMapping("/addStrategy") public Result addStrategy(@RequestBody Strategy strategy){ boolean flag = iStrategyService.addStrategy(strategy); return new Result(flag, flag ? "添加成功^_^" : "添加失败-_-!"); } //根据攻略模糊查询 @PostMapping("/selectStrategyByCriteria") public Result selectStrategyByCriteria(@RequestBody Strategy strategy){ return new Result(true,iStrategyService.selectStrategyByCriteria(strategy)); } //修改攻略 @PutMapping public Result updateStrategyById(@RequestBody Strategy strategy){ boolean flag = iStrategyService.updateStrategyById(strategy); return new Result(flag, flag ? "修改成功^_^" : "修改失败-_-!"); } }

养宠攻略管理功能的Service接口层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service;

import com.user.model.Strategy;

import java.util.List;

public interface IStrategyService {
    //查询所有攻略信息
    List getStrategyAll();
    //根据编号查询攻略信息
    Strategy getStrategyOne(String str_id);
    //根据id删除攻略
    Boolean delStrategy(String str_id);
    //新增攻略
    Boolean addStrategy(Strategy strategy);
    //模糊查询攻略
    List selectStrategyByCriteria(Strategy strategy);
    //根据编号修改攻略
    Boolean updateStrategyById(Strategy strategy);
}

养宠攻略管理功能的Service接口的Impl实现层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service.impl;

import com.user.dao.StrategyDao;
import com.user.model.Strategy;
import com.user.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class StrategyServiceImpl implements IStrategyService {
    @Autowired
    StrategyDao strategyDao;

    //查询所有攻略信息
    @Override
    public List getStrategyAll() {
        List strategy = strategyDao.getStrategyAll();
        return strategy;
    }
    //根据编号查询攻略信息
    @Override
    public Strategy getStrategyOne(String strId) {
        return strategyDao.getStrategyOne(strId);
    }
    //根据id删除攻略
    @Override
    public Boolean delStrategy(String strId) {
        return strategyDao.delStrategy(strId)>0;
    }
    //新增攻略
    @Override
    public Boolean addStrategy(Strategy strategy) {
        strategy.setCreateTime(new Date());
        return strategyDao.addStrategy(strategy)>0;
    }
    //模糊查询攻略
    @Override
    public List selectStrategyByCriteria(Strategy strategy) {
        List sta = strategyDao.selectStrategyByCriteria(strategy);
        return sta;
    }
    //根据编号修改攻略
    @Override
    public Boolean updateStrategyById(Strategy strategy) {
        return strategyDao.updateStrategyById(strategy)>0;
    }
}

养宠攻略管理功能的Dao数据持久化层

DAO层

  • 数据持久层,用于存放sql语句,在SpringBoot中用注解来为每一个方法注入sql语句
  • 又称为mapper层

这一层请注意,我用的是mybatis的注解sql,并没有在mapper的xml里使用sql语句哦

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.dao;

import com.user.model.Strategy;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StrategyDao {
    //查询所有攻略信息
    @Select("select * from strategy")
    List getStrategyAll();
    //根据编号查询攻略信息
    @Select("select str_id,title,content,createTime,b.userid as buserid,username\n" +
            "from `strategy` as a\n" +
            "inner join `user` as b on a.userid = b.userid\n" +
            " where str_id = #{strId}")
    @ResultMap(value = "strategyMap")
    Strategy getStrategyOne(String strId);

    //根据id删除攻略
    @Delete("delete from strategy where str_id = #{strId}")
    Integer delStrategy(String strId);

    //新增攻略
    @Insert("    insert into strategy (str_id, userid, createTime, \n" +
            "      title, content, backup, \n" +
            "      backup2, backup3)\n" +
            "    values (#{strId}, #{userid}, #{createTime}, \n" +
            "      #{title}, #{content}, #{backup}, \n" +
            "      #{backup2}, #{backup3})")
    Integer addStrategy(Strategy strategy);
    //模糊查询攻略
    @Select({""})
    @Results(id="strategyMap",value={
            @Result(id=true,column = "str_id",property = "strId"),
            @Result(column = "title",property = "title"),
            @Result(column = "content",property = "content"),
            @Result(column = "createTime",property = "createTime"),
            //用户信息
            @Result(column = "buserid",property = "user.userid"),
            @Result(column = "fullname",property = "user.username")
    })
    List selectStrategyByCriteria(Strategy strategy);
    //根据编号修改攻略
    @Update(" update strategy\n" +
            "    set userid = #{userid},\n" +
            "      createTime = #{createTime},\n" +
            "      title = #{title},\n" +
            "      content = #{content},\n" +
            "      backup = #{backup},\n" +
            "      backup2 = #{backup2},\n" +
            "      backup3 = #{backup3}\n" +
            "    where str_id = #{strId}")
    Integer updateStrategyById(Strategy strategy);
}

养宠攻略管理功能的Model实体层

MODEL层

  • model层,又称:数据访问层
  • 一张表对应一个实体类

这一层的类,我用的是mybatis-plus的maven插件自动生成数据库对应的字段以及表的实体类

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 

* 攻略表 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) public class Strategy implements Serializable { private static final long serialVersionUID = 1L; /** * 攻略编号 */ @TableId(value = "str_id", type = IdType.AUTO) private Integer strId; /** * 发布人编号 */ private String userid; /** * 发布时间 */ @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") private Date createTime; /** * 标题 */ private String title; /** * 内容 */ private String content; /** * 备用列1 */ private String backup; /** * 备用列1 */ private String backup2; /** * 备用列3 */ private String backup3; //用户信息 private User user; }

6.交流消息管理:消息信息

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第10张图片

交流消息管理Controller展现层

CONTROLLER层

  • 控制层,实现对Get和Post的相应
  • 用于前后端交互,service层和前端通过Controller层进行数据交互

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.controller;


import com.user.model.Information;
import com.user.service.IInformationService;
import com.user.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 

* 交流信息表 前端控制器 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @RestController @RequestMapping("/information") public class InformationController { @Autowired IInformationService iInformationService; //查询所有消息信息 @GetMapping("/list") public Result getInformationAll(){ return new Result(true,iInformationService.getInformationAll()); } //根据编号查询消息信息 @GetMapping("/getInformationOne/{inId}") public Result getInformationOne(@PathVariable String inId){ return new Result(true,iInformationService.getInformationOne(inId)); } //删除消息 @DeleteMapping("{inId}") public Result delInformation(@PathVariable String inId){ String[] sta = inId.split(","); for (String id : sta){ iInformationService.delInformation(id); } return new Result(true); } //新增消息 @PostMapping public Result addInformation(@RequestBody Information information){ boolean flag = iInformationService.addInformation(information); return new Result(flag, flag ? "添加成功^_^" : "添加失败-_-!"); } //根据消息模糊查询 @PostMapping("/selectInformationByCriteria") public Result selectInformationByCriteria(@RequestBody Information information){ return new Result(true,iInformationService.selectInformationByCriteria(information)); } //修改消息信息 @PutMapping public Result updateInformationById(@RequestBody Information information){ boolean flag = iInformationService.updateInformationById(information); return new Result(flag, flag ? "修改成功^_^" : "修改失败-_-!"); } }

交流消息管理功能的Service接口层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service;

import com.user.model.Information;

import java.util.List;

public interface IInformationService {
    //查询所有消息信息
    List getInformationAll();
    //根据编号查询消息信息
    Information getInformationOne(String in_id);
    //根据id删除消息
    Boolean delInformation(String in_id);
    //新增消息
    Boolean addInformation(Information information);
    //模糊查询消息
    List selectInformationByCriteria(Information information);
    //根据编号修改消息
    Boolean updateInformationById(Information information);
}

交流消息管理功能的Service接口的Impl实现层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service.impl;

import com.user.dao.InformationDao;
import com.user.dao.RoleDao;
import com.user.model.Information;
import com.user.model.Role;
import com.user.service.IInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class InformationServiceImpl implements IInformationService {
    @Autowired
    InformationDao informationDao;
    @Autowired
    RoleDao roleDao;

    //查询所有消息信息
    @Override
    public List getInformationAll() {
        List information = informationDao.getInformationAll();
        return information;
    }
    //根据编号查询消息信息
    @Override
    public Information getInformationOne(String inId) {
        return informationDao.getInformationOne(inId);
    }
    //根据id删除消息
    @Override
    public Boolean delInformation(String inId) {
        return informationDao.delInformation(inId)>0;
    }
    //新增消息
    @Override
    public Boolean addInformation(Information information) {
        information.setCreateTime(new Date());
        return informationDao.addInformation(information)>0;
    }
    //模糊查询消息
    @Override
    public List selectInformationByCriteria(Information information) {
        //根据用户编号查询用户角色信息
        Role r = roleDao.r(information.getBackup());
        List sta = new ArrayList();
        //判断此用户不是管理员(查询接收者固定为当前用户)
        if (!"1".equals(r.getRoleid())){
            //其它用户
            System.out.println("当前用户的编号"+information.getBackup());
            System.out.println("发送人编号"+information.getPublishUserid());
            System.out.println("接收人编号"+information.getAddresseeUserid());
            if(null == information.getAddresseeUserid() || "".equals(information.getAddresseeUserid()) && null == information.getContent() || "".equals(information.getContent()) ){
                information.setBackup2("都为空");
            }
            sta=informationDao.selectInformationById(information);
        }else{
            //管理员
            sta = informationDao.selectInformationByCriteria(information);
        }
        return sta;
    }

    //根据编号修改消息
    @Override
    public Boolean updateInformationById(Information information) {
        return informationDao.updateInformationById(information)>0;
    }
}

交流消息管理功能的Dao数据持久化层

DAO层

  • 数据持久层,用于存放sql语句,在SpringBoot中用注解来为每一个方法注入sql语句
  • 又称为mapper层

这一层请注意,我用的是mybatis的注解sql,并没有在mapper的xml里使用sql语句哦

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.dao;

import com.user.model.Information;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface InformationDao {
    //查询所有消息信息
    @Select("select * from information")
    List getInformationAll();
    //根据编号查询消息信息
    @Select("select a.fullname as publishUser,a.userid as publishUserId," +
            "b.fullname as addresseeUser,b.userid as addresseeUserId,i.*\n" +
            "from information as i\n" +
            "inner join `user` as a on a.userid=i.publish_userid\n" +
            "inner join `user` as b on b.userid=i.addressee_userid\n" +
            " where in_id = #{inId}")
    @ResultMap(value = "informationMap")
    Information getInformationOne(String inId);

    //根据id删除消息
    @Delete("delete from information where in_id = #{inId}")
    Integer delInformation(String inId);

    //新增消息
    @Insert("    insert into information (in_id, publish_userid, addressee_userid, \n" +
            "      create_time, content, backup, \n" +
            "      backup2, backup3)\n" +
            "    values (#{inId}, #{publishUserid}, #{addresseeUserid}, \n" +
            "      #{createTime}, #{content}, #{backup}, \n" +
            "      #{backup2}, #{backup3})")
    Integer addInformation(Information information);
    //模糊查询消息
    @Select({""})
    @Results(id="informationMap",value={
            @Result(id=true,column = "in_id",property = "inId"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "content",property = "content"),
            //发送者信息
            @Result(column = "publishUserId",property = "user.userid"),
            @Result(column = "publishUser",property = "user.username"),
            //接收者信息
            @Result(column = "addresseeUserId",property = "user2.userid"),
            @Result(column = "addresseeUser",property = "user2.username")
    })
    List selectInformationByCriteria(Information information);

    //模糊查询消息
    @Select({""})
    @Results(id="informationMapById",value={
            @Result(id=true,column = "in_id",property = "inId"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "content",property = "content"),
            //发送者信息
            @Result(column = "publishUserId",property = "user.userid"),
            @Result(column = "publishUser",property = "user.username"),
            //接收者信息
            @Result(column = "addresseeUserId",property = "user2.userid"),
            @Result(column = "addresseeUser",property = "user2.username")
    })
    List selectInformationById(Information information);


    //根据编号修改消息
    @Update("    update information\n" +
            "    set publish_userid = #{publishUserid},\n" +
            "      addressee_userid = #{addresseeUserid},\n" +
            "      create_time = #{createTime},\n" +
            "      content = #{content},\n" +
            "      backup = #{backup},\n" +
            "      backup2 = #{backup2},\n" +
            "      backup3 = #{backup3}\n" +
            "    where in_id = #{inId}")
    Integer updateInformationById(Information information);
}

交流消息管理功能的Model实体层

MODEL层

  • model层,又称:数据访问层
  • 一张表对应一个实体类

这一层的类,我用的是mybatis-plus的maven插件自动生成数据库对应的字段以及表的实体类

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 

* 交流信息表 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) public class Information implements Serializable { private static final long serialVersionUID = 1L; /** * 消息编号 */ @TableId(value = "in_id", type = IdType.AUTO) private Integer inId; /** * 发送人编号 */ private String publishUserid; /** * 收信人编号 */ private String addresseeUserid; /** * 发送时间 */ @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") private Date createTime; /** * 消息内容 */ private String content; /** * 备用列1 */ private String backup; /** * 备用列1 */ private String backup2; /** * 备用列3 */ private String backup3; /** * 接收者 */ private User user; /** * 发送者 */ private User user2; }

7.捐赠支出管理:捐赠支出信息SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第11张图片

捐赠支出管理Controller展现层

CONTROLLER层

  • 控制层,实现对Get和Post的相应
  • 用于前后端交互,service层和前端通过Controller层进行数据交互

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.controller;


import com.user.model.Donate;
import com.user.service.IDonateService;
import com.user.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 

* 捐赠支出信息表 前端控制器 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @RestController @RequestMapping("/donate") public class DonateController { @Autowired IDonateService iDonateService; //查询所有捐赠支出信息 @GetMapping("/list") public Result getDonateAll(){ return new Result(true,iDonateService.getDonateAll()); } //根据编号查询捐赠支出信息 @GetMapping("/getDonateOne/{doId}") public Result getDonateOne(@PathVariable String doId){ return new Result(true,iDonateService.getDonateOne(doId)); } //删除捐赠支出 @DeleteMapping("{doId}") public Result delDonate(@PathVariable String doId){ String[] sta = doId.split(","); for (String id : sta){ iDonateService.delDonate(id); } return new Result(true); } //新增捐赠支出 @PostMapping("/addDonate") public Result addDonate(@RequestBody Donate Donate){ boolean flag = iDonateService.addDonate(Donate); return new Result(flag, flag ? "添加成功^_^" : "添加失败-_-!"); } //根据捐赠支出模糊查询 @PostMapping("/selectDonateByCriteria") public Result selectDonateByCriteria(@RequestBody Donate donate){ return new Result(true,iDonateService.selectDonateByCriteria(donate)); } //修改捐赠支出 @PutMapping public Result updateDonateById(@RequestBody Donate donate){ boolean flag = iDonateService.updateDonateById(donate); return new Result(flag, flag ? "修改成功^_^" : "修改失败-_-!"); } }

捐赠支出管理功能的Service接口层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service;

import com.user.model.Donate;
import com.user.model.Strategy;

import java.util.List;

public interface IDonateService {
    //查询所有捐赠/支出信息
    List getDonateAll();
    //根据编号查询捐赠/支出信息
    Donate getDonateOne(String doId);
    //根据id删除捐赠/支出
    Boolean delDonate(String doId);
    //新增捐赠/支出
    Boolean addDonate(Donate donate);
    //模糊查询捐赠/支出
    List selectDonateByCriteria(Donate donate);
    //根据编号修改捐赠/支出
    Boolean updateDonateById(Donate donate);
}

捐赠支出管理功能的Service接口的Impl实现层

SERVICE层

  • 业务逻辑层,用于完成功能设计
  • 一般用于调用dao层的接口,实现业务功能

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.service.impl;

import com.user.dao.DonateDao;
import com.user.model.Donate;
import com.user.service.IDonateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DonateServiceImpl implements IDonateService {
    @Autowired
    DonateDao donateDao;

    //查询所有捐赠/支出信息
    @Override
    public List getDonateAll() {
        List Donate = donateDao.getDonateAll();
        return Donate;
    }
    //根据编号查询捐赠/支出信息
    @Override
    public Donate getDonateOne(String doId) {
        return donateDao.getDonateOne(doId);
    }
    //根据id删除捐赠/支出
    @Override
    public Boolean delDonate(String doId) {
        return donateDao.delDonate(doId)>0;
    }
    //新增捐赠/支出
    @Override
    public Boolean addDonate(Donate donate) {
        donate.setCreateTime(new Date());
        donate.setAdminId("1");
        return donateDao.addDonate(donate)>0;
    }
    //模糊查询捐赠/支出
    @Override
    public List selectDonateByCriteria(Donate donate) {
        List sta = donateDao.selectDonateByCriteria(donate);
        return sta;
    }

    //根据编号修改捐赠/支出
    @Override
    public Boolean updateDonateById(Donate donate) {
        return donateDao.updateDonateById(donate)>0;
    }
}

捐赠支出管理功能的Dao数据持久化层

DAO层

  • 数据持久层,用于存放sql语句,在SpringBoot中用注解来为每一个方法注入sql语句
  • 又称为mapper层

这一层请注意,我用的是mybatis的注解sql,并没有在mapper的xml里使用sql语句哦

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.dao;

import com.user.model.Donate;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DonateDao {
    //查询所有捐赠/支出信息
    @Select("select * from donate")
    List getDonateAll();
    //根据编号查询捐赠/支出信息
    @Select("select do_id,personName,`specific`,create_time,admin_id,\n" +
            "case behavior when '0' then '捐赠' else '支出' end as behavior,\n" +
            "b.sta_id as staId,sta_name,\n" +
            "c.userid as cuserId,username\n" +
            "from donate as a \n" +
            "INNER JOIN station as b on a.sta_id = b.sta_id\n" +
            "INNER JOIN `user` as c on a.admin_id = c.userid\n" +
            " where do_id = #{doId}")
    @ResultMap(value = "DonateMap")
    Donate getDonateOne(String doId);

    //根据id删除捐赠/支出
    @Delete("delete from donate where do_id = #{doId}")
    Integer delDonate(String doId);

    //新增捐赠/支出
    @Insert("insert into donate (sta_id, personName, \n" +
            "      behavior, `specific`, create_time, \n" +
            "      admin_id, backup, backup2, \n" +
            "      backup3)\n" +
            "    values ( #{staId}, #{personName}, \n" +
            "      #{behavior}, #{specific}, #{createTime}, \n" +
            "      #{adminId}, #{backup}, #{backup2}, \n" +
            "      #{backup3})")
    Integer addDonate(Donate donate);
    //模糊查询捐赠/支出
    @Select({""})
    @Results(id="DonateMap",value={
            @Result(id=true,column = "do_id",property = "doId"),
            @Result(column = "personName",property = "personName"),
            @Result(column = "specific",property = "specific"),
            @Result(column = "behavior",property = "behavior"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "admin_id",property = "adminId"),
            //救助站信息
            @Result(column = "a.sta_id",property = "sta.staId"),
            @Result(column = "sta_name",property = "sta.staName"),
            //用户信息
            @Result(column = "cuserId",property = "user.userid"),
            @Result(column = "fullname",property = "user.fullname")
    })
    List selectDonateByCriteria(Donate donate);
    //根据编号修改捐赠/支出
    @Update(" update donate\n" +
            "    set sta_id = #{staId},\n" +
            "      personName = #{personName},\n" +
            "      behavior = #{behavior},\n" +
            "      `specific` = #{specific},\n" +
            "      create_time = #{createTime},\n" +
            "      admin_id = #{adminId},\n" +
            "      backup = #{backup},\n" +
            "      backup2 = #{backup2},\n" +
            "      backup3 = #{backup3}\n" +
            "    where do_id = #{doId}")
    Integer updateDonateById(Donate donate);
}

捐赠支出管理功能的Model实体层

MODEL层

  • model层,又称:数据访问层
  • 一张表对应一个实体类

这一层的类,我用的是mybatis-plus的maven插件自动生成数据库对应的字段以及表的实体类

(以下只是部分代码,详情请去文尾下载完整版)

package com.user.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 

* 捐赠信息表 *

* * @author 关爱流浪猫狗,从我做起! * @since 2022-02-19 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) public class Donate implements Serializable { private static final long serialVersionUID = 1L; /** * 捐赠支出编号 */ @TableId(value = "do_id", type = IdType.AUTO) private Integer doId; /** * 救助站编号 */ private String staId; /** * 负责人名称 */ @TableField("personName") private String personName; /** * 行为(0捐赠,1支出) */ private String behavior; /** * 具体行为 */ private String specific; /** * 发布时间 */ @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") private Date createTime; /** * 发布记录的管理员编号 */ private String adminId; /** * 备用列1 */ private String backup; /** * 备用列1 */ private String backup2; /** * 备用列3 */ private String backup3; /** * 救助站对象 */ private Station sta; /** * 用户对象 */ private User user; }

啊,对了还有数据库的sql文件也放在了项目resouce文件夹下了

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第12张图片

 数据库表详解

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第13张图片

adopt:领养记录表
animal:宠物表
donate:救助站捐赠信息表
information:消息记录表
menu:菜单表
menurole:菜单角色中间表
role:角色表
station:救助站表
strategy:养宠攻略表
user:用户表
userrole:用户角色表

源码+项目部署

 源码地址:

https://pan.baidu.com/s/1WN-jDY8H4v5D1K-KkWlNUw
提取码:mcod

嗯嗯嗯......终于到了激动人心的时候了,我来帮你搞定一切,帝王般的服务你值得拥有,免费的哟,记得备注下:曹家的小仙女 / 小哥哥,微信:NIKE2022888

最后附上

一寸光阴一寸金,寸金难买寸光阴。请珍惜现在美好的青春,咱们一起努力奋斗,创造美好未来

拜托拜托!!!拜托拜托!!!拜托拜托!!!

SpringBoot+Mybatis+Mysql+Vue+ElementUi实现一个《流浪猫狗领养救助管理系统》毕业设计(超详细教程)_第14张图片

你可能感兴趣的:(Java后端学习,毕业设计,流浪猫狗,spring,boot,vue,mysql)