diff --git a/project2/README.md b/project2/README.md index 0f38656..ab520f7 100644 --- a/project2/README.md +++ b/project2/README.md @@ -100,50 +100,58 @@ - ~/addinfo - 学生信息添加 [Post] - admin,teacher + - *Redirect*.infomodv2|*Redirect*.infomodv2_t - /system - ~/settings - - 系统设置页 + - 系统设置页 [Get] - admin + - settings - ~/clean - - 清理垃圾 + - 清理垃圾 [Get] - admin + - *Redirect*.settings - /teacher - ~/mamage - - 教师信息管理页 + - 教师信息管理页 [Get] - admin + - teachermanage - ~/query - - 教师信息查询 + - 教师信息查询 [Post] - admin + - teacherQueryResult - ~/mod - - 教师信息修改 + - 教师信息修改 [Post] - admin - ~/del - - 教师信息删除 + - 教师信息删除 [Post] - admin - ~/add - - 教师信息添加 + - 教师信息添加 [Post] - admin - /login - - 用户登录页(和/相同) - - everyone + - 用户登录页(和/相同) [Get] + - Everyone - /signup - - 用户(管理员)注册 - - everyone + - 用户(管理员)注册 [Post] + - Everyone - /user - ~/usermanage - - 用户管理页 + - 用户管理页 [Get] - admin + - usermanage - ~/create - - 用户创建 + - 用户创建 [Post] - admin + - *Redirect*.usermanage - ~/reset - - 重设密码 + - 重设密码 [Post] - admin + - *Redirect*.usermanage - ~/userdisabled - - 禁用用户 + - 禁用用户 [Post] - admin - ~/userenabled - - 启用用户 + - 启用用户 [Post] - admin - /success - 废弃的成功状态页 @@ -152,11 +160,6 @@ - 废弃的失败状态页 - None - /dashboard - - 管理员登陆后的首页 - - admin -- /dashboard-t - - 教师登陆后的首页 - - teacher -- /dashborad-s - - 学生登录后的首页 - - student \ No newline at end of file + - 登陆后的首页 + - admin,teacher,student + - dashboard|dashboard_t|dashboard_s \ No newline at end of file diff --git a/project2/src/main/java/cyou/chenx221/controller/SystemController.java b/project2/src/main/java/cyou/chenx221/controller/SystemController.java index aa35d7f..a775ef0 100644 --- a/project2/src/main/java/cyou/chenx221/controller/SystemController.java +++ b/project2/src/main/java/cyou/chenx221/controller/SystemController.java @@ -1,8 +1,6 @@ package cyou.chenx221.controller; import cyou.chenx221.helper.UsernameHelper; -import cyou.chenx221.pojo.Course; -import cyou.chenx221.pojo.User; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -12,7 +10,6 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import java.io.File; import java.text.DecimalFormat; -import java.util.List; @Controller @RequestMapping("/system") @@ -28,7 +25,7 @@ public class SystemController { model.addAttribute("message", message); } model.addAttribute("trashSize", formatFileSize(getTrashSize())); - return "settings"; + return "system/settings"; } public long getTrashSize() { diff --git a/project2/src/main/java/cyou/chenx221/controller/TeacherController.java b/project2/src/main/java/cyou/chenx221/controller/TeacherController.java index 77d2801..1b6d10d 100644 --- a/project2/src/main/java/cyou/chenx221/controller/TeacherController.java +++ b/project2/src/main/java/cyou/chenx221/controller/TeacherController.java @@ -4,7 +4,6 @@ import cyou.chenx221.helper.CsvHelper; import cyou.chenx221.helper.UsernameHelper; import cyou.chenx221.pojo.Course; import cyou.chenx221.pojo.Teacher; -import cyou.chenx221.service.CourseService; import cyou.chenx221.service.TeacherService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -41,7 +40,7 @@ public class TeacherController { model.addAttribute("errorMessage", errorMessage); List teacherList = teacherService.getAllTeachers(); model.addAttribute("teacherList", teacherList); - return "teachermanage"; + return "teacher/teachermanage"; } @PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8") @@ -103,7 +102,7 @@ public class TeacherController { List teachers = teacherService.getQueryTeachers(teacher); model.addAttribute("teachers", teachers); model.addAttribute("download", new CsvHelper().generateTeacherCSVFile(teachers)); - return "teacherQueryResult"; + return "teacher/teacherQueryResult"; } @ResponseBody diff --git a/project2/src/main/java/cyou/chenx221/controller/UserController.java b/project2/src/main/java/cyou/chenx221/controller/UserController.java index cebbb94..f833e30 100644 --- a/project2/src/main/java/cyou/chenx221/controller/UserController.java +++ b/project2/src/main/java/cyou/chenx221/controller/UserController.java @@ -92,7 +92,7 @@ public class UserController { model.addAttribute("userList", userList); model.addAttribute("successMessage", successMessage); model.addAttribute("errorMessage", errorMessage); - return "usermanage"; + return "user/usermanage"; } @RequestMapping(path = "/user/create", method = {RequestMethod.POST}) diff --git a/project2/src/main/java/cyou/chenx221/controller/ViewController.java b/project2/src/main/java/cyou/chenx221/controller/ViewController.java index b4b0b70..06ded2e 100644 --- a/project2/src/main/java/cyou/chenx221/controller/ViewController.java +++ b/project2/src/main/java/cyou/chenx221/controller/ViewController.java @@ -10,41 +10,27 @@ import org.springframework.web.bind.annotation.RequestMethod; public class ViewController { @RequestMapping(path = "/success", method = {RequestMethod.GET, RequestMethod.POST}) //弃用 public String success() { - return "views/success"; // 视图文件名 + return "success"; // 视图文件名 } @RequestMapping(path = "/fail", method = {RequestMethod.GET, RequestMethod.POST}) //弃用 public String fail() { - return "views/fail"; // 视图文件名 + return "fail"; // 视图文件名 } - @RequestMapping(path = "/dashboard", method = {RequestMethod.GET, RequestMethod.POST}) + @RequestMapping(path = "/dashboard", method = {RequestMethod.GET}) public String showDashboard(Model model) { String username = new UsernameHelper().getCurrentUsername(); if (username != null) { model.addAttribute("username", username); } -// model.addAttribute("errorMessage","null"); - return "dashboard"; // 返回 dashboard 视图名 - } - - @RequestMapping(path = "/dashboard-t", method = {RequestMethod.GET, RequestMethod.POST}) - public String showDashboardT(Model model) { - String username = new UsernameHelper().getCurrentUsername(); - if (username != null) { - model.addAttribute("username", username); + String role = new UsernameHelper().getCurrentRole(); + if (role.equals("[ROLE_admin]")) + return "dashboard/dashboard"; + else if (role.equals("[ROLE_teacher]")) { + return "dashboard/dashboard_t"; + } else { + return "dashboard/dashboard_s"; } -// model.addAttribute("errorMessage","null"); - return "dashboard_t"; // 返回 dashboard 视图名 - } - - @RequestMapping(path = "/dashboard-s", method = {RequestMethod.GET, RequestMethod.POST}) - public String showDashboardS(Model model) { - String username = new UsernameHelper().getCurrentUsername(); - if (username != null) { - model.addAttribute("username", username); - } -// model.addAttribute("errorMessage","null"); - return "dashboard_s"; // 返回 dashboard 视图名 } } diff --git a/project2/web/WEB-INF/views/dashboard.jsp b/project2/web/WEB-INF/views/dashboard/dashboard.jsp similarity index 100% rename from project2/web/WEB-INF/views/dashboard.jsp rename to project2/web/WEB-INF/views/dashboard/dashboard.jsp diff --git a/project2/web/WEB-INF/views/dashboard_s.jsp b/project2/web/WEB-INF/views/dashboard/dashboard_s.jsp similarity index 100% rename from project2/web/WEB-INF/views/dashboard_s.jsp rename to project2/web/WEB-INF/views/dashboard/dashboard_s.jsp diff --git a/project2/web/WEB-INF/views/dashboard_t.jsp b/project2/web/WEB-INF/views/dashboard/dashboard_t.jsp similarity index 100% rename from project2/web/WEB-INF/views/dashboard_t.jsp rename to project2/web/WEB-INF/views/dashboard/dashboard_t.jsp diff --git a/project2/web/WEB-INF/views/settings.jsp b/project2/web/WEB-INF/views/system/settings.jsp similarity index 100% rename from project2/web/WEB-INF/views/settings.jsp rename to project2/web/WEB-INF/views/system/settings.jsp diff --git a/project2/web/WEB-INF/views/teacherQueryResult.jsp b/project2/web/WEB-INF/views/teacher/teacherQueryResult.jsp similarity index 100% rename from project2/web/WEB-INF/views/teacherQueryResult.jsp rename to project2/web/WEB-INF/views/teacher/teacherQueryResult.jsp diff --git a/project2/web/WEB-INF/views/teachermanage.jsp b/project2/web/WEB-INF/views/teacher/teachermanage.jsp similarity index 100% rename from project2/web/WEB-INF/views/teachermanage.jsp rename to project2/web/WEB-INF/views/teacher/teachermanage.jsp diff --git a/project2/web/WEB-INF/views/usermanage.jsp b/project2/web/WEB-INF/views/user/usermanage.jsp similarity index 100% rename from project2/web/WEB-INF/views/usermanage.jsp rename to project2/web/WEB-INF/views/user/usermanage.jsp