Python-基于Django的新生入学管理系统

2023-11-13

末尾获取源码
开发语言:python
框架:Django
数据库:MySQL5.7
开发软件:pycharm


目录

一、项目简介

二、系统功能

三、系统项目截图

3.1前台首页

3.2后台管理

四、核心代码

4.1登录相关

4.2文件上传

4.3封装


一、项目简介

新生入学管理系统利用网络沟通、计算机信息存储管理,有着与传统的方式所无法替代的优点。比如计算检索速度特别快、可靠性特别高、存储容量特别大、保密性特别好、可保存时间特别长、成本特别低等。在工作效率上,能够得到极大地提高,延伸至服务水平也会有好的收获,有了网络,新生入学管理系统的各方面的管理更加科学和系统,更加规范和简便。


二、系统功能

本新生入学管理系统主要包括两大功能模块,即用户功能模块和管理员功能模块。

(1)管理员模块:专业管理、班级管理、学生管理、商品分类管理、商品信息管理、新生签到管理、交流论坛、系统管理、订单管理。 

(2)学生:商品信息、交流论坛、报到指南、个人中心、后台管理、购物车。



三、系统项目截图

3.1前台首页

 前台注册页面,未有账号的学生可在该页面进行注册并且登录。

 登录到前台我们可以看到有以下图片的相关功能模块 

在报到指南我们可以查看学校发布的一些入校指南文章

选择想看的入校指南文章即可查看

入校我们可能需要一些商品,可以选择自己的生活所需品可购买下单

点击相关的商品我们可以查看商品的信息和价格 

下单我们可以选择地址然后点击支付

3.2后台管理


 

四、核心代码

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

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

