项目介绍
本项目分为管理员、学生两种角色,
管理员主要功能包括:
功能:登录、查看个人资料、修改密码、选手管理、赛事管理、报名管理、成绩管理、开幕式管理、闭幕式管理
学生主要功能包括:
首页,
项目管理:报名项目、查看已报名项目;
成绩查询:单个项目查询、总成绩查询、个人总积分查询;
查看开幕式;
查看闭幕式;
个人资料:查看个人资料、修改密码;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 8.0版本;
6.是否Maven项目:是;
技术栈
-
后端:SpringBoot
-
前端:Thymeleaf+HTML+CSS+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
- 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
- 将项目中application.yml配置文件中的数据库配置改为自己的配置;
- 运行项目,输入localhost:8080/ 登录
管理员账号/密码:10001/123456
学生账号/密码:1001/123456
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
List<User> userList = userService.selectList(user);
request.getSession().setAttribute("name",name);
modelAndView.addObject("userList", userList);
return modelAndView;
}
/**
* 跳转到运动员的添加页面
* @param req
* @param resp
* @return
*/
@RequestMapping(value = "add.do", method = RequestMethod.GET)
public ModelAndView add(HttpServletRequest req, HttpServletResponse resp) {
ModelAndView modelAndView = new ModelAndView("user/add");
return modelAndView;
}
/**
* 用户添加的提交 检查成员的个人信息 最后处理图片的上传
*
return AjaxResult.successInstance("失败,只能填数字");
}
}
/**
*
* @param projectId
* @param userId
* @param request
* @return
*/
/**
* 显示用户页面的用户的当前的所有项目
*
* @param id
* @param request
* @param response
* @return
*/
modelAndView.addObject("admin",admin);
return modelAndView;
}
/**
* 裁判员编辑操作
* @return
*/
@ResponseBody
@PostMapping("/edit.do")
public AjaxResult edit(Admin admin){
if (StringUtils.isEmpty(admin.getRealname())) {
return AjaxResult.errorInstance("请填写名称");
}
if (StringUtils.isEmpty(admin.getPhone())) {
return AjaxResult.errorInstance("请填写手机号");
}
if(adminService.editAdmin(admin)<=0){
return AjaxResult.errorInstance("裁判员信息编辑失败");
}
return AjaxResult.successInstance("裁判员信息编辑成功");
}
/**
* 删除裁判信息
* @return
*/
@ResponseBody
@PostMapping("/delete.do")
modelAndView.addObject("userScoresList", userScoresList);
return modelAndView;
}
@RequestMapping(value = "/showProject.do")
public ModelAndView showProject(Long id, HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView("/user/showProject");
// 查询出当前用户id 的所有比赛
UserScore userScore = new UserScore();
userScore.setUserId(id);
List<Project> projectList = userScoreService.selectProject(userScore);
modelAndView.addObject("projectList", projectList);
return modelAndView;
}
/**
* 转到密码修改页面
*
* @param resp
* @param req
* @return
*/
@RequestMapping(value = "updatePassword.do", method = RequestMethod.GET)
public ModelAndView updatePassword(HttpServletResponse resp, HttpServletRequest req) {
return new ModelAndView("user/resetPassword");
}
/**
* 密码修改提交
*
return modelAndView;
}
/**
* 上传图片
* @param photo
* @param request
* @return
*/
@RequestMapping(value="/upload_photo",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> uploadPhoto(MultipartFile photo, HttpServletRequest request){
Map<String, String> ret = new HashMap<String, String>();
if(photo == null){
ret.put("type", "error");
return AjaxResult.errorInstance("该运动员这个项目已经评过分了!");
}
userScore.setUserId(id);
userScore.setScore(score);
userScore.setAdminId(adminId);
userScore.setProjectId(projectId);
// 将数据插入数据库
userScoreService.insert(userScore);
return AjaxResult.successInstance("提交成功");
} catch (NumberFormatException e) {
return AjaxResult.successInstance("失败,只能填数字");
}
}
{
ModelAndView modelAndView = new ModelAndView("/project/edit");
Project project = projectService.selectOne(id);
modelAndView.addObject("project",project);
return modelAndView;
}
/**
* 比赛项目添加操作
* @return
*/
@ResponseBody
@RequestMapping(value="add.do",method=RequestMethod.POST)
public AjaxResult addSubmit(Project project)
{
if(CommonUtils.isEmpty(project.getName())){
return AjaxResult.errorInstance("请填写比赛项目名称");
}
String name = req.getParameter("Nickname");
String pwd = req.getParameter("pwd");
user.setName(name);
user.setPassword(pwd);// 密码应该采用hash保存
userService.insert(user);
return null;
}
@RequestMapping(value = "/register.do", method = RequestMethod.POST)
public ModelAndView registerSubmit(@Valid User user, BindingResult bindingResult) {
if (bindingResult.getFieldError("email") != null || bindingResult.getFieldError("password") != null) {
return registerPage(user);
}
userService.insert(user);
ModelAndView modelAndView = new ModelAndView("registerSuccess");
return modelAndView;
}
@RequestMapping(value = "/message.do")
public ModelAndView message() {
ModelAndView modelAndView = new ModelAndView("Message");
return modelAndView;
}
/**
* 添加一名成员成绩
*/
@RequestMapping(value = "/addscore.do")
return modelAndView;
}else{
ModelAndView modelAndView = new ModelAndView("adminUser/login");
modelAndView.addObject("message", "账号密码错误");
return modelAndView;
}
}
}
@RequestMapping(value = "adminscore.do")
public ModelAndView adminscore(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView("adminUser/listscore");
AdminScore adminScore = new AdminScore();
Admin admin = (Admin) request.getSession().getAttribute("adminUser");
adminScore.setAdminId(admin.getId());
List<AdminScore> AdminScoreList = adminScoreService.selectList(adminScore);
modelAndView.addObject("AdminScoreList", AdminScoreList);
return modelAndView;
}
/**
* 账号的登出
*
* @param
* @param
ret.put("msg", "文件大小不能超过10M!");
return ret;
}
//获取文件后缀
String suffix = photo.getOriginalFilename().substring(photo.getOriginalFilename().lastIndexOf(".")+1,photo.getOriginalFilename().length());
if(!"jpg,jpeg,gif,png".toUpperCase().contains(suffix.toUpperCase())){
ret.put("type", "error");
ret.put("msg", "请选择jpg,jpeg,gif,png格式的图片!");
return ret;
}
String savePath = request.getServletContext().getRealPath("/") + "/upload/";
File savePathFile = new File(savePath);
if(!savePathFile.exists()){
//若不存在改目录,则创建目录
savePathFile.mkdir();
}