Java project: student class attendance management system (java+ssm+jsp+layui+mysql)

pastclouds 2022-06-23 14:46:41 阅读数:866

javaprojectstudentclassattendance

The source code for : My blog home page " resources " Download !

Project introduction


This project includes counselors 、 Administrators 、 Teachers' 、 There are four roles for students ;

Counselors include the following functions :
Counselor role login , Student management , Password change , Leave approval , Check in list and other functions .

The administrator role includes the following functions :
Administrator login , Class management , Counselor Management , Teacher management and other functions .

The teacher role includes the following functions :
Teacher login , Check in Management , Leave list , Password modification and other functions .

The student role includes the following functions :
Student role login , View my sign in , Change Password , Leave management , Start check-in and other functions .

Environmental needs

1. Running environment : It is best to java jdk 1.8, We run on this platform . Other versions can, in theory .
2.IDE Environmental Science :IDEA,Eclipse,Myeclipse Fine . recommend IDEA;
3.tomcat Environmental Science :Tomcat 7.x,8.x,9.x All versions are available
4. Hardware environment :windows 7/8/10 1G Above memory ; perhaps Mac OS; 
5. database :MySql 5.7 edition ;
6. whether Maven project : yes ;


Technology stack

1. Back end :Spring+SpringMVC+Mybatis
2. front end :JSP+CSS+JavaScript+layui


Instructions

1. Use Navicat Or other tools , stay mysql Create a database with the corresponding name in , And import the sql file ;
2. Use IDEA/Eclipse/MyEclipse Import the project ,Eclipse/MyEclipse Import time , if maven Item, please select maven;
if maven project , After importing successfully, please execute maven clean;maven install command , And then run ;
3. In the project db.properties Change the database configuration in the configuration file to your own configuration ;
4. Run the project , Input localhost:8080/ Sign in

 

 

 

 

 

Teacher management control :