4.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;
	}
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Python-基于Django的新生入学管理系统 的相关文章

  • Android 认为我没有关闭数据库!为什么?

    我有一个 SQLiteDatabase 数据成员 我在 onCreate 中初始化它 并在 onPause onStop 和 onDestroy 中调用 close 它在 onResume 中重新初始化 它似乎运行得很好 但当我查看调试器时
  • 如何自定义舍入形式

    我的问题可能看起来很简单 但仍然无法得到有效的东西 我需要自定义 Math round 舍入格式或其他格式以使其工作如下 如果数字是 1 6 他应该四舍五入到 1 如果大于或等于 1 7 他应该四舍五入到 2 0 对于所有其他带有 6 的小
  • IntelliJ Idea:将简单的 Java servlet(无 JSP)部署到 Tomcat 7

    我尝试按照教程进行操作here http wiki jetbrains net intellij Creating a simple Web application and deploying it to Tomcat部署 servlet
  • UseCompressedOops JVM 标志有什么作用以及何时应该使用它?

    HotSpot JVM 标志是什么 XX UseCompressedOops我应该做什么以及什么时候使用它 在 64 位 Java 实例上使用它 与不使用它 时 我会看到什么样的性能和内存使用差异 去年大多数 HotSpot JVM 都默认
  • 数据库中的持久日期不等于检索日期

    我有一个具有 Date 属性的简单实体类 此属性对应于 MySQL 日期时间列 Entity public class Entity Column name start date Temporal TemporalType TIMESTAM
  • 我可以在 if 语句中使用“as”机制吗

    是否可以使用as in if类似的声明with我们使用的 例如 with open tmp foo r as ofile do something with ofile 这是我的代码 def my list rtrn lst True if
  • 更新 matplotlib 中颜色条的范围

    我想更新一个contourf在函数内绘制 效果很好 然而 数据的范围发生了变化 因此我还必须更新颜色条 这就是我未能做到的地方 请参阅以下最小工作示例 import matplotlib pyplot as plt import numpy
  • 无法将matplotlib安装到pycharm

    我最近开始使用Python速成课程学习Python编程 我陷入困境 因为我无法让 matplotlib 在 pycharm 中工作 我已经安装了pip 我已经通过命令提示符使用 pip 安装了 matplotlib 现在 当我打开 pych
  • 我们如何使用 thymeleaf 绑定对象列表的列表

    我有一个表单 用户可以在其中添加任意数量的内容表对象这也可以包含他想要的列对象 就像在 SQL 中构建表一样 我尝试了下面的代码 但没有任何效果 并且当我尝试绑定两个列表时 表单不再出现 控制器 ModelAttribute page pu
  • Django 将对象从视图传递到下一个进行处理

    如果您有 2 个视图 第一个视图使用 modelform 获取用户输入的信息 出生日期 姓名 电话号码等 第二个视图使用此信息创建表 如何将第一个视图中创建的对象传递到下一个视图 以便可以在第二个视图的模板中使用它 如果您能分享任何帮助 我
  • 重定向 python 交互式帮助()

    我正在为使用 Qt 的应用程序开发交互式 python shell 但是我似乎无法获得重定向的交互式帮助 我的 python 代码中有这个 class OutputCatcher def init self self data def wr
  • 使用 Sphinx 时,如何记录没有文档字符串的成员?

    我正在为我发布的包编写文档 我发现您的文档越全面 人们就越容易找到您的包来使用 废话 实际上 我在充满爱心地编写代码的所有功能和细节方面获得了很多乐趣 然而 我对如何为类级变量编写与 Sphinx 兼容的文档感到完全困惑 特别是 我有一些e
  • Python matplotlib:将轴标签/图例从粗体更改为常规粗细

    我正在尝试制作一些出版质量的图 但遇到了一个小问题 默认情况下 matplotlib 轴标签和图例条目的权重似乎比轴刻度线重 是否有办法强制轴标签 图例条目与刻度线的重量相同 import matplotlib pyplot as plt
  • 确定 JavaFX 中是否消耗了事件

    我正在尝试使用 JavaFX 中的事件处理来做一些非滑雪道的事情 我需要能够确定手动触发事件后是否已消耗该事件 在以下示例中 正确接收了合成鼠标事件 但调用 Consumer 不会更新该事件 我对此进行了调试 发现 JavaFX 实际上创建
  • 带 getClassLoader 和不带 getClassLoader 的 getResourceAsStream 有什么区别?

    我想知道以下两者之间的区别 MyClass class getClassLoader getResourceAsStream path to my properties and MyClass class getResourceAsStre
  • 什么是 Java2D 处理程序线程?

    我创建了一个使用 Hibernate 的示例 java 应用程序 当我进行线程转储时 我观察到一个名为 Java2D Disposer 的奇怪线程 有人能告诉我该线程的功能吗 AWT 系统中的某些实体需要最终确定以释放资源 最突出的例子是j
  • python 日志记录替代方案 [关闭]

    Closed 此问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 蟒蛇记录模块 http docs python org library logging html使用起来
  • 在会话即将到期之前调用方法

    我的网络应用程序有登录的用户 有一个超时 在会话过期之前 我想执行一个方法来清理一些锁 我已经实现了sessionListener但一旦我到达public void sessionDestroyed HttpSessionEvent eve
  • 设置 TreeSet 的大小

    有没有办法像数组一样对 Java 集合中的 TreeSet 进行大小限制 例如我们在数组中 anArray new int 10 数组具有固定长度 在创建数组时必须指定该长度 A TreeSet当您向其中添加元素时会自动增长 您无法设置其大
  • 关闭扫描仪是否会影响性能

    我正在解决一个竞争问题 在问题中 我正在使用扫描仪获取用户输入 这是 2 个代码段 一个关闭扫描器 一个不关闭扫描器 关闭扫描仪 import java util Scanner public class JImSelection publ

