一、项目简述
功能包括:
三角色教师 管理员,学生教务管理系统,包括院系管理,课题综合管理,信息管理,以及差旅管理,学生选题等等。
二、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
学生信息控制层:@Authority(roles = {Role.STUDENT})
@Controller
@RequestMapping("/student")
public class StudentController {
private static final Logger LOGGER = LoggerFactory.getLogger(StudentController.class);
@Autowired
private StudentService studentService;
@Autowired
private HttpServletRequest request;
@Autowired
private LoginServiceImpl loginService;
@Autowired
IndexServiceImpl indexService;
@Autowired
AdminService adminService;
@Autowired
TopicsService topicsService;
//Session过期时间
private final Integer SAVE_TIME = 60*60*24;
@GetMapping("/login")
public String login(){
return "student/login";
}
@PostMapping(value = "/login")
@ResponseBody
public String login(String name, String pwd, Model model, HttpServletResponse response) {
name = name.trim();
List<Student> student = studentService.selectByName(name);
if (student.size() >= 1) {
if (student.get(0).getPwd().equals(pwd)) {
request.getSession().setAttribute("student",student.get(0));
request.getSession().setMaxInactiveInterval(SAVE_TIME);
User user = new User();
//-1表示为超管
user.setId(1L);
user.setRole("student");
user.setUserName(name);
//生成Token 存到 Cookie
Cookie cookie = new Cookie("token", TokenUtil.createToken(
user
));
//该Cookie无法被js读取
cookie.setHttpOnly(true);
cookie.setPath("/");
response.addCookie(cookie);
model.addAttribute("student", student.get(0));
return "200";
}else {
return "0";
}
} else {
return "300";
}
}
@RequestMapping("/index")
public String index(Model model, HttpSession httpSession) {
Student student = (Student) request.getSession().getAttribute("student");
Subject project = indexService.indexinfo(student.getId());
String str = null;
Long flag = null;
if (project == null) {
model.addAttribute("projectName", "未选课题");
model.addAttribute("flag", "未选题");
model.addAttribute("teacher", "无");
httpSession.removeAttribute("");
} else {
httpSession.setAttribute("XZproject", project.getProjectname());
model.addAttribute("XZproject", project.getProjectname());
model.addAttribute("projectName", project.getProjectname());
flag = indexService.projectselectedstuflag(student.getId());
if (flag == 0L) {
str = "未选题";
} else if (flag == 1L) {
str = "选题待审核";
} else if (flag == 2L) {
str = "选题未通过";
} else if (flag == 3L) {
str = "选题通过";
}
model.addAttribute("flag", str);
model.addAttribute("teacher", project.getTeachernames());
request.getSession().setAttribute("filePath",project.getFilepath());
}
//用来判断当前页是否为首页
model.addAttribute("path","1");
//判断是否修改了个人信息
// request.getSession().setAttribute(“modifyFlag”,0);
return "student/index";
}
/**
* 查看个人信息
*/
@RequestMapping("/studentinfo")
public String studentinfo(Model model) {
Student student = (Student) request.getSession().getAttribute("student");
MyClass idclass = indexService.studentinfo(student.getIdClass());
model.addAttribute("tclass", idclass);
return "student/studentinfo";
}
/**
* 将查看的个人信息放到信息修改页面
*/
@RequestMapping("/modifyinfo")
public String modifyinfo(Model model) {
Student student = (Student) request.getSession().getAttribute("student");
MyClass idclass = indexService.studentinfo(student.getIdClass());
model.addAttribute("tclass", idclass);
return "student/modifyinfo";
}
/**
* 修改个人信息
* 根据班级(className)修改
*
*/
/*@RequestMapping(value = "/modifyinfodao", method = RequestMethod.PUT)
@ResponseBody
public String modifyinfodao(Student student, String className, Model model) {
Student Tstudent = (Student) request.getSession().getAttribute("student");
MyClass Tclass = indexService.selectByclassName(className);
int count = -1;
student.setIdClass(Tclass.getId());
System.out.println("******"+Tstudent.toString());
System.out.println("******"+student.toString());
if (student.getStunum().equals(Tstudent.getStunum())) {
student.setStunum(null);
}
if (student.getIdClass().equals(Tstudent.getIdClass())) {
student.setIdClass(null);
}
if (student.getName().equals(Tstudent.getName())) {
student.setName(null);
}
if (student.getGender().equals(Tstudent.getGender())) {
student.setGender(null);
}
if (student.getGender() == null && student.getName() == null && student.getIdClass() == null && student.getStunum() == null) {
} else {
student.setId(Tstudent.getId());
count = indexService.updateBymodifyinfo(student);
student = indexService.selectByid(Tstudent.getId());
model.addAttribute("student", student);
}
if (count > 0) {
request.getSession().setAttribute("student",student);
request.getSession().setAttribute("modifyFlag",1);
return "200";
} else {
request.getSession().setAttribute("modifyFlag",0);
return "201";
}
}*/
/**
* 跳转页面(修改密码)
*/
@RequestMapping("/changepsw")
public String changepsw() {
return "student/changepsw";
}
/**
* 200修改成功
* 201对不起密码错误
* 202对不起输入框为空
* 203新密码不一致
* 204修改失败
*/
@RequestMapping(value = "/changepassword", method = RequestMethod.PUT)
@ResponseBody
public String changepswdao(String oldpassword, String newpassword, String newpassword1) {
if(!verifypassword(newpassword)){
return "206";
}
if(!verifypassword(newpassword1)){
return "206";
}
Student student = (Student) request.getSession().getAttribute("student");
Student studentdao = loginService.selectByName(student.getUsername());
int result;
if (newpassword.equals(newpassword1) && !newpassword.equals("") && !newpassword1.equals("")) {
if (studentdao.getPwd().equals(oldpassword)) {
if(oldpassword.equals(newpassword)){
return "205";
}else{
result = indexService.updatepassword(newpassword, student.getId());
if (result > 0) {
return "200";
}else{
return "204";
}
}
} else {
return "201";
}
} else if (newpassword.equals("") && newpassword1.equals("")) {
return "202";
}
return "203";
}
//密码验证
public boolean verifypassword(String password){
if(password.length() < 6 || password.length() > 16){
return false;
}
for(int i = 0;i < password.length();i++){
if(!(password.charAt(i)>='A' && password.charAt(i)<='Z')){
if(!(password.charAt(i)>='a' &am