@Controller
@RequestMapping("/teacher")
public class TeacherController extends BaseController {
/**
* Dependency injection start dao/service/===
*/
@Autowired
private TeacherService teacherService;
@Autowired
private BjService bjService;
@Autowired
private TeacherBjService teacherBjService;
// --------------------------------------- Gorgeous split line ------------------------------
/**
* Paging query return list object ( Through object )
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByObj")
public String findByObj(Teacher teacher, Model model, HttpServletRequest request, HttpServletResponse response) {
// Paging query
Pager<Teacher> pagers = teacherService.findByEntity(teacher);
model.addAttribute("pagers", pagers);
// Store query criteria
model.addAttribute("obj", teacher);
return "teacher/teacher";
}
/**
* Paging query return list object ( Through to By Sql)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findBySql")
public String findBySql(Teacher teacher, Model model, HttpServletRequest request, HttpServletResponse response) {
// Paging query
String sql = "SELECT * FROM teacher WHERE isDelete = 0 ";
if(!isEmpty(teacher.getCode())){
sql += " and code like '%"+teacher.getCode()+"%'";
}
if(!isEmpty(teacher.getUsername())){
sql += " and username like '%"+teacher.getUsername()+"%'";
}
if(!isEmpty(teacher.getPassword())){
sql += " and password like '%"+teacher.getPassword()+"%'";
}
if(!isEmpty(teacher.getKc())){
sql += " and kc like '%"+teacher.getKc()+"%'";
}
if(!isEmpty(teacher.getIsDelete())){
sql += " and isDelete like '%"+teacher.getIsDelete()+"%'";
}
sql += " ORDER BY ID DESC ";
Pager<Teacher> pagers = teacherService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers", pagers);
// Store query criteria
model.addAttribute("obj", teacher);
return "teacher/teacher";
}
/**
* Paging query return list object ( adopt Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap")
public String findByMap(Teacher teacher, Model model, HttpServletRequest request, HttpServletResponse response) {
// adopt map Inquire about
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(teacher.getCode())){
params.put("code", teacher.getCode());
}
if(!isEmpty(teacher.getUsername())){
params.put("username", teacher.getUsername());
}
if(!isEmpty(teacher.getPassword())){
params.put("password", teacher.getPassword());
}
if(!isEmpty(teacher.getKc())){
params.put("kc", teacher.getKc());
}
if(!isEmpty(teacher.getIsDelete())){
params.put("isDelete", teacher.getIsDelete());
}
// Paging query
Pager<Teacher> pagers = teacherService.findByMap(params);
model.addAttribute("pagers", pagers);
// Store query criteria
model.addAttribute("obj", teacher);
return "teacher/teacher";
}
/**********************************【 Additions and deletions 】******************************************************/
/**
* Skip to the add page
* @return
*/
@RequestMapping(value = "/add")
public String add(Model model) {
// Query class list
Bj b = new Bj();
b.setIsDelete(0);
List<Bj> listAllByEntity = bjService.listAllByEntity(b);
model.addAttribute("bjs", listAllByEntity);
return "teacher/add";
}
@RequestMapping(value = "/pass")
public String pass(Integer id,HttpServletRequest request,Model model) {
Object attribute = request.getSession().getAttribute("userId");
if (attribute == null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
Teacher obj = teacherService.load(userId);
model.addAttribute("obj",obj);
return "teacher/pass";
}
@RequestMapping("/upass")
@ResponseBody
public String upass(HttpServletRequest request,String password){
Object attribute = request.getSession().getAttribute("userId");
JSONObject j = new JSONObject();
if (attribute == null){
j.put("res", 0);
return j.toString();
}
Integer userId = Integer.valueOf(attribute.toString());
Teacher byId = teacherService.getById(userId);
byId.setPassword(password);
teacherService.updateById(byId);
j.put("res", 1);
return j.toString();
}
/**
* Jump to the details page
* @return
*/
@RequestMapping(value = "/view")
public String view(Integer id,Model model) {
Teacher obj = teacherService.load(id);
model.addAttribute("obj",obj);
return "teacher/view";
}
/**
* Add execution
* @return
*/
@RequestMapping(value = "/exAdd")
public String exAdd(Teacher teacher,@RequestParam(value = "ids") Integer[] ids, Model model, HttpServletRequest request, HttpServletResponse response) {
if (ids != null && ids.length > 0){
teacher.setIsDelete(0);
teacherService.insert(teacher);
for (Integer bId : ids){
TeacherBj tb = new TeacherBj();
tb.setBjId(bId);
tb.setTeacherId(teacher.getId());
teacherBjService.insert(tb);
}
}
return "redirect:/teacher/findBySql.action";
}
/**
* Skip to the modification page
* @return
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model) {
Teacher obj = teacherService.load(id);
// Query class list
Bj b = new Bj();
b.setIsDelete(0);
List<Bj> listAllByEntity = bjService.listAllByEntity(b);
// View the selected by the teacher
TeacherBj t = new TeacherBj();
t.setTeacherId(id);
List<TeacherBj> select = teacherBjService.listAllByEntity(t);
List<Integer> ids = new ArrayList<Integer>();
if (!CollectionUtils.isEmpty(select)){
for (TeacherBj b2 : select){
ids.add(b2.getBjId());
}
}
if (!CollectionUtils.isEmpty(listAllByEntity)){
for (Bj bj : listAllByEntity){
if (!CollectionUtils.isEmpty(ids) && ids.contains(bj.getId())){
bj.setIsCheck(1);
}else{
bj.setIsCheck(0);
}
}
}
model.addAttribute("bjs", listAllByEntity);
model.addAttribute("obj",obj);
return "teacher/update";
}
/**
* Add modification
* @return
*/
@RequestMapping(value = "/exUpdate")
public String exUpdate(Teacher teacher,@RequestParam(value = "ids") Integer[] ids, Model model, HttpServletRequest request, HttpServletResponse response) {
teacherService.updateById(teacher);
if (ids != null && ids.length > 0){
teacher.setIsDelete(0);
// Delete
TeacherBj t = new TeacherBj();
t.setTeacherId(teacher.getId());
teacherBjService.deleteByEntity(t);
for (Integer bId : ids){
TeacherBj tb = new TeacherBj();
tb.setBjId(bId);
tb.setTeacherId(teacher.getId());
teacherBjService.insert(tb);
}
}
return "redirect:/teacher/findBySql.action";
}
/**
* Delete through primary key
* @return
*/
@RequestMapping(value = "/delete")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
Teacher load = teacherService.load(id);
TeacherBj t = new TeacherBj();
t.setTeacherId(id);
teacherBjService.deleteByEntity(t);
load.setIsDelete(1);
teacherService.updateById(load);
return "redirect:/teacher/findBySql.action";
}
}

Student management control :

