基于SpringBoot+Vue的宠物领养系统设计与实现(LW+数据库文档+讲解)

203 阅读6分钟

课题背景

二十一世纪互联网的出现,改变了几千年以来人们的生活,不仅仅是生活物资的丰富,还有精神层次的丰富。时代进步的标志,就是让人们过上更好的生活。在互联网诞生之前,地域位置往往是人们思想上不可跨域的鸿沟,信息的传播速度极慢,信息处理的速度和要求还是通过人们骑马或者是信鸽传递,这些信息传递都是不可控制的,中间很有可能丢失,信息的传递水平决定了人们生活的水平。现如今,大家都在用互联网来实现自己的目的,从内部管理设置计算机管理,提高内部信息管理水平,从外部市场也可以用计算机获取相关数据进行处理,如今各行各业已经严重依赖于计算机了。 本课题研究和开发宠物领养系统,让安装在计算机上的该系统变成管理人员的小帮手,提高宠物领养信息处理速度,规范宠物领养信息处理流程,让管理人员的产出效益更高。

研究意义

本课题研发的宠物领养系统,就是提供宠物领养信息处理的解决方案,它可以短时间处理完信息,并且只需要使用者动动鼠标和键盘就能获取自己需要的信息,并且这些信息都有专门的存储设备,而且数据的备份和迁移都可以设定为无人值守,从人力角度和信息处理角度以及信息安全角度,宠物领养系统是完胜传统纸质操作的,所以宠物领养系统就是如此的值得信赖。

系统内容实现

基于springboot的宠物领养系统设计分为用户模块和管理员模块,用户和管理员可以通过账号的注册与登录,进入各自的系统模块。用户只有注册成功之后才能进行宠物列表的浏览和领养,注册后的用户需要输入用户名及设定的密码进行系统的登录;管理员输入正确的管理员名称及密码进入系统操作,管理当前的宠物信息与用户信息。系统总体功能如下所示。 管理员功能: 1)账户的注册登录 2)个人信息修改,密码修改 3)用户管理,用户姓名、身份证号、手机号、地址等管理 4)宠物领养管理 5)宠物领养审核管理 6)宠物认领管理 7)宠物认领审核管理 8)教学视频管理 9)教学收藏、留言管理 10)感谢信管理 11)公告管理 12)轮播图管理

用户功能: 1)宠物领养首页 2)宠物领养 3)宠物认领 4)教学视频 5)公告 6)个人中心

系统设计结构图

在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述

代码参考

package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;

import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 宠物领养审核
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/chongwulingyangshenhe")
public class ChongwulingyangshenheController {
    private static final Logger logger = LoggerFactory.getLogger(ChongwulingyangshenheController.class);

    @Autowired
    private ChongwulingyangshenheService chongwulingyangshenheService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service
    @Autowired
    private ChongwulingyangService chongwulingyangService;
    @Autowired
    private YonghuService yonghuService;



    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(StringUtil.isEmpty(role))
            return R.error(511,"权限为空");
        else if("用户".equals(role))
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = chongwulingyangshenheService.queryPage(params);

