目录
摘要
在现代教育体系中,学生选课系统是高校教学管理的重要组成部分。为了提高选课效率和用户体验,本文基于Python语言设计并实现了一个学生选课系统。该系统采用B/S架构,前端使用HTML、CSS和JavaScript进行页面设计和交互,后端采用Django框架进行业务逻辑处理和数据库操作。系统主要包括用户登录注册、课程浏览、课程选择、选课结果查询和管理员管理等功能模块。通过本系统的设计与实现,能够为学生提供一个便捷、高效的在线选课平台,同时也为学校教务管理部门提供了一个有效的选课管理工具。
系统展示
技术介绍
Spring Boot框架
Spring Boot是一个用于快速构建基于Spring框架的Java应用程序的开源框架。它提供了默认配置和丰富的组件封装,使开发者能够快速上手并加速开发过程。Spring Boot并不是对Spring功能上的增强,而是提供了一种快速使用Spring的方式,通过减少繁重的配置,提高了开发效率。
Django框架
Django是一个基于Python的高级Web开发框架,遵循MVT设计模式。它由劳伦斯出版集团于2005年发布,旨在快速、简便地开发数据库驱动的网站。Django以其强大的扩展性和丰富的第三方插件而闻名。
MySQL数据库
MySQL由瑞典的MySQL AB公司开发,后来被Sun Microsystems收购,最终成为Oracle公司的产品。它是一个关系型数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL支持SQL(结构化查询语言),这是数据库操作的标准语言,可以使用SQL来执行数据查询、插入、更新、删除等操作。
Vue框架
Vue的发音类似于“view”,其设计理念是简单、灵活和高效。Vue框架的核心库只关注视图层,使得它非常轻量级和高效。Vue不仅易于上手,还便于与第三方库或既有项目整合。同时,当与现代化的工具链以及各种支持类库结合使用时,Vue也能够为复杂的单页应用提供驱动。
代码实现
管理员实现登录后端代码
package com.cl.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import com.cl.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
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.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.cl.annotation.IgnoreAuth;
import com.cl.entity.UsersEntity;
import com.cl.entity.view.UsersView;
import com.cl.service.UsersService;
import com.cl.service.TokenService;
import com.cl.utils.PageUtils;
import com.cl.utils.R;
import com.cl.utils.MPUtil;
import com.cl.utils.MapUtils;
import com.cl.utils.CommonUtil;
/**
* 管理员
* 后端接口
* @author
* @email
* @date 2024-12-04 12:11:29
*/
@RestController
@RequestMapping("/users")
public class UsersController {
@Autowired
private UsersService usersService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UsersEntity u = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
if(u==null || !u.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(u.getId(), username,"users", "管理员" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody UsersEntity users){
//ValidatorUtils.validateEntity(users);
UsersEntity u = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", u