语言环境:微信小程序
数据库:Mysql: mysql5.7
WEB框架:SpringBoot+Vue
开发工具:IDEA和微信开发者工具
使用旧方法对开放实验室预约管理系统的信息进行系统化管理已经不再让人们信赖了,把现在的网络信息技术运用在开放实验室预约管理系统的管理上面可以解决许多信息管理上面的难题,比如处理数据时间很长,数据存在错误不能及时纠正等问题。这次开发的开放实验室预约管理系统对字典管理、公告管理、课题报名管理、老师管理、实验室管理、实验室预约管理、学生管理、管理员管理等进行集中化处理。经过前面自己查阅的网络知识,加上自己在学校课堂上学习的知识,决定开发系统选择小程序模式这种高效率的模式完成系统功能开发。这种模式让操作员基于浏览器的方式进行网站访问,采用的主流的Java语言这种面向对象的语言进行开放实验室预约管理系统程序的开发,在数据库的选择上面,选择功能强大的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("/gonggao")
public class GonggaoController {
private static final Logger logger = LoggerFactory.getLogger(GonggaoController.class);
private static final String TABLE_NAME = "gonggao";
@Autowired
private GonggaoService gonggaoService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表非注册的service
//注册表service
@Autowired
private YonghuService yonghuService;
@Autowired
private LaoshiService laoshiService;
/**
* 后端列表
*/
@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(false)
return R.error(511,"永不会进入");
else if("学生".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("老师".equals(role))
params.put("laoshiId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = gonggaoService.queryPage(params);
//字典表数据转换
List<GonggaoView> list =(List<GonggaoView>)page.getList();
for(GonggaoView 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);
GonggaoEntity gonggao = gonggaoService.selectById(id);
if(gonggao !=null){
//entity转view
GonggaoView view = new GonggaoView();
BeanUtils.copyProperties( gonggao , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody GonggaoEntity gonggao, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,gonggao:{}",this.getClass().getName(),gonggao.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<GonggaoEntity> queryWrapper = new EntityWrapper<GonggaoEntity>()
.eq("gonggao_name", gonggao.getGonggaoName())
.eq("gonggao_types", gonggao.getGonggaoTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
GonggaoEntity gonggaoEntity = gonggaoService.selectOne(queryWrapper);
if(gonggaoEntity==null){
gonggao.setInsertTime(new Date());
gonggao.setCreateTime(new Date());
gonggaoService.insert(gonggao);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody GonggaoEntity gonggao, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,gonggao:{}",this.getClass().getName(),gonggao.toString());
GonggaoEntity oldGonggaoEntity = gonggaoService.selectById(gonggao.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有相同数据
Wrapper<GonggaoEntity> queryWrapper = new EntityWrapper<GonggaoEntity>()
.notIn("id",gonggao.getId())
.andNew()
.eq("gonggao_name", gonggao.getGonggaoName())
.eq("gonggao_types", gonggao.getGonggaoTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
GonggaoEntity gonggaoEntity = gonggaoService.selectOne(queryWrapper);
if("".equals(gonggao.getGonggaoPhoto()) || "null".equals(gonggao.getGonggaoPhoto())){
gonggao.setGonggaoPhoto(null);
}
if(gonggaoEntity==null){
gonggaoService.updateById(gonggao);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<GonggaoEntity> oldGonggaoList =gonggaoService.selectBatchIds(Arrays.asList(ids));//要删除的数据
gonggaoService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@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");
try {
List<GonggaoEntity> gonggaoList = 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){
//循环
GonggaoEntity gonggaoEntity = new GonggaoEntity();
// gonggaoEntity.setGonggaoName(data.get(0)); //公告名称 要改的
// gonggaoEntity.setGonggaoPhoto("");//详情和图片
// gonggaoEntity.setGonggaoTypes(Integer.valueOf(data.get(0))); //公告类型 要改的
// gonggaoEntity.setInsertTime(date);//时间
// gonggaoEntity.setGonggaoContent("");//详情和图片
// gonggaoEntity.setCreateTime(date);//时间
gonggaoList.add(gonggaoEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
gonggaoService.insertBatch(gonggaoList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
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));
CommonUtil.checkMap(params);
PageUtils page = gonggaoService.queryPage(params);
//字典表数据转换
List<GonggaoView> list =(List<GonggaoView>)page.getList();
for(GonggaoView 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);
GonggaoEntity gonggao = gonggaoService.selectById(id);
if(gonggao !=null){
//entity转view
GonggaoView view = new GonggaoView();
BeanUtils.copyProperties( gonggao , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody GonggaoEntity gonggao, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,gonggao:{}",this.getClass().getName(),gonggao.toString());
Wrapper<GonggaoEntity> queryWrapper = new EntityWrapper<GonggaoEntity>()
.eq("gonggao_name", gonggao.getGonggaoName())
.eq("gonggao_types", gonggao.getGonggaoTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
GonggaoEntity gonggaoEntity = gonggaoService.selectOne(queryWrapper);
if(gonggaoEntity==null){
gonggao.setInsertTime(new Date());
gonggao.setCreateTime(new Date());
gonggaoService.insert(gonggao);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}
基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目
基于Nodejs、Vue等前端技术开发的前端实战项目
基于微信小程序和安卓APP应用开发的相关作品
基于51单片机等嵌入式物联网开发应用
基于各类算法实现的AI智能应用
基于大数据实现的各类数据管理和推荐系统