随机推荐

  • Ubuntu18.04找不到wifi适配器解决办法以及怎么上网

    目录 一 有线上网办法 二 ubuntu找不到wifi适配器解决办法 三 有线无线均上不了网办法 四 最终问题解决 写在前面 如果大家已经尝试了很多方法进来的 可以先看看我目录里的第四部分 说不定跟我同样的问题 一 有线上网办法 拿起你的手
  • 读傅里叶级数有感

    老实讲 傅里叶级数还真的挺厉害的 但是 想到这个东西的人很厉害 把它说明白的人也很厉害 唯一不厉害的就是 指定我们教材的那帮人和学这些教材出来自以为他们掌握了这些内容却实际上根本讲不明白的人 好吧 其实不得已 看到图像可以从时域和频域两个维
  • 五万字整理Mybatis 入门只需要一篇文章

    这里写目录标题 一 简介 1 1 什么是mybatis 1 2 持久化 1 3 持久层 1 4 为什么需要学习mybatis 二 mybatis中的专业名词 三 第一个mybatis程序 3 1 搭建环境 3 1 1 创建一个数据库 3 1
  • 堆栈详解(数据与内存中的存储方式)

    转自 http www 360doc com content 11 0428 18 6580811 112988089 shtml char r hello word char b hello word r w b w 其实应该是语法错误
  • 从远程桌面客户端提取明文凭证的工具RdpThief

    介绍 远程桌面 RDP 是用于管理Windows Server的最广泛使用的工具之一 除了被管理员使用外 也容易成为攻击者的利用目标 登录到RDP会话的凭据通常用于是具有管理权限的 这也使得它们成为红队行动的一个理想目标 站在传统的角度看
  • Java实现S-DES加密算法

    S DES 为了更好的理解DES算法 美国圣塔克拉拉大学的Edward Schaefer教授于1996年开发了Simplified DES方案 简称S DES方案 它是一个供教学二非安全的加密算法 它与DES的特性和结构类似 但参数小 明文
  • IDEA Services窗口启动应用后突然不显示端口号

    转载 原先可以显示端口号的 但是换了个工程以后突然就不显示了 网上对于新安装的idea不显示端口号的解决方案并不适用 好在找到了解决办法 处理前 处理后 1 打开文件管理器 2 打开路径C Users l用户名 AppData Local
  • narwal无法连接机器人_懒无止境 能自己洗抹布的云鲸J1扫拖机器人

    0 篇首语 如果让我总结过去的2019年又哪几样产品 显著的提升了我的幸福感让生活变得更加方便 那么智能指纹锁和扫地机器人一定可以排在最前面 指纹锁其实不用多说出门无需担心没带钥匙 抬手就能开门的流畅体验确实是非常非常的方便 而扫地机器人也
  • centos6.5 搭建hadoop 开发环境(单台服务器)

    一 安装环境 硬件 虚拟机 操作系统 Centos 6 4 64位 IP 120 25 56 93 主机名 120 25 56 93 安装用户 root 二 安装JDK 安装JDK1 6或者以上版本 这里安装jdk1 7 0 71 具体安装
  • vuecli4适配pc端

    vuecli4适配pc端 1 首先安装amfe flexible npm i S amfe flexible 在main js中引入 import amfe flexible 2 安装postcss px2rem npm i postcss
  • el-menu菜单进行路由跳转

    el menu菜单进行路由跳转 el menu 添加 default active this router path 和 router default active前面要有
  • 实时音频编解码之十四 Opus编码-SILK编码-长时预测

    本文谢绝任何形式转载 谢谢 4 1 12 线性预测系数计算 线性预测分为语音和非语音两种情况 该模块的输入是pitch估计模块白化之后的信号 对于语音帧 白化后的信号依然含有较强的pitch特征 因而为了在相同的比特率下获得更高的编码质量需
  • 研发效能工程实践-代码评审

    什么是代码评审 Code Review的定义 是一项单人或者多人通过阅读别人的源代码来检查代码质量的软件质量保证活动 定义有点绕口 其实就是写完代码之后让经验相对丰富一点的同事帮你检查一下你的代码 当然这个检查应该是多方面的 包括但不限于你
  • Goby漏洞更新

    漏洞名称 PbootCMS 3 1 2 远程代码执行漏洞 CVE 2022 32417 English Name PbootCMS 3 1 2 RCE CVE 2022 32417 CVSS core 9 0 漏洞描述 PbootCMS是P
  • RTP 包格式 详细解析

    H 264 视频 RTP 负载格式 1 网络抽象层单元类型 NALU NALU 头由一个字节组成 它的语法如下 0 1 2 3 4 5 6 7 F NRI Type F 1 个比特 forbidden zero bit 在 H 264 规范
  • 装饰器是什么?一文详解装饰器原理及 Python 计时器实战

    在本文中 我将和大家一起了解装饰器的工作原理 如何将我们之前定义的定时器类 Timer 扩展为装饰器 以及如何简化计时功能 最后对 Python 定时器系列文章做个小结 喜欢记得收藏 关注 点赞 文末提供技术交流群 假设我们需要跟踪代码库中
  • 跟我学,你的服务器安全吗?第一篇----centos系统安全篇

    目录 前言 本文主要为centos的系统安全 常规基础操作 服务器使用密钥对登陆 相对密码登录更加安全 配置ECS自动快照策略 linux系统登陆弱口令检查 系统登陆弱口令 重要软件OPENSSH漏洞 用于SSH连接服务器的 基线保障 即系
  • VUE+WebSocket实现实时推送

    data return id 1 webSock null lockReconnect false 避免重复连接 mounted 调取websocket方法 写在mounted方法中 this initWebSocket methods 发
  • JDBC---连接数据库

    编码实现 准备 1 建立一个maven工程 使用quick骨架 2 引入依赖
  • Python-基于Django的新生入学管理系统

    末尾获取源码 开发语言 python 框架 Django 数据库 MySQL5 7 开发软件 pycharm 目录 一 项目简介 二 系统功能 三 系统项目截图 3 1前台首页 3 2后台管理 四 核心代码 4 1登录相关 4 2文件上传