javaweb项目管理系统设计方案包含前端页面,用java代码写示例
时间: 2023-11-12 11:09:39 浏览: 80
设计方案:
1. 技术选型
- 前端框架:Bootstrap
- 后端框架:Spring MVC + MyBatis
- 数据库:MySQL
2. 系统功能
- 用户管理:包括用户的注册、登录、信息修改等;
- 项目管理:包括项目的创建、修改、删除、查看等;
- 任务管理:包括任务的创建、修改、删除、查看等;
- 文件管理:包括文件的上传、下载、删除、查看等;
- 日志管理:包括用户操作日志的记录和查看等。
3. 前端页面设计
- 登录页:包括用户名和密码输入框、登录按钮等;
- 注册页:包括用户名、密码、邮箱等输入框、注册按钮等;
- 项目列表页:包括项目列表、创建项目按钮等;
- 项目详情页:包括项目信息、任务列表、文件列表等;
- 任务详情页:包括任务信息、任务进度、任务附件等;
- 文件列表页:包括文件列表、上传文件按钮等;
- 日志列表页:包括用户操作日志列表等。
4. 后端代码示例
- 用户管理:
```java
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "/register", method = RequestMethod.POST)
public String register(User user) {
userService.register(user);
return "redirect:/login";
}
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String login(User user, HttpSession session) {
User loginUser = userService.login(user);
if (loginUser == null) {
return "redirect:/login?error=true";
}
session.setAttribute("user", loginUser);
return "redirect:/project/list";
}
@RequestMapping("/logout")
public String logout(HttpSession session) {
session.invalidate();
return "redirect:/login";
}
@RequestMapping("/info")
public String info() {
return "user_info";
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(User user) {
userService.update(user);
return "redirect:/user/info";
}
}
```
- 项目管理:
```java
@Controller
@RequestMapping("/project")
public class ProjectController {
@Autowired
private ProjectService projectService;
@RequestMapping("/list")
public String list(Model model) {
List<Project> projects = projectService.list();
model.addAttribute("projects", projects);
return "project_list";
}
@RequestMapping("/add")
public String add() {
return "project_add";
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
public String save(Project project) {
projectService.save(project);
return "redirect:/project/list";
}
@RequestMapping("/edit/{id}")
public String edit(@PathVariable("id") int id, Model model) {
Project project = projectService.get(id);
model.addAttribute("project", project);
return "project_edit";
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(Project project) {
projectService.update(project);
return "redirect:/project/list";
}
@RequestMapping("/delete/{id}")
public String delete(@PathVariable("id") int id) {
projectService.delete(id);
return "redirect:/project/list";
}
@RequestMapping("/detail/{id}")
public String detail(@PathVariable("id") int id, Model model) {
Project project = projectService.get(id);
model.addAttribute("project", project);
return "project_detail";
}
}
```
- 任务管理:
```java
@Controller
@RequestMapping("/task")
public class TaskController {
@Autowired
private TaskService taskService;
@RequestMapping("/list")
public String list(@RequestParam("projectId") int projectId, Model model) {
List<Task> tasks = taskService.list(projectId);
model.addAttribute("tasks", tasks);
model.addAttribute("projectId", projectId);
return "task_list";
}
@RequestMapping("/add")
public String add(@RequestParam("projectId") int projectId, Model model) {
model.addAttribute("projectId", projectId);
return "task_add";
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
public String save(Task task) {
taskService.save(task);
return "redirect:/task/list?projectId=" + task.getProjectId();
}
@RequestMapping("/edit/{id}")
public String edit(@PathVariable("id") int id, Model model) {
Task task = taskService.get(id);
model.addAttribute("task", task);
return "task_edit";
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(Task task) {
taskService.update(task);
return "redirect:/task/list?projectId=" + task.getProjectId();
}
@RequestMapping("/delete/{id}")
public String delete(@PathVariable("id") int id, @RequestParam("projectId") int projectId) {
taskService.delete(id);
return "redirect:/task/list?projectId=" + projectId;
}
@RequestMapping("/detail/{id}")
public String detail(@PathVariable("id") int id, Model model) {
Task task = taskService.get(id);
model.addAttribute("task", task);
return "task_detail";
}
}
```
- 文件管理:
```java
@Controller
@RequestMapping("/file")
public class FileController {
@Autowired
private FileService fileService;
@RequestMapping("/list")
public String list(@RequestParam("projectId") int projectId, Model model) {
List<File> files = fileService.list(projectId);
model.addAttribute("files", files);
model.addAttribute("projectId", projectId);
return "file_list";
}
@RequestMapping("/upload")
public String upload(@RequestParam("projectId") int projectId, Model model) {
model.addAttribute("projectId", projectId);
return "file_upload";
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
public String save(File file, MultipartFile uploadFile) throws IOException {
String filename = uploadFile.getOriginalFilename();
String suffix = filename.substring(filename.lastIndexOf(".") + 1);
String newName = UUID.randomUUID().toString() + "." + suffix;
File dest = new File("d:/upload", newName);
uploadFile.transferTo(dest);
file.setFileName(newName);
file.setFileType(uploadFile.getContentType());
file.setFileSize(uploadFile.getSize());
fileService.save(file);
return "redirect:/file/list?projectId=" + file.getProjectId();
}
@RequestMapping("/download/{id}")
public void download(@PathVariable("id") int id, HttpServletResponse response) throws IOException {
File file = fileService.get(id);
String filePath = "d:/upload/" + file.getFileName();
FileInputStream fis = new FileInputStream(filePath);
response.setCharacterEncoding("utf-8");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(file.getFileName(), "utf-8"));
IOUtils.copy(fis, response.getOutputStream());
fis.close();
}
@RequestMapping("/delete/{id}")
public String delete(@PathVariable("id") int id, @RequestParam("projectId") int projectId) {
fileService.delete(id);
return "redirect:/file/list?projectId=" + projectId;
}
}
```
- 日志管理:
```java
@Controller
@RequestMapping("/log")
public class LogController {
@Autowired
private LogService logService;
@RequestMapping("/list")
public String list(Model model) {
List<Log> logs = logService.list();
model.addAttribute("logs", logs);
return "log_list";
}
}
```
阅读全文