作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
体育器材管理系统主要包含以下功能:
登录注册;
体育器材管理:显示器材表、显示价目表、显示供应商表;
器材借还管理:借用申请、归还申请;
管理员个人信息:对当前管理员的信息进行查看或修改
器材报废登记:登记报废器材,生成、修改以及导出采购清单
信息录入:用户信息录入以及体育器材信息录入
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目:是;
技术栈
1. 后端:SpringBoot+Mybatis
2. 前端:HTML+CSS+Bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,前台地址:http://localhost:8080/web/home.html
运行截图
代码相关
器材管理控制器
@RestController
@RequestMapping("/equ")
public class EquController extends BaseController{
@Autowired
EquServiceImpl service;
@Autowired
EquMapper mapper;
@Autowired
ManagerMapper managerMapper;
@RequestMapping("/delEquById")
public JsonResult<Void> delEqu(Integer id){
System.out.println(id);
if ( service.delEqu(id)==1){
return new JsonResult<>(OK);
}
else {
return new JsonResult<>("shibai");
}
}
@RequestMapping("/delEmpById")
public JsonResult<Void> delEmp(Integer id){
service.delEmp(id);
return new JsonResult<>(OK);
}
@RequestMapping("/updateEmpById")
public JsonResult<Void> updateEmp(Emp emp){
service.updateEmp(emp);
return new JsonResult<>(OK);
}
@RequestMapping("/updateEquById")
public JsonResult<Void> updateEqu(Equipment equipment){
service.updateEqu(equipment);
return new JsonResult<>(OK);
}
@RequestMapping("/showlist")
public JsonResult<List<Equipment>> showlist(Integer page){
List<Equipment> list=mapper.orderequlist(page);
for (Equipment map : list) {
System.err.println(map);
}
return new JsonResult<>(OK,list);
}
@RequestMapping("/showprice")
public JsonResult<List<Equipment>> showprice(Integer page){
System.err.println("showprice执行");
List<Equipment> list=mapper.pricelist(page);
for (Equipment map : list) {
System.err.println(map);
}
System.err.println("showprice执行完毕");
return new JsonResult<>(OK,list);
}
@RequestMapping("/showsup")
public JsonResult<List<Equipment>> showsup(Integer page){
List<Equipment> list=mapper.suplist(page);
for (Equipment map : list) {
System.err.println(map);
}
return new JsonResult<>(OK,list);
}
@RequestMapping("/showEquHistory")
public JsonResult<List<Equipment>> showEquHistory(Integer page){
List<Equipment> list=mapper.equhistory(page);
for (Equipment map : list) {
System.err.println(map);
}
return new JsonResult<>(OK,list);
}
Equipment equipment=new Equipment();
Emp emp=new Emp();
@RequestMapping("/postNotes")
public JsonResult<Void> postNote(Integer id, String key){
System.out.println(id+key);
if (key.equals("equ")){
System.out.println(id);
equipment=mapper.findEquById(id);
System.out.println(equipment);
}
if (key.equals("emp")){
System.out.println(id);
emp=managerMapper.findEmpById(id);
System.out.println(emp);
}
return new JsonResult<>(OK);
}
@RequestMapping("/getEquNotes")
public JsonResult<Equipment> getEquNote(){
System.out.println(equipment);
return new JsonResult<>(OK,equipment);
}
@RequestMapping("/getEmpNotes")
public JsonResult<Emp> getEmpNotes(){
System.out.println(emp);
return new JsonResult<>(OK,emp);
}
@RequestMapping("/addEqu")
public JsonResult<String> addEqu(Equipment equipment){
System.out.println(equipment);
if (service.addEqu(equipment)!=1){
return new JsonResult<>("添加失败,请重试");
}
return new JsonResult<>(OK);
}
@RequestMapping("/addEmp")
public JsonResult<String> addEmp(Emp emp){
System.out.println(emp);
if (service.addEmp(emp)!=1){
return new JsonResult<>("添加失败,请重试");
}
return new JsonResult<>(OK);
}
/**
* 允许上传的文件类型的集合
*/
private static final List<String> AVATAR_TYPES = new ArrayList<>();
static {
AVATAR_TYPES.add("application/vnd.ms-excel");
AVATAR_TYPES.add("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
@PostMapping("/uploadequ")
public JsonResult<String> uploadEqu(
@RequestParam("file") MultipartFile file, HttpSession session) {
// 日志
System.err.println("UserController.changeAvatar()");
// 判断文件是否为空
boolean isEmpty = file.isEmpty();
System.err.println("\tisEmpty=" + isEmpty);
if (isEmpty) {
System.out.println("empty");
throw new FileTypeException(
"上传失败!文件不能为空:" + AVATAR_TYPES);
}
// 获取文件的MIME类型
String contentType = file.getContentType();
System.err.println("\tcontentType=" + contentType);
// 判断上传的文件类型是否符合:excel/xls
if (!AVATAR_TYPES.contains(contentType)) {
throw new FileTypeException(
"上传失败!仅允许上传以下类型的文件:" + AVATAR_TYPES);
}
// 获取原始文件名(客户端设备中的文件名)
String originalFilename
= file.getOriginalFilename();
System.err.println("\toriginalFilename=" + originalFilename);
if (originalFilename=="") {
System.out.println("empty");
throw new FileTypeException(
"上传失败!文件不能为空:" + AVATAR_TYPES);
}
// 将文件上传到哪个文件夹
String parent = session
.getServletContext().getRealPath("upload");
System.err.println("\tupload path=" + parent);
File dir = new File(parent);
if (!dir.exists()) {
dir.mkdirs();
}
// 保存上传的文件时使用的文件名
String filename = ""
+ System.currentTimeMillis()
+ System.nanoTime();
String suffix = "";
int beginIndex = originalFilename
.lastIndexOf(".");
if (beginIndex >= 1) {
suffix = originalFilename
.substring(beginIndex);
}
String child = filename + suffix;
// 将客户端上传的文件保存到服务器端
File dest = new File(parent, child);
try {
file.transferTo(dest);
} catch (IllegalStateException e) {
System.out.println(
"上传失败!您的文件的状态异常!");
} catch (IOException e) {
System.out.println(
"上传失败!读写文件时出现错误,请重新上传!");
}
// 将保存的文件的路径记录到数据库中
String avatar = "\\" + child;
System.err.println("\tavatar path=" + avatar);
if (originalFilename.equals("器材表.xls")||originalFilename.equals("器材表.xlsx")){
service.ExcelReadEqu(parent,avatar);
System.err.println("器材表录入成功");
}else {
throw new FileUploadException("请按要求规范文件名");
}
System.err.println(OK);
return new JsonResult<>(OK);
}
}
管理端控制器
@RestController
@RequestMapping("/users")
public class ManagerController extends BaseController{
@Resource
IManagerService managerService;
@Autowired
ManagerMapper manager;
//登录
@RequestMapping("/logininfo")
public JsonResult<Void> logininfo(HttpSession session){
session.removeAttribute("num");
return new JsonResult<>(OK);
}
@Autowired
EmailSend emailSend;
private String realKey="";
//获取验证码
@RequestMapping("/sendRegKey")
public JsonResult<String> sendVerificationCode(String num){
System.out.println(num);
realKey= emailSend.KeyCreated();
if (emailSend.RegisterManager(realKey,managerService.findRegPwd(num))==1){
return new JsonResult<>(OK);
}
return new JsonResult<>(1000,"发送失败,请重试");
}
//注册
//http//localhost:8080/users/register?username=zm&password=1234
@RequestMapping("/register")
public JsonResult<String> register(Manager manager,String key){
System.out.println("key"+key);
System.out.println("realkey"+realKey);
if (key.equals(realKey)){
System.out.println("==");
managerService.reg(manager);
System.out.println("success");
return new JsonResult<>(OK);
}else {
System.out.println("false");
return new JsonResult<>(1111);
}
}
@RequestMapping("/loginnum")
public JsonResult<String> loginnum( HttpSession session){
String managernum=getNumFromSession(session);
System.err.println(managernum);
return new JsonResult<>(OK,managernum);
}
private String VerificationCode="";
@RequestMapping("/sendFindPwd")
public JsonResult<String> sendFindPwd(String num){
System.out.println(num);
VerificationCode=emailSend.KeyCreated();
System.out.println(VerificationCode);
if (emailSend.RegisterManager(VerificationCode,managerService.findPwd(num))==1){
return new JsonResult<>(OK);
}
return new JsonResult<>(1000,"发送失败,请重试");
}
@RequestMapping("/backPwd")
public JsonResult<String> findPwd(String num,String key){
System.out.println("key:"+key);
System.out.println("VerificationCode:"+VerificationCode);
if (!VerificationCode.equals(key)){
return new JsonResult<>(1111,"验证码错误");
}
return new JsonResult<>(OK);
}
@RequestMapping("/resetPwd")
public JsonResult<String> resetPwd(String num,String password){
if (managerService.resetPwd(num,password)!=1){
return new JsonResult<>(11111,"重置失败,请重试");
}
return new JsonResult<>(OK);
}
//登录
@RequestMapping("/login")
public JsonResult<String> login(String num, String password, HttpSession session){
Manager manager=managerService.login(num,password);
session.setAttribute("mid",manager.getMid());
session.setAttribute("num",manager.getNum());
String managernum=getNumFromSession(session);
System.err.println(managernum);
return new JsonResult<>(OK,managernum);
}
@RequestMapping("/showupdate")
public JsonResult<Manager> showupdate(HttpSession session){
Manager info=manager.findByNum(getNumFromSession(session));
return new JsonResult<>(OK,info);
}
//修改信息(密码,手机号)
@RequestMapping("/updateInfo")
public JsonResult<Void> updatePassword(String oldPassword,String newPassword,String phone,String email,HttpSession session){
String num=getNumFromSession(session);
managerService.changeInfo(oldPassword,newPassword,num,phone,email);
return new JsonResult<>(OK);
}
@GetMapping("showinfo")
public JsonResult<Manager> showEmp(HttpSession session){
return new JsonResult<>(OK,manager.findByNum(getNumFromSession(session)));
}
@GetMapping("/delManager")
public JsonResult<Manager> delManager(Integer num){
if (num!=null) {
if (manager.delManager(num) != 1) {
return new JsonResult<>(50001);
} else {
return new JsonResult<>(OK);
}
}else {
return new JsonResult<>(50001);
}
}
/*显示所有员工信息*/
@RequestMapping("showallemp")
public JsonResult<List> showAllEmp(){
return new JsonResult<List>(OK,manager.findAllEmp());
}
@PostMapping("uploademp")
public JsonResult<String> uploadEmp(
@RequestParam("file") MultipartFile file, HttpSession session) {
// 日志
System.err.println("UserController.changeAvatar()");
// 判断文件是否为空
boolean isEmpty = file.isEmpty();
System.err.println("\tisEmpty=" + isEmpty);
if (isEmpty) {
System.out.println("empty");
}
// 获取原始文件名(客户端设备中的文件名)
String originalFilename
= file.getOriginalFilename();
System.err.println("\toriginalFilename=" + originalFilename);
// 将文件上传到哪个文件夹
String parent = session
.getServletContext().getRealPath("upload");
System.err.println("\tupload path=" + parent);
File dir = new File(parent);
if (!dir.exists()) {
dir.mkdirs();
}
// 保存上传的文件时使用的文件名
String filename = ""
+ System.currentTimeMillis()
+ System.nanoTime();
String suffix = "";
int beginIndex = originalFilename
.lastIndexOf(".");
if (beginIndex >= 1) {
suffix = originalFilename
.substring(beginIndex);
}
String child = filename + suffix;
// 将客户端上传的文件保存到服务器端
File dest = new File(parent, child);
try {
file.transferTo(dest);
} catch (IllegalStateException e) {
System.out.println(
"上传失败!您的文件的状态异常!");
} catch (IOException e) {
System.out.println(
"上传失败!读写文件时出现错误,请重新上传!");
}
// 将保存的文件的路径记录到数据库中
String avatar = "\\" + child;
System.err.println("\tavatar path=" + avatar);
System.out.println();
System.out.println(managerService.ExcelRead(parent,avatar));
return new JsonResult<>(OK);
}
}
如果也想学习本系统,下面领取。回复:083springboot