基于SpringBoot的体育馆管理系统

news2024/10/7 16:23:49

目录

前言

 一、技术栈

二、系统功能介绍

管理员功能介绍

商品列表

场地信息管理

场地类型管理

三、核心代码

1、登录模块

 2、文件上传模块

3、代码封装


前言

现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本体育馆管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此体育馆管理系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了用户在线选择试题并完成答题,在线查看考核分数。管理员管理收货地址管理、购物车管理、场地管理、场地订单管理、字典管理、赛事管理、赛事收藏管理、赛事评价管理、赛事订单管理、商品管理、商品收藏管理、商品评价管理、商品订单管理、用户管理、管理员管理等功能。体育馆管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。

 一、技术栈

末尾获取源码
SpringBoot+Vue+JS+ jQuery+Ajax...

二、系统功能介绍

管理员功能介绍

商品列表

商品列表页面,此页面提供给管理员的功能有:查看商品、新增商品、修改商品、删除商品等。

场地信息管理

场地信息管理页面提供的功能操作有:新增场地,修改场地,删除场地操作。下图就是场地信息管理页面。

 

场地类型管理

场地类型管理页面显示所有场地类型,在此页面既可以让管理员添加新的场地信息类型,也能对已有的场地类型信息执行编辑更新,失效的场地类型信息也能让管理员快速删除。下图就是场地类型管理页面。

三、核心代码

1、登录模块

 
package com.controller;
 
 
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
 
/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;
 
	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }
 
	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }
 
	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }
 
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
 
    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }
 
    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }
 
    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

 2、文件上传模块

package com.controller;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
 
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
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 org.springframework.web.multipart.MultipartFile;
 
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;
 
/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

3、代码封装

package com.utils;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}
 
	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}
 
	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1150281.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

精益制造的工具与方法有什么区别?ECRS工时分析软件的功能和价值

精益制造是一套价值创造系统&#xff0c;它强调在生产过程中减少浪费、提高效率和质量&#xff0c;从而实现持续改进和优化。在精益制造的理念下&#xff0c;企业需要运用一系列的工具和方法来提升生产管理水平。这些工具和方法不仅包括传统的精益工具&#xff0c;如5S、持续改…

Java自学者怎么写简历?

Java自学者怎么写简历&#xff1f; 首先&#xff0c;有技术实力的人绝对不会问这个问题。虽然你是自学的&#xff0c;但是一定要有项目&#xff01;没有项目都是空谈。最近很多小伙伴找我&#xff0c;说想要一些Java资料&#xff0c;然后我根据自己从业十年经验&#xff0c;熬夜…

使用 Sealos 一键部署 Kubernetes 集群

Sealos 是一款以 Kubernetes 为内核的云操作系统发行版&#xff0c;使用户能够像使用个人电脑一样简单地使用云。 与此同时&#xff0c;Sealos 还提供一套强大的工具&#xff0c;可以便利地管理整个 Kubernetes 集群的生命周期。 Sealos 不仅可以一键安装一个单节点的 Kubern…

设计模式(21)中介者模式

一、介绍&#xff1a; 1、定义&#xff1a;中介者模式&#xff08;Mediator Pattern&#xff09;是一种行为型设计模式&#xff0c;它通过引入一个中介者对象来降低多个对象之间的耦合度。在中介者模式中&#xff0c;各个对象之间不直接进行通信&#xff0c;而是通过中介者对象…

Nginx 实战指南:暴露出请求的真实 IP

&#x1f52d; 嗨&#xff0c;您好 &#x1f44b; 我是 vnjohn&#xff0c;在互联网企业担任 Java 开发&#xff0c;CSDN 优质创作者 &#x1f4d6; 推荐专栏&#xff1a;Spring、MySQL、Nacos、Java&#xff0c;后续其他专栏会持续优化更新迭代 &#x1f332;文章所在专栏&…

跑腿小程序开发解析:技术架构、接口设计和前沿趋势

随着生活节奏的加快和个人需求的增加&#xff0c;跑腿小程序成为了人们生活中不可或缺的一部分。从技术角度来看&#xff0c;一个高效、安全、以及用户友好的跑腿小程序是由多个关键要素构成的&#xff0c;包括技术架构、接口设计和前沿趋势。 技术架构 1. 前端技术选型 选择…

Windows Server 2016磁盘管理使用指南:看完即会!

如何打开Windows Server 2016磁盘管理器&#xff1f; 磁盘管理首先在Windows XP中引入&#xff0c;是一个Windows内置实用程序&#xff0c;可让你管理硬盘和关联的分区或卷。在Windows Server磁盘管理对硬盘进行分区非常方便。你可以通过以下方法之一访问它&#xff1a; 方…

数据库系统原理与实践 笔记 #6

文章目录 数据库系统原理与实践 笔记 #6数据库设计和E-R模型设计过程实体-联系模型实体集联系集联系集中实体的角色联系集的度属性复合属性 约束映射基数约束参与约束实体集的码联系集的码冗余属性 实体-联系图E-R图参与联系集中的实体集基数约束角色三元关系上的基数约束弱实体…

