基于springboot的宠物领养系统的设计与实现

 其他源码获取可以看首页:代码老y

个人简介:专注于毕业设计项目定制开发:springboot+vue系统,Java微信小程序,javaSSM系统等技术开发,并提供远程调试部署、代码讲解、文档指导、ppt制作等技术指导。源码获取,毕设定制查看本人首页获取联系

技术范围:SpringBoot、Vue、SSM、Nodejs、小程序等设计与开发。
本人负责:系统功能设计、毕设开题报告的撰写、任务书的制定、中期检查PPT的制作、系统功能的具体实现、论文的撰写与辅导以及长期的答辩答疑辅导。

大家在毕设选题,项目以及论文编写等相关问题都可以和我沟通,我会尽自己所能给大家解答。

感兴趣的同学可在文末获取联系 

1、开发相关技术介绍

1.1 SpringBoot框架

    SpringBoot 是由 Pivotal 团队开发的开源 Java 基础框架,旨在简化 Spring 应用的初始搭建以及开发过程。它通过提供一系列的“Starters”来自动配置 Spring 及其集成的第三方库,极大地降低了开发者的配置难度。SpringBoot 应用通常可以独立运行,通常打包成 JAR 文件,内置了如 Tomcat、Jetty 或 Undertow 等 Web 服务器,无需外部 Servlet SpringBoot 提倡使用 Java 注解 来优化配置流程,简化了设置步骤。此外,它还包含了一些高级的监控和管控工具,特别是 Actuator 模块,它让开发者能够方便地追踪应用程序的运行状况和性能表现。这些特点使得 SpringBoot 成为开发微服务和云应用的优选,同样适用于企业级应用。

1.2 Vue框架

    Vue 是一款专为构建动态和响应式的用户界面而设计的渐进式前端框架。Vue 在与一些更为庞大和全面的框架相比之中以其轻量级和模块化的特性脱颖而出,它的核心专注于视图层的构建,这样降低学习曲线的同时也便于与现有的项目或库进行无缝集成。 Vue 的设计理念强调简洁性和实用性,使开发者可以逐步地将框架的功能集成到项目中,不管是构建小型的交互界面还是处理大型应用,Vue 均能提供强大的功能支持。这种灵活性和易用性使前端开发更加高效和灵活,也是 Vue 受到广泛欢迎的关键因素之一。

1.3 MySQL数据库

    MySQL 数据库是一个使用 SQL 作为查询语言的开源关系型数据库管理系统。这个系统一开始是 MySQL AB 公司所开发的,之后经历了 Sun Microsystems 的收购,最终成为 Oracle 公司旗下的产品。MySQL 因其出色的性能、可靠性和用户友好的特性而受到青睐,正因如此它也被广泛地应用于网站开发、数据存储解决方案和企业级软件系统中。它不但支持多种操作系统,而且还功能丰富且配置灵活,基本上都能满足从小型应用到大型数据仓库的需求,也正因如此是众多开发者和企业第一个选择的数据库解决方案。

2、数据库实体设计 

概念设计的目标是设计出反映某个组织部门信息需求的数据库系统概念模式,数据库系统的概念模式独立于数据库系统的逻辑结构、独立于数据库管理系统(DBMS)、独立于计算机系统。

概念模式的设计方法是在需求分析的基础上,用概念数据模型(例如E-R模型)表示数据及数据之间的相互联系,设计出反映用户信息需求和处理需求的数据库系统概念模式。概念设计的目标是准确描述应用领域的信息模式,支持用户的各种应用,这样既容易转换为数据库系统逻辑模式,又容易为用户理解。数据库系统概念模式是面向现实世界的数据模型,不能直接用于数据库系统的实现。在此阶段,用户可以参与和评价数据库系统的设计,从而有利于保证数据库系统的设计与用户的需求相吻合。在概念模式的设计中,E-R模型法是最常见的设计方法。本系统的E-R图如下图所示:

(1)下图即为宠物认领这个实体所拥有的属性值。

 

(2)下图即为用户这个实体所拥有的属性值。 

 

 (3)下图即为宠物领养这个实体所拥有的属性值。

 

(4)下图即为管理员这个实体所拥有的属性值。 

   

