SSM学生管理系统
简单介绍下搬砖的经过,用时大约一天半,所用技术ssm框架,bootstrap前端框架,springsecrity 安全框架,项目这种东西知道需求和流程后,只要会写sql剩下的都是些重复性工作了。刷剧必备
数据库设计(半天)
这东西应该是最难的,我是用的python读取excel生成sql语句,用了这么半年Java,还是python好用,泪目.jpg
全是真实数据不方便公布,就把python代码公布一下。不过数据库设计还是有不足,想的不充分。
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import math
# date = pd.read_excel("student_import.xlsx")
#
# id = date["学号"]
# # print(len(id))
# for i in range(0, len(id)):
# id1 = str(id[i])
# # id1 = "201711010226"
# sql = "insert into user (userId, PASSWORD, roldId) values ("
# sql= sql + "'" + id1 + "'" + "," + "'" + id1[-6 : ] + "'" + "," + "1);"
# print(sql)
# date = pd.read_excel("teacher_import.xlsx")
#
# id = date["教师工号"]
# # print(len(id))
# for i in range(0, len(id)):
# id1 = str(id[i])
# # id1 = "201711010226"
# sql = "insert into user (userId, PASSWORD, roldId) values ("
# sql= sql + "'" + id1 + "'" + "," + "'" + id1 + "'" + "," + "2);"
# print(sql)
# date = pd.read_excel("student_import.xlsx")
#
# id = date["学号"]
# name = date["姓名"]
# major = date["录取专业"]
# clazz = date["拟分入班级"]
# # print(len(id))
# for i in range(0, len(id)):
# id1 = str(id[i])
# name1 = str(name[i])
# major1 = str(major[i])
# clazz1 = str(clazz[i])
# # id1 = "201711010226"
# sql = "insert into student ( studentId, name,major,clazz) values ("
# sql= sql + "'" + id1 + "'" + "," + "'" + name1 + "'" + "," + "'" + major1[:8] + "'" + "," + "'计工本170" + clazz1 + "'" + ");"
# print(sql)
# date = pd.read_excel("teacher_import.xlsx")
#
# id = date["教师工号"]
# name = date["姓名"]
# major = date["学院"]
# clazz = date["所在系别"]
# # print(len(id))
# for i in range(0, len(id)):
# id1 = str(id[i])
# name1 = str(name[i])
# major1 = str(major[i])
# clazz1 = str(clazz[i])
# # id1 = "201711010226"
# sql = "insert into teacher (teacherId,name ,college,tie) values ("
# sql= sql + "'" + id1 + "'" + "," + "'" + name1 + "'" + "," + "'" + major1[:8] + "'" + "," + "'计工本170" + clazz1 + "'" + ");"
# print(sql)
date = pd.read_excel("course_import.xlsx")
id = date["课程号"]
name = date["课程名称"]
teacher = date["老师"]
num = date["课容量"]
major = date["开设教室"]
clazz = date["教师教工号"]
# print(len(id))
for i in range(0, len(id)):
id1 = str(id[i])
name1 = str(name[i])
teacher1 = str(teacher[i])
num1 = str(num[i])
major1 = str(major[i])
clazz1 = str(clazz[i])
# id1 = "201711010226"
sql = "insert into course (courseId,name ,teachername,num,room,teacherId) values ("
sql= sql + "'" + id1 + "'" + "," + "'" + name1 + "'" + "," + "'" + teacher1 + "'" + ","+num1+"," + "'" + major1[:8] + "'" + "," + "'" + clazz1 + "'" + ");"
print(sql)
admin后台
这应该是最简单的一部分啦,学生查询,教师查询,课程查询还是他们对应的增加修改和删除,简单增删查改的运用
学生后台
学生就是选课和退课还有查成绩,也没啥可说的
教师后台
就是查学他课的学生和查成绩
springsecity
这个想说一下,看了一些登入跳转页面的方法看的我一脸懵逼,其实我的解决方法很简单
1.跳转成功页面设置为一个控制器
authentication-success-forward-url="/user/login.do"
2.控制器根据角色跳转不同页面
@RequestMapping("/login.do")
public String login(){
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext()
.getAuthentication()
.getPrincipal();
String name = userDetails.getUsername();
UserInfo userInfo = userService.findByName(name);
//System.out.println(userInfo);
if(userInfo.getRoldId() == 0)
return "admin/main";
if(userInfo.getRoldId() == 1)
return "student/main";
if(userInfo.getRoldId() == 2)
return "teacher/main";
return "";
}
总结一下
搬砖挺舒服的
GitHub 下载源码