        //字典表数据转换
        List<ChongwulingyangshenheView> list =(List<ChongwulingyangshenheView>)page.getList();
        for(ChongwulingyangshenheView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody ChongwulingyangshenheEntity chongwulingyangshenhe, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,chongwulingyangshenhe:{}",this.getClass().getName(),chongwulingyangshenhe.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(StringUtil.isEmpty(role))
            return R.error(511,"权限为空");
        else if("用户".equals(role))
            chongwulingyangshenhe.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

        Wrapper<ChongwulingyangshenheEntity> queryWrapper = new EntityWrapper<ChongwulingyangshenheEntity>()
            .eq("chongwulingyang_id", chongwulingyangshenhe.getChongwulingyangId())
            .eq("yonghu_id", chongwulingyangshenhe.getYonghuId())
            .eq("chongwurenlingshenhe_text", chongwulingyangshenhe.getChongwurenlingshenheText())
            .eq("chongwulingyangshenhe_yesno_types", chongwulingyangshenhe.getChongwulingyangshenheYesnoTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ChongwulingyangshenheEntity chongwulingyangshenheEntity = chongwulingyangshenheService.selectOne(queryWrapper);
        if(chongwulingyangshenheEntity==null){
            chongwulingyangshenhe.setChongwulingyangshenheYesnoTypes(1);
            chongwulingyangshenhe.setCreateTime(new Date());
            chongwulingyangshenheService.insert(chongwulingyangshenhe);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody ChongwulingyangshenheEntity chongwulingyangshenhe, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,chongwulingyangshenhe:{}",this.getClass().getName(),chongwulingyangshenhe.toString());

        //根据字段查询是否有相同数据
        Wrapper<ChongwulingyangshenheEntity> queryWrapper = new EntityWrapper<ChongwulingyangshenheEntity>()
            .notIn("id",chongwulingyangshenhe.getId())
            .andNew()
            .eq("chongwulingyang_id", chongwulingyangshenhe.getChongwulingyangId())
            .eq("yonghu_id", chongwulingyangshenhe.getYonghuId())
            .eq("chongwurenlingshenhe_text", chongwulingyangshenhe.getChongwurenlingshenheText())
            .eq("chongwulingyangshenhe_yesno_types", chongwulingyangshenhe.getChongwulingyangshenheYesnoTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ChongwulingyangshenheEntity chongwulingyangshenheEntity = chongwulingyangshenheService.selectOne(queryWrapper);
        if(chongwulingyangshenheEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      chongwulingyangshenhe.set
            //  }
            if(chongwulingyangshenhe.getChongwulingyangshenheYesnoTypes() == 2){
                ChongwulingyangEntity chongwulingyangEntity = new ChongwulingyangEntity();
                chongwulingyangEntity.setId(chongwulingyangshenhe.getChongwulingyangId());
                chongwulingyangEntity.setJieshuTypes(1);
                chongwulingyangService.updateById(chongwulingyangEntity);
            }
            chongwulingyangshenheService.updateById(chongwulingyangshenhe);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        chongwulingyangshenheService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }

    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        try {
            List<ChongwulingyangshenheEntity> chongwulingyangshenheList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            ChongwulingyangshenheEntity chongwulingyangshenheEntity = new ChongwulingyangshenheEntity();
//                            chongwulingyangshenheEntity.setChongwulingyangId(Integer.valueOf(data.get(0)));   //宠物领养 要改的
//                            chongwulingyangshenheEntity.setYonghuId(Integer.valueOf(data.get(0)));   //领养用户 要改的
//                            chongwulingyangshenheEntity.setChongwurenlingshenheText(data.get(0));                    //认领理由 要改的
//                            chongwulingyangshenheEntity.setChongwulingyangshenheYesnoTypes(Integer.valueOf(data.get(0)));   //申请状态 要改的
//                            chongwulingyangshenheEntity.setCreateTime(date);//时间
                            chongwulingyangshenheList.add(chongwulingyangshenheEntity);


                            //把要查询是否重复的字段放入map中
                        }

                        //查询是否重复
                        chongwulingyangshenheService.insertBatch(chongwulingyangshenheList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }

参考文献

[1]吴文洋,刘世宇.基于B/S架构宠物领养管理系统设计[J].软件,2020,41(11):85-87. [2]杨华.基于SSM的宠物店信息系统的设计与实现[D].吉林大学,2019. [3]余涛.计算机软件开发中Java编程语言的应用研究[J].信息记录材料,2020,21(01):113-115. [4]王子虎,胡丽珍.基于计算机软件安全开发的JAVA编程语言研究[J].数字技术与应用,2019,37(12):133-134. [5]刘星淇.Java编程语言的特点与应用分析[J].通讯世界,2019,26(09):149-150. [6]张云健.计算机软件Java编程特点及其技术应用[J].信息与电脑(理论版),2019(13):97-98. [7]张振超,吴杰,陈序蓬.浅谈Java中Mysql数据库的连接与操作[J].信息记录材料,2020,21(02):144-145. [8]范开勇,陈宇收.MySQL数据库性能优化研究[J].中国新通信,2019,21(01):57. [9]丁佳.基于JSP+MySQL的用户登录系统SQL注入实例及防范[J].网络安全技术与应用,2020(09):49-51. [10]高远,夏敏,吕林峰.基于Myeclipse集成环境下的JUnit单元测试[J].指挥信息系统与技术,2018,1(06):20-23. [11]吴鹏飞.如何解决Myeclipse开发环境下Web工程项目不编译问题[J].电脑编程技巧与维护,2017(07):93. [12]王丹,孙晓宇,杨路斌,高胜严.基于SpringBoot的软件统计分析系统设计与实现[J].软件工程,2019,22(03):40-42.

获取源码

在这里插入图片描述