fix part4

Signed-off-by: Chenx221 <chenx221@yandex.com>
This commit is contained in:
Chenx221 2023-06-19 20:34:38 +08:00
parent bf3e198ed2
commit 0ef50e408c
12 changed files with 41 additions and 56 deletions

View File

@ -100,50 +100,58 @@
- ~/addinfo - ~/addinfo
- 学生信息添加 [Post] - 学生信息添加 [Post]
- admin,teacher - admin,teacher
- *Redirect*.infomodv2|*Redirect*.infomodv2_t
- /system - /system
- ~/settings - ~/settings
- 系统设置页 - 系统设置页 [Get]
- admin - admin
- settings
- ~/clean - ~/clean
- 清理垃圾 - 清理垃圾 [Get]
- admin - admin
- *Redirect*.settings
- /teacher - /teacher
- ~/mamage - ~/mamage
- 教师信息管理页 - 教师信息管理页 [Get]
- admin - admin
- teachermanage
- ~/query - ~/query
- 教师信息查询 - 教师信息查询 [Post]
- admin - admin
- teacherQueryResult
- ~/mod - ~/mod
- 教师信息修改 - 教师信息修改 [Post]
- admin - admin
- ~/del - ~/del
- 教师信息删除 - 教师信息删除 [Post]
- admin - admin
- ~/add - ~/add
- 教师信息添加 - 教师信息添加 [Post]
- admin - admin
- /login - /login
- 用户登录页(和/相同) - 用户登录页(和/相同) [Get]
- everyone - Everyone
- /signup - /signup
- 用户(管理员)注册 - 用户(管理员)注册 [Post]
- everyone - Everyone
- /user - /user
- ~/usermanage - ~/usermanage
- 用户管理页 - 用户管理页 [Get]
- admin - admin
- usermanage
- ~/create - ~/create
- 用户创建 - 用户创建 [Post]
- admin - admin
- *Redirect*.usermanage
- ~/reset - ~/reset
- 重设密码 - 重设密码 [Post]
- admin - admin
- *Redirect*.usermanage
- ~/userdisabled - ~/userdisabled
- 禁用用户 - 禁用用户 [Post]
- admin - admin
- ~/userenabled - ~/userenabled
- 启用用户 - 启用用户 [Post]
- admin - admin
- /success - /success
- 废弃的成功状态页 - 废弃的成功状态页
@ -152,11 +160,6 @@
- 废弃的失败状态页 - 废弃的失败状态页
- None - None
- /dashboard - /dashboard
- 管理员登陆后的首页 - 登陆后的首页
- admin - admin,teacher,student
- /dashboard-t - dashboard|dashboard_t|dashboard_s
- 教师登陆后的首页
- teacher
- /dashborad-s
- 学生登录后的首页
- student

View File

@ -1,8 +1,6 @@
package cyou.chenx221.controller; package cyou.chenx221.controller;
import cyou.chenx221.helper.UsernameHelper; import cyou.chenx221.helper.UsernameHelper;
import cyou.chenx221.pojo.Course;
import cyou.chenx221.pojo.User;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; 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.io.File;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.List;
@Controller @Controller
@RequestMapping("/system") @RequestMapping("/system")
@ -28,7 +25,7 @@ public class SystemController {
model.addAttribute("message", message); model.addAttribute("message", message);
} }
model.addAttribute("trashSize", formatFileSize(getTrashSize())); model.addAttribute("trashSize", formatFileSize(getTrashSize()));
return "settings"; return "system/settings";
} }
public long getTrashSize() { public long getTrashSize() {

View File

@ -4,7 +4,6 @@ import cyou.chenx221.helper.CsvHelper;
import cyou.chenx221.helper.UsernameHelper; import cyou.chenx221.helper.UsernameHelper;
import cyou.chenx221.pojo.Course; import cyou.chenx221.pojo.Course;
import cyou.chenx221.pojo.Teacher; import cyou.chenx221.pojo.Teacher;
import cyou.chenx221.service.CourseService;
import cyou.chenx221.service.TeacherService; import cyou.chenx221.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -41,7 +40,7 @@ public class TeacherController {
model.addAttribute("errorMessage", errorMessage); model.addAttribute("errorMessage", errorMessage);
List<Teacher> teacherList = teacherService.getAllTeachers(); List<Teacher> teacherList = teacherService.getAllTeachers();
model.addAttribute("teacherList", teacherList); model.addAttribute("teacherList", teacherList);
return "teachermanage"; return "teacher/teachermanage";
} }
@PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8") @PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8")
@ -103,7 +102,7 @@ public class TeacherController {
List<Teacher> teachers = teacherService.getQueryTeachers(teacher); List<Teacher> teachers = teacherService.getQueryTeachers(teacher);
model.addAttribute("teachers", teachers); model.addAttribute("teachers", teachers);
model.addAttribute("download", new CsvHelper().generateTeacherCSVFile(teachers)); model.addAttribute("download", new CsvHelper().generateTeacherCSVFile(teachers));
return "teacherQueryResult"; return "teacher/teacherQueryResult";
} }
@ResponseBody @ResponseBody

View File

@ -92,7 +92,7 @@ public class UserController {
model.addAttribute("userList", userList); model.addAttribute("userList", userList);
model.addAttribute("successMessage", successMessage); model.addAttribute("successMessage", successMessage);
model.addAttribute("errorMessage", errorMessage); model.addAttribute("errorMessage", errorMessage);
return "usermanage"; return "user/usermanage";
} }
@RequestMapping(path = "/user/create", method = {RequestMethod.POST}) @RequestMapping(path = "/user/create", method = {RequestMethod.POST})

View File

@ -10,41 +10,27 @@ import org.springframework.web.bind.annotation.RequestMethod;
public class ViewController { public class ViewController {
@RequestMapping(path = "/success", method = {RequestMethod.GET, RequestMethod.POST}) //弃用 @RequestMapping(path = "/success", method = {RequestMethod.GET, RequestMethod.POST}) //弃用
public String success() { public String success() {
return "views/success"; // 视图文件名 return "success"; // 视图文件名
} }
@RequestMapping(path = "/fail", method = {RequestMethod.GET, RequestMethod.POST}) //弃用 @RequestMapping(path = "/fail", method = {RequestMethod.GET, RequestMethod.POST}) //弃用
public String fail() { 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) { public String showDashboard(Model model) {
String username = new UsernameHelper().getCurrentUsername(); String username = new UsernameHelper().getCurrentUsername();
if (username != null) { if (username != null) {
model.addAttribute("username", username); model.addAttribute("username", username);
} }
// model.addAttribute("errorMessage","null"); String role = new UsernameHelper().getCurrentRole();
return "dashboard"; // 返回 dashboard 视图名 if (role.equals("[ROLE_admin]"))
} return "dashboard/dashboard";
else if (role.equals("[ROLE_teacher]")) {
@RequestMapping(path = "/dashboard-t", method = {RequestMethod.GET, RequestMethod.POST}) return "dashboard/dashboard_t";
public String showDashboardT(Model model) { } else {
String username = new UsernameHelper().getCurrentUsername(); return "dashboard/dashboard_s";
if (username != null) {
model.addAttribute("username", username);
} }
// 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 视图名
} }
} }