(5)下图即为上面介绍的实体中存在的联系。 

   

  3、数据库表设计(展示部分表)     

表3.1 宠物领养表

字段

注释

类型

id (主键)

主键

×

int(11)

chongwulingyang_name

标题

varchar(200)

chongwulingyang_types

类型

int(11)

chongwulingyang_photo

宠物图片

varchar(200)

jieshu_types

是否被认领

int(11)

chongwulingyang_content

宠物详情

text

create_time

创建时间

timestamp

表3.2 管理员表

字段

注释

类型

id (主键)

主键

×

bigint(20)

username

用户名

×

varchar(100)

password

密码

×

varchar(100)

role

角色

varchar(100)

addtime

新增时间

×

timestamp

表3.3 宠物认领审核表

字段

注释

类型

id (主键)

主键

×

int(11)

chongwurenling_id

宠物认领

int(11)

yonghu_id

认领用户

int(11)

chongwurenlingshenhe_text

认领凭据

text

chongwurenlingshenhe_yesno_types

申请状态

int(11)

create_time

创建时间

timestamp

表3.4 宠物认领表

字段

注释

类型

id (主键)

主键

×

int(11)

chongwurenling_name

标题

varchar(200)

chongwulingyang_types

类型

int(11)

chongwurenling_photo

宠物图片

varchar(200)

yonghu_id

发布用户

int(11)

jieshu_types

是否找到主人

int(11)

chongwurenling_content

宠物详情

text

create_time

创建时间

timestamp

表3.5 宠物领养审核表

字段

注释

类型

id (主键)

主键

×

int(11)

chongwulingyang_id

宠物领养

int(11)

yonghu_id

领养用户

int(11)

chongwurenlingshenhe_text

认领凭据

text

chongwulingyangshenhe_yesno_types

申请状态

int(11)

create_time

创建时间

timestamp

表3.6 感谢信表

字段

注释

类型

id (主键)

主键

×

int(11)

ganxiexin_name

标题

varchar(200)

yonghu_id

发布用户

int(11)

ganxiexin_content

内容

text

create_time

创建时间