@Controller
@RequestMapping("/student")
public class StudentController extends BaseController {
@Autowired
private BjService bjService;
/**
* Dependency injection start dao/service/===
*/
@Autowired
private StudentService studentService;
@Autowired
private FdyService fdyService;
@Autowired
private RecordService recordService;
// --------------------------------------- Gorgeous split line ------------------------------
/**
* Paging query return list object ( Through to By Sql)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findBySql")
public String findBySql(Student student, Model model, HttpServletRequest request, HttpServletResponse response) {
Object attribute = request.getSession().getAttribute("userId");
if (attribute == null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
Fdy byId = fdyService.getById(userId);
if (byId== null || byId.getBjId() == null){
return "redirect:/login/message?type=1";
}
// Paging query
String sql = "SELECT * FROM student WHERE isDelete = 0 and bjId = "+ byId.getBjId();
if(!isEmpty(student.getCode())){
sql += " and code like '%"+student.getCode()+"%'";
}
if(!isEmpty(student.getUsername())){
sql += " and username like '%"+student.getUsername()+"%'";
}
if(!isEmpty(student.getPassword())){
sql += " and password like '%"+student.getPassword()+"%'";
}
if(!isEmpty(student.getBjId())){
sql += " and bjId like '%"+student.getBjId()+"%'";
}
if(!isEmpty(student.getIsDelete())){
sql += " and isDelete like '%"+student.getIsDelete()+"%'";
}
sql += " ORDER BY ID DESC ";
Pager<Student> pagers = studentService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers", pagers);
// Store query criteria
model.addAttribute("obj", student);
return "student/student";
}
@RequestMapping(value = "/pass")
public String pass(Integer id,HttpServletRequest request,Model model) {
Object attribute = request.getSession().getAttribute("userId");
if (attribute == null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
Student obj = studentService.load(userId);
model.addAttribute("obj",obj);
return "student/pass";
}
@RequestMapping("/upass")
@ResponseBody
public String upass(HttpServletRequest request,String password){
Object attribute = request.getSession().getAttribute("userId");
JSONObject j = new JSONObject();
if (attribute == null){
j.put("res", 0);
return j.toString();
}
Integer userId = Integer.valueOf(attribute.toString());
Student byId = studentService.getById(userId);
byId.setPassword(password);
studentService.updateById(byId);
j.put("res", 1);
return j.toString();
}
/**
* Paging query return list object ( adopt Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap")
public String findByMap(Student student, Model model, HttpServletRequest request, HttpServletResponse response) {
// adopt map Inquire about
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(student.getCode())){
params.put("code", student.getCode());
}
if(!isEmpty(student.getUsername())){
params.put("username", student.getUsername());
}
if(!isEmpty(student.getPassword())){
params.put("password", student.getPassword());
}
if(!isEmpty(student.getBjId())){
params.put("bjId", student.getBjId());
}
if(!isEmpty(student.getIsDelete())){
params.put("isDelete", student.getIsDelete());
}
// Paging query
Pager<Student> pagers = studentService.findByMap(params);
model.addAttribute("pagers", pagers);
// Store query criteria
model.addAttribute("obj", student);
return "student/student";
}
/**********************************【 Additions and deletions 】******************************************************/
/**
* Skip to the add page
* @return
*/
@RequestMapping(value = "/add")
public String add() {
return "student/add";
}
/**
* Jump to the details page
* @return
*/
@RequestMapping(value = "/view")
public String view(Integer id,Model model) {
Student obj = studentService.load(id);
model.addAttribute("obj",obj);
return "student/view";
}
/**
* Add execution
* @return
*/
@RequestMapping(value = "/exAdd")
public String exAdd(Student student, Model model, HttpServletRequest request, HttpServletResponse response) {
Object attribute = request.getSession().getAttribute("userId");
if (attribute == null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
Fdy byId = fdyService.getById(userId);
if (byId== null || byId.getBjId() == null){
return "redirect:/login/message?type=1";
}
student.setBjId(byId.getBjId());
student.setIsDelete(0);
studentService.insert(student);
return "redirect:/student/findBySql.action";
}
/**
* Skip to the modification page
* @return
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model) {
Student obj = studentService.load(id);
model.addAttribute("obj",obj);
return "student/update";
}
/**
* Add modification
* @return
*/
@RequestMapping(value = "/exUpdate")
public String exUpdate(Student student, Model model, HttpServletRequest request, HttpServletResponse response) {
//1. Modify through entity class , You can transfer multiple modification conditions
studentService.updateById(student);
//2. Through primary key id modify
//studentService.updateById(student);
return "redirect:/student/findBySql.action";
}
/**
* Delete through primary key
* @return
*/
@RequestMapping(value = "/delete")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
Student load = studentService.load(id);
load.setIsDelete(1);
studentService.updateById(load);
return "redirect:/student/findBySql.action";
}
}

