其他源码获取可以看首页:代码老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 感谢信管理
源码获取
谢谢大家点赞、收藏、关注、评论,如有需要可查看主页获取联系方式