基于Java Web的云端学习系统的设计与实现

news2024/9/20 16:41:47

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:采用JSP技术开发
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


目录

一、项目简介

二、系统功能

三、系统项目截图

管理员功能实现

用户管理

课程信息管理

学习课件管理

学习视频管理

用户功能实现

课程信息

论坛

学习课件

学习视频

四、核心代码

登录相关

文件上传

封装


一、项目简介

互联网发展至今,无论是其理论还是技术都已经成熟,而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播,搭配信息管理工具可以很好地为人们提供服务。针对课程学习信息管理混乱,出错率高,信息安全性差,劳动强度大,费时费力等问题,采用云端学习系统可以有效管理,使信息管理能够更加科学和规范。

云端学习系统在Eclipse环境中,使用Java语言进行编码,使用Mysql创建数据表保存本系统产生的数据。系统可以提供信息显示和相应服务,其管理员管理课程,学习课件,学习视频以及论坛信息。用户收藏课程,下载学习课件,播放学习视频,查看论坛里面的帖子以及回帖信息。

总之,云端学习系统集中管理信息,有着保密性强,效率高,存储空间大,成本低等诸多优点。它可以降低信息管理成本,实现信息管理计算机化。


二、系统功能

在前面分析的管理员功能的基础上,进行接下来的设计工作,最终展示设计的管理员结构图(见下图)。管理员管理课程,学习课件,学习视频以及论坛信息。

在前面分析的用户功能的基础上,进行接下来的设计工作,最终展示设计的用户结构图(见下图)。用户收藏课程,下载学习课件,播放学习视频,查看论坛里面的帖子以及回帖信息 。



三、系统项目截图

管理员功能实现

用户管理

管理员进入指定功能操作区之后可以管理用户。其页面见下图。用户的基本资料也需要管理员负责修改与删除等操作。

课程信息管理

管理员进入指定功能操作区之后可以管理课程信息。其页面见下图。管理员负责修改课程信息,可以批量删除课程信息。

 

学习课件管理

管理员进入指定功能操作区之后可以管理学习课件。其页面见下图。管理员提交课件标题可以获取学习课件,在当前页面管理员也能修改学习课件,下载学习课件。

 

学习视频管理

管理员进入指定功能操作区之后可以管理学习视频。其页面见下图。管理员提交视频标题可以获取学习视频,管理员在当前页面可以修改学习视频信息。

用户功能实现

课程信息

用户进入指定功能操作区之后可以查看课程信息。其页面见下图。用户在本页面收藏课程,对该页面显示的课程发布留言。

 

论坛

用户进入指定功能操作区之后可以查看论坛帖子。其页面见下图。用户点击发布帖子按钮可以发布帖子,用户点击帖子标题可以查看帖子并评论帖子。

 

学习课件

用户进入指定功能操作区之后可以查看学习课件。其页面见下图。用户收藏学习课件,在当前页面可以下载学习课件。

 

学习视频

用户进入指定功能操作区之后可以查看学习视频。其页面见下图。用户播放学习视频,能够收藏本页面显示的学习视频。

 


四、核心代码

登录相关


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();
    }
}

文件上传

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);
	}
	
}

封装

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/1212617.html

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

相关文章

Prometheus入门与实战

1.Prometheus介绍 1.什么是监控&#xff1f; 从技术角度来看&#xff0c;监控是度量和管理技术系统的工具和过程&#xff0c;但监控也提供从系统和应用程序生成的指标到业务价值的转换。这些指标转换为用户体验的度量&#xff0c;为业务提供反馈&#xff0c;同样还向技术提供反…

记feign调用第三方接口时header是multipart/form-data

1.请求第三方接口&#xff0c;用feign请求 请求第三方接口&#xff0c;用feign请求&#xff0c;header不通&#xff0c;feign的写法不同 调用时报错Could not write request: no suitable HttpMessageConverter found for request type [com.ccreate.cnpc.mall.dto.zm.ZMPage…

现场直击!触想智能亮相德国2023 SPS展会