JMeter简单使用

JMeter是一个功能强大的开源性能测试工具&#xff0c;用于对各种应用程序、协议和服务器进行性能和负载测试。它被广泛用于测试Web应用程序的性能&#xff0c;并可以模拟多种负载条件和行为。 JMeter使用 添加线程组 设置线程组的配置 设置请求 配置请求 添加监听器 查看压…

Java微服务构建:打造健壮订单模型的完整指南

Java微服务构建一个健壮的订单模型(业务,规划&#xff0c;设计与实现) 在设计领域业务模型时&#xff0c;我们通常会追求理论完美&#xff0c;而忽略实践的脆弱性。尽管我们没有贬低领域建模的意图&#xff0c;但事实上&#xff0c;在电商技术发展多年之后&#xff0c;某些系统…

idea中启动多例项目配置

多实例启动 日常本地开发微服务项目时&#xff0c;博主想要验证一下网关的负载均衡以及感知服务上下线能力时&#xff0c;需要用到多实例启动。 那么什么是多实例启动嘞&#xff1f;简单说就是能在本地同时启动多个同一服务。打个比方项目中有一个 MobileApplication 服务&…

怎么压缩视频?试试这个方法

怎么压缩视频&#xff1f;我们都知道视频的内存比其他类型的文件都要大很多。那是因为视频的分辨率越高&#xff0c;所包含的像素点就越多&#xff0c;因此文件大小也就越大。而且一般来说&#xff0c;视频文件的时长都比较长&#xff0c;当视频的时间越长&#xff0c;那么视频…

RFID银行款箱智能管理应用解决方案

一、行业背景 随着金融业务的不断发展&#xff0c;金融物流的安全性成为越来越重要的问题&#xff0c;银行金库每天都有大量现金款箱的出入库和配送&#xff0c;如果无法确保及时准确地进行入库、库存控制和出库&#xff0c;将给银行带来巨大的风险&#xff0c;增加了银行的管…

堆栈与队列算法-八皇后问题的求解算法

目录 堆栈与队列算法-八皇后问题的求解算法 C代码 堆栈与队列算法-八皇后问题的求解算法 八皇后问题是一种常见的堆栈应用实例。在国际象棋中的皇后可以在没有限定一步走几格的前提下&#xff0c;对棋盘中的其他棋子直吃、横吃和对角斜吃&#xff08;左斜吃或右斜吃均可&…

博客模板博客模板

xservices-bpm-6.2.1.1.jar 本人详解 作者&#xff1a;王文峰&#xff0c;参加过 CSDN 2020年度博客之星&#xff0c;《Java王大师王天师》作者 公众号&#xff1a;山峯草堂&#xff0c;非技术多篇文章&#xff0c;专注于天道酬勤的 Java 开发问题、中国国学、传统文化和代码爱…

使用Objective-C和ASIHTTPRequest库进行Douban电影分析

概述 Douban是一个提供图书、音乐、电影等文化内容的社交网站&#xff0c;它的电影频道包含了大量的电影信息和用户评价。本文将介绍如何使用Objective-C语言和ASIHTTPRequest库进行Douban电影分析&#xff0c;包括如何获取电影数据、如何解析JSON格式的数据、如何使用代理IP技…

文心一言 VS 讯飞星火 VS chatgpt (124)-- 算法导论10.5 5题

五、用go语言&#xff0c;给定一个n结点的二叉树&#xff0c;写出一个 O(n)时间的非递归过程&#xff0c;将该树每个结点的关键字输出。要求除该树本身的存储空间外只能使用固定量的额外存储空间&#xff0c;且在过程中不得修改该树&#xff0c;即使是暂时的修改也不允许。 文…

ice和Dtls 传输的创建及1个简单的SFU转发实例

ice和Dtls 传输的创建及1个简单的SFU转发实例 licode中,webrtcconn基于dtlstransport 收发,而dtlstransport通过libnice作为底层。dtlstransport 使用了srtp加解密。文末给出一个简化的sfu实例的实现。对应的,看下M98的代码,更能理解为啥这么做: IceTransportInternal 与D…

Transformer模型原理

NLP预训练模型的架构大致可以分为三类&#xff1a; 1. Encoder-Decoder架构&#xff08;T5&#xff09;&#xff0c;seq2seq模型&#xff0c;RNN、LSTM网络 2. BERT&#xff1a;自编码语言模型&#xff0c;预测文本随机掩码 3. GPT&#xff1a; 自回归语言模型&#xff0c;预测…

Elasticsearch(一)---搭建

搭建es 不允许root用于运行 创建esuser用户&#xff1a; useradd esuser 设置密码 passwd esuser 让esuser拥有sudo的权限&#xff0c;需要修改/etc/sudoers文件 需要先给/etc/sudoers添加写的权限 [rootnode1 ~]# vim /etc/sudoers 改完之后将写权限删除 三台服务器上操…