一、前言
随着信息时代的来临,过去的传统管理方式缺点逐渐暴露,对过去的传统管理方式的缺点进行分析,采取计算机方式构建宠物救助管理系统。本文通过课题背景、课题目的及意义相关技术,提出了一种寄宠信息、流宠信息、寻宠信息、领养需求、领养申请等于一体的系统构建方案。
本文通过采用B/S架构,MVC开发模式、MySQL数据库以及java语言、springboot框架,结合国内线上管理现状,开发了一个基于springboot的宠物救助管理系统。系统分为多个功能模块:用户信息、救助站用户信息、寄宠信息、流宠信息、寻宠信息、领养需求等。通过系统测试,本系统实现了系统设计目标,相对于人工管理方式,本系统有效的减少了求助站的经济投入,并且大幅度提升了宠物救助管理的效率。
随着网络的高速发展,网络技术的应用越来越广泛,信息化技术发展迅速,计算机管理系统优势逐渐体现,并且大量的计算机进入了千家万户。宠物救助管理系统成为信息时代的一个重要代表,由于其涉及的数据量过大,过去的人工管理方式已经很难再维持下去,所以引用了信息化技术来进行管理[1]。计算机系统管理方式替代了人工管理方式,相对过去人工管理方式,利用计算机进行宠物救助管理系统查询便利、信息准确率高、成本降低、效率提高、本次系统开发主要以宠物救助为对象,根据功能需求开发整个信息化系统。
随着信息化管理技术不断发展,传统的宠物救助已经无法适应,效率与预期相差甚远,因此需要开发一套操作方便,效率较高的宠物救助管理系统。当前,21新世纪,人们已经进入了信息时代,人们获取信息的方式大大增加,摆脱了传统的报纸、电视、广播等媒体,而是从各种网络、自媒体平台上获取信息,这就导致日常生活中产生的数据信息十分巨大,尤其是对于宠物救助管理,更需要大量的信息[2]。本系统能为用户、救助站用户提供一个宠物救助管理平台,就能够快速有效的帮助用户在线查询寄宠信息、流宠信息、寻宠信息、领养需求等,救助站用户发布寻宠信息、领养需求、领养申请等,并且可以让管理员能够轻松效率地添加所有的信息。系统开发的意义主要在于两个方面,一方面,系统上线后,能够为用户和救助站用户带来很大便利,宠物救助管理涉及的数据量较大,要求精度高,采用计算机系统能够很好满足此需求,并且随着目前电脑的普及,方便用户使用。另一方面,通过自己动手操作设计系统,不仅可以提升自己的学习兴趣,也是在进入社会之前的一次很好的锻炼机会。
本文设计并实现了一个宠物救助管理系统,主要包括以下具体工作内容:
(1)参考国内外相关系统开展了系统的需求分析,明确了用户信息、救助站用户信息、救助站信息、寄宠信息、流宠信息、寻宠信息、领养需求、领养申请等主要功能需求;
(2)设计系统技术方案,采用java语言,选用MySQL数据库、B/S架构、springboot框架来设计并实现本系统。
(3)具体介绍了各个功能模块的设计与实现。
(4)对系统的注册、登录等功能进行了全面的测试[4]。
二、系统功能效果
三、核心代码
package com.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.JiuzhuzhanyonghuEntity;
import com.entity.view.JiuzhuzhanyonghuView;
import com.service.JiuzhuzhanyonghuService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
/**
* 救助站用户
* 后端接口
* @author
* @email
* @date 2023-02-13 14:49:19
*/
@RestController
@RequestMapping("/jiuzhuzhanyonghu")
public class JiuzhuzhanyonghuController {
@Autowired
private JiuzhuzhanyonghuService jiuzhuzhanyonghuService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
JiuzhuzhanyonghuEntity u = jiuzhuzhanyonghuService.selectOne(new EntityWrapper<JiuzhuzhanyonghuEntity>().eq("jiuzhuzhanyonghuzhanghao", username));
if(u==null || !u.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(u.getId(), username,"jiuzhuzhanyonghu", "救助站用户" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody JiuzhuzhanyonghuEntity jiuzhuzhanyonghu){
//ValidatorUtils.validateEntity(jiuzhuzhanyonghu);
JiuzhuzhanyonghuEntity u = jiuzhuzhanyonghuService.selectOne(new EntityWrapper<JiuzhuzhanyonghuEntity>().eq("jiuzhuzhanyonghuzhanghao", jiuzhuzhanyonghu.getJiuzhuzhanyonghuzhanghao()));
if(u!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
jiuzhuzhanyonghu.setId(uId);
jiuzhuzhanyonghuService.insert(jiuzhuzhanyonghu);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
JiuzhuzhanyonghuEntity u = jiuzhuzhanyonghuService.selectById(id);
return R.ok().put("data", u);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
JiuzhuzhanyonghuEntity u = jiuzhuzhanyonghuService.selectOne(new EntityWrapper<JiuzhuzhanyonghuEntity>().eq("jiuzhuzhanyonghuzhanghao", username));
if(u==null) {
return R.error("账号不存在");
}
u.setMima("123456");
jiuzhuzhanyonghuService.updateById(u);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,JiuzhuzhanyonghuEntity jiuzhuzhanyonghu,
HttpServletRequest request){
EntityWrapper<JiuzhuzhanyonghuEntity> ew = new EntityWrapper<JiuzhuzhanyonghuEntity>();
PageUtils page = jiuzhuzhanyonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jiuzhuzhanyonghu), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,JiuzhuzhanyonghuEntity jiuzhuzhanyonghu,
HttpServletRequest request){
EntityWrapper<JiuzhuzhanyonghuEntity> ew = new EntityWrapper<JiuzhuzhanyonghuEntity>();
PageUtils page = jiuzhuzhanyonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jiuzhuzhanyonghu), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( JiuzhuzhanyonghuEntity jiuzhuzhanyonghu){
EntityWrapper<JiuzhuzhanyonghuEntity> ew = new EntityWrapper<JiuzhuzhanyonghuEntity>();
ew.allEq(MPUtil.allEQMapPre( jiuzhuzhanyonghu, "jiuzhuzhanyonghu"));
return R.ok().put("data", jiuzhuzhanyonghuService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(JiuzhuzhanyonghuEntity jiuzhuzhanyonghu){
EntityWrapper< JiuzhuzhanyonghuEntity> ew = new EntityWrapper< JiuzhuzhanyonghuEntity>();
ew.allEq(MPUtil.allEQMapPre( jiuzhuzhanyonghu, "jiuzhuzhanyonghu"));
JiuzhuzhanyonghuView jiuzhuzhanyonghuView = jiuzhuzhanyonghuService.selectView(ew);
return R.ok("查询救助站用户成功").put("data", jiuzhuzhanyonghuView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
JiuzhuzhanyonghuEntity jiuzhuzhanyonghu = jiuzhuzhanyonghuService.selectById(id);
return R.ok().put("data", jiuzhuzhanyonghu);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
JiuzhuzhanyonghuEntity jiuzhuzhanyonghu = jiuzhuzhanyonghuService.selectById(id);
return R.ok().put("data", jiuzhuzhanyonghu);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody JiuzhuzhanyonghuEntity jiuzhuzhanyonghu, HttpServletRequest request){
jiuzhuzhanyonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(jiuzhuzhanyonghu);
JiuzhuzhanyonghuEntity u = jiuzhuzhanyonghuService.selectOne(new EntityWrapper<JiuzhuzhanyonghuEntity>().eq("jiuzhuzhanyonghuzhanghao", jiuzhuzhanyonghu.getJiuzhuzhanyonghuzhanghao()));
if(u!=null) {
return R.error("用户已存在");
}
jiuzhuzhanyonghu.setId(new Date().getTime());
jiuzhuzhanyonghuService.insert(jiuzhuzhanyonghu);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody JiuzhuzhanyonghuEntity jiuzhuzhanyonghu, HttpServletRequest request){
jiuzhuzhanyonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(jiuzhuzhanyonghu);
JiuzhuzhanyonghuEntity u = jiuzhuzhanyonghuService.selectOne(new EntityWrapper<JiuzhuzhanyonghuEntity>().eq("jiuzhuzhanyonghuzhanghao", jiuzhuzhanyonghu.getJiuzhuzhanyonghuzhanghao()));
if(u!=null) {
return R.error("用户已存在");
}
jiuzhuzhanyonghu.setId(new Date().getTime());
jiuzhuzhanyonghuService.insert(jiuzhuzhanyonghu);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody JiuzhuzhanyonghuEntity jiuzhuzhanyonghu, HttpServletRequest request){
//ValidatorUtils.validateEntity(jiuzhuzhanyonghu);
jiuzhuzhanyonghuService.updateById(jiuzhuzhanyonghu);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
jiuzhuzhanyonghuService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<JiuzhuzhanyonghuEntity> wrapper = new EntityWrapper<JiuzhuzhanyonghuEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = jiuzhuzhanyonghuService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
package com.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.MessagesEntity;
import com.entity.view.MessagesView;
import com.service.MessagesService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
/**
* 在线反馈
* 后端接口
* @author
* @email
* @date 2023-02-13 14:49:19
*/
@RestController
@RequestMapping("/messages")
public class MessagesController {
@Autowired
private MessagesService messagesService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,MessagesEntity messages,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
messages.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,MessagesEntity messages,
HttpServletRequest request){
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( MessagesEntity messages){
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
ew.allEq(MPUtil.allEQMapPre( messages, "messages"));
return R.ok().put("data", messagesService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(MessagesEntity messages){
EntityWrapper< MessagesEntity> ew = new EntityWrapper< MessagesEntity>();
ew.allEq(MPUtil.allEQMapPre( messages, "messages"));
MessagesView messagesView = messagesService.selectView(ew);
return R.ok("查询在线反馈成功").put("data", messagesView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
MessagesEntity messages = messagesService.selectById(id);
return R.ok().put("data", messages);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
MessagesEntity messages = messagesService.selectById(id);
return R.ok().put("data", messages);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody MessagesEntity messages, HttpServletRequest request){
messages.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(messages);
messagesService.insert(messages);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody MessagesEntity messages, HttpServletRequest request){
messages.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(messages);
messagesService.insert(messages);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody MessagesEntity messages, HttpServletRequest request){
//ValidatorUtils.validateEntity(messages);
messagesService.updateById(messages);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
messagesService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<MessagesEntity> wrapper = new EntityWrapper<MessagesEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = messagesService.selectCount(wrapper);
return R.ok().put("count", count);
}
}