Login management control layer :

@Controller
@RequestMapping("/login")
public class LoginController extends BaseController{
@Autowired
private ManageService manageService;
@Autowired
private FdyService fdyService;
@Autowired
private TeacherService teacherService;
@Autowired
private StudentService studentService;
/**
* Jump landing Administrators
* @return
*/
@RequestMapping("/mLogin")
public String login(){
return "login/mLogin";
}
/**
* Except for the administrator's unexpected login
* @return
*/
@RequestMapping("/uLogin")
public String uLogin(){
return "login/login";
}
@RequestMapping("/message")
public String message(Integer type,Model model){
if (type == 1){
model.addAttribute("mess", " The instructor does not have a class in charge .");
}
return "login/message";
}
/**
* Administrator exit
* @param request
* @return
*/
@RequestMapping("/mtuichu")
public String mtuichu(HttpServletRequest request){
//request.getSession().invalidate();
return "login/mLogin";
}
/**
* The welcome page
* @return
*/
@RequestMapping("/welcome")
private String welcome(){
return "login/welcome";
}
/**
* Administrator login
* @param manage
* @param request
* @param response
* @return
*/
@RequestMapping("/toMlogin")
public String toLogin(Manage manage, HttpServletRequest request, HttpServletResponse response){
Manage byEntity = manageService.getByEntity(manage);
if(byEntity == null){
return "redirect:/login/mtuichu";
}else{
request.getSession().setAttribute("role", 1);
request.getSession().setAttribute("username", byEntity.getUsername());
request.getSession().setAttribute("userId", byEntity.getId());
}
return "login/index";
}
/**
* Except for the administrator's unexpected login
* @param code
* @param password
* @param role
* @param request
* @param response
* @return
*/
@RequestMapping("/tologin")
public String toLogin(String code,String password,Integer role, HttpServletRequest request, HttpServletResponse response){
// 4 Student ,3 The teacher ,2 Instructor
if (role == 4){
Student s = new Student();
s.setIsDelete(0);
s.setCode(code);
s.setPassword(password);
Student byEntity = studentService.getByEntity(s);
if(byEntity == null){
return "redirect:/login/uLogin.action";
}else{
request.getSession().setAttribute("role",role);
request.getSession().setAttribute("username", byEntity.getUsername());
request.getSession().setAttribute("userId", byEntity.getId());
}
}
if (role == 3){
Teacher s = new Teacher();
s.setIsDelete(0);
s.setCode(code);
s.setPassword(password);
Teacher byEntity = teacherService.getByEntity(s);
if(byEntity == null){
return "redirect:/login/uLogin.action";
}else{
request.getSession().setAttribute("role",role);
request.getSession().setAttribute("username", byEntity.getUsername());
request.getSession().setAttribute("userId", byEntity.getId());
}
}
if (role == 2){
Fdy s = new Fdy();
s.setCode(code);
s.setPassword(password);
Fdy byEntity = fdyService.getByEntity(s);
if(byEntity == null){
return "redirect:/login/uLogin.action";
}else{
request.getSession().setAttribute("role",role);
request.getSession().setAttribute("username", byEntity.getUsername());
request.getSession().setAttribute("userId", byEntity.getId());
}
}
return "login/index";
}
/**
* sign out
* @param request
* @param response
* @return
*/
@RequestMapping("/tuichu")
public String tuichu( HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
session.invalidate();
return "login/uLogin";
}
/*
* Other roles exit
*/
@RequestMapping("/uTui")
public String uTui( HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
session.invalidate();
return "redirect:/login/uLogin";
}
@RequestMapping("/head")
private String head(){
return "inc/head";
}
@RequestMapping("/left")
private String left(){
return "inc/left";
}
}

The source code for : My blog home page " resources " Download !

版权声明:本文为[pastclouds]所创,转载请带上原文链接,感谢。 https://qdmana.com/2022/174/202206231350448301.html