近些年来,随着科技的飞速发展,互联网的普及逐渐延伸到各行各业中,给人们生活带来了十分的便利,宿舍管理系统利用计算机网络实现信息化管理,使整个宿舍管理的发展和服务水平有显著提升。
本文拟采用java技术和Springboot搭建系统框架,后台使用MySQL数据库进行信息管理,设计开发的宿舍管理系统。通过调研和分析,系统拥有管理员和学生两个角色,主要具备系统首页、个人中心、学生管理、宿舍信息管理、宿舍分配管理、水电费管理、进入宿舍管理、出入宿舍管理、维修信息管理、卫生信息管理、考勤信息管理、留言板、交流论坛、系统管理等功能模块。将纸质管理有效实现为在线管理,极大提高工作效率。
关键词:宿舍;java;Springboot框架;MySQL
springboot vue宿舍管理系统源码和论文715
演示视频:
springboot vue宿舍管理系统源码和论文
Abstract
In recent years, with the rapid development of science and technology, the popularity of the Internet gradually extends to all walks of life, bringing great convenience to people's lives, dormitory management system using computer network to achieve information management, so that the development of the entire dormitory management and service level has been significantly improved.
This paper intends to use Java technology and Springboot to build a system framework, use MySQL database for information management in the background, and design and develop a dormitory management system. Through research and analysis, the system has two roles of administrator and student, mainly with system home page, personal center, student management, dormitory information management, dormitory allocation management, utility bill management, access to dormitory management, access to dormitory management, maintenance information management, health information management, attendance information management, message board, exchange forum, system management and other functional modules. Effectively realize paper management as online management, greatly improving work efficiency.
Keywords: dormitory; .java; Springboot framework; MySQL
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("/dictionary")
public class DictionaryController {
private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class);
private static final String TABLE_NAME = "dictionary";
@Autowired
private DictionaryService dictionaryService;
@Autowired
private TokenService tokenService;
@Autowired
private ForumService forumService;//交流论坛
@Autowired
private GonggaoService gonggaoService;//公告资讯
@Autowired
private HanfuService hanfuService;//汉服信息
@Autowired
private HanfuCollectionService hanfuCollectionService;//汉服收藏
@Autowired
private HanfuCommentbackService hanfuCommentbackService;//汉服评价
@Autowired
private HanfuOrderService hanfuOrderService;//汉服租赁
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
* 后端列表
*/
@RequestMapping("/page")
@IgnoreAuth
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = dictionaryService.queryPage(params);
//字典表数据转换
List<DictionaryView> list =(List<DictionaryView>)page.getList();
for(DictionaryView 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);
DictionaryEntity dictionary = dictionaryService.selectById(id);
if(dictionary !=null){
//entity转view
DictionaryView view = new DictionaryView();
BeanUtils.copyProperties( dictionary , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode())
.eq("index_name", dictionary.getIndexName())
;
if(dictionary.getDicCode().contains("_erji_types")){
queryWrapper.eq("super_id",dictionary.getSuperId());
}
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){
dictionary.setCreateTime(new Date());
dictionaryService.insert(dictionary);
//字典表新增数据,把数据再重新查出,放入监听器中
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
DictionaryEntity oldDictionaryEntity = dictionaryService.selectById(dictionary.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
dictionaryService.updateById(dictionary);//根据id更新
//如果字典表修改数据的话,把数据再重新查出,放入监听器中
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<DictionaryEntity> oldDictionaryList =dictionaryService.selectBatchIds(Arrays.asList(ids));//要删除的数据
dictionaryService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 最大值
*/
@RequestMapping("/maxCodeIndex")
public R maxCodeIndex(@RequestBody DictionaryEntity dictionary){
logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
List<String> descs = new ArrayList<>();
descs.add("code_index");
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode())
.orderDesc(descs);
logger.info("sql语句:"+queryWrapper.getSqlSegment());
List<DictionaryEntity> dictionaryEntityList = dictionaryService.selectList(queryWrapper);
if(dictionaryEntityList.size()>0 ){
return R.ok().put("maxCodeIndex",dictionaryEntityList.get(0).getCodeIndex()+1);
}else{
return R.ok().put("maxCodeIndex",1);
}
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<DictionaryEntity> dictionaryList = 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){
//循环
DictionaryEntity dictionaryEntity = new DictionaryEntity();
// dictionaryEntity.setDicCode(data.get(0)); //字段 要改的
// dictionaryEntity.setDicName(data.get(0)); //字段名 要改的
// dictionaryEntity.setCodeIndex(Integer.valueOf(data.get(0))); //编码 要改的
// dictionaryEntity.setIndexName(data.get(0)); //编码名字 要改的
// dictionaryEntity.setSuperId(Integer.valueOf(data.get(0))); //父字段id 要改的
// dictionaryEntity.setBeizhu(data.get(0)); //备注 要改的
// dictionaryEntity.setCreateTime(date);//时间
dictionaryList.add(dictionaryEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
dictionaryService.insertBatch(dictionaryList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
}
package com.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
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.ShuidianfeiEntity;
import com.entity.view.ShuidianfeiView;
import com.service.ShuidianfeiService;
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-05-08 17:35:32
*/
@RestController
@RequestMapping("/shuidianfei")
public class ShuidianfeiController {
@Autowired
private ShuidianfeiService shuidianfeiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ShuidianfeiEntity shuidianfei,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("xuesheng")) {
shuidianfei.setXueshengxuehao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<ShuidianfeiEntity> ew = new EntityWrapper<ShuidianfeiEntity>();
PageUtils page = shuidianfeiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shuidianfei), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ShuidianfeiEntity shuidianfei,
HttpServletRequest request){
EntityWrapper<ShuidianfeiEntity> ew = new EntityWrapper<ShuidianfeiEntity>();
PageUtils page = shuidianfeiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shuidianfei), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( ShuidianfeiEntity shuidianfei){
EntityWrapper<ShuidianfeiEntity> ew = new EntityWrapper<ShuidianfeiEntity>();
ew.allEq(MPUtil.allEQMapPre( shuidianfei, "shuidianfei"));
return R.ok().put("data", shuidianfeiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(ShuidianfeiEntity shuidianfei){
EntityWrapper< ShuidianfeiEntity> ew = new EntityWrapper< ShuidianfeiEntity>();
ew.allEq(MPUtil.allEQMapPre( shuidianfei, "shuidianfei"));
ShuidianfeiView shuidianfeiView = shuidianfeiService.selectView(ew);
return R.ok("查询水电费成功").put("data", shuidianfeiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
ShuidianfeiEntity shuidianfei = shuidianfeiService.selectById(id);
return R.ok().put("data", shuidianfei);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
ShuidianfeiEntity shuidianfei = shuidianfeiService.selectById(id);
return R.ok().put("data", shuidianfei);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShuidianfeiEntity shuidianfei, HttpServletRequest request){
shuidianfei.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(shuidianfei);
shuidianfeiService.insert(shuidianfei);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody ShuidianfeiEntity shuidianfei, HttpServletRequest request){
shuidianfei.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(shuidianfei);
shuidianfeiService.insert(shuidianfei);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody ShuidianfeiEntity shuidianfei, HttpServletRequest request){
//ValidatorUtils.validateEntity(shuidianfei);
shuidianfeiService.updateById(shuidianfei);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
shuidianfeiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}