timestamp

  4、部分关键代码实现   

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("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        ChongwulingyangshenheEntity chongwulingyangshenhe = chongwulingyangshenheService.selectById(id);
        if(chongwulingyangshenhe !=null){
            //entity转view
            ChongwulingyangshenheView view = new ChongwulingyangshenheView();
            BeanUtils.copyProperties( chongwulingyangshenhe , view );//把实体数据重构到view中

                //级联表
                ChongwulingyangEntity chongwulingyang = chongwulingyangService.selectById(chongwulingyangshenhe.getChongwulingyangId());
                if(chongwulingyang != null){
                    BeanUtils.copyProperties( chongwulingyang , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setChongwulingyangId(chongwulingyang.getId());
                }
                //级联表
                YonghuEntity yonghu = yonghuService.selectById(chongwulingyangshenhe.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @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,"批量插入数据异常,请联系管理员");
        }
    }




    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(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("/detail/{id}")
    public R detail(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        ChongwulingyangshenheEntity chongwulingyangshenhe = chongwulingyangshenheService.selectById(id);
            if(chongwulingyangshenhe !=null){


                //entity转view
                ChongwulingyangshenheView view = new ChongwulingyangshenheView();
                BeanUtils.copyProperties( chongwulingyangshenhe , view );//把实体数据重构到view中

                //级联表
                    ChongwulingyangEntity chongwulingyang = chongwulingyangService.selectById(chongwulingyangshenhe.getChongwulingyangId());
                if(chongwulingyang != null){
                    BeanUtils.copyProperties( chongwulingyang , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setChongwulingyangId(chongwulingyang.getId());
                }
                //级联表
                    YonghuEntity yonghu = yonghuService.selectById(chongwulingyangshenhe.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody ChongwulingyangshenheEntity chongwulingyangshenhe, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,chongwulingyangshenhe:{}",this.getClass().getName(),chongwulingyangshenhe.toString());
        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());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      chongwulingyangshenhe.set
        //  }
        chongwulingyangshenheService.insert(chongwulingyangshenhe);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


}
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("/chongwurenlingshenhe")
public class ChongwurenlingshenheController {
    private static final Logger logger = LoggerFactory.getLogger(ChongwurenlingshenheController.class);

    @Autowired
    private ChongwurenlingshenheService chongwurenlingshenheService;


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

    //级联表service
    @Autowired
    private ChongwurenlingService chongwurenlingService;
    @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 = chongwurenlingshenheService.queryPage(params);

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

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        ChongwurenlingshenheEntity chongwurenlingshenhe = chongwurenlingshenheService.selectById(id);
        if(chongwurenlingshenhe !=null){
            //entity转view
            ChongwurenlingshenheView view = new ChongwurenlingshenheView();
            BeanUtils.copyProperties( chongwurenlingshenhe , view );//把实体数据重构到view中

                //级联表
                ChongwurenlingEntity chongwurenling = chongwurenlingService.selectById(chongwurenlingshenhe.getChongwurenlingId());
                if(chongwurenling != null){
                    BeanUtils.copyProperties( chongwurenling , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setChongwurenlingId(chongwurenling.getId());
                }
                //级联表
                YonghuEntity yonghu = yonghuService.selectById(chongwurenlingshenhe.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

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

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

        Wrapper<ChongwurenlingshenheEntity> queryWrapper = new EntityWrapper<ChongwurenlingshenheEntity>()
            .eq("chongwurenling_id", chongwurenlingshenhe.getChongwurenlingId())
            .eq("yonghu_id", chongwurenlingshenhe.getYonghuId())
            .eq("chongwurenlingshenhe_text", chongwurenlingshenhe.getChongwurenlingshenheText())
            .eq("chongwurenlingshenhe_yesno_types", chongwurenlingshenhe.getChongwurenlingshenheYesnoTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ChongwurenlingshenheEntity chongwurenlingshenheEntity = chongwurenlingshenheService.selectOne(queryWrapper);
        if(chongwurenlingshenheEntity==null){
            chongwurenlingshenhe.setChongwurenlingshenheYesnoTypes(1);
            chongwurenlingshenhe.setCreateTime(new Date());
            chongwurenlingshenheService.insert(chongwurenlingshenhe);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

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

        //根据字段查询是否有相同数据
        Wrapper<ChongwurenlingshenheEntity> queryWrapper = new EntityWrapper<ChongwurenlingshenheEntity>()
            .notIn("id",chongwurenlingshenhe.getId())
            .andNew()
            .eq("chongwurenling_id", chongwurenlingshenhe.getChongwurenlingId())
            .eq("yonghu_id", chongwurenlingshenhe.getYonghuId())
            .eq("chongwurenlingshenhe_text", chongwurenlingshenhe.getChongwurenlingshenheText())
            .eq("chongwurenlingshenhe_yesno_types", chongwurenlingshenhe.getChongwurenlingshenheYesnoTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ChongwurenlingshenheEntity chongwurenlingshenheEntity = chongwurenlingshenheService.selectOne(queryWrapper);
        if(chongwurenlingshenheEntity==null){
            if(chongwurenlingshenhe.getChongwurenlingshenheYesnoTypes() == 2){
                ChongwurenlingEntity chongwurenlingEntity = new ChongwurenlingEntity();
                chongwurenlingEntity.setId(chongwurenlingshenhe.getChongwurenlingId());
                chongwurenlingEntity.setJieshuTypes(1);
                chongwurenlingService.updateById(chongwurenlingEntity);
            }
            chongwurenlingshenheService.updateById(chongwurenlingshenhe);//根据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());
        chongwurenlingshenheService.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<ChongwurenlingshenheEntity> chongwurenlingshenheList = 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){
                            //循环
                            ChongwurenlingshenheEntity chongwurenlingshenheEntity = new ChongwurenlingshenheEntity();
//                            chongwurenlingshenheEntity.setChongwurenlingId(Integer.valueOf(data.get(0)));   //宠物认领 要改的
//                            chongwurenlingshenheEntity.setYonghuId(Integer.valueOf(data.get(0)));   //认领用户 要改的
//                            chongwurenlingshenheEntity.setChongwurenlingshenheText(data.get(0));                    //认领理由 要改的
//                            chongwurenlingshenheEntity.setChongwurenlingshenheYesnoTypes(Integer.valueOf(data.get(0)));   //申请状态 要改的
//                            chongwurenlingshenheEntity.setCreateTime(date);//时间
                            chongwurenlingshenheList.add(chongwurenlingshenheEntity);


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

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




    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
            params.put("orderBy","id");
        }
        PageUtils page = chongwurenlingshenheService.queryPage(params);

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

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        ChongwurenlingshenheEntity chongwurenlingshenhe = chongwurenlingshenheService.selectById(id);
            if(chongwurenlingshenhe !=null){


                //entity转view
                ChongwurenlingshenheView view = new ChongwurenlingshenheView();
                BeanUtils.copyProperties( chongwurenlingshenhe , view );//把实体数据重构到view中

                //级联表
                    ChongwurenlingEntity chongwurenling = chongwurenlingService.selectById(chongwurenlingshenhe.getChongwurenlingId());
                if(chongwurenling != null){
                    BeanUtils.copyProperties( chongwurenling , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setChongwurenlingId(chongwurenling.getId());
                }
                //级联表
                    YonghuEntity yonghu = yonghuService.selectById(chongwurenlingshenhe.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody ChongwurenlingshenheEntity chongwurenlingshenhe, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,chongwurenlingshenhe:{}",this.getClass().getName(),chongwurenlingshenhe.toString());
        Wrapper<ChongwurenlingshenheEntity> queryWrapper = new EntityWrapper<ChongwurenlingshenheEntity>()
            .eq("chongwurenling_id", chongwurenlingshenhe.getChongwurenlingId())
            .eq("yonghu_id", chongwurenlingshenhe.getYonghuId())
            .eq("chongwurenlingshenhe_text", chongwurenlingshenhe.getChongwurenlingshenheText())
            .eq("chongwurenlingshenhe_yesno_types", chongwurenlingshenhe.getChongwurenlingshenheYesnoTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ChongwurenlingshenheEntity chongwurenlingshenheEntity = chongwurenlingshenheService.selectOne(queryWrapper);
        if(chongwurenlingshenheEntity==null){
            chongwurenlingshenhe.setChongwurenlingshenheYesnoTypes(1);
            chongwurenlingshenhe.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      chongwurenlingshenhe.set
        //  }
        chongwurenlingshenheService.insert(chongwurenlingshenhe);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


}

5、系统实现 (展示部分截图) 

5.1 宠物领养管理

   5.2 宠物领养审核管理 

   5.3 宠物认领管理

   5.4 宠物认领审核管理

   5.5 教学视频管理

   5.6 宠物领养

   

5.7 宠物认领 

   

5.8 教学视频 

   

 5.9 感谢信管理

  

 

源码获取

谢谢大家点赞、收藏、关注、评论,如有需要可查看主页获取联系方式

基于SSM框架开发的SSM员工婚恋交友平台是一个专为企事业单位员工打造的婚恋交友平台。它结合了当前流行的SpringSpringMVC和MyBatis三大框架技术,为系统的稳定性、可扩展性和易维护性提供了有力保障。该平台旨在帮助员工扩大社交圈子,寻找合适的伴侣,从而提高员工的幸福感和归属感。 该平台具有丰富的功能模块,包括用户管理、婚恋交友、活动管理、消息推送等。用户管理模块实现了用户的注册、登录、认证、授权等功能,确保用户信息的安全性和隐私性。婚恋交友模块为用户提供了多种交友方式,如在线征友、缘分匹配、兴趣小组等,帮助用户快速找到合适的对象。活动管理模块则支持举办各类线下活动,如聚餐、旅行、运动等,增加用户间的互动和交流。消息推送模块则通过短信、邮件等方式,及时将最新动态和活动信息推送给用户。 该平台的界面设计简洁大方,操作流程清晰明了,用户体验良好。同时,平台还具备强大的后台管理系统,管理员可以对用户、活动、消息等进行高效的管理和维护。此外,该平台还支持二次开发定制,可以根据企事业单位的实际需求进行功能扩展和个性化定制,以满足不同场景下的使用需求。 总之,基于SSM框架开发的SSM员工婚恋交友平台是一个集实用性、安全性、易用性和可扩展性于一体的婚恋交友平台。它不仅可以满足企事业单位员工的婚恋交友需求,还可以作为一个有效的福利措施,提高员工的满意度和忠诚度。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值