package leslie.information_system.controller;
import leslie.information_system.entity.Department;
import leslie.information_system.entity.Student;
import leslie.information_system.exception.StudentException;
import leslie.information_system.service.DepartmentService;
import leslie.information_system.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Controller
public class StudentController {
@Autowired
private StudentService studentService;
@Autowired
private JavaMailSender javaMailSender;
@Autowired
private DepartmentService departmentService;
@PostMapping("/student/regist")
public String regist(Student student, HttpServletRequest request){
try {
studentService.regist(student);
//因为一些后期bug,所以这里先设置部门号为0,即为空。
Department departmentByDepartment_id = departmentService.getDepartmentByDepartment_id(0);
System.out.println(departmentByDepartment_id);
student.setDepartment(departmentByDepartment_id);
System.out.println(student);
studentService.update(student);
//发送激活邮件
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("[email protected]");
message.setTo(student.getStudent_email());
message.setSubject("学生信息系统激活邮件");
message.setText("<html><body><h1>您好,"+student.getStudent_username()+"</h1><a href='http://localhost:8080/student/active/"+student.getStudent_id()+"'>请点击进行激活</a></body></html>");
request.setAttribute("msg","激活邮件已经发送,请注意查看");
javaMailSender.send(message);
} catch (StudentException e) {
request.setAttribute("msg",e.getMessage());
return "studentPages/regist";
}
return "studentPages/login";
}
@ResponseBody
@GetMapping("/student/active/{student_id}")
public String acitve(@PathVariable Integer student_id){
studentService.active(student_id);
return "激活成功,请回到登录页面进行登录";
}
@PostMapping("/student/login")
public String login(Student student,HttpServletRequest request){
try {
Student login = studentService.login(student);
request.getSession().setAttribute("student",login);
} catch (StudentException e) {
request.setAttribute("msg",e.getMessage());
return "studentPages/login";
}
return "index";
}
@GetMapping("/student/quit")
public String quit(Integer student_id,HttpServletRequest request){
request.getSession().removeAttribute("student");
return "studentPages/login";
}
@PutMapping("/student/update")
public String update(Student student,Integer department_id,HttpServletRequest request){
Department departmentByDepartment_id = departmentService.getDepartmentByDepartment_id(department_id);
student.setDepartment(departmentByDepartment_id);
studentService.update(student);
request.getSession().setAttribute("student",student);
return "studentPages/changeInformation";
}
//根据系id查询所以学生
@GetMapping("/student/{department_id}")
public String getStudentByDepartment_id(@PathVariable Integer department_id,HttpServletRequest request){
List<Student> studentByDepartment_id = studentService.getStudentByDepartment_id(department_id);
request.setAttribute("studentList",studentByDepartment_id);
return "departmentAdminPages/studentList";
}
@DeleteMapping("/student")
public String deleteStudent(@RequestParam("student_id") Integer student_id){
System.out.println(student_id);
Student student = studentService.getStudentByStudent_id(student_id);
//发送删除告知邮件
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("[email protected]");
message.setTo(student.getStudent_email());
message.setSubject("学生信息系统告知邮件");
message.setText("<html><body><h1>您好,"+student.getStudent_name()+"</h1><br/>系管理员当前已将你的账户信息与成绩信息清空,如有疑问,请联系相关的系管理员");
javaMailSender.send(message);
studentService.deleteStudent(student_id);
return "/departmentAdminPages/index";
}
//忘记密码
@PostMapping("/student/forgetPassword")
public String forgetPassword(@RequestParam("student_username") String student_username,HttpServletRequest request){
Student studentByStudent_name = studentService.getStudentByStudent_name(student_username);
if (studentByStudent_name == null){
request.setAttribute("msg","该用户名不存在,或者已经被系管理员删除");
return "studentPages/login";
}
//发送密码告知邮件
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("[email protected]");
message.setTo(studentByStudent_name.getStudent_email());
message.setSubject("学生信息系统告知邮件");
message.setText("<html><body><h1>您好,"+studentByStudent_name.getStudent_name()+"</h1><br/>你的密码为:"+studentByStudent_name.getStudent_password());
javaMailSender.send(message);
request.setAttribute("msg","邮件已发送");
return "studentPages/login";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于SpringBoot+Mybatis的学生信息查看与管理系统.zip
共407个文件
xml:133个
class:93个
jar:58个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 67 浏览量
2023-07-10
21:57:18
上传
评论
收藏 22.58MB ZIP 举报
温馨提示
本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!! 本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!! 本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!!
资源推荐
资源详情
资源评论
收起资源包目录
基于SpringBoot+Mybatis的学生信息查看与管理系统.zip (407个子文件)
StudentController.class 7KB
StudentController.class 7KB
GradeController.class 5KB
GradeController.class 5KB
DepartmentController.class 5KB
DepartmentController.class 5KB
DepartmentAdminController.class 5KB
DepartmentAdminController.class 5KB
SubjectController.class 4KB
SubjectController.class 4KB
StudentServiceImpl.class 3KB
StudentServiceImpl.class 3KB
Student.class 3KB
Student.class 3KB
DepartmentAdminServiceImpl.class 3KB
DepartmentAdminServiceImpl.class 3KB
DepartmentServiceImpl.class 3KB
DepartmentServiceImpl.class 3KB
SubjectServiceImpl.class 2KB
SubjectServiceImpl.class 2KB
DepartmentAdmin.class 2KB
DepartmentAdmin.class 2KB
DepartmentAdminLoginInterceptor.class 2KB
DepartmentAdminLoginInterceptor.class 2KB
StudentLoginInterceptor.class 2KB
StudentLoginInterceptor.class 2KB
AdminInterceptor.class 2KB
AdminInterceptor.class 2KB
Grade.class 2KB
Grade.class 2KB
GradeServiceImpl.class 2KB
GradeServiceImpl.class 2KB
AdminController.class 2KB
AdminController.class 2KB
PageController.class 2KB
PageController.class 2KB
InformationSystemApplicationTests.class 2KB
Subject.class 2KB
Subject.class 2KB
DepartmentConfigurerAdapter.class 2KB
DepartmentConfigurerAdapter.class 2KB
StudentConfigurerAdapter.class 2KB
StudentConfigurerAdapter.class 2KB
AdminConfigurerAdapter.class 2KB
AdminConfigurerAdapter.class 2KB
Admin.class 2KB
Admin.class 2KB
MyLocaleResolver.class 2KB
MyLocaleResolver.class 2KB
AdminServiceImpl.class 1KB
AdminServiceImpl.class 1KB
InformationSystemApplication.class 1KB
InformationSystemApplication.class 1KB
DateUtils.class 1KB
DateUtils.class 1KB
Department.class 1KB
Department.class 1KB
DepartmentAdminMapper.class 1KB
DepartmentAdminMapper.class 1KB
DepartmentAdminException.class 1KB
DepartmentAdminException.class 1KB
DepartmentException.class 1KB
DepartmentException.class 1KB
StudentException.class 1KB
SubjectException.class 1KB
StudentException.class 1KB
SubjectException.class 1KB
AdminException.class 1KB
AdminException.class 1KB
StudentService.class 1KB
StudentService.class 1KB
DepartmentAdminService.class 1012B
DepartmentAdminService.class 1012B
StudentMapper.class 866B
StudentMapper.class 866B
SubjectMapper.class 858B
SubjectMapper.class 858B
DepartmentService.class 823B
DepartmentService.class 823B
GradeMapper.class 815B
GradeMapper.class 815B
SubjectService.class 795B
SubjectService.class 795B
DepartmentMapper.class 736B
DepartmentMapper.class 736B
SpringConfig.class 709B
SpringConfig.class 709B
GradeService.class 708B
GradeService.class 708B
AdminMapper.class 396B
AdminMapper.class 396B
AdminService.class 357B
AdminService.class 357B
departmentAdminList.html 8KB
departmentAdminList.html 8KB
departmentAdminList.html 8KB
gradeList.html 8KB
gradeList.html 8KB
gradeList.html 8KB
subjectList.html 7KB
共 407 条
- 1
- 2
- 3
- 4
- 5
资源评论
白话机器学习
- 粉丝: 8926
- 资源: 7681
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功