当地时间11月14日上午9时 2023 年(德国)纽伦堡国际工业自动化及元器件展览会 SPS 展(以下简称&#xff1a;SPS展会)正式拉开帷幕&#xff0c;触想智能与来自全球各地的领先科技公司及前沿业者齐聚盛会&#xff0c;共赴一场科技与创新交汇的“饕餮盛宴”。 △ 2023 SPS展会开幕(…

sCrypt Playground 发布

sCrypt Playground 发布了。 与桌面IDE 完全相同的功能&#xff0c;但是无需安装。体验地址: https://playground.scrypt.io。 请不要在 sCrypt Playground 上存储重要数据。我们会不定时清除用户保存在其上的数据。

海外邮件接收延迟、接收不到怎么办?U-Mail邮件网关来了

随着经济全球化的发展&#xff0c;很多国内企业开始踏足海外市场&#xff0c;电子邮件就成为了国内企业与海外客户沟通交流的主要渠道。然而海外邮件接收延迟、接收不到等问题成为了困扰企业与海外客户沟通的一大阻碍&#xff0c;导致客户邮件回复不及时&#xff0c;询盘邮件接…

Javaweb之Vue的概述

2.1 Vue概述 通过我们学习的htmlcssjs已经能够开发美观的页面了&#xff0c;但是开发的效率还有待提高&#xff0c;那么如何提高呢&#xff1f;我们先来分析下页面的组成。一个完整的html页面包括了视图和数据&#xff0c;数据是通过请求 从后台获取的&#xff0c;那么意味着我…

移植freertos到qemu上运行

1、freertos源码下载 参考博客&#xff1a;《freertos源码下载和目录结构分析》&#xff1b; 2、编译freertos 2.1、选择合适的Demo freertos官方已经适配过qemu&#xff0c;所以我们并不需要做源码级别的移植&#xff0c;只需要选择合适的Demo文件夹。 2.2、修改Makefile 2.3…

教你轻轻松松写出10万+的微头条爆文,赶紧收藏!

微头条是投放在今日头条上的稿件&#xff0c;重点在于微字&#xff0c;一般在300-500字之间&#xff0c;讲究的是原创干货&#xff0c;有独到见解。 企业和品牌撰写微头条来给自己带来更多曝光和展现。想要让你的微头条写出爆款内容&#xff0c;这是需要讲究技巧的&#xff0c…

PyTorch:张量与矩阵

PyTorch 是一个基于 Python 的科学计算包&#xff0c;专门针对深度学习研究&#xff0c;提供了丰富的工具和库。在 PyTorch 中&#xff0c;张量&#xff08;tensor&#xff09;是深度学习的核心数据结构&#xff0c;它可以看作是可以进行自动微分的多维数组。张量不仅可以代表标…

less详解

拥抱前端开发的未来&#xff0c;掌握Less的魔力&#xff01;在我们精心撰写的博客文章中&#xff0c;你将发现如何通过学习Less这一强大的CSS预处理器&#xff0c;以更高效、更可维护的方式编写样式代码。无论你是初学者还是经验丰富的开发者&#xff0c;我们的指南将带你逐步了…

猫罐头哪种好吃又健康?精选5款营养美味的猫罐头推荐!

不知不觉开宠物店已经7年啦&#xff0c;店里的猫猫大大小小也算是尝试过很多品牌的猫罐头了。一开始选购猫罐头我也是踩了很多坑&#xff0c;各种踩雷。猫罐头的各种门道还是很难摸索的&#xff0c;新手养猫一不小心就会着道了。 作为一个从业宠物行业7年的人&#xff0c;我将给…

vue3 tsx 项目中使用 Antv/G2 实现多线折线图

Antv/G2 文档 Antv/G2 双折线图 安装依赖 项目中安装 antv/g2 依赖库&#xff1a; npm install antv/g2 --save安装成功&#xff1a; 项目使用 新建文件 IndicatorTrend.tsx&#xff1a; import { defineComponent, PropType, onMounted, ref } from vue import { useCh…

环境检测lims系统 环境检测行业实验室管理系统

白码环境监测实验室管理系统针对实验室管理中遇到的问题和难点&#xff0c;提供对环境监测实验室所有监测业务的全流程管理&#xff0c;实现对实验室“人、机、料、法、环”(即人员、仪器、样品、方法、环境)的全面资源管理&#xff0c;实现环境监测实验室工作的自动化和规范化…

二十、泛型(8)

本章概要 潜在的类型机制 pyhton 中的潜在类型C 中的潜在类型Go 中的潜在类型java 中的直接潜在类型 潜在类型机制 在本章的开头介绍过这样的思想&#xff0c;即要编写能够尽可能广泛地应用的代码。为了实现这一点&#xff0c;我们需要各种途径来放松对我们的代码将要作用的…

macos死机后IDEA打不开,Cannot connect to already running IDE instance.

Cannot connect to already running IDE instance. Exception: Process 573 is still running 解决办法 进入&#xff1a;/Users/lzq/Library/Application Support/JetBrains 找到IDEA的目录删除隐藏文件夹 .lock rm -rf .lock

SLAM中提到的相机位姿到底指什么?

不小心又绕进去了&#xff0c;所以掰一下。 以我个人最直观的理解&#xff0c;假设无旋转&#xff0c;相机在世界坐标系的(5,0,0)^T的位置上&#xff0c;所谓“位姿”&#xff0c;应该反映相机的位置&#xff0c;所以相机位姿应该如下&#xff1a; Eigen::Matrix4d T Eigen::M…

Django之模版层

文章目录 模版语法传值模版语法传值特性模版语法标签语法格式if模板标签for模板标签with起别名 模版语法过滤器常用过滤器 自定义过滤器、标签、inclusion_tag自定义过滤器自定义标签自定义inclusion_tag 模版导入模版继承 模版语法传值 模板层三种语法{{}}:主要与数据值相关{%…

【LeetCode刷题-滑动窗口】--1456.定长子串中元音的最大数目

1456.定长子串中元音的最大数目 方法&#xff1a;使用滑动窗口 class Solution {public int maxVowels(String s, int k) {int n s.length();int sum 0;for(int i 0;i<k;i){sum isVowel(s.charAt(i));}int ans sum;for(int i k;i<n;i){sum sum isVowel(s.charAt…

【echarts】实现单线与多线滚轮联动、隐藏拖拽、关闭动画

单线滚轮联动 <!DOCTYPE html> <html> <head><meta charset"utf-8"><title>ECharts DataZoom</title><script src"https://cdn.jsdelivr.net/npm/echarts5.2.0/dist/echarts.min.js"></script> </hea…